aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2015-02-13 17:40:24 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 00:21:42 -0500
commit977ad481b66ca91e1f6492b3c5c4748c68fdee9c (patch)
tree2662accb1f4f5d238a56bff10d541b0797998302 /kernel
parent5125991c9a9360fbdb717e22783c970bbd140660 (diff)
kprobes: set kprobes_all_disarmed earlier to enable re-optimization.
In original code, the probed instruction doesn't get optimized after echo 0 > /sys/kernel/debug/kprobes/enabled echo 1 > /sys/kernel/debug/kprobes/enabled This is because original code checks kprobes_all_disarmed in optimize_kprobe(), but this flag is turned off after calling that function. Therefore, optimize_kprobe() will see kprobes_all_disarmed == true and doesn't do the optimization. This patch simply turns off kprobes_all_disarmed earlier to enable optimization. Signed-off-by: Wang Nan <wangnan0@huawei.com> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Ingo Molnar <mingo@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kprobes.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 2ca272f8f62e..c39790001854 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2320,6 +2320,12 @@ static void arm_all_kprobes(void)
2320 if (!kprobes_all_disarmed) 2320 if (!kprobes_all_disarmed)
2321 goto already_enabled; 2321 goto already_enabled;
2322 2322
2323 /*
2324 * optimize_kprobe() called by arm_kprobe() checks
2325 * kprobes_all_disarmed, so set kprobes_all_disarmed before
2326 * arm_kprobe.
2327 */
2328 kprobes_all_disarmed = false;
2323 /* Arming kprobes doesn't optimize kprobe itself */ 2329 /* Arming kprobes doesn't optimize kprobe itself */
2324 for (i = 0; i < KPROBE_TABLE_SIZE; i++) { 2330 for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
2325 head = &kprobe_table[i]; 2331 head = &kprobe_table[i];
@@ -2328,7 +2334,6 @@ static void arm_all_kprobes(void)
2328 arm_kprobe(p); 2334 arm_kprobe(p);
2329 } 2335 }
2330 2336
2331 kprobes_all_disarmed = false;
2332 printk(KERN_INFO "Kprobes globally enabled\n"); 2337 printk(KERN_INFO "Kprobes globally enabled\n");
2333 2338
2334already_enabled: 2339already_enabled: