Bug 1794160

Summary: lsmem on ARM system does not report useful information
Product: Red Hat Enterprise Linux 8 Reporter: Ben Crocker <bcrocker>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED NOTABUG QA Contact: Radka Brychtova <rskvaril>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.1CC: dhildenb, kzak, piliu
Target Milestone: rc   
Target Release: 8.0   
Hardware: aarch64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-08 10:22:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ben Crocker 2020-01-22 19:33:05 UTC
Description of problem:

The 'lsmem' command on an ARM system I'm using
(hpe-apollo-cn99xx-12.khw4.lab.eng.bos.redhat.com)
produces the following message:

lsmem: This system does not support memory blocks

This seems like an easily fixable friendliness issue;
fixing it would bring lsmem up to the standards of 
other tools like lscpu.


Version-Release number of selected component (if applicable):
util-linux.aarch64    2.32.1-22.el8

How reproducible:

All the time.


Steps to Reproduce:
1. Install RHEL 8
2. Log in
3. Run lsmem command

Actual results:

Unhelpful message: lsmem: This system does not support memory blocks


Expected results:

The 'lsmem' command should at least produce the summary I see on
other archs, e.g.:

X86: 
Memory block size:       128M
Total online memory:    31.5G
Total offline memory:      0B

Power:
Memory block size:       256M
Total online memory:     256G
Total offline memory:      0B

S390x:

RANGE                                 SIZE  STATE REMOVABLE BLOCK
0x0000000000000000-0x000000007fffffff   2G online        no   0-7

Memory block size:       256M
Total online memory:       2G
Total offline memory:      0Binfo:

Comment 1 Karel Zak 2020-07-07 12:47:10 UTC
> lsmem: This system does not support memory blocks

This error message means that lsmem cannot access file "/sys/devices/system/memory/block_size_bytes". Can you provide 

 ls /sys/devices/system/memory

from your system. 

Note that the summary output is calculated from the /sys data ...

Comment 2 Ben Crocker 2020-07-07 16:39:13 UTC
There is no /sys/devices/system/memory directory on the system in question.
I think it would be useful to print the message, followed by the
"Total online memory" message.

Comment 3 Karel Zak 2020-07-08 07:45:34 UTC
I have updated upstream tree to report the problem in a more obvious way, now:

 $ lsmem
 lsmem: cannot open /sys/devices/system/memory: No such file or directory

I don't think that generates a summary from another source (e.g. /proc) makes any sense. The command is designed to list memory ranges, and it's not free(1) replacement.

Note that /sys/devices/system/memory is under active kernel development. Maybe later it will provide some information also for (your) ARM. 
David (added to CC:), any objection?

Comment 4 David Hildenbrand 2020-07-08 08:50:59 UTC
/sys/devices/system/memory is only really helpful for memory hotplug. Otherwise it's just noise. In fact, it's only compiled into the kernel if we compile support for memory hotplug.

Now, on arm64 we don't have memory hotplug support, therefore no /sys/devices/system/memory. arm64 memory hotplug support is upstream (and code is included downstream), but it's not enabled yet in downstream kernels. Once we unlock that we also get /sys/devices/system/memory, and therefore, lsmem.

"man lsmem" somewhat indicates that this is glued to memory hotplug capabilities ("The command also shows the memory block size and the amount of
memory in online and offline state.") - the concept of online/offline memory ranges only exists with memory hot(un)plug.

Side note: The "REMOVABLE" output of lsmem is no longer really helpful on recent kernels. It's output will either be "Yes" or "No".