summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralbert <>2010-05-18 07:02:03 +0000
committeralbert <>2010-05-18 07:02:03 +0000
commit5f570a84f186ca5924be0722ba0956d5fef0b04a (patch)
tree38da9023ae2c4b810878e3ba96ba671fe2876cd1
parent93fd4a460ef250d75f8ce164ac50b147ce8bb7ee (diff)
downloadprocps-ng-5f570a84f186ca5924be0722ba0956d5fef0b04a.tar.gz
per-process swap info available on Linux 2.6.34
-rw-r--r--proc/readproc.c109
-rw-r--r--proc/readproc.h1
2 files changed, 72 insertions, 38 deletions
diff --git a/proc/readproc.c b/proc/readproc.c
index 4fad11d..671d1e0 100644
--- a/proc/readproc.c
+++ b/proc/readproc.c
@@ -77,7 +77,7 @@ typedef struct status_table_struct {
// (leave the colon and newline) So "Pid:\n" and "Threads:\n"
// would be lines in the file. (no quote, no escape, etc.)
//
-// Watch out for name size in the status_table_struct (grrr, expanding)
+// In the status_table_struct watch out for name size (grrr, expanding)
// and the number of entries (we mask with 63 for now). The table
// must be padded out to 64 entries, maybe 128 in the future.
@@ -86,62 +86,81 @@ static void status2proc(char *S, proc_t *restrict P, int is_proc){
long Tgid = 0;
long Pid = 0;
+ // 128 entries because we trust the kernel to use ASCII names
static const unsigned char asso[] =
{
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 61, 15, 61,
- 61, 61, 61, 61, 61, 61, 30, 3, 5, 5,
- 61, 5, 61, 8, 61, 61, 3, 61, 10, 61,
- 6, 61, 13, 0, 30, 25, 0, 61, 61, 61,
- 61, 61, 61, 61, 61, 61, 61, 3, 61, 13,
- 0, 0, 61, 30, 61, 25, 61, 61, 61, 0,
- 61, 61, 61, 61, 5, 61, 0, 61, 61, 61,
- 0, 61, 61, 61, 61, 61, 61, 61
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 28, 64,
+ 64, 64, 64, 64, 64, 64, 8, 25, 23, 25,
+ 6, 25, 0, 3, 64, 64, 3, 64, 25, 64,
+ 20, 1, 1, 5, 0, 30, 0, 0, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 3, 64, 0,
+ 0, 18, 64, 10, 64, 10, 64, 64, 64, 20,
+ 64, 20, 0, 64, 25, 64, 3, 15, 64, 0,
+ 30, 64, 64, 64, 64, 64, 64, 64
};
static const status_table_struct table[] = {
- F(VmStk)
+ F(VmHWM)
NUL NUL
+ F(VmLck)
+ NUL
+ F(VmSwap)
+ F(VmRSS)
+ NUL
+ F(VmStk)
+ NUL
+ F(Tgid)
F(State)
NUL
- F(VmExe)
- F(ShdPnd)
+ F(VmLib)
+ NUL
+ F(VmSize)
+ F(SigQ)
NUL
+ F(SigIgn)
+ NUL
+ F(VmPTE)
+ F(FDSize)
+ NUL
+ F(SigBlk)
+ NUL
+ F(ShdPnd)
F(VmData)
NUL
- F(Name)
- NUL NUL
- F(VmRSS)
- NUL NUL
- F(VmLck)
- NUL NUL NUL
- F(Gid)
- F(Pid)
- NUL NUL NUL
- F(VmSize)
+ F(CapInh)
+ NUL
+ F(PPid)
NUL NUL
- F(VmLib)
+ F(CapBnd)
+ NUL
+ F(SigPnd)
NUL NUL
- F(PPid)
+ F(VmPeak)
NUL
F(SigCgt)
- NUL
+ NUL NUL
F(Threads)
- F(SigPnd)
NUL
- F(SigIgn)
+ F(CapPrm)
+ NUL NUL
+ F(Pid)
NUL
+ F(CapEff)
+ NUL NUL
+ F(Gid)
+ NUL
+ F(VmExe)
+ NUL NUL
F(Uid)
- NUL NUL NUL NUL NUL NUL NUL NUL NUL
- NUL NUL NUL NUL NUL
- F(Tgid)
- NUL NUL NUL NUL
- F(SigBlk)
- NUL NUL NUL
+ NUL
+ F(Groups)
+ NUL NUL
+ F(Name)
};
#undef F
@@ -292,6 +311,20 @@ ENTER(0x220);
case_VmStk:
P->vm_stack = strtol(S,&S,10);
continue;
+ case_VmSwap: // Linux 2.6.34
+ P->vm_swap = strtol(S,&S,10);
+ continue;
+ case_CapBnd:
+ case_CapEff:
+ case_CapInh:
+ case_CapPrm:
+ case_FDSize:
+ case_Groups:
+ case_SigQ:
+ case_VmHWM: // 2005, peak VmRSS unless VmRSS is bigger
+ case_VmPTE:
+ case_VmPeak: // 2005, peak VmSize unless VmSize is bigger
+ continue;
}
#if 0
diff --git a/proc/readproc.h b/proc/readproc.h
index a953b29..4aab78e 100644
--- a/proc/readproc.h
+++ b/proc/readproc.h
@@ -98,6 +98,7 @@ typedef struct proc_t {
vm_rss, // status same as rss in kb
vm_data, // status data size
vm_stack, // status stack size
+ vm_swap, // status based on "swap ents", Linux 2.6.34
vm_exe, // status executable size
vm_lib, // status library size (all pages, not just used ones)
rtprio, // stat real-time priority