LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Wang Nan <wangnan0@huawei.com>
Cc: tixy@linaro.org, linux@arm.linux.org.uk,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] kprobes: bugfix: set kprobes_all_disarmed earlier to enable re-optimization.
Date: Mon, 12 Jan 2015 20:24:02 +0900	[thread overview]
Message-ID: <54B3AED2.5070000@hitachi.com> (raw)
In-Reply-To: <1420461075-27012-1-git-send-email-wangnan0@huawei.com>

(2015/01/05 21:31), Wang Nan wrote:
> 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.

OK, a workaround is to disable/enable optimizing via sysctl.

> 
> This patch simply turns off kprobes_all_disarmed earlier to enable
> optimization.
> 

Anyway, thank you for finding that! :)

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>


> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> ---
>  kernel/kprobes.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index bad4e95..b185464 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:
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



  reply	other threads:[~2015-01-12 11:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-05 12:31 Wang Nan
2015-01-12 11:24 ` Masami Hiramatsu [this message]
2015-01-20  3:02   ` Wang Nan
2015-01-20  7:12     ` Masami Hiramatsu
2015-02-19  0:10       ` Ingo Molnar

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=54B3AED2.5070000@hitachi.com \
    --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=tixy@linaro.org \
    --cc=wangnan0@huawei.com \
    --subject='Re: [PATCH] kprobes: bugfix: set kprobes_all_disarmed earlier to enable re-optimization.' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).