mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Yanfei Xu <yanfei.xu@windriver.com>
Cc: mingo@redhat.com, will@kernel.org, longman@redhat.com,
	boqun.feng@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] locking/mutex: remove rcu_read_lock/unlock as we already disabled preemption
Date: Tue, 12 Oct 2021 15:15:50 +0200	[thread overview]
Message-ID: <YWWKhoRzUWoMsJbk@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20211008032518.1298372-1-yanfei.xu@windriver.com>

On Fri, Oct 08, 2021 at 11:25:18AM +0800, Yanfei Xu wrote:
> preempt_disable/enable() is equal to RCU read-side crital section,
> and the mutex lock slowpath disabled the preemption for the optimistic
> spinning code. Let's remove the rcu_read_lock/unlock for saving some 
> cycles in hot codes.
> 
> Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
> ---
> v1->v2: fix the incorrect comment in code and commit message. 
>         thanks for WaiMan's suggestion.
> 
> BTW, sorry for this late v2 due to a long vocation.
> 
>  kernel/locking/mutex.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
> index 2fede72b6af5..2f654cfb10d9 100644
> --- a/kernel/locking/mutex.c
> +++ b/kernel/locking/mutex.c
> @@ -351,13 +351,14 @@ bool mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner,
>  {
>  	bool ret = true;

	lockdep_assert_preemption_disabled();

> -	rcu_read_lock();
>  	while (__mutex_owner(lock) == owner) {
>  		/*
>  		 * Ensure we emit the owner->on_cpu, dereference _after_

And did you check the other code in locking/ for similar things?

  reply	other threads:[~2021-10-12 13:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08  3:25 Yanfei Xu
2021-10-12 13:15 ` Peter Zijlstra [this message]
2021-10-13  7:54   ` 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=YWWKhoRzUWoMsJbk@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --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®