Linux PARISC architecture development
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Helge Deller <deller@gmx.de>
Cc: linux-parisc@vger.kernel.org,
	James Bottomley <James.Bottomley@hansenpartnership.com>,
	John David Anglin <dave.anglin@bell.net>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] parisc: ftrace: get_kprobe() must be called with preempt disabled
Date: Fri, 6 Nov 2020 11:17:58 +0900	[thread overview]
Message-ID: <20201106111758.8b4d6d0197acec6ca4be9a2c@kernel.org> (raw)
In-Reply-To: <20201103074244.GA5615@ls3530.fritz.box>

On Tue, 3 Nov 2020 08:42:44 +0100
Helge Deller <deller@gmx.de> wrote:

> As noticed by Masami Hiramatsu, get_kprobe() must be called with preempt
> disabled.

Doesn't parisc ftrace implementation preempt off? Then it is required.

Steve, can we expect that op->func() is called under preempt off always
on any arch or is it arch dependent?

Thank you,

> 
> Noticed-by: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Helge Deller <deller@gmx.de>
> 
> diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
> index 63e3ecb9da81..dd356ad18aca 100644
> --- a/arch/parisc/kernel/ftrace.c
> +++ b/arch/parisc/kernel/ftrace.c
> @@ -207,13 +212,22 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
>  			   struct ftrace_ops *ops, struct pt_regs *regs)
>  {
>  	struct kprobe_ctlblk *kcb;
> -	struct kprobe *p = get_kprobe((kprobe_opcode_t *)ip);
> +	struct kprobe *p;
> +
> +	/*
> +	 * We don't want to be preempted for the entire
> +	 * duration of kprobe processing
> +	 */
> +	preempt_disable();
> +	p = get_kprobe((kprobe_opcode_t *)ip);
> 
>  	if (unlikely(!p) || kprobe_disabled(p))
> +		preempt_enable_no_resched();
>  		return;
> 
>  	if (kprobe_running()) {
>  		kprobes_inc_nmissed_count(p);
> +		preempt_enable_no_resched();
>  		return;
>  	}
> 
> @@ -235,6 +249,8 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
>  		}
>  	}
>  	__this_cpu_write(current_kprobe, NULL);
> +
> +	preempt_enable_no_resched();
>  }
>  NOKPROBE_SYMBOL(kprobe_ftrace_handler);
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2020-11-06  2:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03  7:42 [PATCH] parisc: ftrace: get_kprobe() must be called with preempt disabled Helge Deller
2020-11-06  2:17 ` Masami Hiramatsu [this message]
2020-11-06  2:43   ` Steven Rostedt
2020-11-06  9:03     ` Helge Deller

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=20201106111758.8b4d6d0197acec6ca4be9a2c@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=dave.anglin@bell.net \
    --cc=deller@gmx.de \
    --cc=linux-parisc@vger.kernel.org \
    --cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox