[Bug 265937] [Linuxulator]: linprocfs: process size incorrect
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 26 Feb 2023 09:44:01 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265937
Fernando ApesteguĂa <fernape@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fernape@FreeBSD.org
--- Comment #3 from Fernando ApesteguĂa <fernape@FreeBSD.org> ---
Created attachment 240417
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=240417&action=edit
Remove P2K when printing ki_size in 'stat' file
I can confirm. This is what I see in my Ubuntu system:
fernape~ cat /proc/1993/stat
1993 (gnome-session-b) S 1990 1990 1990 1026 1990 4194304 1726 5624 2 6 4 2 6 2
20 0 3 0 9929 --->230969344<--- 3912 18446744073709551615 94683959459840
94683959602729 140731149451200 0 0 0 0 4096 16386 0 0 0 17 0 0 0 0 0 0
94683959675184 94683959689872 94683990056960 140731149454254 140731149454305
140731149454305 140731149455318 0
fernape~ cat /proc/1993/status | grep VmSize
VmSize: 225556 kB <---
fernape~ cat /proc/1993/statm
56389 <--- 3912 3485 35 0 4481 0
According to https://www.kernel.org/doc/html/latest/filesystems/proc.html, the
three marked values should be the same, but in different units:
status is in kB
statm is in pages
stat is in bytes
Let's see if they check out:
In status, we have 225556 kb divided by 4 (since my pages in Ubuntu are 4 kB
each) gives me 56389 pages and if I multiply by 4046 bytes in each page, we get
the 230969344 bytes in the 'stat' file.
This is what I see in current for my fluxbox process in the linprocfs:
fernape@hammer:~$ grep VmSize /compat/linux/proc/1549/status
VmSize: 24708 kB
fernape@hammer:~$ cat /compat/linux/proc/1549/statm
6177 2884 0 208 36 5932 0
fernape@hammer:~$ cut -f23 -d' ' /compat/linux/proc/1549/stat
101203968
This does not check out: 24708 kb bytes = 6177 pages (I have 4 kb pages) =
25300992 bytes, not the 101203968 reported by 'stat'. It is, in effect, exactly
4 times higher.
With the attached patch, the result is the expected one:
fernape@hammer:~$ grep VmSize /compat/linux/proc/1470/status
VmSize: 24708 kB
fernape@hammer:~$ cut -f23 -d' ' /compat/linux/proc/1470/stat
25300992 <--- This is now 24708 * 1024
fernape@hammer:~$ cat /compat/linux/proc/1470/statm
6177 2810 0 208 36 5932 0 <--- This is still 24708/4
--
You are receiving this mail because:
You are the assignee for the bug.