diff mbox

[-tip/urgent,1/2,BUGFIX] kprobes: set kprobes_all_disarmed earlier to enable re-optimization.

Message ID 20150123064224.30731.30127.stgit@localhost.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Masami Hiramatsu Jan. 23, 2015, 6:42 a.m. UTC
From: Wang Nan <wangnan0@huawei.com>

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>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 kernel/kprobes.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Andrew Morton Feb. 5, 2015, 10:49 p.m. UTC | #1
On Fri, 23 Jan 2015 15:42:24 +0900 Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> wrote:

> From: Wang Nan <wangnan0@huawei.com>
> 
> 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>
> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

You sent the patches, so this should have been "Signed-off-by:". 
Documentation/SubmittingPatches section 12 has the details.

I have made that change to my copy of these two patches.
diff mbox

Patch

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 06f5830..9471710 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2320,6 +2320,12 @@  static void arm_all_kprobes(void)
 	if (!kprobes_all_disarmed)
 		goto already_enabled;
 
+	/*
+	 * optimize_kprobe() called by arm_kprobe() checks
+	 * kprobes_all_disarmed, so set kprobes_all_disarmed before
+	 * arm_kprobe.
+	 */
+	kprobes_all_disarmed = false;
 	/* Arming kprobes doesn't optimize kprobe itself */
 	for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
 		head = &kprobe_table[i];
@@ -2328,7 +2334,6 @@  static void arm_all_kprobes(void)
 				arm_kprobe(p);
 	}
 
-	kprobes_all_disarmed = false;
 	printk(KERN_INFO "Kprobes globally enabled\n");
 
 already_enabled: