add proc_mem page fault metrics

This commit is contained in:
Doug MacEachern 2005-11-23 17:39:28 +00:00
parent 663abf6ceb
commit 530157168d
8 changed files with 57 additions and 4 deletions

View File

@ -260,6 +260,21 @@ my %classes = (
desc => 'Process resident set size',
plat => '*'
},
{
name => 'minor_faults', type => 'Long',
desc => '',
plat => ''
},
{
name => 'major_faults', type => 'Long',
desc => '',
plat => ''
},
{
name => 'page_faults', type => 'Long',
desc => '',
plat => ''
},
],
ProcCred => [
{

View File

@ -26,6 +26,9 @@ public class TestProcMem extends SigarTestCase {
traceln("Resident=" + Sigar.formatSize(procMem.getResident()));
traceln("Share=" + Sigar.formatSize(procMem.getShare()));
traceln("Rss=" + Sigar.formatSize(procMem.getRss()));
traceln("MinorFaults=" + procMem.getMinorFaults());
traceln("MajorFaults=" + procMem.getMajorFaults());
traceln("PageFaults=" + procMem.getPageFaults());
//assertTrue(procMem.getSize() > 0);
// XXX vsize, resident, share, rss
}

View File

@ -208,7 +208,10 @@ typedef struct {
vsize,
resident,
share,
rss;
rss,
minor_faults,
major_faults,
page_faults;
} sigar_proc_mem_t;
SIGAR_DECLARE(int) sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,

View File

@ -1090,6 +1090,12 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
procmem->rss = PAGESHIFT(pinfo->pi_drss + pinfo->pi_trss);
procmem->resident = procmem->rss;
procmem->minor_faults = pinfo->pi_minflt;
procmem->major_faults = pinfo->pi_majflt;
procmem->page_faults =
procmem->minor_faults +
procmem->major_faults;
return SIGAR_OK;
}

View File

@ -275,6 +275,12 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
procmem->share = pinfo->pst_shmsize * pagesize;
procmem->minor_faults = pinfo->pst_minorfaults;
procmem->major_faults = pinfo->pst_majorfaults;
procmem->page_faults =
procmem->minor_faults +
procmem->major_faults;
return SIGAR_OK;
}

View File

@ -602,9 +602,9 @@ static int proc_stat_read(sigar_t *sigar, sigar_pid_t pid)
ptr = sigar_skip_token(ptr); /* tty pgrp */
ptr = sigar_skip_token(ptr); /* flags */
ptr = sigar_skip_token(ptr); /* min flt */
pstat->minor_faults = sigar_strtoul(ptr);
ptr = sigar_skip_token(ptr); /* cmin flt */
ptr = sigar_skip_token(ptr); /* maj flt */
pstat->major_faults = sigar_strtoul(ptr);
ptr = sigar_skip_token(ptr); /* cmaj flt */
pstat->utime = sigar_strtoul(ptr) / sigar->ticks;
@ -656,6 +656,10 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
procmem->vsize = pstat->vsize;
procmem->rss = pstat->rss;
procmem->minor_faults = pstat->minor_faults;
procmem->major_faults = pstat->major_faults;
procmem->page_faults =
procmem->minor_faults + procmem->major_faults;
status = SIGAR_PROC_FILE2STR(buffer, pid, "/statm");

View File

@ -19,6 +19,8 @@ typedef struct {
time_t mtime;
sigar_uint64_t vsize;
sigar_uint64_t rss;
sigar_uint64_t minor_faults;
sigar_uint64_t major_faults;
sigar_uint64_t ppid;
int tty;
int priority;

View File

@ -575,6 +575,7 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
{
int status = sigar_proc_psinfo_get(sigar, pid);
psinfo_t *pinfo = sigar->pinfo;
prusage_t usage;
if (status != SIGAR_OK) {
return status;
@ -586,6 +587,19 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
procmem->vsize = SIGAR_FIELD_NOTIMPL;
procmem->share = SIGAR_FIELD_NOTIMPL;
if (sigar_proc_usage_get(sigar, &usage, pid) == SIGAR_OK) {
procmem->minor_faults = usage.pr_minf;
procmem->major_faults = usage.pr_majf;
procmem->page_faults =
procmem->minor_faults +
procmem->major_faults;
}
else {
procmem->minor_faults = SIGAR_FIELD_NOTIMPL;
procmem->major_faults = SIGAR_FIELD_NOTIMPL;
procmem->page_faults = SIGAR_FIELD_NOTIMPL;
}
return SIGAR_OK;
}