All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
	linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Carsten Emde <C.Emde@osadl.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	John Kacur <jkacur@redhat.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	<stable@vger.kernel.org>, <stable-rt@vger.kernel.org>,
	Vikram Mulukutla <markivx@codeaurora.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>
Subject: [PATCH RT 07/14] sched,preempt: Fix preempt_count manipulations
Date: Tue, 12 Jul 2016 12:48:06 -0400	[thread overview]
Message-ID: <20160712164818.663083732@goodmis.org> (raw)
In-Reply-To: 20160712164759.154249453@goodmis.org

[-- Attachment #1: 0007-sched-preempt-Fix-preempt_count-manipulations.patch --]
[-- Type: text/plain, Size: 2024 bytes --]

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 &current_thread_info()->preempt_count;
 }
-- 
2.8.1

  parent reply	other threads:[~2016-07-12 16:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-12 16:47 [PATCH RT 00/14] Linux 3.14.72-rt76-rc1 Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 01/14] kvm, rt: change async pagefault code locking for PREEMPT_RT Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 02/14] mm/zsmalloc: Use get/put_cpu_light in zs_map_object()/zs_unmap_object() Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 03/14] net: dev: always take qdiscs busylock in __dev_xmit_skb() Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 04/14] list_bl: fixup bogus lockdep warning Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 05/14] ARM: imx: always use TWD on IMX6Q Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 06/14] perf/x86/intel/rapl: Make PMU lock raw Steven Rostedt
2016-07-12 16:48 ` Steven Rostedt [this message]
2016-07-12 16:48 ` [PATCH RT 08/14] kernel/printk: Dont try to print from IRQ/NMI region Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 09/14] arm: lazy preempt: correct resched condition Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 10/14] locallock: add local_lock_on() Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 11/14] mm: perform lru_add_drain_all() remotely Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 12/14] trace: correct off by one while recording the trace-event Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 13/14] x86: Fix an RT MCE crash Steven Rostedt
2016-07-12 16:48 ` [PATCH RT 14/14] Linux 3.14.72-rt76-rc1 Steven Rostedt
2016-07-12 23:21 ` Linux 3.14.72-rt76-rc2 Steven Rostedt

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=20160712164818.663083732@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=C.Emde@osadl.org \
    --cc=bigeasy@linutronix.de \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=markivx@codeaurora.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=peterz@infradead.org \
    --cc=stable-rt@vger.kernel.org \
    --cc=stable@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.