Skip to content

Commit

Permalink
percpu-refcount: Add a WARN() for ref going negative
Browse files Browse the repository at this point in the history
AIO had a missing get, which led to an ioctx leak - after percpu_ref_kill() the
ref was 0 so percpu_ref_put() never saw it hit 0.

This wasn't noticed at the time because it all happened completely silently,
this adds a WARN() which would've caught the aio bug.

tj: Used WARN_ONCE() instead of WARN().

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Kent Overstreet authored and Tejun Heo committed Jan 21, 2014
1 parent 6ce4eac commit 687b0ad
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/percpu-refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ static void percpu_ref_kill_rcu(struct rcu_head *rcu)

atomic_add((int) count - PCPU_COUNT_BIAS, &ref->count);

WARN_ONCE(atomic_read(&ref->count) <= 0, "percpu ref <= 0 (%i)",
atomic_read(&ref->count));

/* @ref is viewed as dead on all CPUs, send out kill confirmation */
if (ref->confirm_kill)
ref->confirm_kill(ref);
Expand Down

0 comments on commit 687b0ad

Please sign in to comment.