percpu: fix synchronization between chunk->map_extend_work 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)
commitd273823dc63bb51e3adc11e0f7c324d86e2d2009
tree271933a6ecdd2f1b84b5ed6cd2e06833ff23c47a
parent272d474fc6e9e4362c69df4b77adc0008b53b4ad
percpu: fix synchronization between chunk->map_extend_work and chunk destruction

[ Upstream commit 4f996e234dad488e5d9ba0858bc1bae12eff82c3 ]

Atomic allocations can trigger async map extensions which is serviced
by chunk->map_extend_work.  pcpu_balance_work which is responsible for
destroying idle chunks wasn't synchronizing properly against
chunk->map_extend_work and may end up freeing the chunk while the work
item is still in flight.

This patch fixes the bug by rolling async map extension operations
into pcpu_balance_work.

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: 9c824b6a172c ("percpu: make sure chunk->map array has available space")
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
mm/percpu.c