[lkml]   [2009]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[RFC PATCH tracing/kprobes 0/5] tracing/kprobes, perf: perf kprobe support


These patches introduce perf kprobe command and update kprobe-tracer.
perf kprobe command allows you to add new probe points by C line number
and local variable names.

perf kprobe [<options>] -P PROBEDEF [-P PROBEDEF ...]

-k, --vmlinux <file> vmlinux/module pathname
-r, --release <rel> kernel release
-P, --probe <p|r:[GRP/]NAME,FUNC[+OFFS][@SRC]|@SRC:LINE,ARG[,ARG,...]>
probe point definition, where
p: kprobe probe
r: kretprobe probe
GRP: Group name (optional)
NAME: Event name
FUNC: Function name
OFFS: Offset from function entry (in byte)
SRC: Source code path
LINE: Line number
ARG: Probe argument (local variable name or
kprobe-tracer argument format is supported.)

1) Add a new kprobe probe on a line of C source code.
./perf kprobe -P 'p:myprobe,@fs/bio.c:162,bv,idx'
Adding new event: p:myprobe bvec_free_bs+17 bv=%bx idx=%cx

2) Add a new kretprobe probe on a function return.
./perf kprobe -P 'r:myretprobe,vfs_read,$rv'
Adding new event: r:myretprobe vfs_read+0 $rv

3) Check it in the perf list.
./perf list
rNNN [raw hardware event descriptor]

kprobes:myprobe [Tracepoint event]
kprobes:myretprobe [Tracepoint event]
skb:kfree_skb [Tracepoint event]

4) Check its format

$ cat /sys/kernel/debug/tracing/events/kprobes/myprobe/format
name: myprobe
ID: 687
field:unsigned short common_type; offset:0; size:2;
field:unsigned char common_flags; offset:2; size:1;
field:unsigned char common_preempt_count; offset:3; size:1;
field:int common_pid; offset:4; size:4;
field:int common_lock_depth; offset:8; size:4;

field: unsigned long __probe_ip; offset:12; size:4;
field: int __probe_nargs; offset:16; size:4;
field: unsigned long bv; offset:20; size:4;
field: unsigned long idx; offset:24; size:4;

print fmt: "(%lx) bv=%lx idx=%lx", REC->__probe_ip, REC->bv, REC->idx

Syntax Issue
This version picks '-P event-definition' syntax, but I think
'-p event -a arg' is also possible. I'd like to ask you
which you like or support both?

There are still many enhancements required for catching up
'tracing side' of systemtap. I think it should be done one by one.
I hope that systemtap developers cooperate with us on this

- Support sys_perf_counter_open (non-root)
- Type support
- Non-auto static variable
- Fields of data structure (var->field)
- Bit fields
- Array (var[N])
- Dynamic array indexing (var[var2])
- String/dynamic arrays (var:string, var[N..M])
- Force Type casting ((type)var)
- Non-inline search
- libdw, libdwfl

Thank you,


Masami Hiramatsu (5):
perf: kprobe command supports without libdwarf
perf: Support perf kprobe command for kprobe-event setup helper
tracing/kprobes: Rename fixed field name
tracing/kprobes: Avoid field name confliction
tracing/kprobes: Rename special variables syntax

Documentation/trace/kprobetrace.txt | 10 -
kernel/trace/trace_kprobe.c | 124 +++++-
tools/perf/Makefile | 10 +
tools/perf/builtin-kprobe.c | 340 +++++++++++++++++
tools/perf/builtin.h | 1
tools/perf/perf.c | 1
tools/perf/util/probe-finder.c | 684 +++++++++++++++++++++++++++++++++++
tools/perf/util/probe-finder.h | 70 ++++
8 files changed, 1200 insertions(+), 40 deletions(-)
create mode 100644 tools/perf/builtin-kprobe.c
create mode 100644 tools/perf/util/probe-finder.c
create mode 100644 tools/perf/util/probe-finder.h

Masami Hiramatsu

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


 \ /
  Last update: 2009-09-25 21:15    [W:0.093 / U:5.196 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site