Bug 14716

Summary: top -m doesn't report highest memory consummer
Product: Busybox Reporter: Frédéric <frederic.delabre>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P3    
Version: 1.33.x   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description Frédéric 2022-03-29 13:25:50 UTC
Hi,

Is there a reason why "top" and "top -m" use a different way of computing VSZ ?

When I run "top -m" as a regular user, it doesn't report some processes because it fails to compute their VSZ (Virtual Memory Size).
This happens not only on root processes, but also on some of the user processes (java in my case).

Looking into the code, I found that "top" and "top -m" have a different method of computing VSZ. Howerever, "top -m" needs permissions to read "/proc/XX/smaps" and failed to get the VSZ for some processes. VSZ is set to 0 and the proces is ignored.

Is there a reason for doing so ?


in procps/top.c, function top_main(), around line 1201:
[I removed many lines]
	IF_FEATURE_TOPMEM(if (scan_mask != TOPMEM_MASK)) {
		top[n].vsz = p->vsz;
	}
	else { /* TOPMEM */
		topmem[n].vsz      = p->smaps.mapped_rw + p->smaps.mapped_ro;
Comment 1 Fred_busybox 2022-12-07 17:54:21 UTC
Hello, 

I am also interested, I have this error with "top -m"

top -m
top: no process info in /proc


I am looking for the "Rss" memory info.


If helpful, on kernel 4.9.232 ARM , by example, there is : 

cat /proc/1528/status
cat /proc/1528/status
Name:   myprocess
Umask:  0022
State:  S (sleeping)
Tgid:   1528
Ngid:   0
Pid:    1528
PPid:   1
TracerPid:      0
Uid:    0       0       0       0
Gid:    0       0       0       0
FDSize: 256
Groups:  
NStgid: 1528
NSpid:  1528
NSpgid: 1316
NSsid:  1316
VmPeak:   271524 kB
VmSize:   271524 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:      7856 kB
VmRSS:      7856 kB
RssAnon:             976 kB
RssFile:            6880 kB
RssShmem:              0 kB
VmData:    26984 kB
VmStk:       132 kB
VmExe:       220 kB
VmLib:     10484 kB
VmPTE:        72 kB
VmPMD:         8 kB
VmSwap:        0 kB
Threads:        25
SigQ:   1/9947
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000001006
SigCgt: 0000000180004000
CapInh: 0000000000000000
CapPrm: 0000003fffffffff
CapEff: 0000003fffffffff
CapBnd: 0000003fffffffff
CapAmb: 0000000000000000
Seccomp:        0
Speculation_Store_Bypass:       unknown
Cpus_allowed:   3
Cpus_allowed_list:      0-1
Mems_allowed:   1
Mems_allowed_list:      0
voluntary_ctxt_switches:        6093
nonvoluntary_ctxt_switches:     30

Regards