From: Waiman Long <waiman.long@hpe.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Mike Galbraith <umgwanakikbuti@gmail.com>,
Ingo Molnar <mingo@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
Jason Low <jason.low2@hpe.com>,
Scott J Norton <scott.norton@hpe.com>,
Douglas Hatch <doug.hatch@hpe.com>
Subject: Re: [PATCH -tip] locking/rtmutex: Reduce top-waiter blocking on a lock
Date: Mon, 26 Sep 2016 17:40:04 -0400 [thread overview]
Message-ID: <57E995B4.4070003@hpe.com> (raw)
In-Reply-To: <20160924012803.GC30291@linux-80c1.suse>
On 09/23/2016 09:28 PM, Davidlohr Bueso wrote:
>
> +#ifdef CONFIG_RT_MUTEX_SPIN_ON_OWNER
> +static bool rt_mutex_spin_on_owner(struct rt_mutex *lock,
> + struct task_struct *owner)
> +{
> + bool ret = true;
> +
> + /*
> + * The last owner could have just released the lock,
> + * immediately try taking it again.
> + */
> + if (!owner)
> + goto done;
> +
> + rcu_read_lock();
> + while (rt_mutex_owner(lock) == owner) {
> + /*
> + * Ensure we emit the owner->on_cpu, dereference _after_
> + * checking lock->owner still matches owner. If that fails,
> + * owner might point to freed memory. If it still matches,
> + * the rcu_read_lock() ensures the memory stays valid.
> + */
> + barrier();
> + if (!owner->on_cpu || need_resched()) {
> + ret = false;
> + break;
> + }
> +
> + cpu_relax_lowlatency();
> + }
> + rcu_read_unlock();
> +done:
> + return ret;
> +}
> +
One issue that I saw is that the spinner may no longer be the top waiter
while spinning. Should we also check this condition in the spin loop?
Cheers,
Longman
next prev parent reply other threads:[~2016-09-26 21:40 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 13:42 [RFC PATCH v2 0/5] futex: Introducing throughput-optimized futexes Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 1/5] futex: Add futex_set_timer() helper function Waiman Long
2016-09-22 21:31 ` Thomas Gleixner
2016-09-23 0:45 ` Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 2/5] futex: Rename futex_pi_state to futex_state Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes Waiman Long
2016-09-21 6:59 ` Mike Galbraith
2016-09-21 23:37 ` Waiman Long
2016-09-22 7:49 ` Peter Zijlstra
2016-09-22 13:04 ` Waiman Long
2016-09-22 13:34 ` Thomas Gleixner
2016-09-22 14:41 ` Davidlohr Bueso
2016-09-22 14:46 ` Thomas Gleixner
2016-09-22 15:11 ` Davidlohr Bueso
2016-09-22 20:08 ` Waiman Long
2016-09-22 20:28 ` Waiman Long
2016-09-22 20:38 ` Thomas Gleixner
2016-09-22 21:48 ` Waiman Long
2016-09-23 13:02 ` Thomas Gleixner
2016-09-26 22:02 ` Waiman Long
2016-09-22 21:39 ` Davidlohr Bueso
2016-09-22 21:41 ` Thomas Gleixner
2016-09-22 21:59 ` Waiman Long
2016-09-27 19:02 ` [PATCH v2 -tip] locking/rtmutex: Reduce top-waiter blocking on a lock Davidlohr Bueso
2016-10-24 18:08 ` Davidlohr Bueso
2016-10-24 18:48 ` Thomas Gleixner
2016-09-24 1:28 ` [PATCH " Davidlohr Bueso
2016-09-26 21:40 ` Waiman Long [this message]
2016-09-22 19:56 ` [RFC PATCH v2 3/5] futex: Throughput-optimized (TO) futexes Waiman Long
2016-09-22 20:26 ` Thomas Gleixner
2016-09-22 21:13 ` Waiman Long
2016-09-22 13:23 ` Peter Zijlstra
2016-09-22 17:21 ` Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 4/5] futex: Add timeout support to TO futexes Waiman Long
2016-09-20 13:42 ` [RFC PATCH v2 5/5] futex, doc: TO futexes document Waiman Long
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=57E995B4.4070003@hpe.com \
--to=waiman.long@hpe.com \
--cc=corbet@lwn.net \
--cc=dave@stgolabs.net \
--cc=doug.hatch@hpe.com \
--cc=jason.low2@hpe.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=scott.norton@hpe.com \
--cc=tglx@linutronix.de \
--cc=umgwanakikbuti@gmail.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;
as well as URLs for NNTP newsgroup(s).