Skip to contentSkip to conversation

percpu: use notrace variant of preempt_disable/preempt_enable

PATCH In review Heiko Carstens 3 participants 3 messages Nov 3, 2016 – Nov 8, 2016 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 percpu: use notrace variant of preempt_disable/preempt_enable

Commit 345ddcc882d8 ("ftrace: Have set_ftrace_pid use the bitmap like events do") added a couple of this_cpu_read calls to the ftrace code.

On x86 this is not a problem, since it has single instructions to read percpu data. Other architectures which use the generic variant now have additional preempt_disable and preempt_enable calls in the core ftrace code. This may lead to recursive calls and in result to a dead machine, e.g. if preemption and debugging options are enabled.

To fix this use the notrace variant of preempt_disable and preempt_enable within the generic percpu code.

Reported-and-bisected-by Sebastian Ott <[email protected]>
Fixes 345ddcc882d8 ("ftrace: Have set_ftrace_pid use the bitmap like events do")
---
 include/asm-generic/percpu.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/asm-generic/percpu.h +2 -2
index 40e887068da2..0504ef8f3aa3 100644
@@ -118,9 +118,9 @@ do {									\
 #define this_cpu_generic_read(pcp)					\
 ({									\
 	typeof(pcp) __ret;						\
-	preempt_disable();						\
+	preempt_disable_notrace();					\
 	__ret = raw_cpu_generic_read(pcp);				\
-	preempt_enable();						\
+	preempt_enable_notrace();					\
 	__ret;								\
 })
 
Signature · 1 line
2.8.4
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Thu, 3 Nov 2016 14:58:38 +0100 Heiko Carstens <[email protected]>…

Commit 345ddcc882d8 ("ftrace: Have set_ftrace_pid use the bitmap like events do") added a couple of this_cpu_read calls to the ftrace code.

On x86 this is not a problem, since it has single instructions to read percpu data. Other architectures which use the generic variant now have additional preempt_disable and preempt_enable calls in the core ftrace code. This may lead to recursive calls and in result to a dead machine, e.g. if preemption and debugging options are enabled.

Quoted 7 lines

To fix this use the notrace variant of preempt_disable and preempt_enable within the generic percpu code.

Reported-and-bisected-by Sebastian Ott <[email protected]>
Fixes 345ddcc882d8 ("ftrace: Have set_ftrace_pid use the bitmap like events do")

Feel free to push this in your tree.

-- Steve

Quoted 20 lines
---
 include/asm-generic/percpu.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/asm-generic/percpu.h +2 -2
index 40e887068da2..0504ef8f3aa3 100644
@@ -118,9 +118,9 @@ do {									\
 #define this_cpu_generic_read(pcp)					\
 ({									\
 	typeof(pcp) __ret;						\
-	preempt_disable();						\
+	preempt_disable_notrace();					\
 	__ret = raw_cpu_generic_read(pcp);				\
-	preempt_enable();						\
+	preempt_enable_notrace();					\
 	__ret;								\
 })
 
#2 lore raw
Quoted 15 lines · On Mon, 7 Nov 2016 12:27:16 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 12 lines · On Thu, 3 Nov 2016 14:58:38 +0100 Heiko Carstens <[email protected]>…

Commit 345ddcc882d8 ("ftrace: Have set_ftrace_pid use the bitmap like events do") added a couple of this_cpu_read calls to the ftrace code.

On x86 this is not a problem, since it has single instructions to read percpu data. Other architectures which use the generic variant now have additional preempt_disable and preempt_enable calls in the core ftrace code. This may lead to recursive calls and in result to a dead machine, e.g. if preemption and debugging options are enabled.

To fix this use the notrace variant of preempt_disable and preempt_enable within the generic percpu code.

Quoted 8 lines
Quoted 4 lines
Reported-and-bisected-by Sebastian Ott <[email protected]>
Fixes 345ddcc882d8 ("ftrace: Have set_ftrace_pid use the bitmap like events do")

Feel free to push this in your tree.

Ok, will do. Thanks.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.