All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	lkml <linux-kernel@vger.kernel.org>, Avi Kivity <avi@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andi Kleen <andi@firstfloor.org>,
	Jim Keniston <jkenisto@us.ibm.com>,
	"K.Prasad" <prasad@linux.vnet.ibm.com>,
	Przemys??awPawe??czyk <przemyslaw@pawelczyk.it>,
	Vegard Nossum <vegard.nossum@gmail.com>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	Tom Zanussi <tzanussi@gmail.com>,
	systemtap <systemtap@sources.redhat.com>,
	kvm <kvm@vger.kernel.org>,
	DLE <dle-develop@lists.sourceforge.net>
Subject: Re: [PATCH -tip v8 0/7] tracing: kprobe-based event tracer and x86 instruction decoder
Date: Sun, 31 May 2009 09:43:36 -0400	[thread overview]
Message-ID: <4A228988.4060909@redhat.com> (raw)
In-Reply-To: <20090530080503.GA15755@infradead.org>

Christoph Hellwig wrote:
> Small question to start with: What's your (or Hitachi s/Red Hat's) use case
> for this?  It's obviously really cool technology, but I fear without
> some good user space side to make it easy to use it will most likely
> bit-rot which would be sad.

Good question,
Frankly to say, this was started just for the in-kernel user of kprobes.
However, now I think this can be used for some ideas,
- Quick debugging (checking variables, execution path, etc.) in asm level.
  (elfutils might help us to make it source level debugging)
- Prototyping new tracepoints.
- Stress test of kprobes to find functions which should be __kprobes.
- Vehicle of tracing facilities which will be ported from systemtap runtime.
- As Frank said, we can make systemtap to control this for simple scripts.

Even now, it's not hard to use systemtap for finding variables in
stack/registers. Key options are -v and -p2,

e.g.
$ stap -v -p2 -e 'probe kernel.statement("*@fs/open.c:1024")\
 {printf("%d", $files)}'

Then, you'll get below output,
------
# functions
_dwarf_tvar_get_files_0:long ()
%{{
  {
    uint64_t addr;
    { // DWARF expression: 0x5c
    { uint64_t value = fetch_register (12);addr = value; }
    }
    THIS->__retvalue = addr;
  }
  goto out;
if (0) goto deref_fault;
deref_fault:
  goto out;
}
/* pure */%}
# probes
kernel.statement("fd_install@/home/mhiramat/ksrc/linux-2.6-tip/fs/open.c:1024")
 /* pc=_stext+0xd1f72 */ /* <- kernel.statement("*@fs/open.c:1024") */
printf("%d", _dwarf_tvar_get_files_0())
------

This shows that 'fs/open.c:1024' is located at _stext+0xd1f72, and
'files' is mapped to %r12 (note, pt_regs mapping is different from
dwarf register mapping.) So, below command adds probe at
fs/open.c:1024 and trace 'files' variable :-)

$ echo p _stext+0xd1f72 %r12 > /debug/tracing/kprobe_events


Thank you,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com


WARNING: multiple messages have this Message-ID (diff)
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	        lkml <linux-kernel@vger.kernel.org>,
	Avi Kivity <avi@redhat.com>,
	        "H. Peter Anvin" <hpa@zytor.com>,
	        Frederic Weisbecker <fweisbec@gmail.com>,
	        Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	        Andrew Morton <akpm@linux-foundation.org>,
	        Andi Kleen <andi@firstfloor.org>,
	Jim Keniston <jkenisto@us.ibm.com>,
	        "K.Prasad" <prasad@linux.vnet.ibm.com>,
	        Przemys??awPawe??czyk <przemyslaw@pawelczyk.it>,
	        Vegard Nossum <vegard.nossum@gmail.com>,
	        "Frank Ch. Eigler" <fche@redhat.com>,
	Tom Zanussi <tzanussi@gmail.com>,
	        systemtap <systemtap@sources.redhat.com>,
	kvm <kvm@vger.kernel.org>,
	        DLE <dle-develop@lists.sourceforge.net>
Subject: Re: [PATCH -tip v8 0/7] tracing: kprobe-based event tracer and x86  instruction decoder
Date: Sun, 31 May 2009 09:43:36 -0400	[thread overview]
Message-ID: <4A228988.4060909@redhat.com> (raw)
In-Reply-To: <20090530080503.GA15755@infradead.org>

Christoph Hellwig wrote:
> Small question to start with: What's your (or Hitachi s/Red Hat's) use case
> for this?  It's obviously really cool technology, but I fear without
> some good user space side to make it easy to use it will most likely
> bit-rot which would be sad.

Good question,
Frankly to say, this was started just for the in-kernel user of kprobes.
However, now I think this can be used for some ideas,
- Quick debugging (checking variables, execution path, etc.) in asm level.
  (elfutils might help us to make it source level debugging)
- Prototyping new tracepoints.
- Stress test of kprobes to find functions which should be __kprobes.
- Vehicle of tracing facilities which will be ported from systemtap runtime.
- As Frank said, we can make systemtap to control this for simple scripts.

Even now, it's not hard to use systemtap for finding variables in
stack/registers. Key options are -v and -p2,

e.g.
$ stap -v -p2 -e 'probe kernel.statement("*@fs/open.c:1024")\
 {printf("%d", $files)}'

Then, you'll get below output,
------
# functions
_dwarf_tvar_get_files_0:long ()
%{{
  {
    uint64_t addr;
    { // DWARF expression: 0x5c
    { uint64_t value = fetch_register (12);addr = value; }
    }
    THIS->__retvalue = addr;
  }
  goto out;
if (0) goto deref_fault;
deref_fault:
  goto out;
}
/* pure */%}
# probes
kernel.statement("fd_install@/home/mhiramat/ksrc/linux-2.6-tip/fs/open.c:1024")
 /* pc=_stext+0xd1f72 */ /* <- kernel.statement("*@fs/open.c:1024") */
printf("%d", _dwarf_tvar_get_files_0())
------

This shows that 'fs/open.c:1024' is located at _stext+0xd1f72, and
'files' is mapped to %r12 (note, pt_regs mapping is different from
dwarf register mapping.) So, below command adds probe at
fs/open.c:1024 and trace 'files' variable :-)

$ echo p _stext+0xd1f72 %r12 > /debug/tracing/kprobe_events


Thank you,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

  reply	other threads:[~2009-05-31 13:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-29  0:03 [PATCH -tip v8 0/7] tracing: kprobe-based event tracer and x86 instruction decoder Masami Hiramatsu
2009-05-29  0:03 ` Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 1/7] x86: instruction decoder API Masami Hiramatsu
2009-05-29  0:03   ` Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 2/7] x86: x86 instruction decoder build-time selftest Masami Hiramatsu
2009-05-29  0:03   ` Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 3/7] kprobes: checks probe address is instruction boudary on x86 Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 4/7] kprobes: cleanup fix_riprel() using insn decoder " Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 5/7] x86: add pt_regs register and stack access APIs Masami Hiramatsu
2009-05-30  8:13   ` Christoph Hellwig
2009-05-30 14:48     ` Masami Hiramatsu
2009-06-01 23:40     ` Ingo Molnar
2009-05-29  0:03 ` [PATCH -tip v8 6/7] tracing: ftrace dynamic ftrace_event_call support Masami Hiramatsu
2009-05-30  3:23   ` Steven Rostedt
2009-05-29  0:03 ` [PATCH -tip v8 7/7] tracing: add kprobe-based event tracer Masami Hiramatsu
2009-05-29  0:03   ` Masami Hiramatsu
2009-05-30  3:29   ` Steven Rostedt
2009-05-30  4:11   ` Steven Rostedt
2009-05-30 13:15     ` Masami Hiramatsu
2009-05-30  8:15   ` Christoph Hellwig
2009-05-30 14:38     ` Masami Hiramatsu
2009-05-30  8:05 ` [PATCH -tip v8 0/7] tracing: kprobe-based event tracer and x86 instruction decoder Christoph Hellwig
2009-05-31 13:43   ` Masami Hiramatsu [this message]
2009-05-31 13:43     ` Masami Hiramatsu

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=4A228988.4060909@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=andi@firstfloor.org \
    --cc=avi@redhat.com \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=fche@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=jkenisto@us.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=prasad@linux.vnet.ibm.com \
    --cc=przemyslaw@pawelczyk.it \
    --cc=rostedt@goodmis.org \
    --cc=systemtap@sources.redhat.com \
    --cc=tzanussi@gmail.com \
    --cc=vegard.nossum@gmail.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.