Skip to content

Support splitted PSS components (anon, file, and shmem) #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions deviate.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ calcdiff(struct tstat *devstat, const struct tstat *curstat,
devstat->mem.vmem = curstat->mem.vmem;
devstat->mem.rmem = curstat->mem.rmem;
devstat->mem.pmem = curstat->mem.pmem;
devstat->mem.panon = curstat->mem.panon;
devstat->mem.pfile = curstat->mem.pfile;
devstat->mem.pshmem = curstat->mem.pshmem;
devstat->mem.vdata = curstat->mem.vdata;
devstat->mem.vstack = curstat->mem.vstack;
devstat->mem.vlibs = curstat->mem.vlibs;
Expand Down
12 changes: 12 additions & 0 deletions man/atop.1
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,18 @@ since the proportional memory size is not part of the standard
process accounting record.
.PP
.TP 9
.B PANON
The proportional memory size of this process, shares of anonymous pages.
.PP
.TP 9
.B PFILE
The proportional memory size of this process, shares of file pages.
.PP
.TP 9
.B PSHMEM
The proportional memory size of this process, shares of shmem pages.
.PP
.TP 9
.B RDDSK
The read data transfer issued physically on disk (so reading from the
disk cache is not accounted for).
Expand Down
9 changes: 8 additions & 1 deletion parseable.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ print_PRM(char *hp, struct sstat *ss, struct tstat *ps, int nact)
for (i=0; i < nact; i++, ps++)
{
printf("%s %d %s %c %u %lld %lld %lld %lld %lld %lld "
"%lld %lld %lld %lld %lld %d %c %lld %lld %d %d %d %d\n",
"%lld %lld %lld %lld %lld %d %c %lld %lld %lld "
"%lld %lld %d %d %d %d\n",
hp,
ps->gen.pid,
spaceformat(ps->gen.name, namout),
Expand All @@ -841,6 +842,12 @@ print_PRM(char *hp, struct sstat *ss, struct tstat *ps, int nact)
ps->gen.isproc ? 'y':'n',
ps->mem.pmem == (unsigned long long)-1LL ?
0:ps->mem.pmem,
ps->mem.panon == (unsigned long long)-1LL ?
0:ps->mem.panon,
ps->mem.pfile == (unsigned long long)-1LL ?
0:ps->mem.pfile,
ps->mem.pshmem == (unsigned long long)-1LL ?
0:ps->mem.pshmem,
ps->mem.vlock,
cgroupv2max(ps->gen.isproc, ps->mem.cgmemmax),
cgroupv2max(ps->gen.isproc, ps->mem.cgmemmaxr),
Expand Down
44 changes: 36 additions & 8 deletions photoproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ procsmaps(struct tstat *curtask)
{
FILE *fp;
char line[4096];
count_t pssval;
count_t pssval, panon, pfile, pshmem;
static int procsmaps_firstcall = 1;
static char *smapsfile = "smaps";

Expand All @@ -908,16 +908,41 @@ procsmaps(struct tstat *curtask)

if ( (fp = fopen(smapsfile, "r")) )
{
curtask->mem.pmem = 0;
curtask->mem.pmem = 0;
curtask->mem.panon = 0;
curtask->mem.pfile = 0;
curtask->mem.pshmem = 0;

while (fgets(line, sizeof line, fp))
{
if (memcmp(line, "Pss:", 4) != 0)
if (memcmp(line, "Pss:", 4) == 0)
{
// PSS line found to be accumulated
sscanf(line, "Pss: %llu", &pssval);
curtask->mem.pmem += pssval;
continue;

// PSS line found to be accumulated
sscanf(line, "Pss: %llu", &pssval);
curtask->mem.pmem += pssval;
}
if (memcmp(line, "Pss_Anon:", 9) == 0)
{
// proportional shares of anonymous pages
sscanf(line, "Pss_Anon: %llu", &panon);
curtask->mem.panon += panon;
continue;
}
if (memcmp(line, "Pss_File:", 9) == 0)
{
// proportional shares of file pages
sscanf(line, "Pss_File: %llu", &pfile);
curtask->mem.pfile += pfile;
continue;
}
if (memcmp(line, "Pss_Shmem:", 10) == 0)
{
// proportional shares of shmem pages
sscanf(line, "Pss_Shmem: %llu", &pshmem);
curtask->mem.pshmem += pshmem;
continue;
}
}

/*
Expand All @@ -930,7 +955,10 @@ procsmaps(struct tstat *curtask)
}
else
{
curtask->mem.pmem = (unsigned long long)-1LL;
curtask->mem.pmem = (unsigned long long)-1LL;
curtask->mem.panon = (unsigned long long)-1LL;
curtask->mem.pfile = (unsigned long long)-1LL;
curtask->mem.pshmem = (unsigned long long)-1LL;
}

if (! droprootprivs())
Expand Down
5 changes: 4 additions & 1 deletion photoproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ struct tstat {
count_t vexec; /* virtmem execfile (Kb) */
count_t vmem; /* virtual memory (Kb) */
count_t rmem; /* resident memory (Kb) */
count_t pmem; /* resident memory (Kb) */
count_t pmem; /* proportional memory (Kb) */
count_t panon; /* proportional shares of anonymous pages (Kb) */
count_t pfile; /* proportional shares of file pages (Kb) */
count_t pshmem; /* proportional shares of shmem pages (Kb) */
count_t vgrow; /* virtual growth (Kb) */
count_t rgrow; /* resident growth (Kb) */
count_t vdata; /* virtmem data (Kb) */
Expand Down
14 changes: 12 additions & 2 deletions showgeneric.c
Original file line number Diff line number Diff line change
Expand Up @@ -2542,9 +2542,19 @@ accumulate(struct tstat *curproc, struct tstat *curstat)
if (curstat->mem.pmem != -1)
{
if (curproc->mem.pmem != -1) // no errors?
curstat->mem.pmem += curproc->mem.pmem;
{
curstat->mem.pmem += curproc->mem.pmem;
curstat->mem.panon += curproc->mem.panon;
curstat->mem.pfile += curproc->mem.pfile;
curstat->mem.pshmem += curproc->mem.pshmem;
}
else
curstat->mem.pmem = -1;
{
curstat->mem.pmem = -1;
curstat->mem.panon = -1;
curstat->mem.pfile = -1;
curstat->mem.pshmem = -1;
}
}

curstat->mem.vmem += curproc->mem.vmem;
Expand Down
7 changes: 5 additions & 2 deletions showlinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ proc_printdef *allprocpdefs[]=
&procprt_VSIZE,
&procprt_RSIZE,
&procprt_PSIZE,
&procprt_PANON,
&procprt_PFILE,
&procprt_PSHMEM,
&procprt_VSLIBS,
&procprt_VDATA,
&procprt_VSTACK,
Expand Down Expand Up @@ -1265,8 +1268,8 @@ priphead(int curlist, int totlist, char *showtype, char *showorder,
make_proc_prints(memprocs, MAXITEMS,
"PID:10 TID:3 MINFLT:2 MAJFLT:2 VSTEXT:4 VSLIBS:4 "
"VDATA:4 VSTACK:4 LOCKSZ:3 VSIZE:6 RSIZE:7 PSIZE:5 "
"VGROW:7 RGROW:8 SWAPSZ:5 RUID:1 EUID:0 "
"SORTITEM:9 CMD:10",
"PANON:2 PFILE:2 PSHMEM:2 VGROW:7 RGROW:8 SWAPSZ:5 "
"RUID:1 EUID:0 SORTITEM:9 CMD:10",
"built-in memprocs");

make_proc_prints(schedprocs, MAXITEMS,
Expand Down
3 changes: 3 additions & 0 deletions showlinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ extern proc_printdef procprt_VSTEXT;
extern proc_printdef procprt_VSIZE;
extern proc_printdef procprt_RSIZE;
extern proc_printdef procprt_PSIZE;
extern proc_printdef procprt_PANON;
extern proc_printdef procprt_PFILE;
extern proc_printdef procprt_PSHMEM;
extern proc_printdef procprt_VSLIBS;
extern proc_printdef procprt_VDATA;
extern proc_printdef procprt_VSTACK;
Expand Down
69 changes: 69 additions & 0 deletions showprocs.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ char *procprt_RSIZE_a(struct tstat *, int, int);
char *procprt_RSIZE_e(struct tstat *, int, int);
char *procprt_PSIZE_a(struct tstat *, int, int);
char *procprt_PSIZE_e(struct tstat *, int, int);
char *procprt_PANON_a(struct tstat *, int, int);
char *procprt_PANON_e(struct tstat *, int, int);
char *procprt_PFILE_a(struct tstat *, int, int);
char *procprt_PFILE_e(struct tstat *, int, int);
char *procprt_PSHMEM_a(struct tstat *, int, int);
char *procprt_PSHMEM_e(struct tstat *, int, int);
char *procprt_VSLIBS_a(struct tstat *, int, int);
char *procprt_VSLIBS_e(struct tstat *, int, int);
char *procprt_VDATA_a(struct tstat *, int, int);
Expand Down Expand Up @@ -836,6 +842,69 @@ proc_printdef procprt_PSIZE =
{ " PSIZE", "PSIZE", procprt_PSIZE_a, procprt_PSIZE_e, 6 };
/***************************************************************/
char *
procprt_PANON_a(struct tstat *curstat, int avgval, int nsecs)
{
static char buf[10];

if (curstat->mem.panon == (unsigned long long)-1LL)
return " ?K";

val2memstr(curstat->mem.panon*1024, buf, BFORMAT, 0, 0);
return buf;
}

char *
procprt_PANON_e(struct tstat *curstat, int avgval, int nsecs)
{
return " 0K";
}

proc_printdef procprt_PANON =
{ " PANON", "PANON", procprt_PANON_a, procprt_PANON_e, 6 };
/***************************************************************/
char *
procprt_PFILE_a(struct tstat *curstat, int avgval, int nsecs)
{
static char buf[10];

if (curstat->mem.pfile == (unsigned long long)-1LL)
return " ?K";

val2memstr(curstat->mem.pfile*1024, buf, BFORMAT, 0, 0);
return buf;
}

char *
procprt_PFILE_e(struct tstat *curstat, int avgval, int nsecs)
{
return " 0K";
}

proc_printdef procprt_PFILE =
{ " PFILE", "PFILE", procprt_PFILE_a, procprt_PFILE_e, 6 };
/***************************************************************/
char *
procprt_PSHMEM_a(struct tstat *curstat, int avgval, int nsecs)
{
static char buf[10];

if (curstat->mem.pshmem == (unsigned long long)-1LL)
return " ?K";

val2memstr(curstat->mem.pshmem*1024, buf, BFORMAT, 0, 0);
return buf;
}

char *
procprt_PSHMEM_e(struct tstat *curstat, int avgval, int nsecs)
{
return " 0K";
}

proc_printdef procprt_PSHMEM =
{ "PSHMEM", "PSHMEM", procprt_PSHMEM_a, procprt_PSHMEM_e, 6 };
/***************************************************************/
char *
procprt_VSLIBS_a(struct tstat *curstat, int avgval, int nsecs)
{
static char buf[10];
Expand Down