perf-probe updates: string support, etc.
Subsystems (3)
cover perf-probe updates: string support, etc.
Hi,
Here is a series of patches which improves perf probe to add below features. I cleared some coding style issues.
- String support, which enables dynamic events to trace string variables instead of its address.
- Fixed-index array entry support, which allows user to trace an array entry with digit index, e.g. array[0].
- Global/static variable support, which allows user to trace global or static variables, as same as local one.
TODOs (possible features):
- Support dynamic array-indexing (var[var2])
- Support force type-casting ((type)var)
- Show what deta-structure member is assigned to each argument.
- Better support for probes on modules
- More debugger like enhancements(%next, --disasm, etc.)
Thank you,
---
Masami Hiramatsu (4):
perf probe: Support static and global variables perf probe: Support tracing an entry of array perf probe: Support "string" type tracing/kprobes: Support "string" type
Documentation/trace/kprobetrace.txt | 2 kernel/trace/trace_kprobe.c | 370 ++++++++++++++++++++++++------- tools/perf/Documentation/perf-probe.txt | 4 tools/perf/util/probe-event.c | 71 ++++-- tools/perf/util/probe-event.h | 1 tools/perf/util/probe-finder.c | 192 +++++++++++++--- 6 files changed, 498 insertions(+), 142 deletions(-)
Signature · 2 lines
Masami Hiramatsu e-mail: [email protected]
PATCH 1/4 tracing/kprobes: Support "string" type
Support string type tracing and printing in kprobe-tracer. This allows user to trace string data in kernel including __user data. Note that sometimes __user data may not be accessed if it is paged-out (sorry, but kprobes operation should be done in atomic, we can not wait for page-in).
---
Documentation/trace/kprobetrace.txt | 2 kernel/trace/trace_kprobe.c | 370 ++++++++++++++++++++++++++++------- 2 files changed, 293 insertions(+), 79 deletions(-)
Documentation/trace/kprobetrace.txt +1 -1
@@ -42,7 +42,7 @@ Synopsis of kprobe_events +|-offs(FETCHARG) : Fetch memory at FETCHARG +|- offs address.(**) NAME=FETCHARG : Set NAME as the argument name of FETCHARG. FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types - (u8/u16/u32/u64/s8/s16/s32/s64) are supported. + (u8/u16/u32/u64/s8/s16/s32/s64) and string are supported. (*) only for return probe. (**) this is useful for fetching a field of data structures.
kernel/trace/trace_kprobe.c +292 -78
644 lines not on this page · raw message
Signature · 2 lines
Masami Hiramatsu e-mail: [email protected]
[tip:perf/core] tracing/kprobes: Support "string" type
Commit-ID: e09c8614b32915c16f68e039ac7040e602d73e35 Gitweb: http://git.kernel.org/tip/e09c8614b32915c16f68e039ac7040e602d73e35 Author: Masami Hiramatsu <[email protected]> AuthorDate: Mon, 5 Jul 2010 15:54:45 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Jul 2010 15:54:45 -0300
tracing/kprobes: Support "string" type
Support string type tracing and printing in kprobe-tracer.
This allows user to trace string data in kernel including __user data. Note that sometimes __user data may not be accessed if it is paged-out (sorry, but kprobes operation should be done in atomic, we can not wait for page-in).
Commiter note: Fixed up conflicts with b7e2ece.
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
--- Documentation/trace/kprobetrace.txt | 2 +- kernel/trace/trace_kprobe.c | 370 +++++++++++++++++++++++++++-------- 2 files changed, 293 insertions(+), 79 deletions(-)
Documentation/trace/kprobetrace.txt +1 -1
@@ -42,7 +42,7 @@ Synopsis of kprobe_events +|-offs(FETCHARG) : Fetch memory at FETCHARG +|- offs address.(**) NAME=FETCHARG : Set NAME as the argument name of FETCHARG. FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types - (u8/u16/u32/u64/s8/s16/s32/s64) are supported. + (u8/u16/u32/u64/s8/s16/s32/s64) and string are supported. (*) only for return probe. (**) this is useful for fetching a field of data structures.
kernel/trace/trace_kprobe.c +292 -78
642 lines not on this page · raw message
PATCH 2/4 perf probe: Support "string" type
In reply to Masami HiramatsuSupport string type casting to event argument. If perf-probe finds an argument casted as string, it ensures the target variable is "(unsigned/signed) char *(or []). perf-probe also adds dereference if the target is a pointer.
So, both of 'char buf[10];' and 'char *buf;' can be accessed by 'buf:string'
---
tools/perf/Documentation/perf-probe.txt | 2 + tools/perf/util/probe-finder.c | 59 +++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 12 deletions(-)
tools/perf/Documentation/perf-probe.txt +1 -1
@@ -91,7 +91,7 @@ Each probe argument follows below syntax. [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE] 'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.) -'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. +'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type. LINE SYNTAX -----------
tools/perf/util/probe-finder.c +48 -11
88 lines not on this page · raw message
Signature · 2 lines
Masami Hiramatsu e-mail: [email protected]
[tip:perf/core] perf probe: Support "string" type
Commit-ID: 73317b954041031249e8968d2e9023ff4e960d99 Gitweb: http://git.kernel.org/tip/73317b954041031249e8968d2e9023ff4e960d99 Author: Masami Hiramatsu <[email protected]> AuthorDate: Wed, 19 May 2010 15:57:35 -0400 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Jul 2010 18:47:28 -0300
perf probe: Support "string" type
Support string type casting to event argument. If perf-probe finds an argument casted as string, it ensures the target variable is "(unsigned/signed) char *(or []). perf-probe also adds dereference if the target is a pointer.
So, both of 'char buf[10];' and 'char *buf;' can be accessed by 'buf:string'
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
--- tools/perf/Documentation/perf-probe.txt | 2 +- tools/perf/util/probe-finder.c | 59 +++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 12 deletions(-)
tools/perf/Documentation/perf-probe.txt +1 -1
@@ -95,7 +95,7 @@ Each probe argument follows below syntax. [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE] 'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.) -'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. +'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type. LINE SYNTAX -----------
tools/perf/util/probe-finder.c +48 -11
88 lines not on this page · raw message
PATCH 3/4 perf probe: Support tracing an entry of array
In reply to Masami HiramatsuAdd array-entry tracing support to perf probe. This enables to trace an entry of array which is indexed by constant value, e.g. array[0].
For example:
$ perf probe -a 'bio_split bi->bi_io_vec[0]'
---
tools/perf/Documentation/perf-probe.txt | 2 + tools/perf/util/probe-event.c | 56 ++++++++++++++++++++++--------- tools/perf/util/probe-event.h | 1 + tools/perf/util/probe-finder.c | 48 +++++++++++++++++++++++---- 4 files changed, 83 insertions(+), 24 deletions(-)
tools/perf/Documentation/perf-probe.txt +1 -1
@@ -90,7 +90,7 @@ Each probe argument follows below syntax. [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE] -'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.) +'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), local array with fixed index (e.g. array[1], var->array[0], var->pointer[2]), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.) 'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type. LINE SYNTAX
tools/perf/util/probe-event.c +39 -17
104 lines not on this page · raw message
tools/perf/util/probe-event.h +1 -0
@@ -50,6 +50,7 @@ struct perf_probe_point {struct perf_probe_arg_field {struct perf_probe_arg_field *next;/* Next field */ char *name;/* Name of the field */ +long index;/* Array index number */ bool ref;/* Referencing flag */ };
tools/perf/util/probe-finder.c +42 -6
87 lines not on this page · raw message
Signature · 2 lines
Masami Hiramatsu e-mail: [email protected]
[tip:perf/core] perf probe: Support tracing an entry of array
Commit-ID: b2a3c12b7442247c440f7083d48ef05716753ec1 Gitweb: http://git.kernel.org/tip/b2a3c12b7442247c440f7083d48ef05716753ec1 Author: Masami Hiramatsu <[email protected]> AuthorDate: Wed, 19 May 2010 15:57:42 -0400 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Jul 2010 18:50:27 -0300
perf probe: Support tracing an entry of array
Add array-entry tracing support to perf probe. This enables to trace an entry of array which is indexed by constant value, e.g. array[0].
For example:
$ perf probe -a 'bio_split bi->bi_io_vec[0]'
Cc: Paul Mackerras <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
--- tools/perf/Documentation/perf-probe.txt | 2 +- tools/perf/util/probe-event.c | 56 +++++++++++++++++++++--------- tools/perf/util/probe-event.h | 1 + tools/perf/util/probe-finder.c | 48 +++++++++++++++++++++++--- 4 files changed, 83 insertions(+), 24 deletions(-)
tools/perf/Documentation/perf-probe.txt +1 -1
@@ -94,7 +94,7 @@ Each probe argument follows below syntax. [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE] -'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.) +'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), local array with fixed index (e.g. array[1], var->array[0], var->pointer[2]), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.) 'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type. LINE SYNTAX
tools/perf/util/probe-event.c +39 -17
104 lines not on this page · raw message
tools/perf/util/probe-event.h +1 -0
@@ -50,6 +50,7 @@ struct perf_probe_point {struct perf_probe_arg_field {struct perf_probe_arg_field *next;/* Next field */ char *name;/* Name of the field */ +long index;/* Array index number */ bool ref;/* Referencing flag */ };
tools/perf/util/probe-finder.c +42 -6
87 lines not on this page · raw message
PATCH 4/4 perf probe: Support static and global variables
In reply to Masami HiramatsuAdd static and global variables support to perf probe. This allows user to trace non-local variables (and structure members) at probe points.
---
tools/perf/util/probe-event.c | 15 ++++++- tools/perf/util/probe-finder.c | 85 +++++++++++++++++++++++++++++----------- 2 files changed, 73 insertions(+), 27 deletions(-)
tools/perf/util/probe-event.c +12 -3
@@ -926,6 +926,7 @@ out:static int synthesize_kprobe_trace_arg (struct kprobe_trace_arg *arg,char *buf,size_t buflen) { +struct kprobe_trace_arg_ref *ref = arg->ref;int ret, depth =0 ;char *tmp = buf;
@@ -939,16 +940,24 @@ static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg, buf += ret; buflen -= ret; +/* Special case: @XXX */ +if (arg->value[0 ] =='@' && arg->ref) + ref = ref->next; +/* Dereferencing arguments */ -if (arg->ref) { - depth =__synthesize_kprobe_trace_arg_ref (arg->ref, &buf, +if (ref) { + depth =__synthesize_kprobe_trace_arg_ref (ref, &buf, &buflen,1 );if (depth <0 )return depth; }/* Print argument value */ - ret =e_snprintf (buf, buflen,"%s" , arg->value); +if (arg->value[0 ] =='@' && arg->ref) + ret =e_snprintf (buf, buflen,"%s%+ld" , arg->value, + arg->ref->offset); +else + ret =e_snprintf (buf, buflen,"%s" , arg->value);if (ret <0 )return ret; buf += ret;
tools/perf/util/probe-finder.c +61 -24
136 lines not on this page · raw message
Signature · 2 lines
Masami Hiramatsu e-mail: [email protected]
[tip:perf/core] perf probe: Support static and global variables
Commit-ID: b7dcb857cc3eb89136111fefe89780129c1af1d7 Gitweb: http://git.kernel.org/tip/b7dcb857cc3eb89136111fefe89780129c1af1d7 Author: Masami Hiramatsu <[email protected]> AuthorDate: Wed, 19 May 2010 15:57:49 -0400 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Jul 2010 18:51:33 -0300
perf probe: Support static and global variables
Add static and global variables support to perf probe. This allows user to trace non-local variables (and structure members) at probe points.
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
--- tools/perf/util/probe-event.c | 15 ++++++- tools/perf/util/probe-finder.c | 85 ++++++++++++++++++++++++++++----------- 2 files changed, 73 insertions(+), 27 deletions(-)
tools/perf/util/probe-event.c +12 -3
@@ -926,6 +926,7 @@ out:static int synthesize_kprobe_trace_arg (struct kprobe_trace_arg *arg,char *buf,size_t buflen) { +struct kprobe_trace_arg_ref *ref = arg->ref;int ret, depth =0 ;char *tmp = buf;
@@ -939,16 +940,24 @@ static int synthesize_kprobe_trace_arg(struct kprobe_trace_arg *arg, buf += ret; buflen -= ret; +/* Special case: @XXX */ +if (arg->value[0 ] =='@' && arg->ref) + ref = ref->next; +/* Dereferencing arguments */ -if (arg->ref) { - depth =__synthesize_kprobe_trace_arg_ref (arg->ref, &buf, +if (ref) { + depth =__synthesize_kprobe_trace_arg_ref (ref, &buf, &buflen,1 );if (depth <0 )return depth; }/* Print argument value */ - ret =e_snprintf (buf, buflen,"%s" , arg->value); +if (arg->value[0 ] =='@' && arg->ref) + ret =e_snprintf (buf, buflen,"%s%+ld" , arg->value, + arg->ref->offset); +else + ret =e_snprintf (buf, buflen,"%s" , arg->value);if (ret <0 )return ret; buf += ret;
tools/perf/util/probe-finder.c +61 -24
136 lines not on this page · raw message
Quoted 24 lines · Masami Hiramatsu
Hi,
Here is a series of patches which improves perf probe to add below features. I cleared some coding style issues.
- String support, which enables dynamic events to trace string variables instead of its address.
- Fixed-index array entry support, which allows user to trace an array entry with digit index, e.g. array[0].
- Global/static variable support, which allows user to trace global or static variables, as same as local one.
TODOs (possible features):
- Support dynamic array-indexing (var[var2])
- Support force type-casting ((type)var)
- Show what deta-structure member is assigned to each argument.
- Better support for probes on modules
- More debugger likeenhancements(%next, --disasm, etc.)Thank you,
Quoted 7 lines
---
Masami Hiramatsu (4):
perf probe: Support static and global variables perf probe: Support tracing an entry of array perf probe: Support "string" type tracing/kprobes: Support "string" type
What's the status of these patches? They seem very useful to me, but I don't see them in Arnaldo's tree at git.kernel.org.
Thanks,
-- Chase
Em Mon, Jul 05, 2010 at 10:30:47AM -0400, Chase Douglas escreveu:
Quoted 27 lines · Masami Hiramatsu
Quoted 26 lines
Hi,
Here is a series of patches which improves perf probe to add below features. I cleared some coding style issues.
- String support, which enables dynamic events to trace string variables instead of its address.
- Fixed-index array entry support, which allows user to trace an array entry with digit index, e.g. array[0].
- Global/static variable support, which allows user to trace global or static variables, as same as local one.
TODOs (possible features):
- Support dynamic array-indexing (var[var2])
- Support force type-casting ((type)var)
- Show what deta-structure member is assigned to each argument.
- Better support for probes on modules
- More debugger likeenhancements(%next, --disasm, etc.)Thank you,
---
Quoted 8 lines
Quoted 5 lines
Masami Hiramatsu (4):
perf probe: Support static and global variables perf probe: Support tracing an entry of array perf probe: Support "string" type tracing/kprobes: Support "string" typeWhat's the status of these patches? They seem very useful to me, but I don't see them in Arnaldo's tree at git.kernel.org.
Thanks for reminding me about these ones, will look at them to get them in perf/core.
- Arnaldo
Quoted 33 lines · Arnaldo Carvalho de Melo
Em Mon, Jul 05, 2010 at 10:30:47AM -0400, Chase Douglas escreveu:
Quoted 32 lines · Masami Hiramatsu
Quoted 31 lines
Hi,
Here is a series of patches which improves perf probe to add below features. I cleared some coding style issues.
- String support, which enables dynamic events to trace string variables instead of its address.
- Fixed-index array entry support, which allows user to trace an array entry with digit index, e.g. array[0].
- Global/static variable support, which allows user to trace global or static variables, as same as local one.
TODOs (possible features):
- Support dynamic array-indexing (var[var2])
- Support force type-casting ((type)var)
- Show what deta-structure member is assigned to each argument.
- Better support for probes on modules
- More debugger likeenhancements(%next, --disasm, etc.)Thank you,
---
Masami Hiramatsu (4):
perf probe: Support static and global variables perf probe: Support tracing an entry of array perf probe: Support "string" type tracing/kprobes: Support "string" type
Quoted 5 lines
Quoted 2 lines
What's the status of these patches? They seem very useful to me, but I don't see them in Arnaldo's tree at git.kernel.org.
Thanks for reminding me about these ones, will look at them to get them in perf/core.
Thanks for picking it up. And I need to tell it to Sriker because this will affect his uprobes patchset (ftrace part).
(Actually, my original plan was to update the patchset onto
his uprobes patchset.)
Sriker, the 1st patch in this series will add many macros/functions into trace_kprobe.c. This will directly affect your 8th patch of uprobes, which splits fetch functions out from trace_kprobe.c.
Is that OK for you?
Thank you,
Signature · 4 lines
Masami HIRAMATSU 2nd Research Dept. Hitachi, Ltd., Systems Development Laboratory E-mail: [email protected]
Quoted 16 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Masami Hiramatsu (4):
perf probe: Support static and global variables perf probe: Support tracing an entry of array perf probe: Support "string" type tracing/kprobes: Support "string" typeWhat's the status of these patches? They seem very useful to me, but I don't see them in Arnaldo's tree at git.kernel.org.
Thanks for reminding me about these ones, will look at them to get them in perf/core.
Thanks for picking it up. And I need to tell it to Sriker because this will affect his uprobes patchset (ftrace part).
(Actually, my original plan was to update the patchset onto
his uprobes patchset.)
Quoted 4 lines
Sriker, the 1st patch in this series will add many macros/functions into
trace_kprobe.c. This will directly affect your 8th patch of uprobes, which splits fetch functions out fromtrace_kprobe.c.
Is that OK for you?
Okay, I will keep rebasing to the latest tip/master before sending out patches for review. So I will continue to do the same when pushing the v8 patches.
--
Thanks and Regards
Srikar
Em Mon, Jul 05, 2010 at 02:44:50PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 11 lines
Em Mon, Jul 05, 2010 at 10:30:47AM -0400, Chase Douglas escreveu:
Quoted 9 lines · Masami Hiramatsu
Quoted 8 lines
Here is a series of patches which improves perf probe to add below features. I cleared some coding style issues.
- String support, which enables dynamic events to trace string variables instead of its address.
- Fixed-index array entry support, which allows user to trace an array entry with digit index, e.g. array[0].
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
- Global/static variable support, which allows user to trace global or static variables, as same as local one.
What's the status of these patches? They seem very useful to me, but I don't see them in Arnaldo's tree at git.kernel.org.
Thanks for reminding me about these ones, will look at them to get them in perf/core.
Masami, I fixed up a minor conflict and while trying it this happened:
[root@emilia ~]# perf probe -a 'bio_split bi->bi_io_vec[0]' kprobe_events file does not exist - please rebuild kernel with CONFIG_KPROBE_EVENT.
Error: Failed to add events. (-1)
But on a second try:
[root@emilia ~]# l /sys/kernel/debug/tracing/kprobe_events -rw-r--r-- 1 root root 0 Jul 5 18:37 /sys/kernel/debug/tracing/kprobe_events [root@emilia ~]# cat /sys/kernel/debug/tracing/kprobe_events [root@emilia ~]#
[root@emilia ~]# perf probe -a 'bio_split bi->bi_io_vec[0]'
Add new event:
probe:bio_split (on bio_split with bi_io_vec=bi->bi_io_vec[0])
You can now use it on all perf tools, such as:
perf record -e probe:bio_split -aR sleep 1
[root@emilia ~]# cat /sys/kernel/debug/tracing/kprobe_events p:probe/bio_split bio_split bi_io_vec=+0(+72(%di)):u64 [root@emilia ~]#
I'll push it as is, posting the pull request with the patches today, please check if everything is ok and send fixups if needed,
Thanks,
- Arnaldo