library: add new derived smaps_rollup item, <pids> api

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>
This commit is contained in:
Jim Warner 2021-06-16 00:00:00 -05:00 committed by Craig Small
parent 2ea082b4af
commit 3e94210fe4
2 changed files with 3 additions and 0 deletions

View 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_LOCKED, ul_int, smap_Locked)
REG_set(SMAP_PRV_CLEAN, ul_int, smap_Private_Clean) REG_set(SMAP_PRV_CLEAN, ul_int, smap_Private_Clean)
REG_set(SMAP_PRV_DIRTY, ul_int, smap_Private_Dirty) 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, ul_int, smap_Pss)
REG_set(SMAP_PSS_ANON, ul_int, smap_Pss_Anon) REG_set(SMAP_PSS_ANON, ul_int, smap_Pss_Anon)
REG_set(SMAP_PSS_FILE, ul_int, smap_Pss_File) 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_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_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_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), 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_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) }, { RS(SMAP_PSS_FILE), f_smaps, NULL, QS(ul_int), 0, TS(ul_int) },

View File

@ -135,6 +135,7 @@ enum pids_item {
PIDS_SMAP_LOCKED, // ul_int smaps_rollup: Locked PIDS_SMAP_LOCKED, // ul_int smaps_rollup: Locked
PIDS_SMAP_PRV_CLEAN, // ul_int smaps_rollup: Private_Clean PIDS_SMAP_PRV_CLEAN, // ul_int smaps_rollup: Private_Clean
PIDS_SMAP_PRV_DIRTY, // ul_int smaps_rollup: Private_Dirty 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, // ul_int smaps_rollup: Pss
PIDS_SMAP_PSS_ANON, // ul_int smaps_rollup: Pss_Anon PIDS_SMAP_PSS_ANON, // ul_int smaps_rollup: Pss_Anon
PIDS_SMAP_PSS_FILE, // ul_int smaps_rollup: Pss_File PIDS_SMAP_PSS_FILE, // ul_int smaps_rollup: Pss_File