Skip to content

Commit

Permalink
percpu-refcount: improve WARN messages
Browse files Browse the repository at this point in the history
percpu_ref's WARN messages can be a lot more helpful by indicating
who's the culprit.  Make them report the release function that the
offending percpu-refcount is associated with.  This should make it a
lot easier to track down the reported invalid refcnting operations.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Kent Overstreet <kmo@daterainc.com>
  • Loading branch information
Tejun Heo committed Sep 20, 2014
1 parent 23cb898 commit 4843c33
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/percpu-refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,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));
WARN_ONCE(atomic_read(&ref->count) <= 0,
"percpu ref (%pf) <= 0 (%i) after killed",
ref->release, atomic_read(&ref->count));

/* @ref is viewed as dead on all CPUs, send out kill confirmation */
if (ref->confirm_kill)
Expand Down Expand Up @@ -178,7 +179,8 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref,
percpu_ref_func_t *confirm_kill)
{
WARN_ONCE(ref->pcpu_count_ptr & PCPU_REF_DEAD,
"percpu_ref_kill() called more than once!\n");
"percpu_ref_kill() called more than once on %pf!",
ref->release);

ref->pcpu_count_ptr |= PCPU_REF_DEAD;
ref->confirm_kill = confirm_kill;
Expand Down

0 comments on commit 4843c33

Please sign in to comment.