Does /proc/[pid]/status Always Use kB?

memoryproc

Particularly, does proc always list the VmRSS value in kB? I can't find a solid answer on the documentation, although it appears that it sticks to one unit.

Best Answer

Yes, it's always in kB. KiB (1024-bytes, not 1000) to be exact.

At least in Linux 4.0 (and this code has been largely unchanged since at least April 2005—that's when Linus switched to git, and I don't care to check back further) that output comes from task_mem in fs/proc/task_mmu.c. Excerpting a few lines:

seq_printf(m,
    "VmPeak:\t%8lu kB\n"
    "VmSize:\t%8lu kB\n"
    "VmLck:\t%8lu kB\n"
    "VmPin:\t%8lu kB\n"
    "VmHWM:\t%8lu kB\n"
    "VmRSS:\t%8lu kB\n"
    "VmData:\t%8lu kB\n"
    "VmStk:\t%8lu kB\n"
    "VmExe:\t%8lu kB\n"
    "VmLib:\t%8lu kB\n"
    "VmPTE:\t%8lu kB\n"
    "VmPMD:\t%8lu kB\n"
    "VmSwap:\t%8lu kB\n",
    hiwater_vm << (PAGE_SHIFT-10),
    ⋮
);

Not sure if you can read C, but that "kB" is hardcoded there. There is no logic to output any other unit.