diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-10-15 22:37:02 +0200 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2020-10-19 14:42:35 +0200 |
commit | 361877454fe56c95a995d5bdbb7eb70c21e39d62 (patch) | |
tree | 51f75a8ab66ece247dbbec3c673409028bdbec74 /solaris | |
parent | 0db398d4c3472071b2814505242450cd8f831501 (diff) |
Cache PAGE_SIZE
man:sysconf(3) states:
The values obtained from these functions are system configuration constants.
They do not change during the lifetime of a process.
Diffstat (limited to 'solaris')
-rw-r--r-- | solaris/SolarisProcessList.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index 9662f830..ea552841 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -23,6 +23,9 @@ in the source distribution for its full text. #include <math.h> #include <time.h> +#include "CRT.h" + + #define MAXCMDLINE 255 char* SolarisProcessList_readZoneName(kstat_ctl_t* kd, SolarisProcess* sproc) { @@ -157,22 +160,22 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { freemem_pgs = kstat_data_lookup(meminfo, "freemem"); pages = kstat_data_lookup(meminfo, "pagestotal"); - pl->totalMem = totalmem_pgs->value.ui64 * PAGE_SIZE_KB; - if (pl->totalMem > freemem_pgs->value.ui64 * PAGE_SIZE_KB) - pl->usedMem = pl->totalMem - freemem_pgs->value.ui64 * PAGE_SIZE_KB; + pl->totalMem = totalmem_pgs->value.ui64 * CRT_pageSizeKB; + if (pl->totalMem > freemem_pgs->value.ui64 * CRT_pageSizeKB) + pl->usedMem = pl->totalMem - freemem_pgs->value.ui64 * CRT_pageSizeKB; else - pl->usedMem = 0; // This can happen in non-global zone (in theory) + pl->usedMem = 0; // This can happen in non-global zone (in theory) // Not sure how to implement this on Solaris - suggestions welcome! pl->cachedMem = 0; // Not really "buffers" but the best Solaris analogue that I can find to // "memory in use but not by programs or the kernel itself" - pl->buffersMem = (totalmem_pgs->value.ui64 - pages->value.ui64) * PAGE_SIZE_KB; + pl->buffersMem = (totalmem_pgs->value.ui64 - pages->value.ui64) * CRT_pageSizeKB; } else { // Fall back to basic sysconf if kstat isn't working - pl->totalMem = sysconf(_SC_PHYS_PAGES) * PAGE_SIZE; + pl->totalMem = sysconf(_SC_PHYS_PAGES) * CRT_pageSize; pl->buffersMem = 0; pl->cachedMem = 0; - pl->usedMem = pl->totalMem - (sysconf(_SC_AVPHYS_PAGES) * PAGE_SIZE); + pl->usedMem = pl->totalMem - (sysconf(_SC_AVPHYS_PAGES) * CRT_pageSize); } // Part 2 - swap @@ -198,8 +201,8 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { } free(spathbase); free(sl); - pl->totalSwap = totalswap * PAGE_SIZE_KB; - pl->usedSwap = pl->totalSwap - (totalfree * PAGE_SIZE_KB); + pl->totalSwap = totalswap * CRT_pageSizeKB; + pl->usedSwap = pl->totalSwap - (totalfree * CRT_pageSizeKB); } static inline void SolarisProcessList_scanZfsArcstats(ProcessList* pl) { @@ -297,8 +300,8 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * proc->pgrp = _psinfo->pr_pgid; proc->nlwp = _psinfo->pr_nlwp; proc->tty_nr = _psinfo->pr_ttydev; - proc->m_resident = _psinfo->pr_rssize/PAGE_SIZE_KB; - proc->m_size = _psinfo->pr_size/PAGE_SIZE_KB; + proc->m_resident = _psinfo->pr_rssize/CRT_pageSizeKB; + proc->m_size = _psinfo->pr_size/CRT_pageSizeKB; if (!preExisting) { sproc->realpid = _psinfo->pr_pid; |