mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 1/3] powerpc: kprobes: add support for KPROBES_ON_FTRACE
Date: Wed, 15 Feb 2017 16:11:26 +0900	[thread overview]
Message-ID: <20170215161126.104c1db721182e1e75244125@kernel.org> (raw)
In-Reply-To: <1cc8a5580ae3a642fea137b7fe9c526402d4af33.1487098440.git.naveen.n.rao@linux.vnet.ibm.com>

Hi Naveen,

On Wed, 15 Feb 2017 00:28:34 +0530
"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:

> diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c
> index e51a045f3d3b..a8f414a0b141 100644
> --- a/arch/powerpc/kernel/optprobes.c
> +++ b/arch/powerpc/kernel/optprobes.c
> @@ -70,6 +70,9 @@ static unsigned long can_optimize(struct kprobe *p)
>  	struct instruction_op op;
>  	unsigned long nip = 0;
>  
> +	if (unlikely(kprobe_ftrace(p)))
> +		return 0;
> +

Hmm, this should not be checked in arch-depend code, since it may duplicate
code in each arch. Please try below.

Thanks,

commit 897bb304974c1b0c19a4274fea220b175b07f353
Author: Masami Hiramatsu <mhiramat@kernel.org>
Date:   Wed Feb 15 15:48:14 2017 +0900

    kprobes: Skip preparing optprobe if the probe is ftrace-based
    
    Skip preparing optprobe if the probe is ftrace-based, since
    anyway, it must not be optimized (or already optimized by
    ftrace).
    
    Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index ebb4dad..546a8b1 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -746,13 +746,20 @@ static void kill_optimized_kprobe(struct kprobe *p)
 	arch_remove_optimized_kprobe(op);
 }
 
+static inline
+void __prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
+{
+	if (!kprobe_ftrace(p))
+		arch_prepare_optimized_kprobe(op, p);
+}
+
 /* Try to prepare optimized instructions */
 static void prepare_optimized_kprobe(struct kprobe *p)
 {
 	struct optimized_kprobe *op;
 
 	op = container_of(p, struct optimized_kprobe, kp);
-	arch_prepare_optimized_kprobe(op, p);
+	__prepare_optimized_kprobe(op, p);
 }
 
 /* Allocate new optimized_kprobe and try to prepare optimized instructions */
@@ -766,7 +773,7 @@ static struct kprobe *alloc_aggr_kprobe(struct kprobe *p)
 
 	INIT_LIST_HEAD(&op->list);
 	op->kp.addr = p->addr;
-	arch_prepare_optimized_kprobe(op, p);
+	__prepare_optimized_kprobe(op, p);
 
 	return &op->kp;
 }



-- 
Masami Hiramatsu <mhiramat@kernel.org>

  parent reply	other threads:[~2017-02-15  7:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14 18:58 Naveen N. Rao
2017-02-14 18:58 ` [PATCH 2/3] powerpc: introduce a new helper to obtain function entry points Naveen N. Rao
2017-02-14 18:58 ` [PATCH 3/3] powerpc: kprobes: prefer ftrace when probing function entry Naveen N. Rao
2017-02-15  4:28 ` [PATCH 1/3] powerpc: kprobes: add support for KPROBES_ON_FTRACE Ananth N Mavinakayanahalli
2017-02-16 19:48   ` Naveen N. Rao
2017-02-15  7:11 ` Masami Hiramatsu [this message]
2017-02-16 19:49   ` Naveen N. Rao

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=20170215161126.104c1db721182e1e75244125@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®