UPSTREAM: percpu: fix synchronization between synchronous map extension and chunk destruction
(cherry picked from commit 6710e594f71ccaad8101bc64321152af7cd9ea28)
For non-atomic allocations, pcpu_alloc() can try to extend the area
map synchronously after dropping pcpu_lock; however, the extension
wasn't synchronized against chunk destruction and the chunk might get
freed while extension is in progress.
This patch fixes the bug by putting most of non-atomic allocations
under pcpu_alloc_mutex to synchronize against pcpu_balance_work which
is responsible for async chunk management including destruction.
Signed-off-by: Tejun Heo <email@example.com>
Reported-and-tested-by: Alexei Starovoitov <firstname.lastname@example.org>
Reported-by: Vlastimil Babka <email@example.com>
Reported-by: Sasha Levin <firstname.lastname@example.org>
Cc: email@example.com # v3.18+
Fixes: 1a4d76076cda ("percpu: implement asynchronous chunk population")
1 file changed