From: Masami Hiramatsu <mhiramat@kernel.org>
To: Anju T Sudhakar <anju@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
ananth@in.ibm.com, naveen.n.rao@linux.vnet.ibm.com,
paulus@samba.org, srikar@linux.vnet.ibm.com,
benh@kernel.crashing.org, mpe@ellerman.id.au,
mahesh@linux.vnet.ibm.com, mhiramat@kernel.org
Subject: Re: [PATCH V2 4/4] arch/powerpc: Optimize kprobe in kretprobe_trampoline
Date: Fri, 16 Dec 2016 23:09:14 +0900 [thread overview]
Message-ID: <20161216230914.1d5817b0e7f2813b108ac8ee@kernel.org> (raw)
In-Reply-To: <1481732310-7779-3-git-send-email-anju@linux.vnet.ibm.com>
On Wed, 14 Dec 2016 21:48:28 +0530
Anju T Sudhakar <anju@linux.vnet.ibm.com> wrote:
> Kprobe placed on the kretprobe_trampoline during boot time can be
> optimized, since the instruction at probe point is a 'nop'.
>
How simple & clever way! ;)
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thank you!
> Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
> ---
> arch/powerpc/kernel/kprobes.c | 8 ++++++++
> arch/powerpc/kernel/optprobes.c | 7 +++----
> 2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
> index e785cc9..5b0fd07 100644
> --- a/arch/powerpc/kernel/kprobes.c
> +++ b/arch/powerpc/kernel/kprobes.c
> @@ -282,6 +282,7 @@ asm(".global kretprobe_trampoline\n"
> ".type kretprobe_trampoline, @function\n"
> "kretprobe_trampoline:\n"
> "nop\n"
> + "blr\n"
> ".size kretprobe_trampoline, .-kretprobe_trampoline\n");
>
> /*
> @@ -334,6 +335,13 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
>
> kretprobe_assert(ri, orig_ret_address, trampoline_address);
> regs->nip = orig_ret_address;
> + /*
> + * Make LR point to the orig_ret_address.
> + * When the 'nop' inside the kretprobe_trampoline
> + * is optimized, we can do a 'blr' after executing the
> + * detour buffer code.
> + */
> + regs->link = orig_ret_address;
>
> reset_current_kprobe();
> kretprobe_hash_unlock(current, &flags);
> diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c
> index ecba221..5e4c254 100644
> --- a/arch/powerpc/kernel/optprobes.c
> +++ b/arch/powerpc/kernel/optprobes.c
> @@ -72,12 +72,11 @@ static unsigned long can_optimize(struct kprobe *p)
>
> /*
> * kprobe placed for kretprobe during boot time
> - * is not optimizing now.
> - *
> - * TODO: Optimize kprobe in kretprobe_trampoline
> + * has a 'nop' instruction, which can be emulated.
> + * So further checks can be skipped.
> */
> if (p->addr == (kprobe_opcode_t *)&kretprobe_trampoline)
> - return 0;
> + return (unsigned long)p->addr + sizeof(kprobe_opcode_t);
>
> /*
> * We only support optimizing kernel addresses, but not
> --
> 2.7.4
>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2016-12-16 14:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-14 16:18 [PATCH V2 0/4] OPTPROBES for powerpc Anju T Sudhakar
2016-12-14 16:18 ` [PATCH V2 3/4] arch/powerpc: Implement Optprobes Anju T Sudhakar
2016-12-16 14:02 ` Masami Hiramatsu
2016-12-16 17:54 ` Anju T Sudhakar
2016-12-14 16:18 ` [PATCH V2 4/4] arch/powerpc: Optimize kprobe in kretprobe_trampoline Anju T Sudhakar
2016-12-16 14:09 ` Masami Hiramatsu [this message]
2016-12-14 16:18 ` [PATCH V2 1/4] powerpc: asm/ppc-opcode.h: introduce __PPC_SH64() Anju T Sudhakar
2016-12-14 16:18 ` [PATCH V2 2/4] powerpc: add helper to check if offset is within rel branch range Anju T Sudhakar
2016-12-16 11:52 ` Masami Hiramatsu
2016-12-16 16:31 ` Anju T Sudhakar
2016-12-16 14:46 ` [PATCH V2 0/4] OPTPROBES for powerpc Balbir Singh
2016-12-16 17:19 ` Naveen N. Rao
2016-12-16 17:20 ` Anju T Sudhakar
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=20161216230914.1d5817b0e7f2813b108ac8ee@kernel.org \
--to=mhiramat@kernel.org \
--cc=ananth@in.ibm.com \
--cc=anju@linux.vnet.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mahesh@linux.vnet.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=srikar@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).