Skip to content

Commit

Permalink
percpu: fix pcpu_reclaim() locking
Browse files Browse the repository at this point in the history
pcpu_reclaim() calls pcpu_depopulate_chunk() which makes use of pages
array and bitmap returned by pcpu_get_pages_and_bitmap() and thus
should be called under pcpu_alloc_mutex.  pcpu_reclaim() released the
mutex before calling depopulate leading to double free and other
strange problems caused by the unexpected concurrent usages of pages
array and bitmap.  Fix it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Christoph Lameter <cl@linux-foundation.org>
  • Loading branch information
Tejun Heo committed Aug 14, 2009
1 parent 384be2b commit 971f391
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mm/percpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,12 +1181,13 @@ static void pcpu_reclaim(struct work_struct *work)
}

spin_unlock_irq(&pcpu_lock);
mutex_unlock(&pcpu_alloc_mutex);

list_for_each_entry_safe(chunk, next, &todo, list) {
pcpu_depopulate_chunk(chunk, 0, pcpu_unit_size);
free_pcpu_chunk(chunk);
}

mutex_unlock(&pcpu_alloc_mutex);
}

/**
Expand Down

0 comments on commit 971f391

Please sign in to comment.