Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1441578
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH RT 07/14] sched,preempt: Fix preempt_count manipulations |
| Date | 2016-07-12 19:00 +0200 |
| Message-ID | <rU9cm-7AG-45@gated-at.bofh.it> (permalink) |
| References | <rU92F-7wG-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
3.14.72-rt76-rc1 stable review patch.
If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <peterz@infradead.org>
Vikram reported that his ARM64 compiler managed to 'optimize' away the
preempt_count manipulations in code like:
preempt_enable_no_resched();
put_user();
preempt_disable();
Irrespective of that fact that that is horrible code that should be
fixed for many reasons, it does highlight a deficiency in the generic
preempt_count manipulators. As it is never right to combine/elide
preempt_count manipulations like this.
Therefore sprinkle some volatile in the two generic accessors to
ensure the compiler is aware of the fact that the preempt_count is
observed outside of the regular program-order view and thus cannot be
optimized away like this.
x86; the only arch not using the generic code is not affected as we
do all this in asm in order to use the segment base per-cpu stuff.
Cc: stable@vger.kernel.org
Cc: stable-rt@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: a787870924db ("sched, arch: Create asm/preempt.h")
Reported-by: Vikram Mulukutla <markivx@codeaurora.org>
Tested-by: Vikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/asm-generic/preempt.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/asm-generic/preempt.h b/include/asm-generic/preempt.h
index 54352f4dde1a..65759d8b0b46 100644
--- a/include/asm-generic/preempt.h
+++ b/include/asm-generic/preempt.h
@@ -7,10 +7,10 @@
static __always_inline int preempt_count(void)
{
- return current_thread_info()->preempt_count;
+ return READ_ONCE(current_thread_info()->preempt_count);
}
-static __always_inline int *preempt_count_ptr(void)
+static __always_inline volatile int *preempt_count_ptr(void)
{
return ¤t_thread_info()->preempt_count;
}
--
2.8.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH RT 00/14] Linux 3.14.72-rt76-rc1 Steven Rostedt <rostedt@goodmis.org> - 2016-07-12 19:00 +0200 [PATCH RT 14/14] Linux 3.14.72-rt76-rc1 Steven Rostedt <rostedt@goodmis.org> - 2016-07-12 19:00 +0200 [PATCH RT 11/14] mm: perform lru_add_drain_all() remotely Steven Rostedt <rostedt@goodmis.org> - 2016-07-12 19:00 +0200 [PATCH RT 10/14] locallock: add local_lock_on() Steven Rostedt <rostedt@goodmis.org> - 2016-07-12 19:00 +0200 [PATCH RT 07/14] sched,preempt: Fix preempt_count manipulations Steven Rostedt <rostedt@goodmis.org> - 2016-07-12 19:00 +0200 [PATCH RT 09/14] arm: lazy preempt: correct resched condition Steven Rostedt <rostedt@goodmis.org> - 2016-07-12 19:00 +0200 [PATCH RT 08/14] kernel/printk: Dont try to print from IRQ/NMI region Steven Rostedt <rostedt@goodmis.org> - 2016-07-12 19:00 +0200 [PATCH RT 04/14] list_bl: fixup bogus lockdep warning Steven Rostedt <rostedt@goodmis.org> - 2016-07-12 19:00 +0200 [PATCH RT 03/14] net: dev: always take qdiscs busylock in __dev_xmit_skb() Steven Rostedt <rostedt@goodmis.org> - 2016-07-12 19:00 +0200 Linux 3.14.72-rt76-rc2 Steven Rostedt <rostedt@goodmis.org> - 2016-07-13 01:30 +0200
csiph-web