per-process swap info available on Linux 2.6.34

This commit is contained in:
albert 2010-05-18 07:02:03 +00:00
parent 93fd4a460e
commit 5f570a84f1
2 changed files with 78 additions and 44 deletions

View File

@ -77,7 +77,7 @@ typedef struct status_table_struct {
// (leave the colon and newline) So "Pid:\n" and "Threads:\n" // (leave the colon and newline) So "Pid:\n" and "Threads:\n"
// would be lines in the file. (no quote, no escape, etc.) // 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 // 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. // 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 Tgid = 0;
long Pid = 0; long Pid = 0;
// 128 entries because we trust the kernel to use ASCII names
static const unsigned char asso[] = static const unsigned char asso[] =
{ {
61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
61, 61, 61, 61, 61, 61, 61, 61, 15, 61, 64, 64, 64, 64, 64, 64, 64, 64, 28, 64,
61, 61, 61, 61, 61, 61, 30, 3, 5, 5, 64, 64, 64, 64, 64, 64, 8, 25, 23, 25,
61, 5, 61, 8, 61, 61, 3, 61, 10, 61, 6, 25, 0, 3, 64, 64, 3, 64, 25, 64,
6, 61, 13, 0, 30, 25, 0, 61, 61, 61, 20, 1, 1, 5, 0, 30, 0, 0, 64, 64,
61, 61, 61, 61, 61, 61, 61, 3, 61, 13, 64, 64, 64, 64, 64, 64, 64, 3, 64, 0,
0, 0, 61, 30, 61, 25, 61, 61, 61, 0, 0, 18, 64, 10, 64, 10, 64, 64, 64, 20,
61, 61, 61, 61, 5, 61, 0, 61, 61, 61, 64, 20, 0, 64, 25, 64, 3, 15, 64, 0,
0, 61, 61, 61, 61, 61, 61, 61 30, 64, 64, 64, 64, 64, 64, 64
}; };
static const status_table_struct table[] = { static const status_table_struct table[] = {
F(VmStk) F(VmHWM)
NUL NUL
F(State)
NUL
F(VmExe)
F(ShdPnd)
NUL
F(VmData)
NUL
F(Name)
NUL NUL
F(VmRSS)
NUL NUL NUL NUL
F(VmLck) F(VmLck)
NUL NUL NUL NUL
F(Gid) F(VmSwap)
F(Pid) F(VmRSS)
NUL NUL NUL NUL
F(VmSize) F(VmStk)
NUL NUL NUL
F(Tgid)
F(State)
NUL
F(VmLib) F(VmLib)
NUL NUL
F(PPid)
NUL NUL
F(SigCgt) F(VmSize)
NUL F(SigQ)
F(Threads)
F(SigPnd)
NUL NUL
F(SigIgn) F(SigIgn)
NUL NUL
F(Uid) F(VmPTE)
NUL NUL NUL NUL NUL NUL NUL NUL NUL F(FDSize)
NUL NUL NUL NUL NUL NUL
F(Tgid)
NUL NUL NUL NUL
F(SigBlk) F(SigBlk)
NUL NUL NUL NUL
F(ShdPnd)
F(VmData)
NUL
F(CapInh)
NUL
F(PPid)
NUL NUL
F(CapBnd)
NUL
F(SigPnd)
NUL NUL
F(VmPeak)
NUL
F(SigCgt)
NUL NUL
F(Threads)
NUL
F(CapPrm)
NUL NUL
F(Pid)
NUL
F(CapEff)
NUL NUL
F(Gid)
NUL
F(VmExe)
NUL NUL
F(Uid)
NUL
F(Groups)
NUL NUL
F(Name)
}; };
#undef F #undef F
@ -292,6 +311,20 @@ ENTER(0x220);
case_VmStk: case_VmStk:
P->vm_stack = strtol(S,&S,10); P->vm_stack = strtol(S,&S,10);
continue; 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 #if 0

View File

@ -98,6 +98,7 @@ typedef struct proc_t {
vm_rss, // status same as rss in kb vm_rss, // status same as rss in kb
vm_data, // status data size vm_data, // status data size
vm_stack, // status stack size vm_stack, // status stack size
vm_swap, // status based on "swap ents", Linux 2.6.34
vm_exe, // status executable size vm_exe, // status executable size
vm_lib, // status library size (all pages, not just used ones) vm_lib, // status library size (all pages, not just used ones)
rtprio, // stat real-time priority rtprio, // stat real-time priority