From: Yanfei Xu <yanfei.xu@windriver.com>
To: peterz@infradead.org, mingo@redhat.com, will@kernel.org,
longman@redhat.com, boqun.feng@gmail.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] locking/rwsem: Use rcu_read_lock_sched to simplify codes
Date: Sun, 26 Sep 2021 18:16:24 +0800 [thread overview]
Message-ID: <20210926101624.2460704-2-yanfei.xu@windriver.com> (raw)
In-Reply-To: <20210926101624.2460704-1-yanfei.xu@windriver.com>
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;
--
2.27.0
next prev parent reply other threads:[~2021-09-26 10:17 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 ` Yanfei Xu [this message]
2021-09-26 19:22 ` [PATCH 2/2] locking/rwsem: Use rcu_read_lock_sched to simplify codes Waiman Long
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=20210926101624.2460704-2-yanfei.xu@windriver.com \
--to=yanfei.xu@windriver.com \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=will@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®