All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: tixy@linaro.org, Wang Nan <wangnan0@huawei.com>,
	linux@arm.linux.org.uk,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	lizefan@huawei.com, linux-arm-kernel@lists.infradead.org
Subject: [PATCH -tip/urgent 1/2] [BUGFIX]kprobes: set kprobes_all_disarmed earlier to enable re-optimization.
Date: Fri, 23 Jan 2015 15:42:24 +0900	[thread overview]
Message-ID: <20150123064224.30731.30127.stgit@localhost.localdomain> (raw)
In-Reply-To: <20150123064217.30731.49156.stgit@localhost.localdomain>

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(-)

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:


WARNING: multiple messages have this Message-ID (diff)
From: masami.hiramatsu.pt@hitachi.com (Masami Hiramatsu)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH -tip/urgent 1/2] [BUGFIX]kprobes: set kprobes_all_disarmed earlier to enable re-optimization.
Date: Fri, 23 Jan 2015 15:42:24 +0900	[thread overview]
Message-ID: <20150123064224.30731.30127.stgit@localhost.localdomain> (raw)
In-Reply-To: <20150123064217.30731.49156.stgit@localhost.localdomain>

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(-)

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:

  reply	other threads:[~2015-01-23  6:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23  6:42 [PATCH -tip/urgent 0/2]kprobes bugfixes around optprobe Masami Hiramatsu
2015-01-23  6:42 ` Masami Hiramatsu
2015-01-23  6:42 ` Masami Hiramatsu [this message]
2015-01-23  6:42   ` [PATCH -tip/urgent 1/2] [BUGFIX]kprobes: set kprobes_all_disarmed earlier to enable re-optimization Masami Hiramatsu
2015-02-05 22:49   ` Andrew Morton
2015-02-05 22:49     ` Andrew Morton
2015-01-23  6:42 ` [PATCH -tip/urgent 2/2] [BUGFIX]kprobes: makes kprobes/enabled works correctly for optimized kprobes Masami Hiramatsu
2015-01-23  6:42   ` Masami Hiramatsu
2015-01-26  5:38 ` [PATCH -tip/urgent 0/2]kprobes bugfixes around optprobe Wang Nan
2015-01-26  5:38   ` Wang Nan
2015-02-04 11:01   ` Wang Nan
2015-02-04 11:01     ` Wang Nan
2015-02-05  1:59     ` Wang Nan
2015-02-05  1:59       ` Wang Nan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150123064224.30731.30127.stgit@localhost.localdomain \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=lizefan@huawei.com \
    --cc=mingo@kernel.org \
    --cc=tixy@linaro.org \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.