zramctl fails if called within a certain interval after modprobe zram.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
util-linux (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
On my machine, I can trigger the bug 100% of the time if I do this:
modprobe zram; d=$(zramctl --find) && zramctl --size 256M $d
Here is the error message zramctl emits:
zramctl: /dev/zram0: failed to reset: Device or resource busy
However, the following always work (0% failure)!
modprobe zram; sleep 0.1; d=$(zramctl --find) && zramctl --size 256M $d
modprobe zram; d=$(zramctl --find) && sleep 0.1 && zramctl --size 256M $d
And the following sometimes works and sometimes doesn't:
modprobe zram; d=$(zramctl --find --size 256M)
Chances are about 25% of failure according to this:
for i in {0..99};
do
echo $i;
modprobe -r zram;
modprobe zram;
d=$(zramctl --find --size 256M);
sleep 0.05;
done 2>&1 | grep -c failed
Bizarrely, while putting a long sleep (0.1s) after the modprobe fixes
the problem, putting a short sleep in (0.01s) increases the failure
rate to 95%!
-------
for i in {0..99};
do
echo $i;
modprobe -r zram;
modprobe zram;
sleep 0.01 # <-- this makes things worse!
d=$(zramctl --find --size 256M);
sleep 0.05;
done 2>&1 | grep -c failed
-------
for i in {0..99};
do
echo $i;
modprobe -r zram;
modprobe zram;
sleep 0.10 # <-- this completely fixes the problem
d=$(zramctl --find --size 256M);
sleep 0.05;
done 2>&1 | grep -c failed
-------
Because of the weird window of time in which this bug occurs, I assume it is caused by some asynchronous process briefly locking the device shortly after 'modprobe zram'. I'm guessing zramctl's --find part is running before the lock but the --size part happens while the device is in use.
Status changed to 'Confirmed' because the bug affects multiple users.