> You are
> allocated a complete shash_desc per I/O. We only allocate one per CPU.
I looked at it --- and using percpu variables in workqueues isn't safe
because the workqueue can change CPU if the CPU is hot-unplugged.
dm-crypt has the same bug --- it also uses workqueue with per-cpu
variables and assumes that the CPU doesn't change for a single work item.
This program shows that work executed in a workqueue can be switched to a
I'm wondering how much other kernel code assumes that workqueues are bound
to a specific CPU, which isn't true if we unplug that CPU.
* A proof of concept that a work item executed on a workqueue may change CPU
* when CPU hot-unplugging is used.
* Compile this as a module and run:
* insmod test.ko; sleep 1; echo 0 >/sys/devices/system/cpu/cpu1/online
* You see that the work item starts executing on CPU 1 and ends up executing
* on different CPU, usually 0.