percpu: fix synchronization between synchronous map extension and chunk destruction
authorTejun Heo <tj@kernel.org>
Wed, 25 May 2016 15:48:25 +0000 (11:48 -0400)
committerSasha Levin <sasha.levin@oracle.com>
Mon, 11 Jul 2016 00:19:50 +0000 (20:19 -0400)
commit62f7175fa64005be2e090618da5a20f87752704d
tree0f21bcd6a4afec9652112755c652c3efda3b824e
parentd273823dc63bb51e3adc11e0f7c324d86e2d2009
percpu: fix synchronization between synchronous map extension and chunk destruction

[ Upstream 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 <tj@kernel.org>
Reported-and-tested-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Reported-by: Vlastimil Babka <vbabka@suse.cz>
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Cc: stable@vger.kernel.org # v3.18+
Fixes: 1a4d76076cda ("percpu: implement asynchronous chunk population")
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
mm/percpu.c