From: Steven Rostedt <rostedt@goodmis.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org,
tglx@linutronix.de, peterz@infradead.org
Subject: Re: [PATCH RT] kernel/futex: don't deboost too early
Date: Fri, 30 Sep 2016 12:00:38 -0400 [thread overview]
Message-ID: <20160930120038.5fe7d535@grimm.local.home> (raw)
In-Reply-To: <20160930083913.aqjpynzsj5d3xxho@linutronix.de>
On Fri, 30 Sep 2016 10:39:14 +0200
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> The sequence:
> T1 holds futex
> T2 blocks on futex and boosts T1
> T1 unlocks futex and holds hb->lock
> T1 unlocks rt mutex, so T1 has no more pi waiters
> T3 blocks on hb->lock and adds itself to the pi waiters list of T1
> T1 unlocks hb->lock and deboosts itself
> T4 preempts T1 so the wakeup of T2 gets delayed
>
> As a workaround I attempt here do unlock the hb->lock without a deboost
> and perform the deboost after the wake up of the waiter.
>
> Cc: stable-rt@vger.kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> include/linux/spinlock.h | 6 +++++
> include/linux/spinlock_rt.h | 2 ++
> kernel/futex.c | 2 +-
> kernel/locking/rtmutex.c | 53 +++++++++++++++++++++++++++++++++++++++------
> 4 files changed, 55 insertions(+), 8 deletions(-)
>
This looks awfully complex. Would something as simple as this work?
What harm can happen by moving the holding of the lock after the
wakeups for RT?
-- Steve
diff --git a/kernel/futex.c b/kernel/futex.c
index 2d572ed..bb900bd 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1347,9 +1347,14 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this,
* deboost first (and lose our higher priority), then the task might get
* scheduled away before the wake up can take place.
*/
+#ifndef CONFIG_PREEMPT_RT_FULL
spin_unlock(&hb->lock);
+#endif
wake_up_q(&wake_q);
wake_up_q_sleeper(&wake_sleeper_q);
+#ifdef CONFIG_PREEMPT_RT_FULL
+ spin_unlock(&hb->lock);
+#endif
if (deboost)
rt_mutex_adjust_prio(current);
next prev parent reply other threads:[~2016-09-30 16:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-30 8:39 [PATCH RT] kernel/futex: don't deboost too early Sebastian Andrzej Siewior
2016-09-30 16:00 ` Steven Rostedt [this message]
2016-09-30 16:10 ` Sebastian Andrzej Siewior
2016-09-30 18:43 ` Thomas Gleixner
2016-10-02 10:01 ` Steven Rostedt
2016-10-03 17:38 ` Thomas Gleixner
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=20160930120038.5fe7d535@grimm.local.home \
--to=rostedt@goodmis.org \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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