Skip to content

Commit 77d0e8d

Browse files
committed
[explorer/memory] Fall back to meminfo if memory blocks detection fails
In the unlikely (or impossible?) case that there are no online memory blocks, fall back to /proc/meminfo.
1 parent 53d8a99 commit 77d0e8d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

explorer/memory

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ in
8989
then
9090
# Use memory blocks if the architecture (e.g. x86, PPC64, s390)
9191
# supports them (they denote physical memory)
92-
num_mem_blocks=$(cat /sys/devices/system/memory/memory[0-9]*/state | grep -cxF online)
9392
mem_block_size=$(cat /sys/devices/system/memory/block_size_bytes)
94-
95-
echo $((num_mem_blocks * 0x${mem_block_size})) | bytes2kib && exit
93+
if num_mem_blocks=$(cat /sys/devices/system/memory/memory[0-9]*/state 2>/dev/null | grep -cxF online)
94+
then
95+
echo $((num_mem_blocks * 0x${mem_block_size})) | bytes2kib
96+
exit 0
97+
fi
9698
fi
9799
if test -r /proc/meminfo
98100
then

0 commit comments

Comments
 (0)