public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Xu, Yanfei" <yanfei.xu@windriver.com>
Cc: Waiman Long <longman@redhat.com>, Ingo Molnar <mingo@redhat.com>,
	Will Deacon <will@kernel.org>, Boqun Feng <boqun.feng@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] locking/mutex: Reduce chance of setting HANDOFF bit on unlocked mutex
Date: Wed, 30 Jun 2021 16:50:15 +0200	[thread overview]
Message-ID: <YNyEpy+IUtJbWOZS@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <dbd002b9-d266-0f69-1c55-eb4e5d4d6a57@windriver.com>

On Wed, Jun 30, 2021 at 10:43:37PM +0800, Xu, Yanfei wrote:
> > +static inline struct task_struct *__mutex_trylock_or_owner(struct mutex *lock, bool handoff)
> >   {
> >          unsigned long owner, curr = (unsigned long)current;
> > 
> >          owner = atomic_long_read(&lock->owner);
> >          for (;;) { /* must loop, can race against a flag */
> > +               unsigned long flags = __owner_flags(owner);
> >                  unsigned long task = owner & ~MUTEX_FLAGS;
> > 
> >                  if (task) {
> > +                       if (flags & MUTEX_FLAG_PICKUP) {
> > 
> > +                               if (task != curr)
> > +                                       break;
> > +
> > +                               flags &= ~MUTEX_FLAG_PICKUP;
> > +
> 
> Hmm.. Should we also clear HANDOFF bit here? I don't find where it is
> cleared.

Should already be gone; see __mutex_handoff().

      reply	other threads:[~2021-06-30 14:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29 20:11 [PATCH] locking/mutex: Reduce chance of setting HANDOFF bit on unlocked mutex Waiman Long
2021-06-30 10:21 ` Peter Zijlstra
2021-06-30 13:50   ` Waiman Long
2021-06-30 13:56     ` Peter Zijlstra
2021-06-30 14:13       ` Waiman Long
2021-06-30 14:46         ` Peter Zijlstra
2021-06-30 14:43   ` Xu, Yanfei
2021-06-30 14:50     ` Peter Zijlstra [this message]

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=YNyEpy+IUtJbWOZS@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