From: Peter Zijlstra <peterz@infradead.org>
To: Waiman Long <waiman.long@hpe.com>
Cc: Jason Low <jason.low2@hpe.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ding Tianhong <dingtianhong@huawei.com>,
Thomas Gleixner <tglx@linutronix.de>,
Will Deacon <Will.Deacon@arm.com>, Ingo Molnar <mingo@redhat.com>,
imre.deak@intel.com, linux-kernel@vger.kernel.org,
Davidlohr Bueso <dave@stgolabs.net>,
Tim Chen <tim.c.chen@linux.intel.com>,
terry.rudd@hpe.com, "Paul E. McKenney" <paulmck@us.ibm.com>,
jason.low2@hp.com
Subject: Re: [PATCH v4] locking/mutex: Prevent lock starvation when spinning is disabled
Date: Fri, 19 Aug 2016 21:33:15 +0200 [thread overview]
Message-ID: <20160819193315.GG10153@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <57B73A62.9020901@hpe.com>
Please trim your emails..
On Fri, Aug 19, 2016 at 12:57:06PM -0400, Waiman Long wrote:
> >+static inline bool __mutex_trylock_pending(struct mutex *lock)
> >+{
> >+ return atomic_read(&lock->count)>= 0&&
> >+ atomic_xchg_acquire(&lock->count, -1) == 1;
> >+}
> >+
>
> Maybe you can make a more general __mutex_trylock function that is used in
> all three trylock attempts in the slowpath. For example,
>
> static inline bool __mutex_trylock(struct mutex *lock, bool waiter)
> {
> if (waiter) {
> return atomic_read(&lock->count) >= 0 &&
> atomic_xchg_acquire(&lock->count, -1) == 1;
> } else {
> return !need_yield_to_waiter(lock) &&
> !mutex_is_locked(lock) &&
> ((atomic_xchg_acquire(&lock->count, 0) == 1);
> }
> }
That seems more messy to me..
next prev parent reply other threads:[~2016-08-19 19:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-19 0:39 [PATCH v4] locking/mutex: Prevent lock starvation when spinning is disabled Jason Low
2016-08-19 4:11 ` Jason Low
2016-08-19 12:13 ` Peter Zijlstra
2016-08-19 16:57 ` Waiman Long
2016-08-19 19:33 ` Peter Zijlstra [this message]
2016-08-19 19:45 ` Linus Torvalds
2016-08-23 12:45 ` Peter Zijlstra
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=20160819193315.GG10153@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Will.Deacon@arm.com \
--cc=dave@stgolabs.net \
--cc=dingtianhong@huawei.com \
--cc=imre.deak@intel.com \
--cc=jason.low2@hp.com \
--cc=jason.low2@hpe.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@us.ibm.com \
--cc=terry.rudd@hpe.com \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@linux.intel.com \
--cc=torvalds@linux-foundation.org \
--cc=waiman.long@hpe.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