From: Masami Hiramatsu <mhiramat@kernel.org>
To: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
linuxppc-dev@lists.ozlabs.org,
Masami Hiramatsu <mhiramat@kernel.org>,
Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Subject: Re: [PATCH 2/4] powerpc/kprobes: Do not disable interrupts for optprobes and kprobes_on_ftrace
Date: Wed, 25 Oct 2017 11:19:36 +0900 [thread overview]
Message-ID: <20171025111936.852065923d39aeda96f9c88e@kernel.org> (raw)
In-Reply-To: <60fe689be1e3251c001a6d4303fd808a3a760711.1508776485.git.naveen.n.rao@linux.vnet.ibm.com>
On Mon, 23 Oct 2017 22:07:39 +0530
"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
> Per Documentation/kprobes.txt, we don't necessarily need to disable
> interrupts before invoking the kprobe handlers. Masami submitted
> similar changes for x86 via commit a19b2e3d783964 ("kprobes/x86: Remove
> IRQ disabling from ftrace-based/optimized kprobes"). Do the same for
> powerpc.
Yes, and this requires to make preempt disable :)
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thank you!
>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
> arch/powerpc/kernel/kprobes-ftrace.c | 10 ++--------
> arch/powerpc/kernel/optprobes.c | 10 ----------
> 2 files changed, 2 insertions(+), 18 deletions(-)
>
> diff --git a/arch/powerpc/kernel/kprobes-ftrace.c b/arch/powerpc/kernel/kprobes-ftrace.c
> index 4b1f34f685b1..7a1f99f1b47f 100644
> --- a/arch/powerpc/kernel/kprobes-ftrace.c
> +++ b/arch/powerpc/kernel/kprobes-ftrace.c
> @@ -75,11 +75,7 @@ void kprobe_ftrace_handler(unsigned long nip, unsigned long parent_nip,
> {
> struct kprobe *p;
> struct kprobe_ctlblk *kcb;
> - unsigned long flags;
>
> - /* Disable irq for emulating a breakpoint and avoiding preempt */
> - local_irq_save(flags);
> - hard_irq_disable();
> preempt_disable();
>
> p = get_kprobe((kprobe_opcode_t *)nip);
> @@ -105,16 +101,14 @@ void kprobe_ftrace_handler(unsigned long nip, unsigned long parent_nip,
> else {
> /*
> * If pre_handler returns !0, it sets regs->nip and
> - * resets current kprobe. In this case, we still need
> - * to restore irq, but not preemption.
> + * resets current kprobe. In this case, we should not
> + * re-enable preemption.
> */
> - local_irq_restore(flags);
> return;
> }
> }
> end:
> preempt_enable_no_resched();
> - local_irq_restore(flags);
> }
> NOKPROBE_SYMBOL(kprobe_ftrace_handler);
>
> diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c
> index 60ba7f1370a8..8237884ca389 100644
> --- a/arch/powerpc/kernel/optprobes.c
> +++ b/arch/powerpc/kernel/optprobes.c
> @@ -115,14 +115,10 @@ static unsigned long can_optimize(struct kprobe *p)
> static void optimized_callback(struct optimized_kprobe *op,
> struct pt_regs *regs)
> {
> - unsigned long flags;
> -
> /* This is possible if op is under delayed unoptimizing */
> if (kprobe_disabled(&op->kp))
> return;
>
> - local_irq_save(flags);
> - hard_irq_disable();
> preempt_disable();
>
> if (kprobe_running()) {
> @@ -135,13 +131,7 @@ static void optimized_callback(struct optimized_kprobe *op,
> __this_cpu_write(current_kprobe, NULL);
> }
>
> - /*
> - * No need for an explicit __hard_irq_enable() here.
> - * local_irq_restore() will re-enable interrupts,
> - * if they were hard disabled.
> - */
> preempt_enable_no_resched();
> - local_irq_restore(flags);
> }
> NOKPROBE_SYMBOL(optimized_callback);
>
> --
> 2.14.2
>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2017-10-25 2:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-23 16:37 [PATCH 1/4] powerpc/kprobes: Disable preemption before invoking probe handler for optprobes Naveen N. Rao
2017-10-23 16:37 ` [PATCH 2/4] powerpc/kprobes: Do not disable interrupts for optprobes and kprobes_on_ftrace Naveen N. Rao
2017-10-25 2:19 ` Masami Hiramatsu [this message]
2017-10-23 16:37 ` [PATCH 3/4] powerpc/kprobes: Blacklist emulate_update_regs() from kprobes Naveen N. Rao
2017-10-25 16:36 ` Masami Hiramatsu
2017-10-23 16:37 ` [PATCH 4/4] powerpc/kprobes: refactor kprobe_lookup_name for safer string operations Naveen N. Rao
2017-10-25 16:35 ` Masami Hiramatsu
2017-10-27 11:34 ` Naveen N. Rao
2017-10-25 2:18 ` [PATCH 1/4] powerpc/kprobes: Disable preemption before invoking probe handler for optprobes Masami Hiramatsu
2017-10-27 11:27 ` Naveen N. Rao
2017-11-14 11:12 ` [1/4] " Michael Ellerman
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=20171025111936.852065923d39aeda96f9c88e@kernel.org \
--to=mhiramat@kernel.org \
--cc=ananth@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.vnet.ibm.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 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).