linprocfs(4): Fixup process size in the /proc/pid/stat file

According to the Linux sources the kernel exposes a proces virtual
memory size via proc filesystem into the three files - stat, status
and statm. This is the struct mm->total_vm value adjusted to the
corresponding units - bytes, kilobytes and pages.

The fix is based on a fernape@ analysis.

PR:		265937
Reported by:	Ray Bellis
MFC after:	3 days
This commit is contained in:
Dmitry Chagin 2023-02-26 16:42:22 +03:00
parent 6dbfbe6e11
commit a55b5a9aed

View File

@ -1023,7 +1023,7 @@ linprocfs_doprocstat(PFS_FILL_ARGS)
PS_ADD("0", "%d", 0); /* removed field */
PS_ADD("itrealvalue", "%d", 0); /* XXX */
PS_ADD("starttime", "%lu", TV2J(&kp.ki_start) - TV2J(&boottime));
PS_ADD("vsize", "%ju", P2K((uintmax_t)kp.ki_size));
PS_ADD("vsize", "%ju", (uintmax_t)kp.ki_size);
PS_ADD("rss", "%ju", (uintmax_t)kp.ki_rssize);
PS_ADD("rlim", "%lu", kp.ki_rusage.ru_maxrss);
PS_ADD("startcode", "%ju", (uintmax_t)startcode);