]> granicus.if.org Git - procps-ng/commitdiff
library: add new derived smaps_rollup item, <pids> api
authorJim Warner <james.warner@comcast.net>
Wed, 16 Jun 2021 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Thu, 17 Jun 2021 06:42:58 +0000 (16:42 +1000)
That recent addition of USS to the ps program prompted
this change.  Rather than have it (and soon top) add 2
separate items to yield the desired value, we will let
our new library perform the arithmetic when necessary.

Outside of a little extra storage, there is no runtime
costs for such an extension. There is, however, a real
benefit to having such code in the library. Now should
callers choose to sort on this new field, results will
be guaranteed to be what was expected (i.e. accurate).

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/pids.c
proc/pids.h

index 8cc86c7ddcb90617753c0a27e3cbbccd78b0b067..54fd3a37113eb557479186afb4ce6530a985dc00 100644 (file)
@@ -250,6 +250,7 @@ REG_set(SMAP_LAZY_FREE,   ul_int,  smap_LazyFree)
 REG_set(SMAP_LOCKED,      ul_int,  smap_Locked)
 REG_set(SMAP_PRV_CLEAN,   ul_int,  smap_Private_Clean)
 REG_set(SMAP_PRV_DIRTY,   ul_int,  smap_Private_Dirty)
+setDECL(SMAP_PRV_TOTAL) { (void)I; R->result.ul_int = P->smap_Private_Clean + P->smap_Private_Dirty; }
 REG_set(SMAP_PSS,         ul_int,  smap_Pss)
 REG_set(SMAP_PSS_ANON,    ul_int,  smap_Pss_Anon)
 REG_set(SMAP_PSS_FILE,    ul_int,  smap_Pss_File)
@@ -528,6 +529,7 @@ static struct {
     { RS(SMAP_LOCKED),       f_smaps,    NULL,      QS(ul_int),    0,        TS(ul_int)  },
     { RS(SMAP_PRV_CLEAN),    f_smaps,    NULL,      QS(ul_int),    0,        TS(ul_int)  },
     { RS(SMAP_PRV_DIRTY),    f_smaps,    NULL,      QS(ul_int),    0,        TS(ul_int)  },
+    { RS(SMAP_PRV_TOTAL),    f_smaps,    NULL,      QS(ul_int),    0,        TS(ul_int)  },
     { RS(SMAP_PSS),          f_smaps,    NULL,      QS(ul_int),    0,        TS(ul_int)  },
     { RS(SMAP_PSS_ANON),     f_smaps,    NULL,      QS(ul_int),    0,        TS(ul_int)  },
     { RS(SMAP_PSS_FILE),     f_smaps,    NULL,      QS(ul_int),    0,        TS(ul_int)  },
index b34174d3334486b5b377d14688e95dacbee984c7..10ba9f5186b47f8dbe0423c299efcc91fc235e66 100644 (file)
@@ -135,6 +135,7 @@ enum pids_item {
     PIDS_SMAP_LOCKED,       //   ul_int        smaps_rollup: Locked
     PIDS_SMAP_PRV_CLEAN,    //   ul_int        smaps_rollup: Private_Clean
     PIDS_SMAP_PRV_DIRTY,    //   ul_int        smaps_rollup: Private_Dirty
+    PIDS_SMAP_PRV_TOTAL,    //   ul_int        derived from SMAP_PRV_CLEAN + SMAP_PRV_DIRTY
     PIDS_SMAP_PSS,          //   ul_int        smaps_rollup: Pss
     PIDS_SMAP_PSS_ANON,     //   ul_int        smaps_rollup: Pss_Anon
     PIDS_SMAP_PSS_FILE,     //   ul_int        smaps_rollup: Pss_File