From: Tejun Heo <tj@kernel.org>
To: Douglas Miller <dougmill@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, Christoph Lameter <cl@linux.com>,
linux-block@vger.kernel.org,
Guilherme Piccoli <gpiccoli@br.ibm.com>
Subject: Re: [PATCH 1/1] percpu-refcount: fix reference leak during percpu-atomic transition
Date: Fri, 27 Jan 2017 17:09:58 -0500 [thread overview]
Message-ID: <20170127220958.GA2476@mtj.duckdns.org> (raw)
In-Reply-To: <1485550748-28075-1-git-send-email-dougmill@linux.vnet.ibm.com>
Hello, Douglas.
On Fri, Jan 27, 2017 at 02:59:08PM -0600, Douglas Miller wrote:
> @@ -212,7 +212,7 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref)
> this_cpu_inc(*percpu_count);
> ret = true;
> } else {
> - ret = atomic_long_inc_not_zero(&ref->count);
> + ret = (atomic_long_inc_not_zero(&ref->count) != 0);
> }
>
> rcu_read_unlock_sched();
> @@ -246,7 +246,7 @@ static inline bool percpu_ref_tryget_live(struct percpu_ref *ref)
> this_cpu_inc(*percpu_count);
> ret = true;
> } else if (!(ref->percpu_count_ptr & __PERCPU_REF_DEAD)) {
> - ret = atomic_long_inc_not_zero(&ref->count);
> + ret = (atomic_long_inc_not_zero(&ref->count) != 0);
Ugh.... Damn it. This is why we use bools instead of ints for these
things. For some reason, we're returning bools but using an integer
variable to cache the result. :(
Can you please convert the local variable to bool instead?
Thanks a lot for spotting this.
--
tejun
next prev parent reply other threads:[~2017-01-27 22:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-27 20:59 [PATCH 1/1] percpu-refcount: fix reference leak during percpu-atomic transition Douglas Miller
2017-01-27 21:39 ` Douglas Miller
2017-01-27 22:09 ` Tejun Heo [this message]
2017-01-27 22:14 ` Jens Axboe
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=20170127220958.GA2476@mtj.duckdns.org \
--to=tj@kernel.org \
--cc=cl@linux.com \
--cc=dougmill@linux.vnet.ibm.com \
--cc=gpiccoli@br.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.