From: joe.korty@concurrent-rt.com
To: Julia Cartwright <julia@ni.com>
Cc: tglx@linutronix.de, rostedt@goodmis.org,
linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH RT] sample fix for splat in futex_[un]lock_pi for !rt
Date: Wed, 4 Jul 2018 13:35:19 -0400 [thread overview]
Message-ID: <20180704173519.GA24614@zipoli.concurrent-rt.com> (raw)
Balance atomic/!atomic migrate_enable calls in futex_[un]lock_pi.
The clever use of migrate_disable/enable in rt patch
"futex: workaround migrate_disable/enable in different"
has balanced atomic/!atomic context only for the rt kernel.
This workaround makes it balanced for both rt and !rt.
The 'solution' presented here is for reference only.
A better solution might be for !rt to go back to using
migrate_enable/disable == preempt_enable/disable.
This patch passes the futex selftests for rt and !rt.
Sample kernel splat, edited for brevity. This happens
near the end of boot on a CentOS 7 installation.
WARNING: CPU: 1 PID: 5966 at kernel/sched/core.c:6994 migrate_enable+0x24e/0x2f0
CPU: 1 PID: 5966 Comm: threaded-ml Not tainted 4.14.40-rt31 #1
Hardware name: Supermicro X9DRL-3F/iF/X9DRL-3F/iF, BIOS 3.2 09/22/2015
task: ffff88046b67a6c0 task.stack: ffffc900053a0000
RIP: 0010:migrate_enable+0x24e/0x2f0
RSP: 0018:ffffc900053a3df8 EFLAGS: 00010246
Call Trace:
futex_unlock_pi+0x134/0x210
do_futex+0x13f/0x190
SyS_futex+0x6e/0x150
do_syscall_64+0x6f/0x190
entry_SYSCALL_64_after_hwframe+0x42/0xb7
WARNING: CPU: 1 PID: 5966 at kernel/sched/core.c:6998 migrate_enable+0x75/0x2f0
CPU: 1 PID: 5966 Comm: threaded-ml Tainted: G W 4.14.40-rt31 #1
Hardware name: Supermicro X9DRL-3F/iF/X9DRL-3F/iF, BIOS 3.2 09/22/2015
task: ffff88046b67a6c0 task.stack: ffffc900053a0000
RIP: 0010:migrate_enable+0x75/0x2f0
RSP: 0018:ffffc900053a3df8 EFLAGS: 00010246
Call Trace:
futex_unlock_pi+0x134/0x210
do_futex+0x13f/0x190
SyS_futex+0x6e/0x150
do_syscall_64+0x6f/0x190
entry_SYSCALL_64_after_hwframe+0x42/0xb7
This patch was developed against 4.14.40-rt31. Should be
applicatible to all rt releases in which migrate_enable !=
preempt_enable for !rt kernels.
Signed-off-by: Joe Korty <joe.korty@concurrent-rt.com>
Index: b/kernel/futex.c
===================================================================
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2838,7 +2838,14 @@ retry_private:
spin_unlock(q.lock_ptr);
ret = __rt_mutex_start_proxy_lock(&q.pi_state->pi_mutex, &rt_waiter, current);
raw_spin_unlock_irq(&q.pi_state->pi_mutex.wait_lock);
+#ifdef CONFIG_PREEMPT_RT_FULL
migrate_enable();
+#else
+ /* !rt has to force balanced atomic/!atomic migrate_enable/disable uses */
+ preempt_disable();
+ migrate_enable();
+ preempt_enable();
+#endif
if (ret) {
if (ret == 1)
@@ -2998,7 +3005,14 @@ retry:
/* drops pi_state->pi_mutex.wait_lock */
ret = wake_futex_pi(uaddr, uval, pi_state);
+#ifdef CONFIG_PREEMPT_RT_FULL
+ migrate_enable();
+#else
+ /* !rt has to force balanced atomic/!atomic uses */
+ preempt_disable();
migrate_enable();
+ preempt_enable();
+#endif
put_pi_state(pi_state);
next reply other threads:[~2018-07-04 17:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 17:35 joe.korty [this message]
2018-07-05 15:50 ` [PATCH RT] sched/migrate_disable: fallback to preempt_disable() instead barrier() Sebastian Andrzej Siewior
2018-07-05 16:18 ` joe.korty
2018-07-05 16:59 ` Sebastian Andrzej Siewior
2018-07-06 10:58 ` [PATCH RT v2] " Sebastian Andrzej Siewior
2018-07-06 19:05 ` joe.korty
2018-07-11 15:39 ` Sebastian Andrzej Siewior
2018-07-11 15:43 ` Steven Rostedt
2018-07-05 16:23 ` [PATCH RT] " Steven Rostedt
2018-07-05 16:38 ` Sebastian Andrzej Siewior
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=20180704173519.GA24614@zipoli.concurrent-rt.com \
--to=joe.korty@concurrent-rt.com \
--cc=julia@ni.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).