Bug#911746: zram-tools: Processor count is incorrect on some ARM boards
On some ARM boards, zramswap miscounts the processors due to not anchoring
the regex it uses to count processors.
For example /proc/cpuinfo on a Raspberry Pi looks like:
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 897.37
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2835
Revision : 0002
Serial : 000000003ec63cb3
contains the word "processor" twice when there's only one processor.
To fix this, the regex used by grep on line 23 of zramswap needs to be
"^processor" instead of just "processor".
Alternatively replacing that line with some lscpu invocation punts the problem
of parsing /proc/cpuinfo to another package.
(Note that this was reported on my laptop as reportbug isn't available on the
Bug#911746: Since Kernel 3.15 device per core not needed
Zram has supported streams since 3.15 and part from a history of bugs and the pointless nature of partitioning memory swap size via the reciprocal of cores and creating smaller swaps!
The biggest question is why.
The worst bug is that the script makes zero check to see if any zram devices exist on start or exit.
I don’t think there is another precedent where something and so simple as checking for existing devices is missing in any package.
That is just the start of how flawed the methods are starting with how is it zram-tools when all it does is some bad illogical swaps?
At least do a simple check that zram exists on start and use the hot_add system that zram uses for devices.
>if [ ! -d "/sys/class/zram-control" ]; then
>modprobe --verbose zram
On unload if =$(cat /sys/class/zram-control/hot_add) <> 0 then devices exist.