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 /dragonflybsd | |
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 'dragonflybsd')
-rw-r--r-- | dragonflybsd/DragonFlyBSDProcessList.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index 87f16069..0792c75b 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -9,7 +9,6 @@ in the source distribution for its full text. #include "ProcessList.h" #include "DragonFlyBSDProcessList.h" #include "DragonFlyBSDProcess.h" -#include "Macros.h" #include <unistd.h> #include <stdlib.h> @@ -22,6 +21,9 @@ in the source distribution for its full text. #include <string.h> #include <sys/param.h> +#include "CRT.h" +#include "Macros.h" + static int MIB_hw_physmem[2]; static int MIB_vm_stats_vm_v_page_count[4]; @@ -54,8 +56,8 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui len = sizeof(pageSize); if (sysctlbyname("vm.stats.vm.v_page_size", &pageSize, &len, NULL, 0) == -1) { - pageSize = PAGE_SIZE; - pageSizeKb = PAGE_SIZE_KB; + pageSize = CRT_pageSize; + pageSizeKb = CRT_pageSizeKB; } else { pageSizeKb = pageSize / ONE_K; } @@ -431,12 +433,12 @@ void ProcessList_goThroughEntries(ProcessList* this) { proc->m_size = kproc->kp_vm_map_size / 1024 / pageSizeKb; proc->m_resident = kproc->kp_vm_rssize; - proc->percent_mem = (proc->m_resident * PAGE_SIZE_KB) / (double)(this->totalMem) * 100.0; + proc->percent_mem = (proc->m_resident * CRT_pageSizeKB) / (double)(this->totalMem) * 100.0; proc->nlwp = kproc->kp_nthreads; // number of lwp thread proc->time = (kproc->kp_swtime + 5000) / 10000; proc->percent_cpu = 100.0 * ((double)kproc->kp_lwp.kl_pctcpu / (double)kernelFScale); - proc->percent_mem = 100.0 * (proc->m_resident * PAGE_SIZE_KB) / (double)(this->totalMem); + proc->percent_mem = 100.0 * (proc->m_resident * pageSizeKb) / (double)(this->totalMem); if (proc->percent_cpu > 0.1) { // system idle process should own all CPU time left regardless of CPU count |