From: Mike Galbraith <umgwanakikbuti@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
rostedt@goodmis.org, John Kacur <jkacur@redhat.com>
Subject: Re: [ANNOUNCE] 3.14-rt1
Date: Wed, 23 Apr 2014 12:37:05 +0200 [thread overview]
Message-ID: <1398249425.5910.14.camel@marge.simpson.net> (raw)
In-Reply-To: <20140411185739.GA6644@linutronix.de>
On Fri, 2014-04-11 at 20:57 +0200, Sebastian Andrzej Siewior wrote:
> This -RT series didn't crashed within ~4h testing on my ARM and
> x86-32.
> x86-64 crashed after I started hackbench. I figured out that the crash
> does not happen with lazy-preempt disabled. Therefore the last but one
> patch in the queue disables lazy preempt on x86-64. With this change the
> test box survived ~2h without a crash. I look at this later but it looks
> good now.
I think the below fixes it (in a more or less minimalist way), but it's
not very pretty. Methinks it would be prettier to either clone the x86
percpu + fold logic, or neutralize that optimization completely when
PREEMPT_LAZY is enabled.
x86_32 bit is completely untested, x86_64 hasn't exploded.. yet :)
---
include/linux/preempt.h | 3 +--
arch/x86/include/asm/preempt.h | 8 ++++++++
arch/x86/kernel/asm-offsets.c | 1 +
arch/x86/kernel/entry_32.S | 9 ++++++---
arch/x86/kernel/entry_64.S | 7 +++++--
5 files changed, 21 insertions(+), 7 deletions(-)
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -126,8 +126,7 @@ do { \
#define preempt_enable_notrace() \
do { \
barrier(); \
- if (unlikely(__preempt_count_dec_and_test() || \
- test_thread_flag(TIF_NEED_RESCHED_LAZY))) \
+ if (unlikely(__preempt_count_dec_and_test())) \
__preempt_schedule_context(); \
} while (0)
#else
--- a/arch/x86/include/asm/preempt.h
+++ b/arch/x86/include/asm/preempt.h
@@ -94,7 +94,11 @@ static __always_inline bool __preempt_co
{
if (____preempt_count_dec_and_test())
return true;
+#ifdef CONFIG_PREEMPT_LAZY
return test_thread_flag(TIF_NEED_RESCHED_LAZY);
+#else
+ return false;
+#endif
}
/*
@@ -102,8 +106,12 @@ static __always_inline bool __preempt_co
*/
static __always_inline bool should_resched(void)
{
+#ifdef CONFIG_PREEMPT_LAZY
return unlikely(!__this_cpu_read_4(__preempt_count) || \
test_thread_flag(TIF_NEED_RESCHED_LAZY));
+#else
+ return unlikely(!__this_cpu_read_4(__preempt_count));
+#endif
}
#ifdef CONFIG_PREEMPT
--- a/arch/x86/kernel/asm-offsets.c
+++ b/arch/x86/kernel/asm-offsets.c
@@ -72,4 +72,5 @@ void common(void) {
BLANK();
DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
+ DEFINE(_PREEMPT_ENABLED, PREEMPT_ENABLED);
}
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -365,19 +365,22 @@ ENTRY(resume_kernel)
need_resched:
# preempt count == 0 + NEED_RS set?
cmpl $0,PER_CPU_VAR(__preempt_count)
+#ifndef CONFIG_PREEMPT_LAZY
+ jnz restore_all
+#else
jz test_int_off
# atleast preempt count == 0 ?
- cmpl $_TIF_NEED_RESCHED,PER_CPU_VAR(__preempt_count)
+ cmpl $_PREEMPT_ENABLED,PER_CPU_VAR(__preempt_count)
jne restore_all
cmpl $0,TI_preempt_lazy_count(%ebp) # non-zero preempt_lazy_count ?
jnz restore_all
- testl $_TIF_NEED_RESCHED_LAZY, %ecx
+ testl $_TIF_NEED_RESCHED_LAZY, TI_flags(%ebp)
jz restore_all
-
test_int_off:
+#endif
testl $X86_EFLAGS_IF,PT_EFLAGS(%esp) # interrupts off (exception path) ?
jz restore_all
call preempt_schedule_irq
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1104,10 +1104,13 @@ ENTRY(native_iret)
/* rcx: threadinfo. interrupts off. */
ENTRY(retint_kernel)
cmpl $0,PER_CPU_VAR(__preempt_count)
+#ifndef CONFIG_PREEMPT_LAZY
+ jnz retint_restore_args
+#else
jz check_int_off
# atleast preempt count == 0 ?
- cmpl $_TIF_NEED_RESCHED,PER_CPU_VAR(__preempt_count)
+ cmpl $_PREEMPT_ENABLED,PER_CPU_VAR(__preempt_count)
jnz retint_restore_args
cmpl $0, TI_preempt_lazy_count(%rcx)
@@ -1115,8 +1118,8 @@ ENTRY(retint_kernel)
bt $TIF_NEED_RESCHED_LAZY,TI_flags(%rcx)
jnc retint_restore_args
-
check_int_off:
+#endif
bt $9,EFLAGS-ARGOFFSET(%rsp) /* interrupts off? */
jnc retint_restore_args
call preempt_schedule_irq
next prev parent reply other threads:[~2014-04-23 10:37 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-11 18:57 Sebastian Andrzej Siewior
2014-04-11 19:34 ` Pavel Vasilyev
2014-04-19 14:46 ` Mike Galbraith
2014-04-21 3:31 ` Mike Galbraith
2014-05-02 10:16 ` Sebastian Andrzej Siewior
2014-04-25 7:40 ` Mike Galbraith
2014-04-26 8:38 ` Mike Galbraith
2014-04-26 13:58 ` Mike Galbraith
2014-04-28 5:09 ` Mike Galbraith
2014-04-28 9:09 ` Mike Galbraith
2014-04-28 14:18 ` Steven Rostedt
2014-04-28 14:37 ` Mike Galbraith
2014-04-28 14:43 ` Mike Galbraith
2014-04-29 5:21 ` Mike Galbraith
2014-04-30 0:13 ` Steven Rostedt
2014-04-30 7:43 ` Mike Galbraith
2014-04-30 13:06 ` Mike Galbraith
2014-04-30 13:15 ` Steven Rostedt
2014-04-30 14:00 ` Mike Galbraith
2014-04-30 14:19 ` Steven Rostedt
2014-04-30 14:33 ` Steven Rostedt
2014-04-30 14:54 ` Mike Galbraith
2014-04-30 15:11 ` Steven Rostedt
2014-04-30 15:15 ` Mike Galbraith
2014-04-30 15:48 ` Steven Rostedt
2014-04-30 15:56 ` Mike Galbraith
2014-05-01 17:36 ` Mike Galbraith
2014-05-01 18:42 ` Steven Rostedt
2014-05-02 1:45 ` Mike Galbraith
2014-04-30 15:21 ` Mike Galbraith
2014-04-30 14:45 ` Mike Galbraith
2014-05-02 10:09 ` Sebastian Andrzej Siewior
2014-05-02 11:16 ` Mike Galbraith
2014-04-23 10:37 ` Mike Galbraith [this message]
2014-04-23 12:19 ` Steven Rostedt
2014-04-24 4:06 ` Mike Galbraith
2014-04-24 7:12 ` Sebastian Andrzej Siewior
2014-04-24 7:26 ` Mike Galbraith
2014-04-26 18:29 ` Fernando Lopez-Lezcano
2014-05-02 11:37 ` Sebastian Andrzej Siewior
2014-05-15 17:51 ` Fernando Lopez-Lezcano
2014-05-15 20:09 ` Fernando Lopez-Lezcano
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=1398249425.5910.14.camel@marge.simpson.net \
--to=umgwanakikbuti@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=jkacur@redhat.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
all inboxes | Powered by JetHome®