Re: [PATCH -tip v8 0/7] tracing: kprobe-based event tracer and x86 instruction decoder

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux