statm should report memory as multiples of allocation_granularity instead of page_size

that ensures that values in statm mupltiplied by POSIX _SC_PAGESIZE give the correct values
This commit is contained in:
Erik M. Bray 2016-11-16 15:36:41 +01:00 committed by Corinna Vinschen
parent 9ba4744620
commit 6477a48cd1
1 changed files with 5 additions and 1 deletions

View File

@ -1251,12 +1251,16 @@ format_process_statm (void *data, char *&destbuf)
_pinfo *p = (_pinfo *) data;
unsigned long vmsize = 0UL, vmrss = 0UL, vmtext = 0UL, vmdata = 0UL,
vmlib = 0UL, vmshare = 0UL;
size_t page_scale;
if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata,
&vmlib, &vmshare))
return 0;
page_scale = wincap.allocation_granularity() / wincap.page_size();
destbuf = (char *) crealloc_abort (destbuf, 96);
return __small_sprintf (destbuf, "%ld %ld %ld %ld %ld %ld 0\n",
vmsize, vmrss, vmshare, vmtext, vmlib, vmdata);
vmsize / page_scale, vmrss / page_scale, vmshare / page_scale,
vmtext / page_scale, vmlib / page_scale, vmdata / page_scale);
}
extern "C" {