ladybird/Libraries/LibCore/CProcessStatisticsReader.h
Andreas Kling 35138437ef Kernel+SystemMonitor: Add fault counters
This patch adds three separate per-process fault counters:

- Inode faults

    An inode fault happens when we've memory-mapped a file from disk
    and we end up having to load 1 page (4KB) of the file into memory.

- Zero faults

    Memory returned by mmap() is lazily zeroed out. Every time we have
    to zero out 1 page, we count a zero fault.

- CoW faults

    VM objects can be shared by multiple mappings that make their own
    unique copy iff they want to modify it. The typical reason here is
    memory shared between a parent and child process.
2019-10-02 14:13:49 +02:00

43 lines
866 B
C++

#pragma once
#include <AK/String.h>
#include <AK/HashMap.h>
struct CProcessStatistics {
// Keep this in sync with /proc/all.
// From the kernel side:
pid_t pid;
unsigned times_scheduled;
unsigned pgid;
unsigned pgp;
unsigned sid;
uid_t uid;
gid_t gid;
String state;
pid_t ppid;
unsigned nfds;
String name;
String tty;
size_t amount_virtual;
size_t amount_resident;
size_t amount_shared;
unsigned ticks;
String priority;
unsigned syscall_count;
unsigned inode_faults;
unsigned zero_faults;
unsigned cow_faults;
int icon_id;
// synthetic
String username;
};
class CProcessStatisticsReader {
public:
static HashMap<pid_t, CProcessStatistics> get_all();
private:
static String username_from_uid(uid_t);
static HashMap<uid_t, String> s_usernames;
};