perf/ftrace: Introduce hexadecimal type casting
Subsystems (3)
Masami Hiramatsu
maintainercover perf/ftrace: Introduce hexadecimal type casting
Hi Arnaldo and Steven,
Here is an RFC series of hexadecimal type casting and changing default type casting of perf and ftrace.
I've introduced x8,x16,x32,x64 according to previous discussion on LKML.
https://lkml.org/lkml/2016/8/10/339
This series includes not only adding hexadecimal types (x8,x16,x32,x64), but also checking it is supported by running kernel and keeping the backward compativility.
[1/6] Add hexadecimal type casting, but does not touch
existing types like 'u8'.
[2/6] Show the supported types on README of ftrace so
that user application (e.g. perf) can check that.
[3/6] Add a type availability check to perf-probe. [4/6] Add hexadecimal prefix support to perf-probe if
it is supported by the kernel.
[5/6] Change the perf-probe default type casting for
unsigned type to hexadecimal (for backward compatibility)
[6/6] Change ftrace's 'uNN' to show value in decimal
and use 'xNN' by default (for backward compatibility)
This way, we can also add "octal" type, pointer type, and "character" type etc. and perf can check whether the kernel supports it or not. :)
Thanks,
---
Masami Hiramatsu (6):
ftrace: kprobe: uprobe: Add x8/x16/x32/x64 for hexadecimal types
ftrace: probe: Add README entries for k/uprobe-events perf probe: Add supported type casting of running kernel perf probe: Support hexadecimal casting
perf-probe: Use hexadecimal type by default if possible
ftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal
tools/perf/Documentation/perf-probe.txt | 5 +-- tools/perf/util/probe-file.c | 57 +++++++++++++++++++++++++++++++ tools/perf/util/probe-file.h | 10 +++++ tools/perf/util/probe-finder.c | 19 +++++++--- 4 files changed, 81 insertions(+), 10 deletions(-)
--
Masami Hiramatsu (Linaro Ltd.) <[email protected]>
Masami Hiramatsu
maintainerPATCH 1/6 ftrace: kprobe: uprobe: Add x8/x16/x32/x64 for hexadecimal types
Add x8/x16/x32/x64 for hexadecimal type casting to kprobe/uprobe event tracer.
These type casts can be used for integer arguments for explicitly showing them in hexadecimal digits in formatted text.
--- tools/perf/Documentation/perf-probe.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/trace/kprobetrace.txt +2 -2
@@ -44,8 +44,8 @@ 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), "string" and bitfield - are supported. + (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types + (x8/x16/x32/x64), "string" and bitfield are supported. (*) only for return probe. (**) this is useful for fetching a field of data structures.
Documentation/trace/uprobetracer.txt +2 -2
@@ -40,8 +40,8 @@ Synopsis of uprobe_tracer +|-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), "string" and bitfield - are supported. + (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types + (x8/x16/x32/x64), "string" and bitfield are supported. (*) only for return probe. (**) this is useful for fetching a field of data structures.
kernel/trace/trace_kprobe.c +4 -0
@@ -253,6 +253,10 @@ static const struct fetch_type kprobes_fetch_type_table[] = {ASSIGN_FETCH_TYPE (s16, u16,1 ),ASSIGN_FETCH_TYPE (s32, u32,1 ),ASSIGN_FETCH_TYPE (s64, u64,1 ), +ASSIGN_FETCH_TYPE_ALIAS (x8, u8, u8,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x16, u16, u16,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x32, u32, u32,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x64, u64, u64,0 ), ASSIGN_FETCH_TYPE_END };
kernel/trace/trace_probe.c +17 -13
@@ -36,24 +36,28 @@ const char *reserved_field_names[] = { };/* Printing in basic type function template */ -#define DEFINE_BASIC_PRINT_TYPE_FUNC (type, fmt) \ -int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, const char *name, \ +#define DEFINE_BASIC_PRINT_TYPE_FUNC (tname, type, fmt) \ +int PRINT_TYPE_FUNC_NAME(tname)(struct trace_seq *s, const char *name, \ void *data, void *ent) \ { \ trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \ return !trace_seq_has_overflowed(s); \ } \ -const char PRINT_TYPE_FMT_NAME(type)[] = fmt; \ -NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(type)); - -DEFINE_BASIC_PRINT_TYPE_FUNC(u8 , "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "0x%Lx") -DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d") -DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d") -DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%d") -DEFINE_BASIC_PRINT_TYPE_FUNC (s64,"%Ld" ) +const char PRINT_TYPE_FMT_NAME(tname)[] = fmt; \ +NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(tname)); + +DEFINE_BASIC_PRINT_TYPE_FUNC(u8, u8, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, u16, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, u32, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, u64, "0x%Lx") +DEFINE_BASIC_PRINT_TYPE_FUNC(s8, s8, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s16, s16, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s32, s32, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s64, s64, "%Ld") +DEFINE_BASIC_PRINT_TYPE_FUNC(x8, u8, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(x16, u16, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(x32, u32, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC (x64, u64,"0x%Lx" ) /* Print type function for string type */ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, const char *name,
kernel/trace/trace_probe.h +9 -0
@@ -149,6 +149,11 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(s8);DECLARE_BASIC_PRINT_TYPE_FUNC (s16);DECLARE_BASIC_PRINT_TYPE_FUNC (s32);DECLARE_BASIC_PRINT_TYPE_FUNC (s64); +DECLARE_BASIC_PRINT_TYPE_FUNC (x8); +DECLARE_BASIC_PRINT_TYPE_FUNC (x16); +DECLARE_BASIC_PRINT_TYPE_FUNC (x32); +DECLARE_BASIC_PRINT_TYPE_FUNC (x64); +DECLARE_BASIC_PRINT_TYPE_FUNC (string);#define FETCH_FUNC_NAME (method, type) fetch_##method##_##type
@@ -234,6 +239,10 @@ ASSIGN_FETCH_FUNC(file_offset, ftype), \#define ASSIGN_FETCH_TYPE (ptype, ftype, sign) \ __ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #ptype) +/* If ptype is an alias of atype, use this macro (show atype in format) */ +#define ASSIGN_FETCH_TYPE_ALIAS (ptype, atype, ftype, sign) \ + __ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #atype) +#define ASSIGN_FETCH_TYPE_END {}#define FETCH_TYPE_STRING 0
kernel/trace/trace_uprobe.c +4 -0
@@ -211,6 +211,10 @@ static const struct fetch_type uprobes_fetch_type_table[] = {ASSIGN_FETCH_TYPE (s16, u16,1 ),ASSIGN_FETCH_TYPE (s32, u32,1 ),ASSIGN_FETCH_TYPE (s64, u64,1 ), +ASSIGN_FETCH_TYPE_ALIAS (x8, u8, u8,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x16, u16, u16,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x32, u32, u32,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x64, u64, u64,0 ), ASSIGN_FETCH_TYPE_END };
tools/perf/Documentation/perf-probe.txt +2 -2
@@ -176,13 +176,13 @@ Each probe argument follows below syntax. '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'.) '$vars' and '$params' special arguments are also available for NAME, '$vars' is expanded to the local variables (including function parameters) which can access at given probe point. '$params' is expanded to only the function parameters. -'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) +'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. TYPES ----- -Basic types (u8/u16/u32/u64/s8/s16/s32/s64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. +Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. 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. Bitfield is another special type, which takes 3 parameters, bit-width, bit-offset, and container-size (usually 32). The syntax is;
Re: [PATCH 1/6] ftrace: kprobe: uprobe: Add x8/x16/x32/x64 for hexadecimal types
Quoted 7 lines · On Thu, 18 Aug 2016 17:57:50 +0900 Masami Hiramatsu <[email protected]> wrote:
Add x8/x16/x32/x64 for hexadecimal type casting to kprobe/uprobe event tracer.
These type casts can be used for integer arguments for explicitly showing them in hexadecimal digits in formatted text.
Signed-off-by Masami Hiramatsu <[email protected]>
-- Steve
tip-bot for Masami Hiramatsu
merge bot[tip:perf/core] ftrace: kprobe: uprobe: Add x8/x16/x32/x64 for hexadecimal types
In reply to Masami Hiramatsuftrace: kprobe: uprobe: Add x8/x16/x32/x64 for hexadecimal types
Commit-ID: 17ce3dc7e5a0e4796cc7838d1f7b2531d0bca130 Gitweb: http://git.kernel.org/tip/17ce3dc7e5a0e4796cc7838d1f7b2531d0bca130 Author: Masami Hiramatsu <[email protected]> AuthorDate: Thu, 18 Aug 2016 17:57:50 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 15:38:09 -0300
ftrace: kprobe: uprobe: Add x8/x16/x32/x64 for hexadecimal types
Add x8/x16/x32/x64 for hexadecimal type casting to kprobe/uprobe event tracer.
These type casts can be used for integer arguments for explicitly showing them in hexadecimal digits in formatted text.
--- Documentation/trace/kprobetrace.txt | 4 ++-- Documentation/trace/uprobetracer.txt | 4 ++-- kernel/trace/trace_kprobe.c | 4 ++++ kernel/trace/trace_probe.c | 30 +++++++++++++++++------------- kernel/trace/trace_probe.h | 9 +++++++++ kernel/trace/trace_uprobe.c | 4 ++++ tools/perf/Documentation/perf-probe.txt | 4 ++-- 7 files changed, 40 insertions(+), 19 deletions(-)
Documentation/trace/kprobetrace.txt +2 -2
@@ -44,8 +44,8 @@ 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), "string" and bitfield - are supported. + (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types + (x8/x16/x32/x64), "string" and bitfield are supported. (*) only for return probe. (**) this is useful for fetching a field of data structures.
Documentation/trace/uprobetracer.txt +2 -2
@@ -40,8 +40,8 @@ Synopsis of uprobe_tracer +|-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), "string" and bitfield - are supported. + (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types + (x8/x16/x32/x64), "string" and bitfield are supported. (*) only for return probe. (**) this is useful for fetching a field of data structures.
kernel/trace/trace_kprobe.c +4 -0
@@ -253,6 +253,10 @@ static const struct fetch_type kprobes_fetch_type_table[] = {ASSIGN_FETCH_TYPE (s16, u16,1 ),ASSIGN_FETCH_TYPE (s32, u32,1 ),ASSIGN_FETCH_TYPE (s64, u64,1 ), +ASSIGN_FETCH_TYPE_ALIAS (x8, u8, u8,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x16, u16, u16,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x32, u32, u32,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x64, u64, u64,0 ), ASSIGN_FETCH_TYPE_END };
kernel/trace/trace_probe.c +17 -13
@@ -36,24 +36,28 @@ const char *reserved_field_names[] = { };/* Printing in basic type function template */ -#define DEFINE_BASIC_PRINT_TYPE_FUNC (type, fmt) \ -int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, const char *name, \ +#define DEFINE_BASIC_PRINT_TYPE_FUNC (tname, type, fmt) \ +int PRINT_TYPE_FUNC_NAME(tname)(struct trace_seq *s, const char *name, \ void *data, void *ent) \ { \ trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \ return !trace_seq_has_overflowed(s); \ } \ -const char PRINT_TYPE_FMT_NAME(type)[] = fmt; \ -NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(type)); - -DEFINE_BASIC_PRINT_TYPE_FUNC(u8 , "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "0x%Lx") -DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d") -DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d") -DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%d") -DEFINE_BASIC_PRINT_TYPE_FUNC (s64,"%Ld" ) +const char PRINT_TYPE_FMT_NAME(tname)[] = fmt; \ +NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(tname)); + +DEFINE_BASIC_PRINT_TYPE_FUNC(u8, u8, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, u16, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, u32, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, u64, "0x%Lx") +DEFINE_BASIC_PRINT_TYPE_FUNC(s8, s8, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s16, s16, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s32, s32, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s64, s64, "%Ld") +DEFINE_BASIC_PRINT_TYPE_FUNC(x8, u8, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(x16, u16, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(x32, u32, "0x%x") +DEFINE_BASIC_PRINT_TYPE_FUNC (x64, u64,"0x%Lx" ) /* Print type function for string type */ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, const char *name,
kernel/trace/trace_probe.h +9 -0
@@ -149,6 +149,11 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(s8);DECLARE_BASIC_PRINT_TYPE_FUNC (s16);DECLARE_BASIC_PRINT_TYPE_FUNC (s32);DECLARE_BASIC_PRINT_TYPE_FUNC (s64); +DECLARE_BASIC_PRINT_TYPE_FUNC (x8); +DECLARE_BASIC_PRINT_TYPE_FUNC (x16); +DECLARE_BASIC_PRINT_TYPE_FUNC (x32); +DECLARE_BASIC_PRINT_TYPE_FUNC (x64); +DECLARE_BASIC_PRINT_TYPE_FUNC (string);#define FETCH_FUNC_NAME (method, type) fetch_##method##_##type
@@ -234,6 +239,10 @@ ASSIGN_FETCH_FUNC(file_offset, ftype), \#define ASSIGN_FETCH_TYPE (ptype, ftype, sign) \ __ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #ptype) +/* If ptype is an alias of atype, use this macro (show atype in format) */ +#define ASSIGN_FETCH_TYPE_ALIAS (ptype, atype, ftype, sign) \ + __ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #atype) +#define ASSIGN_FETCH_TYPE_END {}#define FETCH_TYPE_STRING 0
kernel/trace/trace_uprobe.c +4 -0
@@ -211,6 +211,10 @@ static const struct fetch_type uprobes_fetch_type_table[] = {ASSIGN_FETCH_TYPE (s16, u16,1 ),ASSIGN_FETCH_TYPE (s32, u32,1 ),ASSIGN_FETCH_TYPE (s64, u64,1 ), +ASSIGN_FETCH_TYPE_ALIAS (x8, u8, u8,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x16, u16, u16,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x32, u32, u32,0 ), +ASSIGN_FETCH_TYPE_ALIAS (x64, u64, u64,0 ), ASSIGN_FETCH_TYPE_END };
tools/perf/Documentation/perf-probe.txt +2 -2
@@ -176,13 +176,13 @@ Each probe argument follows below syntax. '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'.) '$vars' and '$params' special arguments are also available for NAME, '$vars' is expanded to the local variables (including function parameters) which can access at given probe point. '$params' is expanded to only the function parameters. -'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) +'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. TYPES ----- -Basic types (u8/u16/u32/u64/s8/s16/s32/s64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. +Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. 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. Bitfield is another special type, which takes 3 parameters, bit-width, bit-offset, and container-size (usually 32). The syntax is;
Masami Hiramatsu
maintainerPATCH 2/6 ftrace: probe: Add README entries for k/uprobe-events
In reply to Masami HiramatsuAdd README entries for kprobe-events and uprobe-events. This allows user to check what options can be acceptable for running kernel.
E.g. perf tools can choose correct types for the kernel.
---
0 files changed
kernel/trace/trace.c +24 -0
@@ -4123,6 +4123,30 @@ static const char readme_msg[] = "\t\t\t traces\n"#endif #endif /* CONFIG_STACK_TRACER */ +#ifdef CONFIG_KPROBE_EVENT +" kprobe_events\t\t- Add/remove/show the kernel dynamic events\n" + "\t\t\t Write into this file to define/undefine new trace events.\n" +#endif +#ifdef CONFIG_UPROBE_EVENT +" uprobe_events\t\t- Add/remove/show the userspace dynamic events\n" + "\t\t\t Write into this file to define/undefine new trace events.\n" +#endif +#if defined(CONFIG_KPROBE_EVENT ) || defined(CONFIG_UPROBE_EVENT ) +"\t accepts: event-definitions (one definition per line)\n" +"\t Format: p|r[:[<group>/]<event>] <place> [<args>]\n" +"\t -:[<group>/]<event>\n" +#ifdef CONFIG_KPROBE_EVENT + "\t place: [<module>:]<symbol>[+<offset>]|<memaddr>\n" +#endif +#ifdef CONFIG_UPROBE_EVENT +"\t place: <path>:<offset>\n" +#endif +"\t args: <name>=fetcharg[:type]\n" +"\t fetcharg: %<register>, @<address>, @<symbol>[+|-<offset>],\n" +"\t $stack<index>, $stack, $retval, $comm\n" +"\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string,\n" + "\t b<bit-width>@<bit-offset>/<container-size>\n" +#endif " events/\t\t- Directory containing all trace event subsystems:\n" " enable\t\t- Write 0/1 to enable/disable tracing of all events\n" " events/<system>/\t- Directory containing all trace events for <system>:\n"
Re: [PATCH 2/6] ftrace: probe: Add README entries for k/uprobe-events
Quoted 7 lines · On Thu, 18 Aug 2016 17:58:15 +0900 Masami Hiramatsu <[email protected]> wrote:
Add README entries for kprobe-events and uprobe-events. This allows user to check what options can be acceptable for running kernel.
E.g. perf tools can choose correct types for the kernel.Signed-off-by Masami Hiramatsu <[email protected]>---
-- Steve
tip-bot for Masami Hiramatsu
merge bot[tip:perf/core] ftrace: probe: Add README entries for k/uprobe-events
In reply to Masami Hiramatsuftrace: probe: Add README entries for k/uprobe-events
Commit-ID: 864256255597aad86abcecbe6c53da8852ded15b Gitweb: http://git.kernel.org/tip/864256255597aad86abcecbe6c53da8852ded15b Author: Masami Hiramatsu <[email protected]> AuthorDate: Thu, 18 Aug 2016 17:58:15 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 15:39:57 -0300
ftrace: probe: Add README entries for k/uprobe-events
Add README entries for kprobe-events and uprobe-events. This allows user to check what options can be acceptable for running kernel.
E.g. perf tools can choose correct types for the kernel.
--- kernel/trace/trace.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
kernel/trace/trace.c +24 -0
@@ -4123,6 +4123,30 @@ static const char readme_msg[] = "\t\t\t traces\n"#endif #endif /* CONFIG_STACK_TRACER */ +#ifdef CONFIG_KPROBE_EVENT +" kprobe_events\t\t- Add/remove/show the kernel dynamic events\n" + "\t\t\t Write into this file to define/undefine new trace events.\n" +#endif +#ifdef CONFIG_UPROBE_EVENT +" uprobe_events\t\t- Add/remove/show the userspace dynamic events\n" + "\t\t\t Write into this file to define/undefine new trace events.\n" +#endif +#if defined(CONFIG_KPROBE_EVENT ) || defined(CONFIG_UPROBE_EVENT ) +"\t accepts: event-definitions (one definition per line)\n" +"\t Format: p|r[:[<group>/]<event>] <place> [<args>]\n" +"\t -:[<group>/]<event>\n" +#ifdef CONFIG_KPROBE_EVENT + "\t place: [<module>:]<symbol>[+<offset>]|<memaddr>\n" +#endif +#ifdef CONFIG_UPROBE_EVENT +"\t place: <path>:<offset>\n" +#endif +"\t args: <name>=fetcharg[:type]\n" +"\t fetcharg: %<register>, @<address>, @<symbol>[+|-<offset>],\n" +"\t $stack<index>, $stack, $retval, $comm\n" +"\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string,\n" + "\t b<bit-width>@<bit-offset>/<container-size>\n" +#endif " events/\t\t- Directory containing all trace event subsystems:\n" " enable\t\t- Write 0/1 to enable/disable tracing of all events\n" " events/<system>/\t- Directory containing all trace events for <system>:\n"
Masami Hiramatsu
maintainerPATCH 3/6 perf probe: Add supported type casting of running kernel
In reply to Masami HiramatsuAdd a checking routine what types are supported by the running kernel by finding the pattern in <debugfs>/tracing/README.
--- tools/perf/util/probe-file.c | 57 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/probe-file.h | 10 +++++++ tools/perf/util/probe-finder.c | 1 + 3 files changed, 68 insertions(+)
tools/perf/util/probe-file.c +57 -0
@@ -855,3 +855,60 @@ int probe_cache__show_all_caches(struct strfilter *filter)return 0 ; } + +static struct { +const char *pattern; +bool avail; +bool checked; +} probe_type_table[] = { +#define DEFINE_TYPE(idx, pat, def_avail) \ + [idx] = {.pattern = pat, .avail = (def_avail)} +DEFINE_TYPE (PROBE_TYPE_U ,"* u8/16/32/64,*" , true), +DEFINE_TYPE (PROBE_TYPE_S ,"* s8/16/32/64,*" , true), +DEFINE_TYPE (PROBE_TYPE_X ,"* x8/16/32/64,*" , false), +DEFINE_TYPE (PROBE_TYPE_STRING ,"* string,*" , true), +DEFINE_TYPE (PROBE_TYPE_BITFIELD , +"* b<bit-width>@<bit-offset>/<container-size>" , true), +}; + +bool probe_type_is_available (enum probe_type type) +{ +FILE *fp; +char *buf =NULL ; +size_t len =0 ; +bool target_line = false; +bool ret = probe_type_table[type].avail; + +if (type <0 || type >=PROBE_TYPE_END ) +return false; +/* We don't have to check the type which supported by default */ +if (ret || probe_type_table[type].checked) +return ret; + +if (asprintf (&buf,"%s/README" , tracing_path) <0 ) +return ret; + + fp =fopen (buf,"r" ); +if (!fp) + goto end; + +zfree (&buf); +while (getline (&buf, &len, fp) >0 && !ret) { +if (!target_line) { + target_line = !!strstr (buf," type: " ); +if (!target_line) +continue ; + }else if (strstr (buf,"\t " ) != buf) +break ; + ret =strglobmatch (buf, probe_type_table[type].pattern); + } +/* Cache the result */ + probe_type_table[type].checked = true; + probe_type_table[type].avail = ret; + +fclose (fp); +end: +free (buf); + +return ret; +}
tools/perf/util/probe-file.h +10 -0
@@ -19,6 +19,15 @@ struct probe_cache {struct list_head entries; }; +enum probe_type { +PROBE_TYPE_U =0 , +PROBE_TYPE_S , +PROBE_TYPE_X , +PROBE_TYPE_STRING , +PROBE_TYPE_BITFIELD , +PROBE_TYPE_END , +}; +#define PF_FL_UPROBE 1#define PF_FL_RW 2#define for_each_probe_cache_entry (entry, pcache) \
@@ -54,6 +63,7 @@ struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,struct probe_cache_entry *probe_cache__find_by_name (struct probe_cache *pcache,const char *group,const char *event);int probe_cache__show_all_caches (struct strfilter *filter); +bool probe_type_is_available (enum probe_type type);#else /* ! HAVE_LIBELF_SUPPORT */ static inline struct probe_cache *probe_cache__new (const char *tgt__maybe_unused ) {
tools/perf/util/probe-finder.c +1 -0
@@ -39,6 +39,7 @@#include "util.h" #include "symbol.h" #include "probe-finder.h" +#include "probe-file.h" /* Kprobe tracer basic type is up to u64 */ #define MAX_BASIC_TYPE_BITS 64
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 3/6] perf probe: Add supported type casting of running kernel
Em Thu, Aug 18, 2016 at 05:58:31PM +0900, Masami Hiramatsu escreveu:
Quoted 3 lines
Add a checking routine what types are supported by the running kernel by finding the pattern in <debugfs>/tracing/README.
Fails in several distros, I'm fixing it:
# time dm 1 67.863552726 alpine:3.4: Ok 2 26.710853767 android-ndk:r12b-arm: Ok 3 72.985361634 archlinux:latest: Ok 4 19.637909096 centos:5: FAIL CC /tmp/build/perf/util/probe-event.o cc1: warnings being treated as errors util/probe-file.c: In function 'probe_type_is_available': util/probe-file.c:904: warning: comparison of unsigned expression < 0 is always false mv: cannot stat `/tmp/build/perf/util/.probe-file.o.tmp': No such file or directory make[3]: *** [/tmp/build/perf/util/probe-file.o] Error 1 make[3]: *** Waiting for unfinished jobs.... 5 28.720326873 centos:6: FAIL cc1: warnings being treated as errors util/probe-file.c: In function 'probe_type_is_available': util/probe-file.c:904: error: comparison of unsigned expression < 0 is always false mv: cannot stat `/tmp/build/perf/util/.probe-file.o.tmp': No such file or directory make[3]: *** [/tmp/build/perf/util/probe-file.o] Error 1 make[3]: *** Waiting for unfinished jobs.... 6 70.156507794 centos:7: Ok 7 32.013330592 debian:7: FAIL CC /tmp/build/perf/util/probe-file.o util/probe-file.c: In function 'probe_type_is_available': util/probe-file.c:904:2: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits] cc1: all warnings being treated as errors mv: cannot stat `/tmp/build/perf/util/.probe-file.o.tmp': No such file or directory make[3]: *** [/tmp/build/perf/util/probe-file.o] Error 1 make[3]: *** Waiting for unfinished jobs.... 8 69.603178590 debian:8: Ok 9 73.783068558 debian:experimental: Ok 10 69.957097133 fedora:20: Ok 11 76.603382387 fedora:21: Ok 12 73.468157842 fedora:22: Ok 13 71.936508182 fedora:23: Ok 14 77.361195679 fedora:24: Ok 15 38.279025856 fedora:24-x-ARC-uClibc: Ok 16 97.249261355 fedora:rawhide: Ok 17 98.245080998 mageia:5: Ok 18 94.932568645 opensuse:13.2: Ok 19 75.037585460 opensuse:42.1: Ok 20 78.874088196 opensuse:tumbleweed: Ok 21 29.516286324 ubuntu:12.04.5: FAIL CC /tmp/build/perf/util/probe-event.o util/probe-file.c: In function 'probe_type_is_available': util/probe-file.c:904:2: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits] cc1: all warnings being treated as errors mv: cannot stat `/tmp/build/perf/util/.probe-file.o.tmp': No such file or directory make[3]: *** [/tmp/build/perf/util/probe-file.o] Error 1 make[3]: *** Waiting for unfinished jobs.... 22 67.473466290 ubuntu:14.04.4: Ok 23 70.052930002 ubuntu:15.10: Ok 24 73.910662998 ubuntu:16.04: Ok 25 58.592432948 ubuntu:16.04-x-arm: Ok 26 53.732729132 ubuntu:16.04-x-arm64: Ok 27 53.279460667 ubuntu:16.04-x-powerpc64: Ok 28 53.933970903 ubuntu:16.04-x-powerpc64el: Ok 29 73.724853906 ubuntu:16.10: Ok 30 55.651095622 ubuntu:16.10-x-s390: Ok
Quoted 112 lines
Signed-off-by Masami Hiramatsu <[email protected]>--- tools/perf/util/probe-file.c | 57 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/probe-file.h | 10 +++++++ tools/perf/util/probe-finder.c | 1 + 3 files changed, 68 insertions(+)tools/perf/util/probe-file.c +57
-0@@ -855,3 +855,60 @@ int probe_cache__show_all_caches(struct strfilter *filter)return 0 ; } + +static struct { +const char *pattern; +bool avail; +bool checked; +} probe_type_table[] = { +#define DEFINE_TYPE(idx, pat, def_avail) \ + [idx] = {.pattern = pat, .avail = (def_avail)} +DEFINE_TYPE (PROBE_TYPE_U ,"* u8/16/32/64,*" , true), +DEFINE_TYPE (PROBE_TYPE_S ,"* s8/16/32/64,*" , true), +DEFINE_TYPE (PROBE_TYPE_X ,"* x8/16/32/64,*" , false), +DEFINE_TYPE (PROBE_TYPE_STRING ,"* string,*" , true), +DEFINE_TYPE (PROBE_TYPE_BITFIELD , +"* b<bit-width>@<bit-offset>/<container-size>" , true), +}; + +bool probe_type_is_available (enum probe_type type) +{ +FILE *fp; +char *buf =NULL ; +size_t len =0 ; +bool target_line = false; +bool ret = probe_type_table[type].avail; + +if (type <0 || type >=PROBE_TYPE_END ) +return false; +/* We don't have to check the type which supported by default */ +if (ret || probe_type_table[type].checked) +return ret; + +if (asprintf (&buf,"%s/README" , tracing_path) <0 ) +return ret; + + fp =fopen (buf,"r" ); +if (!fp) + goto end; + +zfree (&buf); +while (getline (&buf, &len, fp) >0 && !ret) { +if (!target_line) { + target_line = !!strstr (buf," type: " ); +if (!target_line) +continue ; + }else if (strstr (buf,"\t " ) != buf) +break ; + ret =strglobmatch (buf, probe_type_table[type].pattern); + } +/* Cache the result */ + probe_type_table[type].checked = true; + probe_type_table[type].avail = ret; + +fclose (fp); +end: +free (buf); + +return ret; +}tools/perf/util/probe-file.h +10
-0@@ -19,6 +19,15 @@ struct probe_cache {struct list_head entries; }; +enum probe_type { +PROBE_TYPE_U =0 , +PROBE_TYPE_S , +PROBE_TYPE_X , +PROBE_TYPE_STRING , +PROBE_TYPE_BITFIELD , +PROBE_TYPE_END , +}; +#define PF_FL_UPROBE 1#define PF_FL_RW 2#define for_each_probe_cache_entry (entry, pcache) \@@ -54,6 +63,7 @@ struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,struct probe_cache_entry *probe_cache__find_by_name (struct probe_cache *pcache,const char *group,const char *event);int probe_cache__show_all_caches (struct strfilter *filter); +bool probe_type_is_available (enum probe_type type);#else /* ! HAVE_LIBELF_SUPPORT */ static inline struct probe_cache *probe_cache__new (const char *tgt__maybe_unused ) {tools/perf/util/probe-finder.c +1
-0@@ -39,6 +39,7 @@#include "util.h" #include "symbol.h" #include "probe-finder.h" +#include "probe-file.h" /* Kprobe tracer basic type is up to u64 */ #define MAX_BASIC_TYPE_BITS 64
tip-bot for Masami Hiramatsu
merge bot[tip:perf/core] perf probe: Add supported for type casting by the running kernel
In reply to Masami Hiramatsuperf probe: Add supported for type casting by the running kernel
Commit-ID: 180b20616ce57e93eb692170c793be94c456b1e2 Gitweb: http://git.kernel.org/tip/180b20616ce57e93eb692170c793be94c456b1e2 Author: Masami Hiramatsu <[email protected]> AuthorDate: Thu, 18 Aug 2016 17:58:31 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 17:03:31 -0300
perf probe: Add supported for type casting by the running kernel
Add a checking routine what types are supported by the running kernel by finding the pattern in <debugfs>/tracing/README.
[ 'enum probe_type' has no negative entries, so ends up as 'unsigned', remove '< 0'
test to fix the build on at least centos:5, debian:7 & ubuntu:12.04.5 ]
--- tools/perf/util/probe-file.c | 57 ++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/probe-file.h | 10 ++++++++ tools/perf/util/probe-finder.c | 1 + 3 files changed, 68 insertions(+)
tools/perf/util/probe-file.c +57 -0
@@ -877,3 +877,60 @@ int probe_cache__show_all_caches(struct strfilter *filter)return 0 ; } + +static struct { +const char *pattern; +bool avail; +bool checked; +} probe_type_table[] = { +#define DEFINE_TYPE(idx, pat, def_avail) \ + [idx] = {.pattern = pat, .avail = (def_avail)} +DEFINE_TYPE (PROBE_TYPE_U ,"* u8/16/32/64,*" , true), +DEFINE_TYPE (PROBE_TYPE_S ,"* s8/16/32/64,*" , true), +DEFINE_TYPE (PROBE_TYPE_X ,"* x8/16/32/64,*" , false), +DEFINE_TYPE (PROBE_TYPE_STRING ,"* string,*" , true), +DEFINE_TYPE (PROBE_TYPE_BITFIELD , +"* b<bit-width>@<bit-offset>/<container-size>" , true), +}; + +bool probe_type_is_available (enum probe_type type) +{ +FILE *fp; +char *buf =NULL ; +size_t len =0 ; +bool target_line = false; +bool ret = probe_type_table[type].avail; + +if (type >=PROBE_TYPE_END ) +return false; +/* We don't have to check the type which supported by default */ +if (ret || probe_type_table[type].checked) +return ret; + +if (asprintf (&buf,"%s/README" , tracing_path) <0 ) +return ret; + + fp =fopen (buf,"r" ); +if (!fp) + goto end; + +zfree (&buf); +while (getline (&buf, &len, fp) >0 && !ret) { +if (!target_line) { + target_line = !!strstr (buf," type: " ); +if (!target_line) +continue ; + }else if (strstr (buf,"\t " ) != buf) +break ; + ret =strglobmatch (buf, probe_type_table[type].pattern); + } +/* Cache the result */ + probe_type_table[type].checked = true; + probe_type_table[type].avail = ret; + +fclose (fp); +end: +free (buf); + +return ret; +}
tools/perf/util/probe-file.h +10 -0
@@ -19,6 +19,15 @@ struct probe_cache {struct list_head entries; }; +enum probe_type { +PROBE_TYPE_U =0 , +PROBE_TYPE_S , +PROBE_TYPE_X , +PROBE_TYPE_STRING , +PROBE_TYPE_BITFIELD , +PROBE_TYPE_END , +}; +#define PF_FL_UPROBE 1#define PF_FL_RW 2#define for_each_probe_cache_entry (entry, pcache) \
@@ -54,6 +63,7 @@ struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,struct probe_cache_entry *probe_cache__find_by_name (struct probe_cache *pcache,const char *group,const char *event);int probe_cache__show_all_caches (struct strfilter *filter); +bool probe_type_is_available (enum probe_type type);#else /* ! HAVE_LIBELF_SUPPORT */ static inline struct probe_cache *probe_cache__new (const char *tgt__maybe_unused ) {
tools/perf/util/probe-finder.c +1 -0
@@ -39,6 +39,7 @@#include "util.h" #include "symbol.h" #include "probe-finder.h" +#include "probe-file.h" /* Kprobe tracer basic type is up to u64 */ #define MAX_BASIC_TYPE_BITS 64
Masami Hiramatsu
maintainerPATCH 4/6 perf probe: Support hexadecimal casting
In reply to Masami HiramatsuSupport hexadecimal unsigned integer casting by 'x'. This allows user to explicitly specify the output format of the probe arguments as hexadecimal.
--- tools/perf/Documentation/perf-probe.txt | 4 ++-- tools/perf/util/probe-finder.c | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-)
tools/perf/Documentation/perf-probe.txt +2 -2
@@ -176,13 +176,13 @@ Each probe argument follows below syntax. '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'.) '$vars' and '$params' special arguments are also available for NAME, '$vars' is expanded to the local variables (including function parameters) which can access at given probe point. '$params' is expanded to only the function parameters. -'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) +'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. TYPES ----- -Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. +Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. Moreover, you can use 'x' to explicitly specify to be shown in hexadecimal (the size is also auto-detected). String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. 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. Bitfield is another special type, which takes 3 parameters, bit-width, bit-offset, and container-size (usually 32). The syntax is;
tools/perf/util/probe-finder.c +10 -7
@@ -298,13 +298,13 @@ static int convert_variable_type(Dwarf_Die *vr_die,char sbuf[STRERR_BUFSIZE ];int bsize, boffs, total;int ret; -char sign; +char prefix;/* TODO: check all types */ -if (cast &&strcmp (cast,"string" ) !=0 && +if (cast &&strcmp (cast,"string" ) !=0 &&strcmp (cast,"x" ) !=0 &&strcmp (cast,"s" ) !=0 &&strcmp (cast,"u" ) !=0 ) {/* Non string type is OK */ -/* and respect signedness cast */ +/* and respect signedness/hexadecimal cast */ tvar->type =strdup (cast);return (tvar->type ==NULL ) ? -ENOMEM :0 ; }
@@ -366,11 +366,14 @@ static int convert_variable_type(Dwarf_Die *vr_die, }if (cast && (strcmp (cast,"u" ) ==0 )) - sign ='u' ; + prefix ='u' ;else if (cast && (strcmp (cast,"s" ) ==0 )) - sign ='s' ; + prefix ='s' ; +else if (cast && (strcmp (cast,"x" ) ==0 ) && +probe_type_is_available (PROBE_TYPE_X )) + prefix ='x' ;else - sign =die_is_signed_type (&type) ?'s' :'u' ; + prefix =die_is_signed_type (&type) ?'s' :'u' ; ret =dwarf_bytesize (&type);if (ret <=0 )
@@ -384,7 +387,7 @@ static int convert_variable_type(Dwarf_Die *vr_die, dwarf_diename(&type), MAX_BASIC_TYPE_BITS); ret =MAX_BASIC_TYPE_BITS ; } - ret =snprintf (buf,16 ,"%c%d" , sign, ret); + ret =snprintf (buf,16 ,"%c%d" , prefix, ret); formatted:if (ret <0 || ret >=16 ) {
tip-bot for Masami Hiramatsu
merge bot[tip:perf/core] perf probe: Support hexadecimal casting
perf probe: Support hexadecimal casting
Commit-ID: 925437872525ee229736a9a8bdf804fc98f75b44 Gitweb: http://git.kernel.org/tip/925437872525ee229736a9a8bdf804fc98f75b44 Author: Masami Hiramatsu <[email protected]> AuthorDate: Thu, 18 Aug 2016 17:58:47 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 17:06:37 -0300
perf probe: Support hexadecimal casting
Support hexadecimal unsigned integer casting by 'x'. This allows user to explicitly specify the output format of the probe arguments as hexadecimal.
--- tools/perf/Documentation/perf-probe.txt | 4 ++-- tools/perf/util/probe-finder.c | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-)
tools/perf/Documentation/perf-probe.txt +2 -2
@@ -176,13 +176,13 @@ Each probe argument follows below syntax. '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'.) '$vars' and '$params' special arguments are also available for NAME, '$vars' is expanded to the local variables (including function parameters) which can access at given probe point. '$params' is expanded to only the function parameters. -'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) +'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. TYPES ----- -Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. +Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. Moreover, you can use 'x' to explicitly specify to be shown in hexadecimal (the size is also auto-detected). String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. 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. Bitfield is another special type, which takes 3 parameters, bit-width, bit-offset, and container-size (usually 32). The syntax is;
tools/perf/util/probe-finder.c +10 -7
@@ -298,13 +298,13 @@ static int convert_variable_type(Dwarf_Die *vr_die,char sbuf[STRERR_BUFSIZE ];int bsize, boffs, total;int ret; -char sign; +char prefix;/* TODO: check all types */ -if (cast &&strcmp (cast,"string" ) !=0 && +if (cast &&strcmp (cast,"string" ) !=0 &&strcmp (cast,"x" ) !=0 &&strcmp (cast,"s" ) !=0 &&strcmp (cast,"u" ) !=0 ) {/* Non string type is OK */ -/* and respect signedness cast */ +/* and respect signedness/hexadecimal cast */ tvar->type =strdup (cast);return (tvar->type ==NULL ) ? -ENOMEM :0 ; }
@@ -366,11 +366,14 @@ static int convert_variable_type(Dwarf_Die *vr_die, }if (cast && (strcmp (cast,"u" ) ==0 )) - sign ='u' ; + prefix ='u' ;else if (cast && (strcmp (cast,"s" ) ==0 )) - sign ='s' ; + prefix ='s' ; +else if (cast && (strcmp (cast,"x" ) ==0 ) && +probe_type_is_available (PROBE_TYPE_X )) + prefix ='x' ;else - sign =die_is_signed_type (&type) ?'s' :'u' ; + prefix =die_is_signed_type (&type) ?'s' :'u' ; ret =dwarf_bytesize (&type);if (ret <=0 )
@@ -384,7 +387,7 @@ static int convert_variable_type(Dwarf_Die *vr_die, dwarf_diename(&type), MAX_BASIC_TYPE_BITS); ret =MAX_BASIC_TYPE_BITS ; } - ret =snprintf (buf,16 ,"%c%d" , sign, ret); + ret =snprintf (buf,16 ,"%c%d" , prefix, ret); formatted:if (ret <0 || ret >=16 ) {
Masami Hiramatsu
maintainerPATCH 5/6 perf-probe: Use hexadecimal type by default if possible
In reply to Masami HiramatsuUse hexadecimal type by default if it is available on current running kernel.
This keeps the default behavior of perf probe after changing the output format of 'u8/16/32/64' to unsigned decimal number.
--- tools/perf/util/probe-finder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/probe-finder.c +2 -1
@@ -373,7 +373,8 @@ static int convert_variable_type(Dwarf_Die *vr_die, probe_type_is_available(PROBE_TYPE_X)) prefix ='x' ; else - prefix =die_is_signed_type (&type) ?'s' :'u' ; + prefix =die_is_signed_type (&type) ?'s' : +probe_type_is_available (PROBE_TYPE_X ) ?'x' :'u' ; ret =dwarf_bytesize (&type);if (ret <=0 )
tip-bot for Masami Hiramatsu
merge bot[tip:perf/core] perf probe: Use hexadecimal type by default if possible
perf probe: Use hexadecimal type by default if possible
Commit-ID: 9880ce4a69ba5c66a5ffdd711fe446bd0226bd8c Gitweb: http://git.kernel.org/tip/9880ce4a69ba5c66a5ffdd711fe446bd0226bd8c Author: Masami Hiramatsu <[email protected]> AuthorDate: Thu, 18 Aug 2016 17:59:07 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 17:06:37 -0300
perf probe: Use hexadecimal type by default if possible
Use hexadecimal type by default if it is available on current running kernel.
This keeps the default behavior of perf probe after changing the output format of 'u8/16/32/64' to unsigned decimal number.
--- tools/perf/util/probe-finder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/probe-finder.c +2 -1
@@ -373,7 +373,8 @@ static int convert_variable_type(Dwarf_Die *vr_die, probe_type_is_available(PROBE_TYPE_X)) prefix ='x' ; else - prefix =die_is_signed_type (&type) ?'s' :'u' ; + prefix =die_is_signed_type (&type) ?'s' : +probe_type_is_available (PROBE_TYPE_X ) ?'x' :'u' ; ret =dwarf_bytesize (&type);if (ret <=0 )
Masami Hiramatsu
maintainerPATCH 6/6 ftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal
In reply to Masami HiramatsuChange kprobe/uprobe-tracer to show the arguments type-casted with u8/u16/u32/u64 in decimal digits instead of hexadecimal.
To minimize compatibility issue, the arguments without type casting are typed by x64 (or x32 for 32bit arch) by default.
Note: all arguments set by old perf probe without types are shown in decimal by default.
--- tools/perf/Documentation/perf-probe.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Documentation/trace/kprobetrace.txt +4 -1
@@ -54,7 +54,10 @@ Types ----- Several types are supported for fetch-args. Kprobe tracer will access memory by given type. Prefix 's' and 'u' means those types are signed and unsigned -respectively. Traced arguments are shown in decimal (signed) or hex (unsigned). +respectively. 'x' prefix implies it is unsigned. Traced arguments are shown +in decimal ('s' and 'u') or hexadecimal ('x'). Without type casting, 'x32' +or 'x64' is used depends on the architecture (e.g. x86-32 uses x32, and +x86-64 uses x64). String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out.
Documentation/trace/uprobetracer.txt +4 -1
@@ -50,7 +50,10 @@ Types ----- Several types are supported for fetch-args. Uprobe tracer will access memory by given type. Prefix 's' and 'u' means those types are signed and unsigned -respectively. Traced arguments are shown in decimal (signed) or hex (unsigned). +respectively. 'x' prefix implies it is unsigned. Traced arguments are shown +in decimal ('s' and 'u') or hexadecimal ('x'). Without type casting, 'x32' +or 'x64' is used depends on the architecture (e.g. x86-32 uses x32, and +x86-64 uses x64). String type is a special type, which fetches a "null-terminated" string from user space. Bitfield is another special type, which takes 3 parameters, bit-width, bit-
kernel/trace/trace_probe.c +4 -4
@@ -46,10 +46,10 @@ int PRINT_TYPE_FUNC_NAME(tname)(struct trace_seq *s, const char *name, \const char PRINT_TYPE_FMT_NAME (tname )[] = fmt; \NOKPROBE_SYMBOL (PRINT_TYPE_FUNC_NAME (tname)); -DEFINE_BASIC_PRINT_TYPE_FUNC(u8, u8, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, u16, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, u32, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u64, u64, "0x%Lx") +DEFINE_BASIC_PRINT_TYPE_FUNC(u8, u8, "%u") +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, u16, "%u") +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, u32, "%u") +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, u64, "%Lu") DEFINE_BASIC_PRINT_TYPE_FUNC(s8, s8, "%d") DEFINE_BASIC_PRINT_TYPE_FUNC(s16, s16, "%d")DEFINE_BASIC_PRINT_TYPE_FUNC (s32, s32,"%d" )
kernel/trace/trace_probe.h +1 -1
@@ -208,7 +208,7 @@ DEFINE_FETCH_##method(u32) \ DEFINE_FETCH_##method(u64)/* Default (unsigned long) fetch type */ -#define __DEFAULT_FETCH_TYPE (t) u##t +#define __DEFAULT_FETCH_TYPE (t) x##t#define _DEFAULT_FETCH_TYPE (t) __DEFAULT_FETCH_TYPE(t)#define DEFAULT_FETCH_TYPE _DEFAULT_FETCH_TYPE(BITS_PER_LONG)#define DEFAULT_FETCH_TYPE_STR __stringify(DEFAULT_FETCH_TYPE)
tools/perf/Documentation/perf-probe.txt +2 -3
@@ -176,13 +176,12 @@ Each probe argument follows below syntax. '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'.) '$vars' and '$params' special arguments are also available for NAME, '$vars' is expanded to the local variables (including function parameters) which can access at given probe point. '$params' is expanded to only the function parameters. -'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) - +'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo (*). Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. TYPES ----- -Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. Moreover, you can use 'x' to explicitly specify to be shown in hexadecimal (the size is also auto-detected). +Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (sNN/uNN) or hex (xNN). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. Moreover, you can use 'x' to explicitly specify to be shown in hexadecimal (the size is also auto-detected). String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. 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. Bitfield is another special type, which takes 3 parameters, bit-width, bit-offset, and container-size (usually 32). The syntax is;
Re: [PATCH 6/6] ftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal
Quoted 11 lines · On Thu, 18 Aug 2016 17:59:21 +0900 Masami Hiramatsu <[email protected]> wrote:
Change kprobe/uprobe-tracer to show the arguments type-casted with u8/u16/u32/u64 in decimal digits instead of hexadecimal.
To minimize compatibility issue, the arguments without type casting are typed by x64 (or x32 for 32bit arch) by default.
Note: all arguments set by old perf probe without types are shown in decimal by default.
Signed-off-by Masami Hiramatsu <[email protected]>---
-- Steve
tip-bot for Masami Hiramatsu
merge bot[tip:perf/core] ftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal
In reply to Masami Hiramatsuftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal
Commit-ID: bdca79c2bf40556b664c9b1c32aec103e9bdb4a9 Gitweb: http://git.kernel.org/tip/bdca79c2bf40556b664c9b1c32aec103e9bdb4a9 Author: Masami Hiramatsu <[email protected]> AuthorDate: Thu, 18 Aug 2016 17:59:21 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 17:06:38 -0300
ftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal
Change kprobe/uprobe-tracer to show the arguments type-casted with u8/u16/u32/u64 in decimal digits instead of hexadecimal.
To minimize compatibility issue, the arguments without type casting are typed by x64 (or x32 for 32bit arch) by default.
Note: all arguments set by old perf probe without types are shown in decimal by default.
--- Documentation/trace/kprobetrace.txt | 5 ++++- Documentation/trace/uprobetracer.txt | 5 ++++- kernel/trace/trace_probe.c | 8 ++++---- kernel/trace/trace_probe.h | 2 +- tools/perf/Documentation/perf-probe.txt | 5 ++--- 5 files changed, 15 insertions(+), 10 deletions(-)
Documentation/trace/kprobetrace.txt +4 -1
@@ -54,7 +54,10 @@ Types ----- Several types are supported for fetch-args. Kprobe tracer will access memory by given type. Prefix 's' and 'u' means those types are signed and unsigned -respectively. Traced arguments are shown in decimal (signed) or hex (unsigned). +respectively. 'x' prefix implies it is unsigned. Traced arguments are shown +in decimal ('s' and 'u') or hexadecimal ('x'). Without type casting, 'x32' +or 'x64' is used depends on the architecture (e.g. x86-32 uses x32, and +x86-64 uses x64). String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out.
Documentation/trace/uprobetracer.txt +4 -1
@@ -50,7 +50,10 @@ Types ----- Several types are supported for fetch-args. Uprobe tracer will access memory by given type. Prefix 's' and 'u' means those types are signed and unsigned -respectively. Traced arguments are shown in decimal (signed) or hex (unsigned). +respectively. 'x' prefix implies it is unsigned. Traced arguments are shown +in decimal ('s' and 'u') or hexadecimal ('x'). Without type casting, 'x32' +or 'x64' is used depends on the architecture (e.g. x86-32 uses x32, and +x86-64 uses x64). String type is a special type, which fetches a "null-terminated" string from user space. Bitfield is another special type, which takes 3 parameters, bit-width, bit-
kernel/trace/trace_probe.c +4 -4
@@ -46,10 +46,10 @@ int PRINT_TYPE_FUNC_NAME(tname)(struct trace_seq *s, const char *name, \const char PRINT_TYPE_FMT_NAME (tname )[] = fmt; \NOKPROBE_SYMBOL (PRINT_TYPE_FUNC_NAME (tname)); -DEFINE_BASIC_PRINT_TYPE_FUNC(u8, u8, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, u16, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, u32, "0x%x") -DEFINE_BASIC_PRINT_TYPE_FUNC(u64, u64, "0x%Lx") +DEFINE_BASIC_PRINT_TYPE_FUNC(u8, u8, "%u") +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, u16, "%u") +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, u32, "%u") +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, u64, "%Lu") DEFINE_BASIC_PRINT_TYPE_FUNC(s8, s8, "%d") DEFINE_BASIC_PRINT_TYPE_FUNC(s16, s16, "%d")DEFINE_BASIC_PRINT_TYPE_FUNC (s32, s32,"%d" )
kernel/trace/trace_probe.h +1 -1
@@ -208,7 +208,7 @@ DEFINE_FETCH_##method(u32) \ DEFINE_FETCH_##method(u64)/* Default (unsigned long) fetch type */ -#define __DEFAULT_FETCH_TYPE (t) u##t +#define __DEFAULT_FETCH_TYPE (t) x##t#define _DEFAULT_FETCH_TYPE (t) __DEFAULT_FETCH_TYPE(t)#define DEFAULT_FETCH_TYPE _DEFAULT_FETCH_TYPE(BITS_PER_LONG)#define DEFAULT_FETCH_TYPE_STR __stringify(DEFAULT_FETCH_TYPE)
tools/perf/Documentation/perf-probe.txt +2 -3
@@ -176,13 +176,12 @@ Each probe argument follows below syntax. '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'.) '$vars' and '$params' special arguments are also available for NAME, '$vars' is expanded to the local variables (including function parameters) which can access at given probe point. '$params' is expanded to only the function parameters. -'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) - +'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo (*). Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. TYPES ----- -Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. Moreover, you can use 'x' to explicitly specify to be shown in hexadecimal (the size is also auto-detected). +Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (sNN/uNN) or hex (xNN). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. Moreover, you can use 'x' to explicitly specify to be shown in hexadecimal (the size is also auto-detected). String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. 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. Bitfield is another special type, which takes 3 parameters, bit-width, bit-offset, and container-size (usually 32). The syntax is;
Arnaldo Carvalho de Melo
maintainerEm Thu, Aug 18, 2016 at 05:57:32PM +0900, Masami Hiramatsu escreveu:
Quoted 25 lines
Hi Arnaldo and Steven,
Here is an RFC series of hexadecimal type casting and changing default type casting of perf and ftrace.
I've introduced x8,x16,x32,x64 according to previous discussion on LKML.
https://lkml.org/lkml/2016/8/10/339This series includes not only adding hexadecimal types (x8,x16,x32,x64), but also checking it is supported by running kernel and keeping the backward compativility.
[1/6] Add hexadecimal type casting, but does not touch
existing types like 'u8'.
[2/6] Show the supported types on README of ftrace so
that user application (e.g. perf) can check that.
[3/6] Add a type availability check to perf-probe. [4/6] Add hexadecimal prefix support to perf-probe if
it is supported by the kernel.
[5/6] Change the perf-probe default type casting for
unsigned type to hexadecimal (for backward compatibility)
[6/6] Change ftrace's 'uNN' to show value in decimal
and use 'xNN' by default (for backward compatibility)
Quoted 3 lines
This way, we can also add "octal" type, pointer type, and "character" type etc. and perf can check whether the kernel supports it or not. :)
But this requires a kernel update... If we do it all in the tooling side, no kernel changes are required _and_ newer tools will work with older kernels, as this is just a formatting issue, the value is there and from its format one can infer its value, it is not even necessary to look at its "type".
I understand this is necessary for ftrace, because the pretty printer is in the kernel, but I don't see why we would prevent tooling from doing this pretty printing work and make it support any kernel.
I.e. no need at all for checking if the kernel supports anything, just pretty print it.
- Arnaldo
Masami Hiramatsu
maintainerQuoted 36 lines · On Thu, 18 Aug 2016 11:14:42 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Thu, Aug 18, 2016 at 05:57:32PM +0900, Masami Hiramatsu escreveu:
Quoted 25 lines
Hi Arnaldo and Steven,
Here is an RFC series of hexadecimal type casting and changing default type casting of perf and ftrace.
I've introduced x8,x16,x32,x64 according to previous discussion on LKML.
https://lkml.org/lkml/2016/8/10/339This series includes not only adding hexadecimal types (x8,x16,x32,x64), but also checking it is supported by running kernel and keeping the backward compativility.
[1/6] Add hexadecimal type casting, but does not touch
existing types like 'u8'.
[2/6] Show the supported types on README of ftrace so
that user application (e.g. perf) can check that.
[3/6] Add a type availability check to perf-probe. [4/6] Add hexadecimal prefix support to perf-probe if
it is supported by the kernel.
[5/6] Change the perf-probe default type casting for
unsigned type to hexadecimal (for backward compatibility)
[6/6] Change ftrace's 'uNN' to show value in decimal
and use 'xNN' by default (for backward compatibility)Quoted 3 lines
This way, we can also add "octal" type, pointer type, and "character" type etc. and perf can check whether the kernel supports it or not. :)
But this requires a kernel update... If we do it all in the tooling side, no kernel changes are required _and_ newer tools will work with older kernels, as this is just a formatting issue, the value is there and from its format one can infer its value, it is not even necessary to look at its "type".
Quoted 6 lines
I understand this is necessary for ftrace, because the pretty printer is in the kernel, but I don't see why we would prevent tooling from doing this pretty printing work and make it support any kernel.
I.e. no need at all for checking if the kernel supports anything, just pretty print it.
That's should be handled by libtraceevent. And if you need just a pretty printing, you can do it in python/perl script via perf-script. Anyway, to see the event parameters via perf tools, we have to use perf-script with/without scripts. As you know, perf-script without scripts, the output format depends on libtraceevent. And it seems that the libtraceevent output depends on ftrace event "format" file.
And also as you can see in Naohiro's report ( https://lkml.org/lkml/2016/8/5/191 ) he was using perf-probe with ftrace trace_pipe interface, which was my expected usecase. In that case we have to change ftrace side to support various pretty printing.
IOW, perf only has very strong pretty printing interface - script based output - for trace event arguments. For lighter use cases, ftrace provide the print format.
So, I think this is a better meeting point, wouldn't you?
Thank you,
Signature · 1 line
Masami Hiramatsu <[email protected]>
Arnaldo Carvalho de Melo
maintainerEm Fri, Aug 19, 2016 at 01:01:43AM +0900, Masami Hiramatsu escreveu:
Quoted 53 lines
Quoted 36 lines · On Thu, 18 Aug 2016 11:14:42 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Thu, Aug 18, 2016 at 05:57:32PM +0900, Masami Hiramatsu escreveu:
Quoted 25 lines
Hi Arnaldo and Steven,
Here is an RFC series of hexadecimal type casting and changing default type casting of perf and ftrace.
I've introduced x8,x16,x32,x64 according to previous discussion on LKML.
https://lkml.org/lkml/2016/8/10/339This series includes not only adding hexadecimal types (x8,x16,x32,x64), but also checking it is supported by running kernel and keeping the backward compativility.
[1/6] Add hexadecimal type casting, but does not touch
existing types like 'u8'.
[2/6] Show the supported types on README of ftrace so
that user application (e.g. perf) can check that.
[3/6] Add a type availability check to perf-probe. [4/6] Add hexadecimal prefix support to perf-probe if
it is supported by the kernel.
[5/6] Change the perf-probe default type casting for
unsigned type to hexadecimal (for backward compatibility)
[6/6] Change ftrace's 'uNN' to show value in decimal
and use 'xNN' by default (for backward compatibility)Quoted 3 lines
This way, we can also add "octal" type, pointer type, and "character" type etc. and perf can check whether the kernel supports it or not. :)
But this requires a kernel update... If we do it all in the tooling side, no kernel changes are required _and_ newer tools will work with older kernels, as this is just a formatting issue, the value is there and from its format one can infer its value, it is not even necessary to look at its "type".
Quoted 6 lines
I understand this is necessary for ftrace, because the pretty printer is in the kernel, but I don't see why we would prevent tooling from doing this pretty printing work and make it support any kernel.
I.e. no need at all for checking if the kernel supports anything, just pretty print it.
That's should be handled by libtraceevent. And if you need just a pretty printing, you can do it in python/perl script via perf-script. Anyway, to see the event parameters via perf tools, we have to use perf-script with/without scripts. As you know, perf-script without scripts, the output format depends on libtraceevent. And it seems that the libtraceevent output depends on ftrace event "format" file.
Quoted 4 lines
And also as you can see in Naohiro's report ( https://lkml.org/lkml/2016/8/5/191 ) he was using perf-probe with ftrace
trace_pipeinterface, which was my expected usecase. In that case we have to change ftrace side to support various pretty printing.
Sure, if one wants to have pretty printing via trace_pipe, then a kernel reboot is needed, I'm talking about those who don't want to or can't reboot their machines :-)
But anyway, your patches allow seeing those events in decimal for people that can reboot their machine when that wasn't possible without extra scripting via perl/python, a clear advance!
It remains to be coded a way to achieve the same result without requiring a kernel reboot, i.e. a tooling only change.
Quoted 5 lines
IOW, perf only has very strong pretty printing interface - script based output - for trace event arguments. For lighter use cases, ftrace provide the print format.
So, I think this is a better meeting point, wouldn't you?
If upgrading the kernel is possible, yes.
- Arnaldo
Masami Hiramatsu
maintainerQuoted 63 lines · On Thu, 18 Aug 2016 13:13:21 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Fri, Aug 19, 2016 at 01:01:43AM +0900, Masami Hiramatsu escreveu:
Quoted 53 lines
Quoted 36 lines · On Thu, 18 Aug 2016 11:14:42 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Thu, Aug 18, 2016 at 05:57:32PM +0900, Masami Hiramatsu escreveu:
Quoted 25 lines
Hi Arnaldo and Steven,
Here is an RFC series of hexadecimal type casting and changing default type casting of perf and ftrace.
I've introduced x8,x16,x32,x64 according to previous discussion on LKML.
https://lkml.org/lkml/2016/8/10/339This series includes not only adding hexadecimal types (x8,x16,x32,x64), but also checking it is supported by running kernel and keeping the backward compativility.
[1/6] Add hexadecimal type casting, but does not touch
existing types like 'u8'.
[2/6] Show the supported types on README of ftrace so
that user application (e.g. perf) can check that.
[3/6] Add a type availability check to perf-probe. [4/6] Add hexadecimal prefix support to perf-probe if
it is supported by the kernel.
[5/6] Change the perf-probe default type casting for
unsigned type to hexadecimal (for backward compatibility)
[6/6] Change ftrace's 'uNN' to show value in decimal
and use 'xNN' by default (for backward compatibility)Quoted 3 lines
This way, we can also add "octal" type, pointer type, and "character" type etc. and perf can check whether the kernel supports it or not. :)
But this requires a kernel update... If we do it all in the tooling side, no kernel changes are required _and_ newer tools will work with older kernels, as this is just a formatting issue, the value is there and from its format one can infer its value, it is not even necessary to look at its "type".
Quoted 6 lines
I understand this is necessary for ftrace, because the pretty printer is in the kernel, but I don't see why we would prevent tooling from doing this pretty printing work and make it support any kernel.
I.e. no need at all for checking if the kernel supports anything, just pretty print it.
That's should be handled by libtraceevent. And if you need just a pretty printing, you can do it in python/perl script via perf-script. Anyway, to see the event parameters via perf tools, we have to use perf-script with/without scripts. As you know, perf-script without scripts, the output format depends on libtraceevent. And it seems that the libtraceevent output depends on ftrace event "format" file.
Quoted 4 lines
And also as you can see in Naohiro's report ( https://lkml.org/lkml/2016/8/5/191 ) he was using perf-probe with ftrace
trace_pipeinterface, which was my expected usecase. In that case we have to change ftrace side to support various pretty printing.Sure, if one wants to have pretty printing via
trace_pipe, then a kernel reboot is needed, I'm talking about those who don't want to or can't reboot their machines :-)
Quoted 6 lines
But anyway, your patches allow seeing those events in decimal for people that can reboot their machine when that wasn't possible without extra scripting via perl/python, a clear advance!
It remains to be coded a way to achieve the same result without requiring a kernel reboot, i.e. a tooling only change.
Hmm, one solution for user space tool is to identify the probed event from event name, and decide output format based on the format locally stored, like cached entries. Actually, current perf-probe to perf-script execution chain lacks such kind of information, that is a problem.
DWARF -> perf-probe -> ftrace -> perf-record -> perf-script
perf-probe can read DWARF(debuginfo) so it can handle a variety of types, but between perf-probe to ftrace, it lacks type information and all types falls into s8/16/32/64, u8/16/32/64, string and bitfield. So after that process, perf-record treats data as a raw binary, and perf-script tries to parse that binary based on ftrace's event format.
But if we can pass the data format in perf-cache entries like below
DWARF -> perf-probe -> ftrace -> perf-record -+-> perf-script
+-------> probe-cache entry --+
then perf-probe can pass correct format to perf-script.
But anyway, I will update ftrace to add other types since that will help ftrace users.
Thanks,
Signature · 1 line
Masami Hiramatsu <[email protected]>
Steven Rostedt
maintainerQuoted 2 lines · On Thu, 18 Aug 2016 17:57:32 +0900 Masami Hiramatsu <[email protected]> wrote:
Hi Arnaldo and Steven,
Arnaldo,
I acked all the patches with ftrace in the subject. You can take the series through your tree.
Thanks,
-- Steve
Arnaldo Carvalho de Melo
maintainerEm Thu, Aug 18, 2016 at 12:03:26PM -0400, Steven Rostedt escreveu:
Quoted 10 lines
Quoted 2 lines · On Thu, 18 Aug 2016 17:57:32 +0900 Masami Hiramatsu <[email protected]> wrote:
Hi Arnaldo and Steven,
Arnaldo,
I acked all the patches with ftrace in the subject. You can take the series through your tree.
Ok!
- Arnaldo