From: Kent Overstreet <kmo@daterainc.com>
To: tj@kernel.org
Cc: linux-kernel@vger.kernel.org, Kent Overstreet <kmo@daterainc.com>
Subject: [PATCH] percpu-refcount: Add a WARN() for ref going negative
Date: Mon, 6 Jan 2014 13:13:26 -0800 [thread overview]
Message-ID: <1389042806-23967-1-git-send-email-kmo@daterainc.com> (raw)
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.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Cc: Tejun Heo <tj@kernel.org>
---
lib/percpu-refcount.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
index 1a53d497a8..32538f12f8 100644
--- a/lib/percpu-refcount.c
+++ b/lib/percpu-refcount.c
@@ -120,6 +120,9 @@ static void percpu_ref_kill_rcu(struct rcu_head *rcu)
atomic_add((int) count - PCPU_COUNT_BIAS, &ref->count);
+ WARN(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);
--
1.8.5.2
next reply other threads:[~2014-01-06 21:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-06 21:13 Kent Overstreet [this message]
2014-01-12 3:35 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389042806-23967-1-git-send-email-kmo@daterainc.com \
--to=kmo@daterainc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®