All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "Frank Ch. Eigler" <fche@redhat.com>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	yrl.pp-manager.tt@hitachi.com
Subject: Re: Re: [PATCH 6/9][RFC] kprobes: Allow probe on ftrace reserved text (but move it)
Date: Mon, 07 May 2012 20:37:52 +0900	[thread overview]
Message-ID: <4FA7B410.1000804@hitachi.com> (raw)
In-Reply-To: <1336002032.14207.52.camel@gandalf.stny.rr.com>

(2012/05/03 8:40), Steven Rostedt wrote:
> On Wed, 2012-05-02 at 16:40 -0400, Frank Ch. Eigler wrote:
>> rostedt wrote:
>>
>>> [...]  Added KPROBE_FLAG_MOVED (as suggested by Masami) that is set
>>> when the address is moved to get around an ftrace nop. [...]
>>
>> Steve, perhaps my earlier comments on this got lost during the mailing
>> list outage.
> 
> I saw it, but it didn't really specify what you wanted. Here's your
> comment:
> 
> 
>> I suspect Masami intended that this flag is later used during int3
>> processing to subtract MCOUNT_INSN_SIZE back out from the pt_regs->ip
>> during kprobe_handler() if this flag was set.
> 
> This is what I thought too, but to me it sounded like Masami could do
> the work. I was just setting up a flag to make it possible.
> 
>>
>> The gist is that a KPROBE_FLAG_MOVED being set this way accomplishes
>> very little since nothing is looking for that flag.  Instead, you
>> should patch {arch/*}/kernel/kprobe.c kprobe_handler() to subtract
>> MCOUNT_INSN_SIZE back out from pt_regs->ip if KPROBE_FLAG_MOVED was
>> set.  That way, kprobes clients need do not perceive the int3 movement.
> 
> I basically thought that Masami wanted me to add the flag, and then
> others could look for this and do the adjustment. I'm not the kprobes
> author. I was just adding a flag that Masami and others could use to do
> such updates.

Right, that was what I thought. Since the kp->addr is changed when
kprobe is set, kprobes itself don't need to adjust the pt_regs->ip.
I mean, struct kprobe itself puts a probe on the next to the mcount
entry, even if the caller tries to put a probe on the mcount entry.

This change may be unintended and caller will doubt that why the
kp->addr is automatically changed. So this KPROBE_FLAG_MOVED gives
a hint for the caller who knows the original intended probed address.

> I'm not sure if the adjustment is fine with everyone, as it may cause
> repercussions that I don't know about. 

Yeah, that's a point. if the adjustment is transparently done, there
is no problem. But it changes kp->addr when registering a probe.
If adjustment is done, following code (still) doesn't work.

---
int func(struct kprobe *kp, strcut pt_regs *regs)
{
	BUG_ON(kp->addr != regs->ip);
	/* or */
	store_probed_address(kp->addr);	/* since regs->ip depends on x86*/
}

kp->handler = func;
kp->addr = <somewhere on ftrace>
register_kprobe(kp);
---

but if adjustment is not done, at least, kprobes behavior itself
looks same. (but just be moved if probed on ftrace)

Yeah, I know systemtap people likes regs->ip to be adjusted, but
there may be someone who use raw kprobes.

> Perhaps that could be another patch (want to write it?)

Oh, so I think we need to show the new flag on debugfs for
someone who want to know why the probe has been moved. :)


By the way, there is another way to do that transparently which
we add a "real_addr" member to struct kprobes and put the real
probed address to the member (without changing kp->addr). This
will keep API compatibility.

Thank you,


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

  reply	other threads:[~2012-05-07 11:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-02 19:24 [PATCH 0/9][RFC] ftrace: ftrace location lookup speedup, and clean ups Steven Rostedt
2012-05-02 19:24 ` [PATCH 1/9][RFC] ftrace: Sort all function addresses, not just per page Steven Rostedt
2012-05-02 19:24 ` [PATCH 2/9][RFC] ftrace: Remove extra helper functions Steven Rostedt
2012-05-02 19:24 ` [PATCH 3/9][RFC] ftrace: Speed up search by skipping pages by address Steven Rostedt
2012-05-02 19:24 ` [PATCH 4/9][RFC] ftrace: Consolidate ftrace_location() and ftrace_text_reserved() Steven Rostedt
2012-05-02 19:24 ` [PATCH 5/9][RFC] ftrace: Return record ip addr for ftrace_location() Steven Rostedt
2012-05-02 19:24 ` [PATCH 6/9][RFC] kprobes: Allow probe on ftrace reserved text (but move it) Steven Rostedt
2012-05-02 20:40   ` Frank Ch. Eigler
2012-05-02 23:40     ` Steven Rostedt
2012-05-07 11:37       ` Masami Hiramatsu [this message]
2012-05-07 11:59         ` Masami Hiramatsu
2012-05-07 12:44           ` Steven Rostedt
2012-05-07 12:51             ` Steven Rostedt
2012-05-07 12:43         ` Steven Rostedt
2012-05-08  3:08           ` Masami Hiramatsu
2012-05-08 13:04             ` Steven Rostedt
2012-05-09  5:53               ` Masami Hiramatsu
2012-05-09  8:12                 ` Masami Hiramatsu
2012-05-09  9:02                   ` Masami Hiramatsu
2012-05-09 14:50                     ` Steven Rostedt
2012-05-10 11:54                     ` [RFC PATCH -tip ] x86/kprobes: kprobes call optimization Masami Hiramatsu
2012-05-11  8:29                       ` Masami Hiramatsu
2012-05-02 19:24 ` [PATCH 7/9][RFC] ftrace: Make ftrace_modify_all_code() global for archs to use Steven Rostedt
2012-05-02 19:24 ` [PATCH 8/9][RFC] ftrace/x86: Have x86 ftrace use the ftrace_modify_all_code() Steven Rostedt
2012-05-02 19:24 ` [PATCH 9/9][RFC] ftrace: Remove selecting FRAME_POINTER with FUNCTION_TRACER Steven Rostedt

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=4FA7B410.1000804@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=akpm@linux-foundation.org \
    --cc=fche@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=yrl.pp-manager.tt@hitachi.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 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.