[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YNyEpy+IUtJbWOZS@hirez.programming.kicks-ass.net>
Date: Wed, 30 Jun 2021 16:50:15 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: "Xu, Yanfei" <yanfei.xu@...driver.com>
Cc: Waiman Long <longman@...hat.com>, Ingo Molnar <mingo@...hat.com>,
Will Deacon <will@...nel.org>,
Boqun Feng <boqun.feng@...il.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] locking/mutex: Reduce chance of setting HANDOFF bit on
unlocked mutex
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().
Powered by blists - more mailing lists