linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <yang.shi@linaro.org>
To: tglx@linutronix.de, bigeasy@linutronix.de, rostedt@goodmis.org
Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org,
	linaro-kernel@lists.linaro.org, yang.shi@linaro.org
Subject: [PATCH v2] rt: x86: enable preemption in IST exception for x86-32
Date: Mon, 14 Dec 2015 15:06:44 -0800	[thread overview]
Message-ID: <1450134404-16662-1-git-send-email-yang.shi@linaro.org> (raw)

When running some ptrace single step tests on x86-32 machine, the below problem
is triggered:

BUG: sleeping function called from invalid context at linux-rt/kernel/locking/rtmutex.c:917
in_atomic(): 1, irqs_disabled(): 0, pid: 1041, name: dummy2
INFO: lockdep is turned off.
Preemption disabled at:[<c100326f>] do_debug+0x1f/0x1a0

CPU: 10 PID: 1041 Comm: dummy2 Tainted: G        W       4.1.13-rt13 #1
Hardware name: Intel Corporation S5520HC/S5520HC, BIOS S5500.86B.01.10.0025.030220091519 03/02/2009
 00000000 00000000 e1811e80 c1aa8306 00000000 e1811ea8 c1080517 c1d8b2e8
 c100326f c100326f 00000411 e5b7d5b4 e1d521c4 00000005 e1811f74 e1811ec4
 c1ab0eff e1d51cc0 e5b7d180 c1081403 e5b7d180 e5b7d180 e1811ee4 c1064b5a
Call Trace:
 [<c1aa8306>] dump_stack+0x46/0x5c
 [<c1080517>] ___might_sleep+0x137/0x220
 [<c100326f>] ? do_debug+0x1f/0x1a0
 [<c100326f>] ? do_debug+0x1f/0x1a0
 [<c1ab0eff>] rt_spin_lock+0x1f/0x80
 [<c1081403>] ? preempt_count_sub+0xb3/0x110
 [<c1064b5a>] do_force_sig_info+0x2a/0xc0
 [<c106567d>] force_sig_info+0xd/0x10
 [<c1010cff>] send_sigtrap+0x6f/0x80
 [<c10033b1>] do_debug+0x161/0x1a0
 [<c1ab2921>] debug_stack_correct+0x2e/0x35

Mainline kernel commit 959274753857efe9c5f1ba35fe727f51e9aa128d
("x86, traps: Track entry into and exit from IST context"), introduced
ist_enter which disables preemption uncondiontionally for both x86-64 and
x86-32. However, x86-32 does not have an IST and the stack still belongs to
the current task and there is no problem in scheduling out the task.

Signed-off-by: Yang Shi <yang.shi@linaro.org>
---
 arch/x86/kernel/traps.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index ebae118..7139bc0 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -90,7 +90,7 @@ static inline void conditional_sti(struct pt_regs *regs)
 
 static inline void conditional_sti_ist(struct pt_regs *regs)
 {
-#ifdef CONFIG_X86_64
+#if !defined(CONFIG_X86_64)
 	/*
 	 * X86_64 uses a per CPU stack on the IST for certain traps
 	 * like int3. The task can not be preempted when using one
@@ -101,7 +101,7 @@ static inline void conditional_sti_ist(struct pt_regs *regs)
 	 * On x86_32 the task keeps its own stack and it is OK if the
 	 * task schedules out.
 	 */
-	preempt_count_inc();
+	ist_begin_non_atomic(regs);
 #endif
 	if (regs->flags & X86_EFLAGS_IF)
 		local_irq_enable();
@@ -117,8 +117,8 @@ static inline void conditional_cli_ist(struct pt_regs *regs)
 {
 	if (regs->flags & X86_EFLAGS_IF)
 		local_irq_disable();
-#ifdef CONFIG_X86_64
-	preempt_count_dec();
+#if !defined(CONFIG_X86_64)
+	ist_end_non_atomic();
 #endif
 }
 
-- 
2.0.2


             reply	other threads:[~2015-12-14 23:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-14 23:06 Yang Shi [this message]
2015-12-22 12:06 ` [PATCH v2] rt: x86: enable preemption in IST exception for x86-32 Sebastian Andrzej Siewior
2015-12-22 18:12   ` Shi, Yang

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=1450134404-16662-1-git-send-email-yang.shi@linaro.org \
    --to=yang.shi@linaro.org \
    --cc=bigeasy@linutronix.de \
    --cc=linaro-kernel@lists.linaro.org \
    --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).