All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Petr Mladek <pmladek@suse.cz>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Kosina <jkosina@suse.cz>,
	linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH 2/6] x86: allow to call text_poke_bp during boot
Date: Sun, 20 Oct 2013 00:02:32 +0900	[thread overview]
Message-ID: <52629F08.2010609@hitachi.com> (raw)
In-Reply-To: <1382106445-31468-3-git-send-email-pmladek@suse.cz>

(2013/10/18 23:27), Petr Mladek wrote:
> We would like to use text_poke_bp in ftrace. It might be called also during
> boot when the interupts are disabled. We need to enable them for syncing
> the cores on each CPU. Otherwise, there might be a deadlock, see the
> warning in "smp_call_function_many", kernel/smp.c:371.

Steven, is this really needed?
I think if this is the special use(e.g. boottime test),
we'd better to run it after boot...

Thank you,

> 
> This change is taken from the current code in arch/x86/kernel/ftrace.c.
> 
> Signed-off-by: Petr Mladek <pmladek@suse.cz>
> ---
>  arch/x86/kernel/alternative.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index f714316..13cae15 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -629,6 +629,20 @@ static void do_sync_core(void *info)
>  	sync_core();
>  }
>  
> +static void run_sync(void)
> +{
> +	int enable_irqs = irqs_disabled();
> +
> +	/* We may be called with interrupts disbled (on bootup). */
> +	if (enable_irqs)
> +		local_irq_enable();
> +
> +	on_each_cpu(do_sync_core, NULL, 1);
> +
> +	if (enable_irqs)
> +		local_irq_disable();
> +}
> +
>  static bool bp_patching_in_progress;
>  static void *bp_int3_handler, *bp_int3_addr;
>  
> @@ -688,7 +702,7 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
>  
>  	text_poke_part(addr, &int3, sizeof(int3));
>  
> -	on_each_cpu(do_sync_core, NULL, 1);
> +	run_sync();
>  
>  	if (len - sizeof(int3) > 0) {
>  		/* patch all but the first byte */
> @@ -700,13 +714,13 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
>  		 * not necessary and we'd be safe even without it. But
>  		 * better safe than sorry (plus there's not only Intel).
>  		 */
> -		on_each_cpu(do_sync_core, NULL, 1);
> +		run_sync();
>  	}
>  
>  	/* patch the first byte */
>  	text_poke_part(addr, opcode, sizeof(int3));
>  
> -	on_each_cpu(do_sync_core, NULL, 1);
> +	run_sync();
>  
>  	bp_patching_in_progress = false;
>  	smp_wmb();
> 


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



  reply	other threads:[~2013-10-19 15:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18 14:27 [PATCH 2/6] x86: allow to call text_poke_bp during boot Petr Mladek
2013-10-19 15:02 ` Masami Hiramatsu [this message]
2013-10-19 19:16   ` Steven Rostedt
2013-10-19 19:19     ` Steven Rostedt
2013-10-19 21:33       ` Paul E. McKenney
2013-10-19 21:58         ` Steven Rostedt
2013-10-19 22:02         ` Steven Rostedt
2013-10-20 15:42           ` Paul E. McKenney
2013-10-28  9:18             ` Masami Hiramatsu

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=52629F08.2010609@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=fweisbec@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.cz \
    --cc=rostedt@goodmis.org \
    --cc=x86@kernel.org \
    /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.