From: Tejun Heo <tj@kernel.org>
To: Pavel Begunkov <asml.silence@gmail.com>
Cc: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Christoph Lameter <cl@linux.com>, Dennis Zhou <dennis@kernel.org>
Subject: Re: [PATCH 1/2] percpu_ref: percpu_ref_tryget_live() version holding RCU
Date: Wed, 20 Oct 2021 10:10:07 -1000 [thread overview]
Message-ID: <YXB3n2pxiKYbd2Il@slm.duckdns.org> (raw)
In-Reply-To: <d65d6d60faf773293e5189bd2b95c7bbc034976b.1634759754.git.asml.silence@gmail.com>
On Wed, Oct 20, 2021 at 09:03:18PM +0100, Pavel Begunkov wrote:
> +/**
> + * percpu_ref_tryget_live_rcu - same as percpu_ref_tryget_live() but the
> + * caller is responsible for taking RCU.
> + *
> + * This function is safe to call as long as @ref is between init and exit.
> + */
> +static inline bool percpu_ref_tryget_live_rcu(struct percpu_ref *ref)
> +{
> + unsigned long __percpu *percpu_count;
> + bool ret = false;
> +
> + if (likely(__ref_is_percpu(ref, &percpu_count))) {
> + this_cpu_inc(*percpu_count);
> + ret = true;
> + } else if (!(ref->percpu_count_ptr & __PERCPU_REF_DEAD)) {
> + ret = atomic_long_inc_not_zero(&ref->data->count);
> + }
> + return ret;
> +}
Can we please add rcu_read_lock_held() assertion? Other than that, looks
fine to me.
Thanks.
--
tejun
next prev parent reply other threads:[~2021-10-20 20:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-20 20:03 [PATCH 0/2] optimise blk_try_enter_queue() Pavel Begunkov
2021-10-20 20:03 ` [PATCH 1/2] percpu_ref: percpu_ref_tryget_live() version holding RCU Pavel Begunkov
2021-10-20 20:10 ` Tejun Heo [this message]
2021-10-21 8:41 ` Pavel Begunkov
2021-10-20 20:03 ` [PATCH 2/2] block: kill extra rcu lock/unlock in queue enter Pavel Begunkov
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=YXB3n2pxiKYbd2Il@slm.duckdns.org \
--to=tj@kernel.org \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=cl@linux.com \
--cc=dennis@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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