Pika · #193

97-zram.rules (kernel-pika-config) disables zswap on every udev event: stray text breaks the rule's line continuation

PendingBug1 votes0 commentsby Ghostbroker

Line 11 of 97-zram.rules contains stray text, Add commentMore actions, after its line-continuation backslash. It looks like it was copied from the GitHub web UI. udev rejects line 11 (Invalid key/value pair, ignoring.) and throws away its match keys, but it keeps line 12 as a standalone rule with no match conditions:

ACTION=="change", KERNEL=="zram0", ATTR{initstate}=="1", SYSCTL{vm.swappiness}="150", \Add commentMore actions RUN+="/bin/sh -c 'echo N > /sys/module/zswap/parameters/enabled'"

So instead of running once when zram0 starts up, echo N > /sys/module/zswap/parameters/enabled runs for every udev event on every device. (The intended vm.swappiness=150 is never applied.)

So this leads to the following issues:

  • zswap can't be used on PikaOS. The kernel boots with zswap on, and udev coldplug turns it off around 2.5s into boot. Anything that turns it back on (a tmpfiles.d w line, a manual write) gets undone at the next device event: USB plug, monitor wake, audio device change, and so on.
  • Overhead: a /bin/sh is spawned per udev event. I counted 2,193 of these writes during one boot, still firing more than 60s in.
  • This hits anyone who disables zram and uses zswap plus disk swap instead. It also hits anyone with zram who expected zswap to stay off only while zram is active, since it now goes off regardless.

Bug report

Steps to reproduce

sudo udevadm test /sys/class/net/lo 2>&1 | grep 97-zram Output: /usr/lib/udev/rules.d/97-zram.rules:11 Invalid key/value pair, ignoring. lo: /usr/lib/udev/rules.d/97-zram.rules:12 RUN+="/bin/sh -c 'echo N > /sys/module/zswap/parameters/enabled'": Set command: ... The same happens for any device, e.g. /sys/class/block/nvme0n1. To see it live:

echo Y | sudo tee /sys/module/zswap/parameters/enabled sudo udevadm trigger --action=change --settle /sys/class/mem/null cat /sys/module/zswap/parameters/enabled # -> N

I confirmed who was writing with ftrace: the function tracer with set_ftrace_filter=zswap_enabled_param_set shows hundreds of sh callers via param_attr_store during boot.

Actual behavior

Fix:

Remove the stray text so the continuation works:

ACTION=="change", KERNEL=="zram0", ATTR{initstate}=="1", SYSCTL{vm.swappiness}="150",
RUN+="/bin/sh -c 'echo N > /sys/module/zswap/parameters/enabled'"

Line 2 of the file's comment has the same stray text. It's harmless there, but worth cleaning up. It might also be worth adding udevadm verify to the package build, since it flags this file (udev rules check failed).

Discussion

Sign in with Discord to comment.