提交 a30b85df 编写于 作者: M Masami Hiramatsu 提交者: Ingo Molnar

kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y

We want to wait for all potentially preempted kprobes trampoline
execution to have completed. This guarantees that any freed
trampoline memory is not in use by any task in the system anymore.
synchronize_rcu_tasks() gives such a guarantee, so use it.

Also, this guarantees to wait for all potentially preempted tasks
on the instructions which will be replaced with a jump.

Since this becomes a problem only when CONFIG_PREEMPT=y, enable
CONFIG_TASKS_RCU=y for synchronize_rcu_tasks() in that case.
Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
Acked-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Naveen N . Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/150845661962.5443.17724352636247312231.stgit@devboxSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 4f3a8714
...@@ -90,7 +90,7 @@ config STATIC_KEYS_SELFTEST ...@@ -90,7 +90,7 @@ config STATIC_KEYS_SELFTEST
config OPTPROBES config OPTPROBES
def_bool y def_bool y
depends on KPROBES && HAVE_OPTPROBES depends on KPROBES && HAVE_OPTPROBES
depends on !PREEMPT select TASKS_RCU if PREEMPT
config KPROBES_ON_FTRACE config KPROBES_ON_FTRACE
def_bool y def_bool y
......
...@@ -573,13 +573,15 @@ static void kprobe_optimizer(struct work_struct *work) ...@@ -573,13 +573,15 @@ static void kprobe_optimizer(struct work_struct *work)
do_unoptimize_kprobes(); do_unoptimize_kprobes();
/* /*
* Step 2: Wait for quiesence period to ensure all running interrupts * Step 2: Wait for quiesence period to ensure all potentially
* are done. Because optprobe may modify multiple instructions * preempted tasks to have normally scheduled. Because optprobe
* there is a chance that Nth instruction is interrupted. In that * may modify multiple instructions, there is a chance that Nth
* case, running interrupt can return to 2nd-Nth byte of jump * instruction is preempted. In that case, such tasks can return
* instruction. This wait is for avoiding it. * to 2nd-Nth byte of jump instruction. This wait is for avoiding it.
* Note that on non-preemptive kernel, this is transparently converted
* to synchronoze_sched() to wait for all interrupts to have completed.
*/ */
synchronize_sched(); synchronize_rcu_tasks();
/* Step 3: Optimize kprobes after quiesence period */ /* Step 3: Optimize kprobes after quiesence period */
do_optimize_kprobes(); do_optimize_kprobes();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册