Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <sebott@linux.vnet.ibm.com>
Tested-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Fixes: 345ddcc882d8 ("ftrace: Have set_ftrace_pid use the bitmap like events do")
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Heiko Carstens and committed by
Martin Schwidefsky
7f8d61f0 237d6e68

+2 -2
+2 -2
include/asm-generic/percpu.h
··· 118 118 #define this_cpu_generic_read(pcp) \ 119 119 ({ \ 120 120 typeof(pcp) __ret; \ 121 - preempt_disable(); \ 121 + preempt_disable_notrace(); \ 122 122 __ret = raw_cpu_generic_read(pcp); \ 123 - preempt_enable(); \ 123 + preempt_enable_notrace(); \ 124 124 __ret; \ 125 125 }) 126 126