From: Waiman Long <llong@redhat.com>
To: Yanfei Xu <yanfei.xu@windriver.com>,
peterz@infradead.org, mingo@redhat.com, will@kernel.org,
boqun.feng@gmail.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] locking/rwsem: Use rcu_read_lock_sched to simplify codes
Date: Sun, 26 Sep 2021 15:22:19 -0400 [thread overview]
Message-ID: <4e4c9adf-5444-e331-fefa-0d72aea8ba57@redhat.com> (raw)
In-Reply-To: <20210926101624.2460704-2-yanfei.xu@windriver.com>
On 9/26/21 6:16 AM, Yanfei Xu wrote:
> Use rcu_read_lock_sched to simplify the codes, and it also saves
> some cycles of handling rcu nesting counter.
>
> Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
> ---
> kernel/locking/rwsem.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
> index 000e8d5a2884..7afadfe02286 100644
> --- a/kernel/locking/rwsem.c
> +++ b/kernel/locking/rwsem.c
> @@ -616,8 +616,7 @@ static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem)
> return false;
> }
>
> - preempt_disable();
> - rcu_read_lock();
> + rcu_read_lock_sched();
> owner = rwsem_owner_flags(sem, &flags);
> /*
> * Don't check the read-owner as the entry may be stale.
> @@ -625,8 +624,7 @@ static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem)
> if ((flags & RWSEM_NONSPINNABLE) ||
> (owner && !(flags & RWSEM_READER_OWNED) && !owner_on_cpu(owner)))
> ret = false;
> - rcu_read_unlock();
> - preempt_enable();
> + rcu_read_unlock_sched();
>
> lockevent_cond_inc(rwsem_opt_fail, !ret);
> return ret;
I don't think there is any performance gain with this change. I would
prefer the original code that is more readable as some people may not
know rcu_read_lock_sched() will disable preemption if they don't look
into it.
Cheers,
Longman
next prev parent reply other threads:[~2021-09-26 19:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-26 10:16 [PATCH 1/2] locking/mutex: remove rcu_read_lock/unlock as we already disabled preemption Yanfei Xu
2021-09-26 10:16 ` [PATCH 2/2] locking/rwsem: Use rcu_read_lock_sched to simplify codes Yanfei Xu
2021-09-26 19:22 ` Waiman Long [this message]
2021-09-27 16:41 ` Xu, Yanfei
2021-09-26 19:16 ` [PATCH 1/2] locking/mutex: remove rcu_read_lock/unlock as we already disabled preemption Waiman Long
2021-09-27 0:46 ` Waiman Long
2021-09-27 9:28 ` Xu, Yanfei
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=4e4c9adf-5444-e331-fefa-0d72aea8ba57@redhat.com \
--to=llong@redhat.com \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
--cc=yanfei.xu@windriver.com \
/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®