diff options
author | Peter Zijlstra <peterz@infradead.org> | 2013-11-28 08:26:41 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-12-11 09:52:32 -0500 |
commit | ba1f14fbe70965ae0fb1655a5275a62723f65b77 (patch) | |
tree | 412534b605bf33e5e930172686dd4f31d157fc51 /arch | |
parent | 8e8339a3a1069141985daaa2521ba304509ddecd (diff) |
sched: Remove PREEMPT_NEED_RESCHED from generic code
While hunting a preemption issue with Alexander, Ben noticed that the
currently generic PREEMPT_NEED_RESCHED stuff is horribly broken for
load-store architectures.
We currently rely on the IPI to fold TIF_NEED_RESCHED into
PREEMPT_NEED_RESCHED, but when this IPI lands while we already have
a load for the preempt-count but before the store, the store will erase
the PREEMPT_NEED_RESCHED change.
The current preempt-count only works on load-store archs because
interrupts are assumed to be completely balanced wrt their preempt_count
fiddling; the previous preempt_count load will match the preempt_count
state after the interrupt and therefore nothing gets lost.
This patch removes the PREEMPT_NEED_RESCHED usage from generic code and
pushes it into x86 arch code; the generic code goes back to relying on
TIF_NEED_RESCHED.
Boot tested on x86_64 and compile tested on ppc64.
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reported-and-Tested-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20131128132641.GP10022@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/preempt.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h index 8729723636fd..c8b051933b1b 100644 --- a/arch/x86/include/asm/preempt.h +++ b/arch/x86/include/asm/preempt.h | |||
@@ -8,6 +8,12 @@ | |||
8 | DECLARE_PER_CPU(int, __preempt_count); | 8 | DECLARE_PER_CPU(int, __preempt_count); |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * We use the PREEMPT_NEED_RESCHED bit as an inverted NEED_RESCHED such | ||
12 | * that a decrement hitting 0 means we can and should reschedule. | ||
13 | */ | ||
14 | #define PREEMPT_ENABLED (0 + PREEMPT_NEED_RESCHED) | ||
15 | |||
16 | /* | ||
11 | * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users | 17 | * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users |
12 | * that think a non-zero value indicates we cannot preempt. | 18 | * that think a non-zero value indicates we cannot preempt. |
13 | */ | 19 | */ |
@@ -74,6 +80,11 @@ static __always_inline void __preempt_count_sub(int val) | |||
74 | __this_cpu_add_4(__preempt_count, -val); | 80 | __this_cpu_add_4(__preempt_count, -val); |
75 | } | 81 | } |
76 | 82 | ||
83 | /* | ||
84 | * Because we keep PREEMPT_NEED_RESCHED set when we do _not_ need to reschedule | ||
85 | * a decrement which hits zero means we have no preempt_count and should | ||
86 | * reschedule. | ||
87 | */ | ||
77 | static __always_inline bool __preempt_count_dec_and_test(void) | 88 | static __always_inline bool __preempt_count_dec_and_test(void) |
78 | { | 89 | { |
79 | GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e"); | 90 | GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e"); |