util-linux/sys-utils
Gerald Schaefer 49834246f5 lsmem: fix total online/offline memory calculation
lsmem currently calculates the total online/offline memory by iterating
over all lsmem->blocks. Depending on the lsmem options, there may be
only one lsmem->block, because all sysfs memory blocks could be merged
into one. In this case, the calculation is wrong, because the individual
online/offline state of the sysfs memory blocks is not preserved, but
rather lsmem->blocks[0].state is set to the state of the first sysfs
memory block, typically MEMORY_STATE_ONLINE (at least on s390).

This means that "Total offline memory" will always be calculated as 0
in such cases, e.g. when using "lsmem --summary", or any options that
would merge the table output to one line, like "lsmem -o RANGE":

~# lsmem --summary
Memory block size:         1G
Total online memory:      20G
Total offline memory:      0B

Adding the "-a" option shows the real summary, since there is no block
merging going on, and the calculation is therefore correct:

~# lsmem -a --summary
Memory block size:         1G
Total online memory:      16G
Total offline memory:      4G

Fix this by moving the online/offline calculation into the loop that
is iterating over all sysfs memory blocks, instead of iterating over
potentially merged lsmem->blocks.

Reported-by: Alexander Klein <alkl@linux.vnet.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
2018-03-20 18:57:07 +01:00
..
.gitignore build-sys: support ./configure ADJTIME_PATH= 2014-06-19 10:30:56 +02:00
Makemodule.am lscpu: move ARM decoding to lscpu-arm.c 2018-01-22 13:08:11 +01:00
blkdiscard.8 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
blkdiscard.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
blkzone.8 blkzone: Fix a typo in blkzone.8 2018-02-26 16:42:35 +01:00
blkzone.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
chcpu.8 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
chcpu.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
chmem.8 lsmem: add --split 2017-10-20 12:37:04 +02:00
chmem.c chmem: cleanup includes 2017-10-23 15:49:22 +02:00
ctrlaltdel.8 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
ctrlaltdel.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
dmesg.1 dmesg: Add --force-prefix option 2017-11-01 15:37:00 +01:00
dmesg.c misc: fix typos using codespell 2018-02-16 11:12:52 +01:00
eject.1 docs: remove some old history from manpages 2017-06-29 12:56:22 +02:00
eject.c sys-utils: use errexec() 2018-02-01 15:44:25 +01:00
fallocate.1 fallocate: Added posix_fallocate() support. 2017-01-31 12:51:28 +01:00
fallocate.c fallocate: remove typo 2017-11-29 15:13:24 +01:00
flock.1 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
flock.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
fsfreeze.8 fsfreeze: move filesystem support info to manual page 2016-12-22 12:18:45 +01:00
fsfreeze.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
fstab.5 fstab(5): mention how tabs are escaped 2017-07-31 13:48:04 +02:00
fstrim.8 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
fstrim.c fstrim: fix fs.h and mount.h collision 2018-03-20 11:42:34 +01:00
fstrim.service.in fstrim: add -v to the systemd service 2016-10-18 12:09:53 +02:00
fstrim.timer fstrim: systemd timer units should be WantedBy=timers.target 2016-01-12 10:30:36 +01:00
hwclock-cmos.c hwclock: remove bool type definition 2017-08-30 11:21:56 +02:00
hwclock-rtc.c hwclock: rename --debug option to --verbose 2018-01-17 13:29:11 +01:00
hwclock.8.in hwclock: rename --debug option to --verbose 2018-01-17 13:29:11 +01:00
hwclock.c hwclock: add --ul-debug implementing debug.h 2018-01-22 11:10:22 +01:00
hwclock.h hwclock: add --ul-debug implementing debug.h 2018-01-22 11:10:22 +01:00
ipcmk.1 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
ipcmk.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
ipcrm.1 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
ipcrm.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
ipcs.1 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
ipcs.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
ipcutils.c ipcs: fix memory leak [coverity scan] 2017-10-12 14:39:54 +02:00
ipcutils.h ipcs: ulong -> unsigned long 2016-02-11 12:31:03 +01:00
ldattach.8 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
ldattach.c ldattach: simplify debugging function when vwarnx(3) is available 2017-07-15 22:02:53 +01:00
losetup.8 losetup: rename to --sector-size and LOG-SEC 2017-10-02 11:59:57 +02:00
losetup.c losetup: fix bitwise vs. logical typo [coverity scan] 2017-10-12 14:45:11 +02:00
lscpu-arm.c lscpu-arm: add Faraday And Brahma cores 2018-02-13 15:25:20 +02:00
lscpu-dmi.c lscpu: move struct lscpu_desc header file 2018-01-22 13:04:12 +01:00
lscpu.1 lscpu: add --json 2017-03-14 15:32:53 +01:00
lscpu.c Avoid crash in min/max caculation when cpu#0 being offline 2018-03-17 13:22:13 +01:00
lscpu.h lscpu: move ARM decoding to lscpu-arm.c 2018-01-22 13:08:11 +01:00
lsipc.1 lsipc: fix options parsing and sync with man page 2017-05-02 23:22:04 +01:00
lsipc.c lib/timeutils: add common ISO timestamp masks 2017-11-10 16:34:55 -05:00
lsmem.1 Fix minor typos on man pages 2018-03-01 16:42:34 +02:00
lsmem.c lsmem: fix total online/offline memory calculation 2018-03-20 18:57:07 +01:00
lsns.8 Fix minor typos on man pages 2018-03-01 16:42:34 +02:00
lsns.c lsns: remove if-after-xcalloc 2018-02-20 14:59:40 +01:00
mount.8 mount: (man) be explicit about bind operation 2018-03-19 11:46:11 +01:00
mount.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
mountpoint.1 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
mountpoint.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
nsenter.1 nsenter: fix usage() and improve man page 2017-01-09 12:50:09 +01:00
nsenter.c sys-utils: use errexec() 2018-02-01 15:44:25 +01:00
pivot_root.8 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
pivot_root.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
prlimit.1 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
prlimit.c sys-utils: use errexec() 2018-02-01 15:44:25 +01:00
readprofile.8 docs: remove some old history from manpages 2017-06-29 12:56:22 +02:00
readprofile.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
renice.1 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
renice.c Fix minor typo: priorty -> priority 2017-12-31 13:07:43 +02:00
rfkill.8 Fix minor typos on man pages 2018-03-01 16:42:34 +02:00
rfkill.c misc: fix typos using codespell 2018-02-16 11:12:52 +01:00
rtcwake.8.in misc: fix typos using codespell 2018-02-16 11:12:52 +01:00
rtcwake.c rtcwake: wait stdin to settle down before entering a system sleep 2018-01-02 15:14:37 +01:00
setarch.8 docs: improve setarch(8) manual page 2017-12-10 10:50:32 +00:00
setarch.c sys-utils: use errexec() 2018-02-01 15:44:25 +01:00
setpriv.1 setpriv: add example section 2018-03-08 16:31:59 +00:00
setpriv.c sys-utils: use errexec() 2018-02-01 15:44:25 +01:00
setsid.1 setsid: new option --fork 2017-11-08 11:38:26 +01:00
setsid.c sys-utils: use errexec() 2018-02-01 15:44:25 +01:00
swapoff.8 build-sys: move swapon from mount/ to sys-utils/ 2012-01-11 12:14:29 +01:00
swapoff.c build-sys: don't check for swapon() number of arguments 2017-12-18 13:57:20 +01:00
swapon-common.c mount, umount, swapon, fsck, lsblk, findmnt: harmonize six error messages 2016-03-16 10:39:38 +01:00
swapon-common.h swapon: split swapon-common.c 2014-09-22 13:16:25 +02:00
swapon.8 docs: remove some old history from manpages 2017-06-29 12:56:22 +02:00
swapon.c sys-utils: use errexec() 2018-02-01 15:44:25 +01:00
switch_root.8 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
switch_root.c sys-utils: use errexec() 2018-02-01 15:44:25 +01:00
tunelp.8 tunelp: use linux header 2017-07-31 13:48:04 +02:00
tunelp.c tunelp: use linux header 2017-07-31 13:48:04 +02:00
umount.8 docs: remove some old history from manpages 2017-06-29 12:56:22 +02:00
umount.c misc: consolidate macro style USAGE_HELP_OPTIONS 2017-06-29 16:54:33 +02:00
unshare.1 Fix minor typos on man pages 2018-03-01 16:42:34 +02:00
unshare.c sys-utils: use errexec() 2018-02-01 15:44:25 +01:00
wdctl.8 docs: replace FTP by HTTPS in kernel.org URLs 2016-12-19 11:22:26 +01:00
wdctl.c wdctl: do not call fsync(2) when closing watchdog device 2017-07-31 13:48:04 +02:00
zramctl.8 Added the support for lz4hc, deflate, and 842 2018-01-24 17:10:09 +01:00
zramctl.c zramctl: use xstrdup() 2018-01-30 12:21:03 +01:00