ftrace, perf: Adding support to use function trace
Subsystems (3)
Re: [PATCH 5/7] ftrace, perf: Add support to use function tracepoint in perf
In reply to Jiri OlsaQuoted 13 lines · Jiri Olsa
Adding perf registration support for the ftrace function event, so it is now possible to register it via perf interface.
The
perf_eventstruct statically containsftrace_opsas a handle for function tracer. The function tracer is registered/unregistered in open/close actions.To be efficient, we enable/disable
ftrace_opseach time the traced process is scheduled in/out (viaTRACE_REG_PERF_(ADD|DELL)handlers). This way tracing is enabled only when the process is running. Intentionally using this way instead of the event's hw statePERF_HES_STOPPED, which would not disable theftrace_ops.
Quoted 7 lines
It is now possible to use function trace within perf commands like:
perf record -e ftrace:function ls
perf stat -e ftrace:function lsAllowed only for root.
Good idea. We probably don't want to leak the rate of calls of a kernel function to userspace.
[...]
Quoted 73 lines
kernel/trace/trace_event_perf.c +73
-0+static void +perf_ftrace_function_call (unsigned long ip,unsigned long parent_ip) +{ +struct ftrace_entry *entry; +struct hlist_head *head; +struct pt_regs regs; +int rctx; + +#define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \ + sizeof(u64)) - sizeof(u32)) + +BUILD_BUG_ON (ENTRY_SIZE >PERF_MAX_TRACE_SIZE ); + +perf_fetch_caller_regs (®s); + + entry =perf_trace_buf_prepare (ENTRY_SIZE ,TRACE_FN ,NULL , &rctx); +if (!entry) +return ; + + entry->ip = ip; + entry->parent_ip = parent_ip; + + head =this_cpu_ptr (event_function.perf_events); +perf_trace_buf_submit (entry,ENTRY_SIZE , rctx,0 , +1 , ®s, head); + +#undef ENTRY_SIZE +} + +static int perf_ftrace_function_register (struct perf_event *event) +{ +struct ftrace_ops *ops = &event->ftrace_ops; + + ops->flags |=FTRACE_OPS_FL_CONTROL ; + ops->func = perf_ftrace_function_call; +return register_ftrace_function (ops); +} + +static int perf_ftrace_function_unregister (struct perf_event *event) +{ +struct ftrace_ops *ops = &event->ftrace_ops; +return unregister_ftrace_function (ops); +} + +static void perf_ftrace_function_enable (struct perf_event *event) +{ +ftrace_function_local_enable (&event->ftrace_ops); +} + +static void perf_ftrace_function_disable (struct perf_event *event) +{ +ftrace_function_local_disable (&event->ftrace_ops); +} + +int perf_ftrace_event_register (struct ftrace_event_call *call, +enum trace_reg type,void *data) +{ +int etype = call->event.type; + +if (etype !=TRACE_FN ) +return -EINVAL ; + +switch (type) { +case TRACE_REG_REGISTER : +case TRACE_REG_UNREGISTER : +break ; +case TRACE_REG_PERF_REGISTER : +case TRACE_REG_PERF_UNREGISTER : +return 0 ; +case TRACE_REG_PERF_OPEN : +return perf_ftrace_function_register (data); +case TRACE_REG_PERF_CLOSE : +return perf_ftrace_function_unregister (data);
kernel/trace/trace_event_perf.c __kprobes void *perf_trace_buf_prepare(int size, unsigned short type, · line 342
Quoted 10 lines
kernel/trace/trace_event_perf.c +10
-0+case TRACE_REG_PERF_ADD : +perf_ftrace_function_enable (data); +return 0 ; +case TRACE_REG_PERF_DEL : +perf_ftrace_function_disable (data); +return 0 ; + } + +return -EINVAL ; +}
All the above from perf_ftrace_function_call() to here should perhaps go to trace_function.c.
Quoted 19 lines
kernel/trace/trace_export.c +11
-0@@ -131,6 +131,28 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \#include "trace_entries.h" +static int ftrace_event_class_register (struct ftrace_event_call *call, +enum trace_reg type,void *data) +{ +switch (type) { +case TRACE_REG_PERF_REGISTER : +case TRACE_REG_PERF_UNREGISTER : +return 0 ; +case TRACE_REG_PERF_OPEN : +case TRACE_REG_PERF_CLOSE : +case TRACE_REG_PERF_ADD : +case TRACE_REG_PERF_DEL :
kernel/trace/trace_export.c ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ · line 154
Quoted 10 lines
kernel/trace/trace_export.c +10
-0+#ifdef CONFIG_PERF_EVENTS +return perf_ftrace_event_register (call, type, data); +#endif +case TRACE_REG_REGISTER : +case TRACE_REG_UNREGISTER : +break ; + } + +return -EINVAL ; +}
Hmm, one day we'll need to demux here. What about adding an argument to FTRACE_ENTRY() to add the pointer to .reg ?
Quoted 25 lines
kernel/trace/trace_export.c +7
-0+#undef __entry#define __entry REC@@ -159,6 +181,7 @@ struct ftrace_event_class event_class_ftrace_##call = { \ .system = __stringify(TRACE_SYSTEM), \ .define_fields = ftrace_define_fields_##call, \ .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\ + .reg = ftrace_event_class_register, \ }; \ \ struct ftrace_event_call __used event_##call = { \@@ -170,4 +193,9 @@ struct ftrace_event_call __used event_##call = { \ struct ftrace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call; +int ftrace_event_is_function (struct ftrace_event_call *call) +{ +return call == &event_function; +} +#include "trace_entries.h" Signature · 1 line
1.7.1
Re: [PATCH 5/7] ftrace, perf: Add support to use function tracepoint in perf
Quoted 9 lines · Frederic Weisbecker
Quoted 8 lines · Jiri Olsa
Adding perf registration support for the ftrace function event, so it is now possible to register it via perf interface.
The
perf_eventstruct statically containsftrace_opsas a handle for function tracer. The function tracer is registered/unregistered in open/close actions.To be efficient, we enable/disable
ftrace_opseach time the traced
SNIP
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ + return -EINVAL; +}All the above from
perf_ftrace_function_call()to here should perhaps go totrace_function.c.
hm, I'd call it rather trace_perf_function.c
Quoted 25 lines
Quoted 25 lines
kernel/trace/trace_export.c +16
-0@@ -131,6 +131,28 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \#include "trace_entries.h" +static int ftrace_event_class_register (struct ftrace_event_call *call, +enum trace_reg type,void *data) +{ +switch (type) { +case TRACE_REG_PERF_REGISTER : +case TRACE_REG_PERF_UNREGISTER : +return 0 ; +case TRACE_REG_PERF_OPEN : +case TRACE_REG_PERF_CLOSE : +case TRACE_REG_PERF_ADD : +case TRACE_REG_PERF_DEL : +#ifdef CONFIG_PERF_EVENTS +return perf_ftrace_event_register (call, type, data); +#endif +case TRACE_REG_REGISTER : +case TRACE_REG_UNREGISTER :
Quoted 8 lines
kernel/trace/trace_export.c ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ · line 154
Quoted 5 lines
kernel/trace/trace_export.c +5
-0+break ; + } + +return -EINVAL ; +}Hmm, one day we'll need to demux here. What about adding an argument to
FTRACE_ENTRY()to add the pointer to .reg ?
ok, would something like the attached change be ok?
thanks,
jirka
---
kernel/trace/trace.h +4 -0
@@ -68,6 +68,10 @@ enum trace_type {#undef FTRACE_ENTRY_DUP#define FTRACE_ENTRY_DUP (name, name_struct, id, tstruct, printk) +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, regfn) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) +#include "trace_entries.h" /*
kernel/trace/trace_export.c +16 -2
@@ -18,6 +18,14 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM ftrace +/* +* The FTRACE_ENTRY_REG macro allows ftrace entry to define register +* function and thus become accesible via perf. +*/ +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, regfn) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) +/* not needed for this file */ #undef __field_struct#define __field_struct (type, item)
@@ -152,13 +160,14 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \#undef F_printk #define F_printk(fmt, args...) #fmt ", " __stringify(args) -#undef FTRACE_ENTRY -#define FTRACE_ENTRY (call, struct_name, etype, tstruct, print) \ +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (call, struct_name, etype, tstruct, print, regfn)\ \ struct ftrace_event_class event_class_ftrace_##call = { \ .system = __stringify(TRACE_SYSTEM), \ .define_fields = ftrace_define_fields_##call, \ .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\ + .reg = regfn, \ }; \ \ struct ftrace_event_call __used event_##call = { \
@@ -170,4 +179,9 @@ struct ftrace_event_call __used event_##call = { \ struct ftrace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call; +#undef FTRACE_ENTRY +#define FTRACE_ENTRY (call, struct_name, etype, tstruct, print) \ + FTRACE_ENTRY_REG(call, struct_name, etype, \ + PARAMS(tstruct), PARAMS(print), NULL) +#include "trace_entries.h"
Re: [PATCH 5/7] ftrace, perf: Add support to use function tracepoint in perf
Quoted 56 lines · Jiri Olsa
Quoted 9 lines · Frederic Weisbecker
Quoted 8 lines · Jiri Olsa
Adding perf registration support for the ftrace function event, so it is now possible to register it via perf interface.
The
perf_eventstruct statically containsftrace_opsas a handle for function tracer. The function tracer is registered/unregistered in open/close actions.To be efficient, we enable/disable
ftrace_opseach time the tracedSNIP
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ + return -EINVAL; +}All the above from
perf_ftrace_function_call()to here should perhaps go totrace_function.c.hm, I'd call it rather
trace_perf_function.cQuoted 25 lines
Quoted 25 lines
kernel/trace/trace_export.c +16
-0@@ -131,6 +131,28 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \#include "trace_entries.h" +static int ftrace_event_class_register (struct ftrace_event_call *call, +enum trace_reg type,void *data) +{ +switch (type) { +case TRACE_REG_PERF_REGISTER : +case TRACE_REG_PERF_UNREGISTER : +return 0 ; +case TRACE_REG_PERF_OPEN : +case TRACE_REG_PERF_CLOSE : +case TRACE_REG_PERF_ADD : +case TRACE_REG_PERF_DEL : +#ifdef CONFIG_PERF_EVENTS +return perf_ftrace_event_register (call, type, data); +#endif +case TRACE_REG_REGISTER : +case TRACE_REG_UNREGISTER :Quoted 8 lines
kernel/trace/trace_export.c ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ · line 154
Quoted 5 lines
kernel/trace/trace_export.c +5
-0+break ; + } + +return -EINVAL ; +}Hmm, one day we'll need to demux here. What about adding an argument to
FTRACE_ENTRY()to add the pointer to .reg ?
Quoted 4 lines
ok, would something like the attached change be ok?
thanks,
jirka
and use FTRACE_ENTRY_REG for ftrace event like:
FTRACE_ENTRY_REG(function, ftrace_entry,
TRACE_FN,
F_STRUCT(
__field( unsigned long, ip )
__field( unsigned long, parent_ip )
),
F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip),
perf_ftrace_event_register);
jirka
Quoted 64 lines
---
kernel/trace/trace.h +4
-0@@ -68,6 +68,10 @@ enum trace_type {#undef FTRACE_ENTRY_DUP#define FTRACE_ENTRY_DUP (name, name_struct, id, tstruct, printk) +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, regfn) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) +#include "trace_entries.h" /* kernel/trace/trace_export.c +16
-2@@ -18,6 +18,14 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM ftrace +/* +* The FTRACE_ENTRY_REG macro allows ftrace entry to define register +* function and thus become accesible via perf. +*/ +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, regfn) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) +/* not needed for this file */ #undef __field_struct#define __field_struct (type, item)@@ -152,13 +160,14 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \#undef F_printk #define F_printk(fmt, args...) #fmt ", " __stringify(args) -#undef FTRACE_ENTRY -#define FTRACE_ENTRY (call, struct_name, etype, tstruct, print) \ +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (call, struct_name, etype, tstruct, print, regfn)\ \ struct ftrace_event_class event_class_ftrace_##call = { \ .system = __stringify(TRACE_SYSTEM), \ .define_fields = ftrace_define_fields_##call, \ .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\ + .reg = regfn, \ }; \ \ struct ftrace_event_call __used event_##call = { \@@ -170,4 +179,9 @@ struct ftrace_event_call __used event_##call = { \ struct ftrace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call; +#undef FTRACE_ENTRY +#define FTRACE_ENTRY (call, struct_name, etype, tstruct, print) \ + FTRACE_ENTRY_REG(call, struct_name, etype, \ + PARAMS(tstruct), PARAMS(print), NULL) +#include "trace_entries.h"
Steven Rostedt
maintainerRe: [PATCH 5/7] ftrace, perf: Add support to use function tracepoint in perf
Quoted 11 lines · Jiri Olsa
and use
FTRACE_ENTRY_REGfor ftrace event like:FTRACE_ENTRY_REG(function,
ftrace_entry,TRACE_FN, F_STRUCT( __field( unsigned long, ip ) __field( unsigned long, parent_ip ) ), F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip), perf_ftrace_event_register);
This should be fine.
-- Steve
Re: [PATCH 5/7] ftrace, perf: Add support to use function tracepoint in perf
In reply to Jiri OlsaQuoted 13 lines · Jiri Olsa
Quoted 9 lines · Frederic Weisbecker
Quoted 8 lines · Jiri Olsa
Adding perf registration support for the ftrace function event, so it is now possible to register it via perf interface.
The
perf_eventstruct statically containsftrace_opsas a handle for function tracer. The function tracer is registered/unregistered in open/close actions.To be efficient, we enable/disable
ftrace_opseach time the tracedSNIP
Quoted 8 lines
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ + return -EINVAL; +}All the above from
perf_ftrace_function_call()to here should perhaps go totrace_function.c.hm, I'd call it rather
trace_perf_function.c
Yeah looks fine.
Quoted 94 lines
Quoted 26 lines
Quoted 26 lines
kernel/trace/trace_export.c +16
-0@@ -131,6 +131,28 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \#include "trace_entries.h" +static int ftrace_event_class_register (struct ftrace_event_call *call, +enum trace_reg type,void *data) +{ +switch (type) { +case TRACE_REG_PERF_REGISTER : +case TRACE_REG_PERF_UNREGISTER : +return 0 ; +case TRACE_REG_PERF_OPEN : +case TRACE_REG_PERF_CLOSE : +case TRACE_REG_PERF_ADD : +case TRACE_REG_PERF_DEL : +#ifdef CONFIG_PERF_EVENTS +return perf_ftrace_event_register (call, type, data); +#endif +case TRACE_REG_REGISTER : +case TRACE_REG_UNREGISTER :Quoted 8 lines
kernel/trace/trace_export.c ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ · line 154
Quoted 5 lines
kernel/trace/trace_export.c +5
-0+break ; + } + +return -EINVAL ; +}Hmm, one day we'll need to demux here. What about adding an argument to
FTRACE_ENTRY()to add the pointer to .reg ?ok, would something like the attached change be ok?
thanks,
jirka---
kernel/trace/trace.h +4
-0@@ -68,6 +68,10 @@ enum trace_type {#undef FTRACE_ENTRY_DUP#define FTRACE_ENTRY_DUP (name, name_struct, id, tstruct, printk) +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, regfn) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) +#include "trace_entries.h" /* kernel/trace/trace_export.c +11
-2@@ -18,6 +18,14 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM ftrace +/* +* The FTRACE_ENTRY_REG macro allows ftrace entry to define register +* function and thus become accesible via perf. +*/ +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, regfn) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) +/* not needed for this file */ #undef __field_struct#define __field_struct (type, item)@@ -152,13 +160,14 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \#undef F_printk #define F_printk(fmt, args...) #fmt ", " __stringify(args) -#undef FTRACE_ENTRY -#define FTRACE_ENTRY (call, struct_name, etype, tstruct, print) \ +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (call, struct_name, etype, tstruct, print, regfn)\ \ struct ftrace_event_class event_class_ftrace_##call = { \ .system = __stringify(TRACE_SYSTEM), \ .define_fields = ftrace_define_fields_##call, \ .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\ + .reg = regfn, \ }; \ \ struct ftrace_event_call __used event_##call = { \
kernel/trace/trace_export.c struct ftrace_event_call __used event_##call = { \ · line 187
Quoted 9 lines
kernel/trace/trace_export.c +5
-0@@ -170,4 +179,9 @@ struct ftrace_event_call __used event_##call = { \ struct ftrace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call; +#undef FTRACE_ENTRY +#define FTRACE_ENTRY (call, struct_name, etype, tstruct, print) \ + FTRACE_ENTRY_REG(call, struct_name, etype, \ + PARAMS(tstruct), PARAMS(print), NULL) +#include "trace_entries.h"
Yeah looks good. I wouldn't mind having only FTRACE_ENTRY() with one more parameter but I'm fine with the two macros as well.
Steven Rostedt
maintainerRe: [PATCH 5/7] ftrace, perf: Add support to use function tracepoint in perf
Quoted 5 lines · Frederic Weisbecker
struct
ftrace_event_call__usedevent_##call = { \Quoted 4 lines
kernel/trace/trace_export.c +0
-0@@ -170,4 +179,9 @@ struct ftrace_event_call __used event_##call = { \ struct ftrace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call;
Quoted 10 lines
kernel/trace/trace_export.c struct ftrace_event_call __used event_##call = { \ · line 187
Quoted 6 lines
kernel/trace/trace_export.c +5
-0+#undef FTRACE_ENTRY +#define FTRACE_ENTRY (call, struct_name, etype, tstruct, print) \ + FTRACE_ENTRY_REG(call, struct_name, etype, \ + PARAMS(tstruct), PARAMS(print), NULL) +#include "trace_entries.h" Yeah looks good. I wouldn't mind having only
FTRACE_ENTRY()with one more parameter but I'm fine with the two macros as well.
I prefer the two macros. It's cleaner.
-- Steve
Steven Rostedt
maintainerRe: [PATCH 5/7] ftrace, perf: Add support to use function tracepoint in perf
In reply to Frederic WeisbeckerQuoted 2 lines · Frederic Weisbecker
All the above from
perf_ftrace_function_call()to here should perhaps go totrace_function.c.
Please no. This is a perf specific call into the function tracer. Unless it is rewritten to be a completely generic function. As with the normal rational on "generic" vs "specific" in the kernel. When there's only one user, then keep it "specific". When we get two or more users, then it can be converted to be generic.
Please do not put this into trace_function.c, as the only user of it is here.
-- Steve
PATCH v5 6/7 ftrace, perf: Distinguish ftrace function event field type
In reply to Jiri OlsaAdding FILTER_TRACE_FN event field type for function tracepoint event, so it can be properly recognized within filtering code.
Currently all fields of ftrace subsystem events share the common field type FILTER_OTHER. Since the function trace fields need special care within the filtering code we need to recognize it properly, hence adding the FILTER_TRACE_FN event type.
--- include/linux/ftrace_event.h | 1 + kernel/trace/trace_events_filter.c | 7 ++++++- kernel/trace/trace_export.c | 25 ++++++++++++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-)
include/linux/ftrace_event.h +1 -0
@@ -245,6 +245,7 @@ enum {FILTER_STATIC_STRING ,FILTER_DYN_STRING ,FILTER_PTR_STRING , + FILTER_TRACE_FN, };#define EVENT_STORAGE_SIZE 128
kernel/trace/trace_events_filter.c +6 -1
@@ -900,6 +900,11 @@ int filter_assign_type(const char *type)return FILTER_OTHER ; } +static bool is_function_field (struct ftrace_event_field *field) +{ +return field->filter_type ==FILTER_TRACE_FN ; +} +static bool is_string_field (struct ftrace_event_field *field) { return field->filter_type == FILTER_DYN_STRING ||
@@ -987,7 +992,7 @@ static int init_pred(struct filter_parse_state *ps, fn = filter_pred_strloc; else fn = filter_pred_pchar; - }else { + }else if (!is_function_field (field)) {if (field->is_signed) ret =strict_strtoll (pred->regex.pattern,0 , &val);else
kernel/trace/trace_export.c +20 -5
@@ -67,7 +67,7 @@ static void __always_unused ____ftrace_check_##name(void) \ ret = trace_define_field(event_call, #type, #item, \ offsetof(typeof (field ), item), \sizeof (field.item), \ -is_signed_type (type),FILTER_OTHER ); \ +is_signed_type (type), filter_type); \if (ret) \return ret;
@@ -77,7 +77,7 @@ static void __always_unused ____ftrace_check_##name(void) \ offsetof(typeof (field ), \ container.item), \sizeof (field.container.item), \ - is_signed_type(type), FILTER_OTHER); \ + is_signed_type(type), filter_type); \if (ret) \return ret;
@@ -91,7 +91,7 @@ static void __always_unused ____ftrace_check_##name(void) \ ret = trace_define_field(event_call, event_storage, #item, \ offsetof(typeof (field ), item), \sizeof (field.item), \ -is_signed_type (type),FILTER_OTHER ); \ +is_signed_type (type), filter_type); \mutex_unlock (&event_storage_mutex); \if (ret) \return ret; \
@@ -104,7 +104,7 @@ static void __always_unused ____ftrace_check_##name(void) \ offsetof(typeof (field ), \ container.item), \sizeof (field.container.item), \ - is_signed_type(type), FILTER_OTHER); \ + is_signed_type(type), filter_type); \if (ret) \return ret;
@@ -112,10 +112,24 @@ static void __always_unused ____ftrace_check_##name(void) \#define __dynamic_array (type, item) \ ret = trace_define_field(event_call, #type, #item, \ offsetof(typeof(field), item), \ - 0, is_signed_type(type), FILTER_OTHER);\ + 0, is_signed_type(type), filter_type);\ if (ret) \ return ret; +#define FILTER_TYPE_TRACE_FN FILTER_TRACE_FN +#define FILTER_TYPE_TRACE_GRAPH_ENT FILTER_OTHER +#define FILTER_TYPE_TRACE_GRAPH_RET FILTER_OTHER +#define FILTER_TYPE_TRACE_CTX FILTER_OTHER +#define FILTER_TYPE_TRACE_WAKE FILTER_OTHER +#define FILTER_TYPE_TRACE_STACK FILTER_OTHER +#define FILTER_TYPE_TRACE_USER_STACK FILTER_OTHER +#define FILTER_TYPE_TRACE_BPRINT FILTER_OTHER +#define FILTER_TYPE_TRACE_PRINT FILTER_OTHER +#define FILTER_TYPE_TRACE_MMIO_RW FILTER_OTHER +#define FILTER_TYPE_TRACE_MMIO_MAP FILTER_OTHER +#define FILTER_TYPE_TRACE_BRANCH FILTER_OTHER +#define FILTER_TYPE (arg) FILTER_TYPE_##arg +#undef FTRACE_ENTRY#define FTRACE_ENTRY (name, struct_name, id, tstruct, print) \ int \
@@ -123,6 +137,7 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ { \struct struct_name field; \int ret; \ +int filter_type =FILTER_TYPE (id); \ \ tstruct; \ \
Signature · 1 line
1.7.1
Steven Rostedt
maintainerRe: [PATCH 6/7] ftrace, perf: Distinguish ftrace function event field type
Quoted 7 lines · Jiri Olsa
kernel/trace/trace_export.c +6
-0+#define FILTER_TYPE_TRACE_FN FILTER_TRACE_FN +#define FILTER_TYPE_TRACE_GRAPH_ENT FILTER_OTHER +#define FILTER_TYPE_TRACE_GRAPH_RET FILTER_OTHER +#define FILTER_TYPE_TRACE_CTX FILTER_OTHER +#define FILTER_TYPE_TRACE_WAKE FILTER_OTHER +#define FILTER_TYPE_TRACE_STACK FILTER_OTHER
kernel/trace/trace_export.c static void __always_unused ____ftrace_check_##name(void) \ · line 134
Quoted 10 lines
kernel/trace/trace_export.c +8
-0+#define FILTER_TYPE_TRACE_USER_STACK FILTER_OTHER +#define FILTER_TYPE_TRACE_BPRINT FILTER_OTHER +#define FILTER_TYPE_TRACE_PRINT FILTER_OTHER +#define FILTER_TYPE_TRACE_MMIO_RW FILTER_OTHER +#define FILTER_TYPE_TRACE_MMIO_MAP FILTER_OTHER +#define FILTER_TYPE_TRACE_BRANCH FILTER_OTHER +#define FILTER_TYPE (arg) FILTER_TYPE_##arg +#undef FTRACE_ENTRY#define FTRACE_ENTRY (name, struct_name, id, tstruct, print) \
If all FTRACE_ENTRY needs a filter defined (as you did with the #defines above), then we should just add a FILTER field to FTRACE_ENTRY(). The defines are just ugly, and will be a pain if we ever add or remove a type. If we remove a type, we'll probably forget to remove the define for it.
#define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter)
int filter_type = filter;
And then the trace entries can have the type of filter.
F_STRUCT( ... ), FILTER_OTHER
That would be much cleaner.
-- Steve
Quoted 9 lines
int \
kernel/trace/trace_export.c +1
-0@@ -123,6 +137,7 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ { \struct struct_name field; \int ret; \ +int filter_type =FILTER_TYPE (id); \ \ tstruct; \ \
PATCH v5 7/7 ftrace, perf: Add filter support for function trace event
In reply to Jiri OlsaAdding support to filter function trace event via perf interface. It is now possible to use filter interface in the perf tool like:
perf record -e ftrace:function --filter="(ip == mm_*)" ls
The filter syntax is restricted to the the 'ip' field only, and following operators are accepted '==' '!=' '||', ending up with the filter strings like:
ip == f1[, ]f2 ... || ip != f3[, ]f4 ...
with comma ',' or space ' ' as a function separator. If the space ' ' is used as a separator, the right side of the assignment needs to be enclosed in double quotes '"'.
The '==' operator adds trace filter with same effect as would be added via set_ftrace_filter file.
The '!=' operator adds trace filter with same effect as would be added via set_ftrace_notrace file.
The right side of the '!=', '==' operators is list of functions or regexp. to be added to filter separated by space.
The '||' operator is used for connecting multiple filter definitions together. It is possible to have more than one '==' and '!=' operators within one filter string.
--- include/linux/ftrace.h | 1 + kernel/trace/ftrace.c | 6 ++ kernel/trace/trace.h | 2 - kernel/trace/trace_event_perf.c | 4 +- kernel/trace/trace_events_filter.c | 169 +++++++++++++++++++++++++++++++++--- 5 files changed, 168 insertions(+), 14 deletions(-)
include/linux/ftrace.h +1 -0
@@ -249,6 +249,7 @@ int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf, int len, int reset);void ftrace_set_global_filter (unsigned char *buf,int len,int reset);void ftrace_set_global_notrace (unsigned char *buf,int len,int reset); +void ftrace_free_filter (struct ftrace_ops *ops);int register_ftrace_command (struct ftrace_func_command *cmd);int unregister_ftrace_command (struct ftrace_func_command *cmd);
kernel/trace/ftrace.c +6 -0
@@ -1186,6 +1186,12 @@ static void free_ftrace_hash_rcu(struct ftrace_hash *hash)call_rcu_sched (&hash->rcu, __free_ftrace_hash_rcu); } +void ftrace_free_filter (struct ftrace_ops *ops) +{ +free_ftrace_hash (ops->filter_hash); +free_ftrace_hash (ops->notrace_hash); +} +static struct ftrace_hash *alloc_ftrace_hash (int size_bits) {struct ftrace_hash *hash;
kernel/trace/trace.h +0 -2
@@ -770,9 +770,7 @@ struct filter_pred {u64 val;struct regex regex;unsigned short *ops; -#ifdef CONFIG_FTRACE_STARTUP_TEST struct ftrace_event_field *field; -#endif int offset;int not;int op;
kernel/trace/trace_event_perf.c +3 -1
@@ -298,7 +298,9 @@ static int perf_ftrace_function_register(struct perf_event *event)static int perf_ftrace_function_unregister (struct perf_event *event) {struct ftrace_ops *ops = &event->ftrace_ops; -return unregister_ftrace_function (ops); +int ret =unregister_ftrace_function (ops); +ftrace_free_filter (ops); +return ret; }static void perf_ftrace_function_enable (struct perf_event *event)
kernel/trace/trace_events_filter.c +158 -11
239 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [PATCH 7/7] ftrace, perf: Add filter support for function trace event
Quoted 30 lines · Jiri Olsa
Adding support to filter function trace event via perf interface. It is now possible to use filter interface in the perf tool like:
perf record -e ftrace:function --filter="(ip == mm_*)" lsThe filter syntax is restricted to the the 'ip' field only, and following operators are accepted '==' '!=' '||', ending up with the filter strings like:
ip == f1[, ]f2 ... || ip != f3[, ]f4 ...
with comma ',' or space ' ' as a function separator. If the space ' ' is used as a separator, the right side of the assignment needs to be enclosed in double quotes '"'.
The '==' operator adds trace filter with same effect as would be added via
set_ftrace_filterfile.The '!=' operator adds trace filter with same effect as would be added via
set_ftrace_notracefile.The right side of the '!=', '==' operators is list of functions or regexp. to be added to filter separated by space.
The '||' operator is used for connecting multiple filter definitions together. It is possible to have more than one '==' and '!=' operators within one filter string.
Signed-off-by Jiri Olsa <[email protected]>
SNIP
Quoted 6 lines
static void
perf_ftrace_function_enable(struct perf_event *event)kernel/trace/trace_events_filter.c +0
-0
kernel/trace/trace_events_filter.c struct filter_op { · line 62
Quoted 9 lines
kernel/trace/trace_events_filter.c +6
-0@@ -54,6 +54,13 @@ struct filter_op {int precedence; }; +static struct filter_op filter_ftrace_ops[] = { + {OP_OR ,"||" ,1 }, + {OP_NE ,"!=" ,2 }, + {OP_EQ ,"==" ,2 }, + {OP_NONE ,"OP_NONE" ,0 }, +};
ugh.. just found I cannot define filter_ftrace_ops like this, will send fix with new version.
thanks,
jirka
v8 cover ftrace, perf: Adding support to use function trace
In reply to Jiri Olsahi,
here's another version of perf support for function trace with filter.
attached patches:
- 1/8 ftrace: Change filter/notrace set functions to return exit code
- 2/8 ftrace: Add enable/disable ftrace_ops control interface
- 3/8 ftrace, perf: Add open/close tracepoint perf registration actions
- 4/8 ftrace, perf: Add add/del tracepoint perf registration actions
- 5/8 ftrace: Add FTRACE_ENTRY_REG macro to allow event registration
- 6/8 ftrace, perf: Add support to use function tracepoint in perf
- 7/8 ftrace: Allow to specify filter field type for ftrace events
- 8/8 ftrace, perf: Add filter support for function trace event
v8 changes:
1/8 - acked
2/8 - acked
3/8 - acked
4/8 - acked
5/8 - new patch - added FTRACE_ENTRY_REG macro 6/8 - using FTRACE_ENTRY_REG macro to define ftrace event 7/8 - adding filter parameter to FTRACE_ENTRY macro 8/8 - using only walk_pred_tree to check the filter
instead using different special filter_ops,
v7 changes:
2/7 - using int instead of atomic_t for ftrace_ops::disable
- using this_cpu_ptr to touch ftrace_ops::disable
- renamed ftrace_ops:disable API
void ftrace_function_local_enable(struct ftrace_ops *ops) void ftrace_function_local_disable(struct ftrace_ops *ops) int ftrace_function_local_disabled(struct ftrace_ops *ops)
v6 changes:
2/7 - added comments to FTRACE_OPS_FL_* bits enum
5/7 - added more info to the change log regarding ftrace_ops enable/disable 7/7 - rebased to the latest filter changes
v5 changes:
7/7 - fixed to properly support ',' in filter expressions
v4 changes:
2/7 - FL_GLOBAL_CONTROL changed to FL_GLOBAL_CONTROL_MASK
- changed WARN_ON_ONCE() to include the !preempt_count()
- changed this_cpu_ptr to per_cpu_ptr
ommited Fix possible NULL dereferencing in __ftrace_hash_rec_update (2/8 in v3)
v3 changes:
3/8 - renamed __add/remove_ftrace_ops
- fixed preemtp_enable/recursion_clear order in ftrace_ops_control_func
- renamed/commented API functions - enable/disable_ftrace_function
ommited graph tracer workarounf patch 10/10
v2 changes:
01/10 - keeping the old fix instead of adding hash_has_contents func
I'll send separating patchset for this
02/10 - using different way to avoid the issue (3/9 in v1) 03/10 - using the way proposed by Steven for controling ftrace_ops
(4/9 in v1)
06/10 - added check ensuring the ftrace:function event could be used by
root only (7/9 in v1) 08/10 - added more description (8/9 in v1)
09/10 - changed '&&' operator to '||' which seems more suitable
in this case (9/9 in v1)
thanks,
jirka
--- include/linux/ftrace.h | 71 ++++++++++++- include/linux/ftrace_event.h | 9 ++- include/linux/perf_event.h | 3 + kernel/trace/ftrace.c | 132 +++++++++++++++++++++--- kernel/trace/trace.h | 34 ++++-- kernel/trace/trace_entries.h | 54 +++++++--- kernel/trace/trace_event_perf.c | 206 ++++++++++++++++++++++++++++-------- kernel/trace/trace_events.c | 12 ++- kernel/trace/trace_events_filter.c | 160 +++++++++++++++++++++++++++- kernel/trace/trace_export.c | 64 ++++++++---- kernel/trace/trace_kprobe.c | 8 ++- kernel/trace/trace_syscalls.c | 18 +++- 12 files changed, 654 insertions(+), 117 deletions(-)
PATCH v3 1/8 ftrace: Change filter/notrace set functions to return exit code
Currently the ftrace_set_filter and ftrace_set_notrace functions do not return any return code. So there's no way for ftrace_ops user to tell wether the filter was correctly applied.
The set_ftrace_filter interface returns error in case the filter did not match:
# echo krava > set_ftrace_filter bash: echo: write error: Invalid argument
Changing both ftrace_set_filter and ftrace_set_notrace functions to return zero if the filter was applied correctly or -E* values in case of error.
--- include/linux/ftrace.h | 4 ++-- kernel/trace/ftrace.c | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-)
include/linux/ftrace.h +2 -2
@@ -178,9 +178,9 @@ struct dyn_ftrace { };int ftrace_force_update (void ); -void ftrace_set_filter (struct ftrace_ops *ops,unsigned char *buf, +int ftrace_set_filter (struct ftrace_ops *ops,unsigned char *buf,int len,int reset); -void ftrace_set_notrace (struct ftrace_ops *ops,unsigned char *buf, +int ftrace_set_notrace (struct ftrace_ops *ops,unsigned char *buf,int len,int reset);void ftrace_set_global_filter (unsigned char *buf,int len,int reset);void ftrace_set_global_notrace (unsigned char *buf,int len,int reset);
kernel/trace/ftrace.c +9 -6
@@ -3146,8 +3146,10 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len,mutex_lock (&ftrace_regex_lock);if (reset)ftrace_filter_reset (hash); -if (buf) -ftrace_match_records (hash, buf, len); +if (buf && !ftrace_match_records (hash, buf, len)) { + ret = -EINVAL ; + goto out_regex_unlock; + }mutex_lock (&ftrace_lock); ret =ftrace_hash_move (ops, enable, orig_hash, hash);
@@ -3157,6 +3159,7 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len,mutex_unlock (&ftrace_lock); + out_regex_unlock:mutex_unlock (&ftrace_regex_lock);free_ftrace_hash (hash);
@@ -3173,10 +3176,10 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len,* Filters denote which functions should be enabled when tracing is enabled. * If @buf is NULL and reset is set, all functions will be enabled for tracing. */ -void ftrace_set_filter (struct ftrace_ops *ops,unsigned char *buf, +int ftrace_set_filter (struct ftrace_ops *ops,unsigned char *buf,int len,int reset) { -ftrace_set_regex (ops, buf, len, reset,1 ); +return ftrace_set_regex (ops, buf, len, reset,1 ); }EXPORT_SYMBOL_GPL (ftrace_set_filter);
@@ -3191,10 +3194,10 @@ EXPORT_SYMBOL_GPL(ftrace_set_filter);* is enabled. If @buf is NULL and reset is set, all functions will be enabled * for tracing. */ -void ftrace_set_notrace (struct ftrace_ops *ops,unsigned char *buf, +int ftrace_set_notrace (struct ftrace_ops *ops,unsigned char *buf,int len,int reset) { -ftrace_set_regex (ops, buf, len, reset,0 ); +return ftrace_set_regex (ops, buf, len, reset,0 ); }EXPORT_SYMBOL_GPL (ftrace_set_notrace);/**
Signature · 1 line
1.7.1
PATCH v3 2/8 ftrace: Add enable/disable ftrace_ops control interface
In reply to Jiri OlsaAdding a way to temporarily enable/disable ftrace_ops. The change follows the same way as 'global' ftrace_ops are done.
Introducing 2 global ftrace_ops - control_ops and ftrace_control_list which take over all ftrace_ops registered with FTRACE_OPS_FL_CONTROL flag. In addition new per cpu flag called 'disabled' is also added to ftrace_ops to provide the control information for each cpu.
When ftrace_ops with FTRACE_OPS_FL_CONTROL is registered, it is set as disabled for all cpus.
The ftrace_control_list contains all the registered 'control' ftrace_ops. The control_ops provides function which iterates ftrace_control_list and does the check for 'disabled' flag on current cpu.
Adding 3 inline functions:
ftrace_function_local_disable/ftrace_function_local_enable
- enable/disable the ftrace_ops on current cpu ftrace_function_local_disabled
- get disabled ftrace_ops::disabled value for current cpu
--- include/linux/ftrace.h | 66 ++++++++++++++++++++++++++++ kernel/trace/ftrace.c | 111 +++++++++++++++++++++++++++++++++++++++++++++--- kernel/trace/trace.h | 2 + 3 files changed, 172 insertions(+), 7 deletions(-)
include/linux/ftrace.h +66 -0
@@ -31,16 +31,33 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,typedef void (*ftrace_func_t )(unsigned long ip,unsigned long parent_ip); +/* +* FTRACE_OPS_FL_* bits denote the state of ftrace_ops struct and are +* set in the flags member. +* +* ENABLED - set/unset when ftrace_ops is registered/unregistered +* GLOBAL - set manualy by ftrace_ops user to denote the ftrace_ops +* is part of the global tracers sharing the same filter +* via set_ftrace_* debugfs files. +* DYNAMIC - set when ftrace_ops is registered to denote dynamically +* allocated ftrace_ops which need special care +* CONTROL - set manualy by ftrace_ops user to denote the ftrace_ops +* could be controled by following calls: +* ftrace_function_local_enable +* ftrace_function_local_disable +*/ enum {FTRACE_OPS_FL_ENABLED =1 <<0 ,FTRACE_OPS_FL_GLOBAL =1 <<1 ,FTRACE_OPS_FL_DYNAMIC =1 <<2 , +FTRACE_OPS_FL_CONTROL =1 <<3 , };struct ftrace_ops {ftrace_func_t func;struct ftrace_ops *next;unsigned long flags; +int __percpu *disabled;#ifdef CONFIG_DYNAMIC_FTRACE struct ftrace_hash *notrace_hash;struct ftrace_hash *filter_hash;
@@ -97,6 +114,55 @@ int register_ftrace_function(struct ftrace_ops *ops);int unregister_ftrace_function (struct ftrace_ops *ops);void clear_ftrace_function (void ); +/** +* ftrace_function_local_enable - enable controlled ftrace_ops on current cpu +* +* This function enables tracing on current cpu by decreasing +* the per cpu control variable. +* It must be called with preemption disabled and only on ftrace_ops +* registered with FTRACE_OPS_FL_CONTROL. If called without preemption +* disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled. +*/ +static inline void ftrace_function_local_enable (struct ftrace_ops *ops) +{ +if (WARN_ON_ONCE (!(ops->flags &FTRACE_OPS_FL_CONTROL ))) +return ; + + (*this_cpu_ptr (ops->disabled))--; +} + +/** +* ftrace_function_local_disable - enable controlled ftrace_ops on current cpu +* +* This function enables tracing on current cpu by decreasing +* the per cpu control variable. +* It must be called with preemption disabled and only on ftrace_ops +* registered with FTRACE_OPS_FL_CONTROL. If called without preemption +* disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled. +*/ +static inline void ftrace_function_local_disable (struct ftrace_ops *ops) +{ +if (WARN_ON_ONCE (!(ops->flags &FTRACE_OPS_FL_CONTROL ))) +return ; + + (*this_cpu_ptr (ops->disabled))++; +} + +/** +* ftrace_function_local_disabled - returns ftrace_ops disabled value +* on current cpu +* +* This function returns value of ftrace_ops::disabled on current cpu. +* It must be called with preemption disabled and only on ftrace_ops +* registered with FTRACE_OPS_FL_CONTROL. If called without preemption +* disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled. +*/ +static inline int ftrace_function_local_disabled (struct ftrace_ops *ops) +{ +WARN_ON_ONCE (!(ops->flags &FTRACE_OPS_FL_CONTROL )); +return *this_cpu_ptr (ops->disabled); +} +extern void ftrace_stub (unsigned long a0,unsigned long a1);#else /* !CONFIG_FUNCTION_TRACER */
kernel/trace/ftrace.c +104 -7
166 lines not on this page · raw message
kernel/trace/trace.h +2 -0
@@ -288,6 +288,8 @@ struct tracer {/* for function tracing recursion */ #define TRACE_INTERNAL_BIT (1<<11)#define TRACE_GLOBAL_BIT (1<<12) +#define TRACE_CONTROL_BIT (1<<13) +/* * Abuse of the trace_recursion. * As we need a way to maintain state if we are tracing the function
Signature · 1 line
1.7.1
PATCH v3 3/8 ftrace, perf: Add open/close tracepoint perf registration actions
In reply to Jiri OlsaAdding TRACE_REG_PERF_OPEN and TRACE_REG_PERF_CLOSE to differentiate register/unregister from open/close actions.
The register/unregister actions are invoked for the first/last tracepoint user when opening/closing the event.
The open/close actions are invoked for each tracepoint user when opening/closing the event.
--- include/linux/ftrace_event.h | 6 +- kernel/trace/trace_event_perf.c | 116 +++++++++++++++++++++++++-------------- kernel/trace/trace_events.c | 10 ++- kernel/trace/trace_kprobe.c | 6 ++- kernel/trace/trace_syscalls.c | 14 +++- 5 files changed, 101 insertions(+), 51 deletions(-)
include/linux/ftrace_event.h +4 -2
@@ -146,6 +146,8 @@ enum trace_reg {TRACE_REG_UNREGISTER ,TRACE_REG_PERF_REGISTER ,TRACE_REG_PERF_UNREGISTER , +TRACE_REG_PERF_OPEN , + TRACE_REG_PERF_CLOSE, };struct ftrace_event_call ;
@@ -157,7 +159,7 @@ struct ftrace_event_class {void *perf_probe;#endif int (*reg)(struct ftrace_event_call *event, -enum trace_reg type); +enum trace_reg type,void *data);int (*define_fields)(struct ftrace_event_call *);struct list_head *(*get_fields)(struct ftrace_event_call *);struct list_head fields;
@@ -165,7 +167,7 @@ struct ftrace_event_class { };extern int ftrace_event_reg (struct ftrace_event_call *event, -enum trace_reg type); +enum trace_reg type,void *data);enum {TRACE_EVENT_FL_ENABLED_BIT ,
kernel/trace/trace_event_perf.c +75 -41
154 lines not on this page · raw message
kernel/trace/trace_events.c +7 -3
@@ -147,7 +147,8 @@ int trace_event_raw_init(struct ftrace_event_call *call) }EXPORT_SYMBOL_GPL (trace_event_raw_init); -int ftrace_event_reg (struct ftrace_event_call *call,enum trace_reg type) +int ftrace_event_reg (struct ftrace_event_call *call, +enum trace_reg type,void *data) {switch (type) {case TRACE_REG_REGISTER :
@@ -170,6 +171,9 @@ int ftrace_event_reg(struct ftrace_event_call *call, enum trace_reg type) call->class->perf_probe, call);return 0 ; +case TRACE_REG_PERF_OPEN : +case TRACE_REG_PERF_CLOSE : +return 0 ;#endif }return 0 ;
@@ -209,7 +213,7 @@ static int ftrace_event_enable_disable(struct ftrace_event_call *call,tracing_stop_cmdline_record (); call->flags &= ~TRACE_EVENT_FL_RECORDED_CMD ; } - call->class->reg (call,TRACE_REG_UNREGISTER ); + call->class->reg (call,TRACE_REG_UNREGISTER ,NULL ); }break ;case 1 :
@@ -218,7 +222,7 @@ static int ftrace_event_enable_disable(struct ftrace_event_call *call,tracing_start_cmdline_record (); call->flags |=TRACE_EVENT_FL_RECORDED_CMD ; } - ret = call->class->reg (call,TRACE_REG_REGISTER ); + ret = call->class->reg (call,TRACE_REG_REGISTER ,NULL );if (ret) {tracing_stop_cmdline_record (); pr_info("event trace: Could not enable event "
kernel/trace/trace_kprobe.c +5 -1
@@ -1892,7 +1892,8 @@ static __kprobes void kretprobe_perf_func(struct kretprobe_instance *ri,#endif /* CONFIG_PERF_EVENTS */ static __kprobes -int kprobe_register (struct ftrace_event_call *event,enum trace_reg type) +int kprobe_register (struct ftrace_event_call *event, +enum trace_reg type,void *data) {struct trace_probe *tp = (struct trace_probe *)event->data;
@@ -1909,6 +1910,9 @@ int kprobe_register(struct ftrace_event_call *event, enum trace_reg type)case TRACE_REG_PERF_UNREGISTER :disable_trace_probe (tp,TP_FLAG_PROFILE );return 0 ; +case TRACE_REG_PERF_OPEN : +case TRACE_REG_PERF_CLOSE : +return 0 ;#endif }return 0 ;
kernel/trace/trace_syscalls.c +10 -4
@@ -17,9 +17,9 @@ static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls); static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls);static int syscall_enter_register (struct ftrace_event_call *event, -enum trace_reg type); +enum trace_reg type,void *data);static int syscall_exit_register (struct ftrace_event_call *event, -enum trace_reg type); +enum trace_reg type,void *data);static int syscall_enter_define_fields (struct ftrace_event_call *call);static int syscall_exit_define_fields (struct ftrace_event_call *call);
@@ -649,7 +649,7 @@ void perf_sysexit_disable(struct ftrace_event_call *call)#endif /* CONFIG_PERF_EVENTS */ static int syscall_enter_register (struct ftrace_event_call *event, -enum trace_reg type) +enum trace_reg type,void *data) {switch (type) {case TRACE_REG_REGISTER :
@@ -664,13 +664,16 @@ static int syscall_enter_register(struct ftrace_event_call *event,case TRACE_REG_PERF_UNREGISTER :perf_sysenter_disable (event);return 0 ; +case TRACE_REG_PERF_OPEN : +case TRACE_REG_PERF_CLOSE : +return 0 ;#endif }return 0 ; }static int syscall_exit_register (struct ftrace_event_call *event, -enum trace_reg type) +enum trace_reg type,void *data) {switch (type) {case TRACE_REG_REGISTER :
@@ -685,6 +688,9 @@ static int syscall_exit_register(struct ftrace_event_call *event,case TRACE_REG_PERF_UNREGISTER :perf_sysexit_disable (event);return 0 ; +case TRACE_REG_PERF_OPEN : +case TRACE_REG_PERF_CLOSE : +return 0 ;#endif }return 0 ;
Signature · 1 line
1.7.1
PATCH v3 4/8 ftrace, perf: Add add/del tracepoint perf registration actions
In reply to Jiri OlsaAdding TRACE_REG_PERF_ADD and TRACE_REG_PERF_DEL to handle perf event schedule in/out actions.
The add action is invoked for when the perf event is scheduled in, while the del action is invoked when the event is scheduled out.
--- include/linux/ftrace_event.h | 2 ++ kernel/trace/trace_event_perf.c | 4 +++- kernel/trace/trace_events.c | 2 ++ kernel/trace/trace_kprobe.c | 2 ++ kernel/trace/trace_syscalls.c | 4 ++++ 5 files changed, 13 insertions(+), 1 deletions(-)
include/linux/ftrace_event.h +2 -0
@@ -148,6 +148,8 @@ enum trace_reg {TRACE_REG_PERF_UNREGISTER ,TRACE_REG_PERF_OPEN ,TRACE_REG_PERF_CLOSE , +TRACE_REG_PERF_ADD , + TRACE_REG_PERF_DEL, };struct ftrace_event_call ;
kernel/trace/trace_event_perf.c +3 -1
@@ -211,12 +211,14 @@ int perf_trace_add(struct perf_event *p_event, int flags) list =this_cpu_ptr (pcpu_list);hlist_add_head_rcu (&p_event->hlist_entry, list); -return 0 ; +return tp_event->class->reg (tp_event,TRACE_REG_PERF_ADD , p_event); }void perf_trace_del (struct perf_event *p_event,int flags) { +struct ftrace_event_call *tp_event = p_event->tp_event;hlist_del_rcu (&p_event->hlist_entry); + tp_event->class->reg (tp_event,TRACE_REG_PERF_DEL , p_event); } __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
kernel/trace/trace_events.c +2 -0
@@ -173,6 +173,8 @@ int ftrace_event_reg(struct ftrace_event_call *call,return 0 ;case TRACE_REG_PERF_OPEN :case TRACE_REG_PERF_CLOSE : +case TRACE_REG_PERF_ADD : +case TRACE_REG_PERF_DEL :return 0 ;#endif }
kernel/trace/trace_kprobe.c +2 -0
@@ -1912,6 +1912,8 @@ int kprobe_register(struct ftrace_event_call *event,return 0 ;case TRACE_REG_PERF_OPEN :case TRACE_REG_PERF_CLOSE : +case TRACE_REG_PERF_ADD : +case TRACE_REG_PERF_DEL :return 0 ;#endif }
kernel/trace/trace_syscalls.c +4 -0
@@ -666,6 +666,8 @@ static int syscall_enter_register(struct ftrace_event_call *event,return 0 ;case TRACE_REG_PERF_OPEN :case TRACE_REG_PERF_CLOSE : +case TRACE_REG_PERF_ADD : +case TRACE_REG_PERF_DEL :return 0 ;#endif }
@@ -690,6 +692,8 @@ static int syscall_exit_register(struct ftrace_event_call *event,return 0 ;case TRACE_REG_PERF_OPEN :case TRACE_REG_PERF_CLOSE : +case TRACE_REG_PERF_ADD : +case TRACE_REG_PERF_DEL :return 0 ;#endif }
Signature · 1 line
1.7.1
PATCH v3 5/8 ftrace: Add FTRACE_ENTRY_REG macro to allow event registration
In reply to Jiri OlsaAdding FTRACE_ENTRY_REG macro so particular ftrace entries could specify registration function and thus become accesible via perf.
This will be used in upcomming patch for function trace.
--- kernel/trace/trace.h | 4 ++++ kernel/trace/trace_export.c | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)
kernel/trace/trace.h +4 -0
@@ -68,6 +68,10 @@ enum trace_type {#undef FTRACE_ENTRY_DUP#define FTRACE_ENTRY_DUP (name, name_struct, id, tstruct, printk) +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, regfn) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) +#include "trace_entries.h" /*
kernel/trace/trace_export.c +16 -2
@@ -18,6 +18,14 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM ftrace +/* +* The FTRACE_ENTRY_REG macro allows ftrace entry to define register +* function and thus become accesible via perf. +*/ +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, regfn) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) +/* not needed for this file */ #undef __field_struct#define __field_struct (type, item)
@@ -152,13 +160,14 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \#undef F_printk #define F_printk(fmt, args...) #fmt ", " __stringify(args) -#undef FTRACE_ENTRY -#define FTRACE_ENTRY (call, struct_name, etype, tstruct, print) \ +#undef FTRACE_ENTRY_REG +#define FTRACE_ENTRY_REG (call, struct_name, etype, tstruct, print, regfn)\ \ struct ftrace_event_class event_class_ftrace_##call = { \ .system = __stringify(TRACE_SYSTEM), \ .define_fields = ftrace_define_fields_##call, \ .fields = LIST_HEAD_INIT(event_class_ftrace_##call.fields),\ + .reg = regfn, \ }; \ \ struct ftrace_event_call __used event_##call = { \
@@ -170,4 +179,9 @@ struct ftrace_event_call __used event_##call = { \ struct ftrace_event_call __used \ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call; +#undef FTRACE_ENTRY +#define FTRACE_ENTRY (call, struct_name, etype, tstruct, print) \ + FTRACE_ENTRY_REG(call, struct_name, etype, \ + PARAMS(tstruct), PARAMS(print), NULL) +#include "trace_entries.h"
Signature · 1 line
1.7.1
PATCH v3 6/8 ftrace, perf: Add support to use function tracepoint in perf
In reply to Jiri OlsaAdding perf registration support for the ftrace function event, so it is now possible to register it via perf interface.
The perf_event struct statically contains ftrace_ops as a handle for function tracer. The function tracer is registered/unregistered in open/close actions.
To be efficient, we enable/disable ftrace_ops each time the traced process is scheduled in/out (via TRACE_REG_PERF_(ADD|DELL) handlers). This way tracing is enabled only when the process is running. Intentionally using this way instead of the event's hw state PERF_HES_STOPPED, which would not disable the ftrace_ops.
It is now possible to use function trace within perf commands like:
perf record -e ftrace:function ls
perf stat -e ftrace:function ls
Allowed only for root.
--- include/linux/perf_event.h | 3 + kernel/trace/trace.h | 7 +++ kernel/trace/trace_entries.h | 6 ++- kernel/trace/trace_event_perf.c | 84 +++++++++++++++++++++++++++++++++++++++ kernel/trace/trace_export.c | 5 ++ 5 files changed, 103 insertions(+), 2 deletions(-)
include/linux/perf_event.h +3 -0
@@ -859,6 +859,9 @@ struct perf_event {#ifdef CONFIG_EVENT_TRACING struct ftrace_event_call *tp_event;struct event_filter *filter; +#ifdef CONFIG_FUNCTION_TRACER +struct ftrace_ops ftrace_ops; +#endif #endif #ifdef CONFIG_CGROUP_PERF
kernel/trace/trace.h +7 -0
@@ -595,6 +595,8 @@ static inline int ftrace_trace_task(struct task_struct *task)static inline int ftrace_is_dead (void ) {return 0 ; }#endif +int ftrace_event_is_function (struct ftrace_event_call *call); +/* * struct trace_parser - servers for reading the user input separated by spaces * @cont: set if the input is not complete - no final space char was found
@@ -832,4 +834,9 @@ extern const char *__stop___trace_bprintk_fmt[]; FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))#include "trace_entries.h" +#ifdef CONFIG_PERF_EVENTS +int perf_ftrace_event_register (struct ftrace_event_call *call, +enum trace_reg type,void *data); +#endif +#endif /* _LINUX_KERNEL_TRACE_H */
kernel/trace/trace_entries.h +4 -2
@@ -55,7 +55,7 @@/* * Function trace entry - function address and parent function address: */ -FTRACE_ENTRY(function, ftrace_entry, +FTRACE_ENTRY_REG(function, ftrace_entry, TRACE_FN,
@@ -64,7 +64,9 @@ FTRACE_ENTRY(function, ftrace_entry, __field( unsigned long, parent_ip ) ), - F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip) + F_printk(" %lx <-- %lx", __entry->ip, __entry->parent_ip), + +perf_ftrace_event_register );/* Function call entry */
kernel/trace/trace_event_perf.c +84 -0
93 lines not on this page · raw message
kernel/trace/trace_export.c +5 -0
@@ -184,4 +184,9 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call;FTRACE_ENTRY_REG (call, struct_name, etype, \ PARAMS(tstruct), PARAMS(print), NULL) +int ftrace_event_is_function (struct ftrace_event_call *call) +{ +return call == &event_function; +} +#include "trace_entries.h"
Signature · 1 line
1.7.1
PATCH v3 7/8 ftrace: Allow to specify filter field type for ftrace events
In reply to Jiri OlsaAdding FILTER_TRACE_FN event field type for function tracepoint event, so it can be properly recognized within filtering code.
Currently all fields of ftrace subsystem events share the common field type FILTER_OTHER. Since the function trace fields need special care within the filtering code we need to recognize it properly, hence adding the FILTER_TRACE_FN event type.
Adding filter parameter to the FTRACE_ENTRY macro, to specify the filter field type for the event.
--- include/linux/ftrace_event.h | 1 + kernel/trace/trace.h | 23 +++++++++------- kernel/trace/trace_entries.h | 48 ++++++++++++++++++++++++--------- kernel/trace/trace_events_filter.c | 7 ++++- kernel/trace/trace_export.c | 51 +++++++++++++++++++---------------- 5 files changed, 83 insertions(+), 47 deletions(-)
include/linux/ftrace_event.h +1 -0
@@ -245,6 +245,7 @@ enum {FILTER_STATIC_STRING ,FILTER_DYN_STRING ,FILTER_PTR_STRING , + FILTER_TRACE_FN, };#define EVENT_STORAGE_SIZE 128
kernel/trace/trace.h +13 -10
@@ -56,21 +56,23 @@ enum trace_type { #define F_STRUCT(args...) args#undef FTRACE_ENTRY -#define FTRACE_ENTRY (name, struct_name, id, tstruct, print) \ - struct struct_name { \ - struct trace_entry ent; \ - tstruct \ +#define FTRACE_ENTRY (name, struct_name, id, tstruct, print, filter) \ + struct struct_name { \ + struct trace_entry ent; \ + tstruct \ }#undef TP_ARGS #define TP_ARGS(args...) args#undef FTRACE_ENTRY_DUP -#define FTRACE_ENTRY_DUP (name, name_struct, id, tstruct, printk) +#define FTRACE_ENTRY_DUP (name, name_struct, id, tstruct, printk, filter)#undef FTRACE_ENTRY_REG -#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, regfn) \ - FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) +#define FTRACE_ENTRY_REG (name, struct_name, id, tstruct, print, \ + filter, regfn) \ + FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \ + filter)#include "trace_entries.h"
@@ -826,12 +828,13 @@ extern const char *__start___trace_bprintk_fmt[];extern const char *__stop___trace_bprintk_fmt[];#undef FTRACE_ENTRY -#define FTRACE_ENTRY (call, struct_name, id, tstruct, print) \ +#define FTRACE_ENTRY (call, struct_name, id, tstruct, print, filter) \ extern struct ftrace_event_call \ __attribute__((__aligned__(4))) event_##call;#undef FTRACE_ENTRY_DUP -#define FTRACE_ENTRY_DUP (call, struct_name, id, tstruct, print) \ - FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print)) +#define FTRACE_ENTRY_DUP (call, struct_name, id, tstruct, print, filter) \ + FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \ + filter)#include "trace_entries.h" #ifdef CONFIG_PERF_EVENTS
kernel/trace/trace_entries.h +35 -13
119 lines not on this page · raw message
kernel/trace/trace_events_filter.c +6 -1
@@ -900,6 +900,11 @@ int filter_assign_type(const char *type)return FILTER_OTHER ; } +static bool is_function_field (struct ftrace_event_field *field) +{ +return field->filter_type ==FILTER_TRACE_FN ; +} +static bool is_string_field (struct ftrace_event_field *field) { return field->filter_type == FILTER_DYN_STRING ||
@@ -987,7 +992,7 @@ static int init_pred(struct filter_parse_state *ps, fn = filter_pred_strloc; else fn = filter_pred_pchar; - }else { + }else if (!is_function_field (field)) {if (field->is_signed) ret =strict_strtoll (pred->regex.pattern,0 , &val);else
kernel/trace/trace_export.c +28 -23
118 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 8/8 ftrace, perf: Add filter support for function trace event
In reply to Jiri OlsaAdding support to filter function trace event via perf interface. It is now possible to use filter interface in the perf tool like:
perf record -e ftrace:function --filter="(ip == mm_*)" ls
The filter syntax is restricted to the the 'ip' field only, and following operators are accepted '==' '!=' '||', ending up with the filter strings like:
ip == f1[, ]f2 ... || ip != f3[, ]f4 ...
with comma ',' or space ' ' as a function separator. If the space ' ' is used as a separator, the right side of the assignment needs to be enclosed in double quotes '"', e.g.:
perf record -e ftrace:function --filter '(ip == do_execve,sys_*,ext*)' ls perf record -e ftrace:function --filter '(ip == "do_execve,sys_*,ext*")' ls perf record -e ftrace:function --filter '(ip == "do_execve sys_* ext*")' ls
The '==' operator adds trace filter with same effect as would be added via set_ftrace_filter file.
The '!=' operator adds trace filter with same effect as would be added via set_ftrace_notrace file.
The right side of the '!=', '==' operators is list of functions or regexp. to be added to filter separated by space.
The '||' operator is used for connecting multiple filter definitions together. It is possible to have more than one '==' and '!=' operators within one filter string.
--- include/linux/ftrace.h | 1 + kernel/trace/ftrace.c | 6 ++ kernel/trace/trace.h | 2 - kernel/trace/trace_event_perf.c | 4 +- kernel/trace/trace_events_filter.c | 157 ++++++++++++++++++++++++++++++++++-- 5 files changed, 161 insertions(+), 9 deletions(-)
include/linux/ftrace.h +1 -0
@@ -250,6 +250,7 @@ int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf, int len, int reset);void ftrace_set_global_filter (unsigned char *buf,int len,int reset);void ftrace_set_global_notrace (unsigned char *buf,int len,int reset); +void ftrace_free_filter (struct ftrace_ops *ops);int register_ftrace_command (struct ftrace_func_command *cmd);int unregister_ftrace_command (struct ftrace_func_command *cmd);
kernel/trace/ftrace.c +6 -0
@@ -1186,6 +1186,12 @@ static void free_ftrace_hash_rcu(struct ftrace_hash *hash)call_rcu_sched (&hash->rcu, __free_ftrace_hash_rcu); } +void ftrace_free_filter (struct ftrace_ops *ops) +{ +free_ftrace_hash (ops->filter_hash); +free_ftrace_hash (ops->notrace_hash); +} +static struct ftrace_hash *alloc_ftrace_hash (int size_bits) {struct ftrace_hash *hash;
kernel/trace/trace.h +0 -2
@@ -776,9 +776,7 @@ struct filter_pred {u64 val;struct regex regex;unsigned short *ops; -#ifdef CONFIG_FTRACE_STARTUP_TEST struct ftrace_event_field *field; -#endif int offset;int not;int op;
kernel/trace/trace_event_perf.c +3 -1
@@ -297,7 +297,9 @@ static int perf_ftrace_function_register(struct perf_event *event)static int perf_ftrace_function_unregister (struct perf_event *event) {struct ftrace_ops *ops = &event->ftrace_ops; -return unregister_ftrace_function (ops); +int ret =unregister_ftrace_function (ops); +ftrace_free_filter (ops); +return ret; }static void perf_ftrace_function_enable (struct perf_event *event)
kernel/trace/trace_events_filter.c +151 -6
195 lines not on this page · raw message
Signature · 1 line
1.7.1
Steven Rostedt
maintainerQuoted 3 lines · Jiri Olsa
hi,
here's another version of perf support for function trace with filter.
OK, I've applied all of these and I'm now going to run them through my test suite before sending them to Ingo. I'll let you know if anything goes wrong.
Also, in the future, PLEASE do not send a new version of the patches as a reply to a previous version. It's OK to do so for a single patch, if you only modified one patch of a series. But don't make a full series a reply of the last series. It just screws up my inbox.
Thanks!
-- Steve
Steven Rostedt
maintainerQuoted 8 lines · Steven Rostedt
Quoted 3 lines · Jiri Olsa
hi,
here's another version of perf support for function trace with filter.OK, I've applied all of these and I'm now going to run them through my test suite before sending them to Ingo. I'll let you know if anything goes wrong.
OK, I build booted and installed a kernel with your patches. I also installed the latest perf code from linus/master. Then I ran the following:
# perf record -e ftrace:function ls
and then ran
# perf report
It went into an infinite loop of "Processing time ordered events".
Is this expected?
Although perf script works fine.
-- Steve
Quoted 18 lines · Steven Rostedt
Quoted 8 lines · Steven Rostedt
Quoted 3 lines · Jiri Olsa
hi,
here's another version of perf support for function trace with filter.OK, I've applied all of these and I'm now going to run them through my test suite before sending them to Ingo. I'll let you know if anything goes wrong.
OK, I build booted and installed a kernel with your patches. I also installed the latest perf code from linus/master. Then I ran the following:
# perf record -e ftrace:function lsand then ran
Quoted 7 lines
# perf reportIt went into an infinite loop of "Processing time ordered events".
Is this expected?
Although perf script works fine.
yep, I was using perf script for testing
I get the same error for perf report, also if you run it like:
[root@dhcp-26-214 perf]# ./perf report --stdio
Warning:
Processed 82392 events and lost 1 chunks!
Check IO/CPU overload!
# ========
# captured on: Fri Feb 10 19:15:37 2012
# hostname : dhcp-26-214.brq.redhat.com
# os release : 3.3.0-rc3+
# perf version : 3.3.rc3.1274.g135d69
# arch : x86_64
# nrcpus online : 2
# nrcpus avail : 2
# cpudesc : Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz
# cpuid : GenuineIntel,6,23,10
# total memory : 1969896 kB
# cmdline : /home/jolsa/tip/tools/perf/perf record -e ftrace:function ls
# event : name = ftrace:function, type = 2, config = 0x1, config1 = 0x0,
# config2 = 0x0, excl_usr = 0, excl_kern = 0, id = { 3, 4 }
# HEADER_CPU_TOPOLOGY info available, use -I to display
# ========
#
Warning: Timestamp below last timeslice flush
# Events: 78K ftrace:function
#
# Overhead Command Shared Object Symbol
# ........ ....... ................. .......................
#
100.00% ls [kernel.kallsyms] [k] ftrace_ops_control_func#
# (For a higher level overview, try: perf report --sort comm,dso)
I'll check whats going on, thanks
jirka
Quoted 46 lines · Jiri Olsa
Quoted 18 lines · Steven Rostedt
Quoted 8 lines · Steven Rostedt
Quoted 3 lines · Jiri Olsa
hi,
here's another version of perf support for function trace with filter.OK, I've applied all of these and I'm now going to run them through my test suite before sending them to Ingo. I'll let you know if anything goes wrong.
OK, I build booted and installed a kernel with your patches. I also installed the latest perf code from linus/master. Then I ran the following:
# perf record -e ftrace:function lsand then ran
Quoted 7 lines
# perf reportIt went into an infinite loop of "Processing time ordered events".
Is this expected?
Although perf script works fine.
yep, I was using perf script for testing
I get the same error for perf report, also if you run it like:[root@dhcp-26-214 perf]# ./perf report --stdio
Warning:
Processed 82392 events and lost 1 chunks!Check IO/CPU overload!
# ========
# captured on: Fri Feb 10 19:15:37 2012 # hostname : dhcp-26-214.brq.redhat.com # os release : 3.3.0-rc3+ # perf version : 3.3.rc3.1274.g135d69 # arch : x86_64 # nrcpus online : 2 # nrcpus avail : 2 # cpudesc : Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz # cpuid : GenuineIntel,6,23,10
Quoted 8 lines
# total memory : 1969896 kB
# cmdline : /home/jolsa/tip/tools/perf/perf record -e ftrace:function ls
# event : name = ftrace:function, type = 2, config = 0x1, config1 = 0x0,
# config2 = 0x0, excl_usr = 0, excl_kern = 0, id = { 3, 4 }
# HEADER_CPU_TOPOLOGY info available, use -I to display
# ========
#
Warning: Timestamp below last timeslice flushStephane Eranian has reported a similar problem but perhaps not with the same cause.
I need to have a look.
Steven Rostedt
maintainerQuoted 4 lines · Frederic Weisbecker
Stephane Eranian has reported a similar problem but perhaps not with the same cause.
I need to have a look.
Not sure if this is related, but the "script" output of the problem perf.dat file had this warning:
Warning: Timestamp below last timeslice flush
-- Steve
Quoted 11 lines · Steven Rostedt
Quoted 4 lines · Frederic Weisbecker
Stephane Eranian has reported a similar problem but perhaps not with the same cause.
I need to have a look.
Not sure if this is related, but the "script" output of the problem perf.dat file had this warning:
Warning: Timestamp below last timeslice flush
Yup, that's what I'm looking at.
Quoted 6 lines · Frederic Weisbecker
Quoted 5 lines · Steven Rostedt
Quoted 3 lines · Frederic Weisbecker
Stephane Eranian has reported a similar problem but perhaps not with the same cause.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
I need to have a look.
Not sure if this is related, but the "script" output of the problem perf.dat file had this warning:
Warning: Timestamp below last timeslice flush
Yup, that's what I'm looking at.
Does increasing MAX_SAMPLE_BUFFER in util/session.c help?
Steven Rostedt
maintainerQuoted 4 lines · Jiri Olsa
hi,
here's another version of perf support for function trace with filter.
Quoted 9 lines
attached patches:
- 1/8 ftrace: Change filter/notrace set functions to return exit code
- 2/8 ftrace: Add enable/disableftrace_opscontrol interface
- 3/8 ftrace, perf: Add open/close tracepoint perf registration actions
- 4/8 ftrace, perf: Add add/del tracepoint perf registration actions
- 5/8 ftrace: AddFTRACE_ENTRY_REGmacro to allow event registration
- 6/8 ftrace, perf: Add support to use function tracepoint in perf
- 7/8 ftrace: Allow to specify filter field type for ftrace events
- 8/8 ftrace, perf: Add filter support for function trace event
OK, these break on a lot of configs.
Make sure they build with the following before sending another series. I'll give you some of the fixes I added already.
Please test: allnoconfig, allmodconfig
http://rostedt.homelinux.com/private/configs/config-ftrace-patchcheck
http://rostedt.homelinux.com/private/configs/config-ftrace-static-patchcheck
http://rostedt.homelinux.com/private/configs/config-nofunc-patchcheck
http://rostedt.homelinux.com/private/configs/config-notrace-patchcheck
Thanks!
-- Steve
Note, These need to be defines and not static inlines, because ftrace_ops is not defined in some cases.
include/linux/ftrace.h +3 -3
@@ -381,9 +381,6 @@ extern void ftrace_enable_daemon(void);#else static inline int skip_trace (unsigned long ip) {return 0 ; }static inline int ftrace_force_update (void ) {return 0 ; } -static inline void ftrace_set_filter (unsigned char *buf,int len,int reset) -{ -}static inline void ftrace_disable_daemon (void ) { }static inline void ftrace_enable_daemon (void ) { }static inline void ftrace_release_mod (struct module *mod) {}
@@ -407,6 +404,9 @@ static inline int ftrace_text_reserved(void *start, void *end)*/ #define ftrace_regex_open (ops, flag, inod, file) ({ -ENODEV; })#define ftrace_set_early_filter (ops, buf, enable) do { } while (0) +#define ftrace_free_filter (ops) do { } while (0) +#define ftrace_set_filter (ops, buf, len, reset) ({ -ENODEV; }) +#define ftrace_set_notrace (ops, buf, len, reset) ({ -ENODEV; })static inline ssize_t ftrace_filter_write (struct file *file,const char __user *ubuf,size_t cnt,loff_t *ppos) {return -ENODEV ; }