tracing: Various cleanups and preparation for trace event hist
Subsystems (3)
Steven Rostedt
maintainercover tracing: Various cleanups and preparation for trace event hist
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: 1cf8067b541884366b7db3a328342073fed2f38f
Chunyu Hu (2):
tracing: Make tracer_flags use the right set_flag callback
tracing: Fix typoes in code comment and printk in trace_nop.c
Steven Rostedt (Red Hat) (2):
tracing: Remove duplicate checks for online CPUs
tracing: Use flags instead of bool in trigger structure
Tom Zanussi (7):
tracing: Make ftrace_event_field checking functions available
tracing: Make event trigger functions available
tracing: Add event record param to trigger_ops.func()
tracing: Add get_syscall_name()
tracing: Add a per-event-trigger 'paused' field
tracing: Add needs_rec flag to event triggers
tracing: Add an unreg_all() callback to trigger commands
Yang Shi (1):
tracing, writeback: Replace cgroup path to cgroup ino
----
include/linux/trace_events.h | 7 ++- include/trace/events/kmem.h | 42 ++----------- include/trace/events/tlb.h | 4 +- include/trace/events/writeback.h | 121 ++++++++++++++---------------------- kernel/trace/trace.c | 28 ++++----- kernel/trace/trace.h | 112 ++++++++++++++++++++++++++------- kernel/trace/trace_events_filter.c | 12 ---- kernel/trace/trace_events_trigger.c | 88 +++++++++++++++----------- kernel/trace/trace_functions.c | 6 ++ kernel/trace/trace_nop.c | 4 +- kernel/trace/trace_syscalls.c | 11 ++++ 11 files changed, 229 insertions(+), 206 deletions(-)
Steven Rostedt
maintainerPATCH 1/12 tracing: Make tracer_flags use the right set_flag callback
From: Chunyu Hu <[email protected]>
When I was updating the ftrace_stress test of ltp. I encountered a strange phenomemon, excute following steps:
echo nop > /sys/kernel/debug/tracing/current_tracer echo 0 > /sys/kernel/debug/tracing/options/funcgraph-cpu
bash: echo: write error: Invalid argument
check dmesg:
[ 1024.903855] nop_test_refuse flag set to 0: we refuse.Now cat trace_options to see the result
The reason is that the trace option test will randomly setup trace option under tracing/options no matter what the current_tracer is. but the set_tracer_option is always using the set_flag callback from the current_tracer. This patch adds a pointer to tracer_flags and make it point to the tracer it belongs to. When the option is setup, the set_flag of the right tracer will be used no matter what the the current_tracer is.
And the old dummy_tracer_flags is used for all the tracers which doesn't have a tracer_flags, having issue to use it to save the pointer of a tracer. So remove it and use dynamic dummy tracer_flags for tracers needing a dummy tracer_flags, as a result, there are no tracers sharing tracer_flags, so remove the check code.
And save the current tracer to trace_option_dentry seems not good as it may waste mem space when mount the debug/trace fs more than one time.
--- kernel/trace/trace.c | 28 ++++++++++++++-------------- kernel/trace/trace.h | 1 + kernel/trace/trace_functions.c | 6 ++++++ 3 files changed, 21 insertions(+), 14 deletions(-)
kernel/trace/trace.c +14 -14
@@ -74,11 +74,6 @@ static struct tracer_opt dummy_tracer_opt[] = { { } }; -static struct tracer_flags dummy_tracer_flags = { - .val =0 , - .opts = dummy_tracer_opt -}; -static int dummy_set_flag (struct trace_array *tr,u32 old_flags,u32 bit,int set) {
@@ -1258,12 +1253,20 @@ int __init register_tracer(struct tracer *type)if (!type->set_flag) type->set_flag = &dummy_set_flag; -if (!type->flags) - type->flags = &dummy_tracer_flags; -else +if (!type->flags) { +/*allocate a dummy tracer_flags*/ + type->flags =kmalloc (sizeof (*type->flags),GFP_KERNEL ); +if (!type->flags) +return -ENOMEM ; + type->flags->val =0 ; + type->flags->opts = dummy_tracer_opt; + }else if (!type->flags->opts) type->flags->opts = dummy_tracer_opt; +/* store the tracer for __set_tracer_option */ + type->flags->trace = type; + ret =run_tracer_selftest (type);if (ret <0 ) goto out;
@@ -3505,7 +3508,7 @@ static int __set_tracer_option(struct trace_array *tr,struct tracer_flags *tracer_flags, struct tracer_opt *opts, int neg) { - struct tracer *trace = tr->current_trace; + struct tracer *trace = tracer_flags->trace;int ret; ret = trace->set_flag (tr, tracer_flags->val, opts->bit, !neg);
@@ -6391,11 +6394,8 @@ create_trace_option_files(struct trace_array *tr, struct tracer *tracer)return ;for (i =0 ; i < tr->nr_topts; i++) { -/* -* Check if these flags have already been added. -* Some tracers share flags. -*/ -if (tr->topts[i].tracer->flags == tracer->flags) +/* Make sure there's no duplicate flags. */ +if (WARN_ON_ONCE (tr->topts[i].tracer->flags == tracer->flags))return ; }
kernel/trace/trace.h +1 -0
@@ -345,6 +345,7 @@ struct tracer_opt {struct tracer_flags {u32 val;struct tracer_opt *opts; +struct tracer *trace; };/* Makes more easy to define a tracer opt */
kernel/trace/trace_functions.c +6 -0
@@ -219,6 +219,8 @@ static void tracing_stop_function_trace(struct trace_array *tr)unregister_ftrace_function (tr->ops); } +static struct tracer function_trace; +static int func_set_flag (struct trace_array *tr,u32 old_flags,u32 bit,int set) {
@@ -228,6 +230,10 @@ func_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)if (!!set == !!(func_flags.val &TRACE_FUNC_OPT_STACK ))break ; +/* We can change this flag when not running. */ +if (tr->current_trace != &function_trace) +break ; +unregister_ftrace_function (tr->ops);if (set) {
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 2/12 tracing: Remove duplicate checks for online CPUs
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Some trace events have conditions that check if the current CPU is online or not before recording the tracepoint. That's because certain trace events are in locations that can be called as the CPU is going offline and when RCU no longer monitors it (like kfree and friends). The check was added because trace events require RCU to be active.
This is a trace event infrastructure issue and not something that individual trace events should worry about. The tracepoint.h code now has added a check to see if the current CPU is considered online, and it only does the tracepoint if it is. There's no more need for individual trace events to also include this check. It is now redundant.
--- include/trace/events/kmem.h | 42 ++++-------------------------------------- include/trace/events/tlb.h | 4 +--- 2 files changed, 5 insertions(+), 41 deletions(-)
include/trace/events/kmem.h +4 -38
@@ -140,42 +140,19 @@ DEFINE_EVENT(kmem_free, kfree,TP_ARGS (call_site, ptr) ); -DEFINE_EVENT_CONDITION (kmem_free, kmem_cache_free, +DEFINE_EVENT (kmem_free, kmem_cache_free, TP_PROTO(unsigned long call_site, const void *ptr), -TP_ARGS (call_site, ptr), - -/* -* This trace can be potentially called from an offlined cpu. -* Since trace points use RCU and RCU should not be used from -* offline cpus, filter such calls out. -* While this trace can be called from a preemptable section, -* it has no impact on the condition since tasks can migrate -* only from online cpus to other online cpus. Thus its safe -* to use raw_smp_processor_id. -*/ -TP_CONDITION (cpu_online (raw_smp_processor_id ())) +TP_ARGS (call_site, ptr) ); -TRACE_EVENT_CONDITION(mm_page_free, +TRACE_EVENT(mm_page_free, TP_PROTO(struct page *page, unsigned int order), TP_ARGS(page, order), - - /* - * This trace can be potentially called from an offlined cpu. - * Since trace points use RCU and RCU should not be used from - * offline cpus, filter such calls out. - * While this trace can be called from a preemptable section, - * it has no impact on the condition since tasks can migrate - * only from online cpus to other online cpus. Thus its safe - * to use raw_smp_processor_id. - */ - TP_CONDITION(cpu_online(raw_smp_processor_id())), - TP_STRUCT__entry( __field( unsigned long, pfn ) __field( unsigned int, order )
@@ -276,23 +253,12 @@ DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked,TP_ARGS (page, order, migratetype) ); -TRACE_EVENT_CONDITION(mm_page_pcpu_drain, +TRACE_EVENT(mm_page_pcpu_drain, TP_PROTO(struct page *page, unsigned int order, int migratetype), TP_ARGS(page, order, migratetype), - /* - * This trace can be potentially called from an offlined cpu. - * Since trace points use RCU and RCU should not be used from - * offline cpus, filter such calls out. - * While this trace can be called from a preemptable section, - * it has no impact on the condition since tasks can migrate - * only from online cpus to other online cpus. Thus its safe - * to use raw_smp_processor_id. - */ - TP_CONDITION(cpu_online(raw_smp_processor_id())), - TP_STRUCT__entry( __field( unsigned long, pfn ) __field( unsigned int, order )
include/trace/events/tlb.h +1 -3
@@ -34,13 +34,11 @@ TLB_FLUSH_REASON#define EM (a,b) { a, b },#define EMe (a,b) { a, b } -TRACE_EVENT_CONDITION(tlb_flush, +TRACE_EVENT(tlb_flush, TP_PROTO(int reason, unsigned long pages), TP_ARGS(reason, pages), - TP_CONDITION(cpu_online(smp_processor_id())), - TP_STRUCT__entry( __field( int, reason) __field(unsigned long, pages)
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 3/12 tracing: Make ftrace_event_field checking functions available
In reply to Steven RostedtFrom: Tom Zanussi <[email protected]>
Make is_string_field() and is_function_field() accessible outside of trace_event_filters.c for other users of ftrace_event_fields.
--- kernel/trace/trace.h | 12 ++++++++++++ kernel/trace/trace_events_filter.c | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-)
kernel/trace/trace.h +12 -0
@@ -1112,6 +1112,18 @@ struct filter_pred {unsigned short right; }; +static inline bool is_string_field (struct ftrace_event_field *field) +{ +return field->filter_type ==FILTER_DYN_STRING || + field->filter_type ==FILTER_STATIC_STRING || + field->filter_type ==FILTER_PTR_STRING ; +} + +static inline bool is_function_field (struct ftrace_event_field *field) +{ +return field->filter_type ==FILTER_TRACE_FN ; +} +extern enum regex_type filter_parse_regex (char *buff,int len,char **search,int *not); extern void print_event_filter(struct trace_event_file *file,
kernel/trace/trace_events_filter.c +0 -12
@@ -961,18 +961,6 @@ 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 || - field->filter_type ==FILTER_STATIC_STRING || - field->filter_type ==FILTER_PTR_STRING ; -} -static bool is_legal_op (struct ftrace_event_field *field,int op) { if (is_string_field(field) &&
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 4/12 tracing: Make event trigger functions available
In reply to Steven RostedtFrom: Tom Zanussi <[email protected]>
Make various event trigger utility functions available outside of trace_events_trigger.c so that new triggers can be defined outside of that file.
--- kernel/trace/trace.h | 14 ++++++++++++++ kernel/trace/trace_events_trigger.c | 28 +++++++++++++--------------- 2 files changed, 27 insertions(+), 15 deletions(-)
kernel/trace/trace.h +14 -0
@@ -1175,6 +1175,20 @@ struct event_trigger_data {struct list_head list; }; +extern void trigger_data_free (struct event_trigger_data *data); +extern int event_trigger_init (struct event_trigger_ops *ops, +struct event_trigger_data *data); +extern int trace_event_trigger_enable_disable (struct trace_event_file *file, +int trigger_enable); +extern void update_cond_flag (struct trace_event_file *file); +extern void unregister_trigger (char *glob,struct event_trigger_ops *ops, +struct event_trigger_data *test, +struct trace_event_file *file); +extern int set_trigger_filter (char *filter_str, +struct event_trigger_data *trigger_data, +struct trace_event_file *file); +extern int register_event_command (struct event_command *cmd); +/** * struct event_trigger_ops - callbacks for trace event triggers *
kernel/trace/trace_events_trigger.c +13 -15
@@ -28,8 +28,7 @@static LIST_HEAD (trigger_commands);static DEFINE_MUTEX (trigger_cmd_mutex); -static void -trigger_data_free (struct event_trigger_data *data) +void trigger_data_free (struct event_trigger_data *data) {if (data->cmd_ops->set_filter) data->cmd_ops->set_filter (NULL , data,NULL );
@@ -306,7 +305,7 @@ const struct file_operations event_trigger_fops = {* Currently we only register event commands from __init, so mark this * __init too. */ -static __init int register_event_command (struct event_command *cmd) +__init int register_event_command (struct event_command *cmd) {struct event_command *p;int ret =0 ;
@@ -395,9 +394,8 @@ event_trigger_print(const char *name, struct seq_file *m,* * Return: 0 on success, errno otherwise */ -static int -event_trigger_init (struct event_trigger_ops *ops, -struct event_trigger_data *data) +int event_trigger_init (struct event_trigger_ops *ops, +struct event_trigger_data *data) { data->ref++;return 0 ;
@@ -425,8 +423,8 @@ event_trigger_free(struct event_trigger_ops *ops,trigger_data_free (data); } -static int trace_event_trigger_enable_disable (struct trace_event_file *file, -int trigger_enable) +int trace_event_trigger_enable_disable (struct trace_event_file *file, +int trigger_enable) {int ret =0 ;
@@ -483,7 +481,7 @@ clear_event_triggers(struct trace_array *tr)* its TRIGGER_COND bit set, otherwise the TRIGGER_COND bit should be * cleared. */ -static void update_cond_flag (struct trace_event_file *file) +void update_cond_flag (struct trace_event_file *file) {struct event_trigger_data *data;bool set_cond = false;
@@ -560,9 +558,9 @@ out:* Usually used directly as the @unreg method in event command * implementations. */ -static void unregister_trigger (char *glob,struct event_trigger_ops *ops, -struct event_trigger_data *test, -struct trace_event_file *file) +void unregister_trigger (char *glob,struct event_trigger_ops *ops, +struct event_trigger_data *test, +struct trace_event_file *file) {struct event_trigger_data *data;bool unregistered = false;
@@ -696,9 +694,9 @@ event_trigger_callback(struct event_command *cmd_ops,* * Return: 0 on success, errno otherwise */ -static int set_trigger_filter (char *filter_str, -struct event_trigger_data *trigger_data, -struct trace_event_file *file) +int set_trigger_filter (char *filter_str, +struct event_trigger_data *trigger_data, +struct trace_event_file *file) {struct event_trigger_data *data = trigger_data;struct event_filter *filter =NULL , *tmp;
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 5/12 tracing: Add event record param to trigger_ops.func()
In reply to Steven RostedtFrom: Tom Zanussi <[email protected]>
Some triggers may need access to the trace event, so pass it in. Also fix up the existing trigger funcs and their callers.
--- include/linux/trace_events.h | 7 ++++--- kernel/trace/trace.h | 6 ++++-- kernel/trace/trace_events_trigger.c | 36 +++++++++++++++++++----------------- 3 files changed, 27 insertions(+), 22 deletions(-)
include/linux/trace_events.h +4 -3
@@ -430,7 +430,8 @@ extern int call_filter_check_discard(struct trace_event_call *call, void *rec,extern enum event_trigger_type event_triggers_call (struct trace_event_file *file,void *rec);extern void event_triggers_post_call (struct trace_event_file *file, -enum event_trigger_type tt); +enum event_trigger_type tt, +void *rec);bool trace_event_ignore_this_pid (struct trace_event_file *trace_file);
@@ -517,7 +518,7 @@ event_trigger_unlock_commit(struct trace_event_file *file,trace_buffer_unlock_commit (file->tr, buffer, event, irq_flags, pc);if (tt) -event_triggers_post_call (file, tt); +event_triggers_post_call (file, tt, entry); }/**
@@ -550,7 +551,7 @@ event_trigger_unlock_commit_regs(struct trace_event_file *file, irq_flags, pc, regs);if (tt) -event_triggers_post_call (file, tt); +event_triggers_post_call (file, tt, entry); }#ifdef CONFIG_BPF_EVENTS
kernel/trace/trace.h +4 -2
@@ -1201,7 +1201,8 @@ extern int register_event_command(struct event_command *cmd);* @func: The trigger 'probe' function called when the triggering * event occurs. The data passed into this callback is the data * that was supplied to the event_command @reg() function that -* registered the trigger (see struct event_command). +* registered the trigger (see struct event_command) along with +* the trace record, rec. * * @init: An optional initialization function called for the trigger * when the trigger is registered (via the event_command reg()
@@ -1226,7 +1227,8 @@ extern int register_event_command(struct event_command *cmd);* (see trace_event_triggers.c). */ struct event_trigger_ops { -void (*func)(struct event_trigger_data *data); +void (*func)(struct event_trigger_data *data, +void *rec);int (*init)(struct event_trigger_ops *ops,struct event_trigger_data *data); void (*free)(struct event_trigger_ops *ops,
kernel/trace/trace_events_trigger.c +19 -17
@@ -73,7 +73,7 @@ event_triggers_call(struct trace_event_file *file, void *rec)list_for_each_entry_rcu (data, &file->triggers, list) {if (!rec) { - data->ops->func (data); + data->ops->func (data, rec);continue ; } filter =rcu_dereference_sched (data->filter);
@@ -83,7 +83,7 @@ event_triggers_call(struct trace_event_file *file, void *rec) tt |= data->cmd_ops->trigger_type;continue ; } - data->ops->func (data); + data->ops->func (data, rec); }return tt; }
@@ -93,6 +93,7 @@ EXPORT_SYMBOL_GPL(event_triggers_call);* event_triggers_post_call - Call 'post_triggers' for a trace event * @file: The trace_event_file associated with the event * @tt: enum event_trigger_type containing a set bit for each trigger to invoke +* @rec: The trace entry for the event * * For each trigger associated with an event, invoke the trigger * function registered with the associated trigger command, if the
@@ -103,13 +104,14 @@ EXPORT_SYMBOL_GPL(event_triggers_call);*/ void event_triggers_post_call (struct trace_event_file *file, -enum event_trigger_type tt) +enum event_trigger_type tt, +void *rec) {struct event_trigger_data *data;list_for_each_entry_rcu (data, &file->triggers, list) {if (data->cmd_ops->trigger_type & tt) - data->ops->func (data); + data->ops->func (data, rec); } }EXPORT_SYMBOL_GPL (event_triggers_post_call);
@@ -745,7 +747,7 @@ int set_trigger_filter(char *filter_str, }static void -traceon_trigger (struct event_trigger_data *data) +traceon_trigger (struct event_trigger_data *data,void *rec) {if (tracing_is_on ())return ;
@@ -754,7 +756,7 @@ traceon_trigger(struct event_trigger_data *data) }static void -traceon_count_trigger (struct event_trigger_data *data) +traceon_count_trigger (struct event_trigger_data *data,void *rec) {if (tracing_is_on ())return ;
@@ -769,7 +771,7 @@ traceon_count_trigger(struct event_trigger_data *data) }static void -traceoff_trigger (struct event_trigger_data *data) +traceoff_trigger (struct event_trigger_data *data,void *rec) {if (!tracing_is_on ())return ;
@@ -778,7 +780,7 @@ traceoff_trigger(struct event_trigger_data *data) }static void -traceoff_count_trigger (struct event_trigger_data *data) +traceoff_count_trigger (struct event_trigger_data *data,void *rec) {if (!tracing_is_on ())return ;
@@ -874,13 +876,13 @@ static struct event_command trigger_traceoff_cmd = {#ifdef CONFIG_TRACER_SNAPSHOT static void -snapshot_trigger (struct event_trigger_data *data) +snapshot_trigger (struct event_trigger_data *data,void *rec) {tracing_snapshot (); }static void -snapshot_count_trigger (struct event_trigger_data *data) +snapshot_count_trigger (struct event_trigger_data *data,void *rec) {if (!data->count)return ;
@@ -888,7 +890,7 @@ snapshot_count_trigger(struct event_trigger_data *data)if (data->count !=-1 ) (data->count)--; -snapshot_trigger (data); +snapshot_trigger (data, rec); } static int
@@ -967,13 +969,13 @@ static __init int register_trigger_snapshot_cmd(void) { return 0; }#define STACK_SKIP 3static void -stacktrace_trigger (struct event_trigger_data *data) +stacktrace_trigger (struct event_trigger_data *data,void *rec) {trace_dump_stack (STACK_SKIP ); }static void -stacktrace_count_trigger (struct event_trigger_data *data) +stacktrace_count_trigger (struct event_trigger_data *data,void *rec) {if (!data->count)return ;
@@ -981,7 +983,7 @@ stacktrace_count_trigger(struct event_trigger_data *data)if (data->count !=-1 ) (data->count)--; -stacktrace_trigger (data); +stacktrace_trigger (data, rec); } static int
@@ -1052,7 +1054,7 @@ struct enable_trigger_data { };static void -event_enable_trigger (struct event_trigger_data *data) +event_enable_trigger (struct event_trigger_data *data,void *rec) {struct enable_trigger_data *enable_data = data->private_data;
@@ -1063,7 +1065,7 @@ event_enable_trigger(struct event_trigger_data *data) }static void -event_enable_count_trigger (struct event_trigger_data *data) +event_enable_count_trigger (struct event_trigger_data *data,void *rec) {struct enable_trigger_data *enable_data = data->private_data;
@@ -1077,7 +1079,7 @@ event_enable_count_trigger(struct event_trigger_data *data)if (data->count !=-1 ) (data->count)--; -event_enable_trigger (data); +event_enable_trigger (data, rec); } static int
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 6/12 tracing: Add get_syscall_name()
In reply to Steven RostedtFrom: Tom Zanussi <[email protected]>
Add a utility function to grab the syscall name from the syscall metadata, given a syscall id.
--- kernel/trace/trace.h | 5 +++++ kernel/trace/trace_syscalls.c | 11 +++++++++++ 2 files changed, 16 insertions(+)
kernel/trace/trace.h +5 -0
@@ -1394,8 +1394,13 @@ int perf_ftrace_event_register(struct trace_event_call *call,#ifdef CONFIG_FTRACE_SYSCALLS void init_ftrace_syscalls (void ); +const char *get_syscall_name (int syscall);#else static inline void init_ftrace_syscalls (void ) { } +static inline const char *get_syscall_name (int syscall) +{ +return NULL ; +}#endif #ifdef CONFIG_EVENT_TRACING
kernel/trace/trace_syscalls.c +11 -0
@@ -106,6 +106,17 @@ static struct syscall_metadata *syscall_nr_to_meta(int nr)return syscalls_metadata[nr]; } +const char *get_syscall_name (int syscall) +{ +struct syscall_metadata *entry; + + entry =syscall_nr_to_meta (syscall); +if (!entry) +return NULL ; + +return entry->name; +} +static enum print_line_t print_syscall_enter (struct trace_iterator *iter,int flags,struct trace_event *event)
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 7/12 tracing: Add a per-event-trigger paused field
In reply to Steven RostedtFrom: Tom Zanussi <[email protected]>
Add a simple per-trigger 'paused' flag, allowing individual triggers to pause. We could leave it to individual triggers that need this functionality to do it themselves, but we also want to allow other events to control pausing, so add it to the trigger data.
--- kernel/trace/trace.h | 1 + kernel/trace/trace_events_trigger.c | 4 ++++ 2 files changed, 5 insertions(+)
kernel/trace/trace.h +1 -0
@@ -1172,6 +1172,7 @@ struct event_trigger_data {struct event_filter __rcu *filter;char *filter_str;void *private_data; +bool paused;struct list_head list; };
kernel/trace/trace_events_trigger.c +4 -0
@@ -72,6 +72,8 @@ event_triggers_call(struct trace_event_file *file, void *rec)return tt;list_for_each_entry_rcu (data, &file->triggers, list) { +if (data->paused) +continue ;if (!rec) { data->ops->func (data, rec);continue ;
@@ -110,6 +112,8 @@ event_triggers_post_call(struct trace_event_file *file,struct event_trigger_data *data;list_for_each_entry_rcu (data, &file->triggers, list) { +if (data->paused) +continue ;if (data->cmd_ops->trigger_type & tt) data->ops->func (data, rec); }
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 8/12 tracing: Add needs_rec flag to event triggers
In reply to Steven RostedtFrom: Tom Zanussi <[email protected]>
Add a new needs_rec flag for triggers that require unconditional access to trace records in order to function.
Normally a trigger requires access to the contents of a trace record only if it has a filter associated with it (since filters need the contents of a record in order to make a filtering decision). Some types of triggers, such as 'hist' triggers, require access to trace record contents independent of the presence of filters, so add a new flag for those triggers.
--- kernel/trace/trace.h | 7 +++++++ kernel/trace/trace_events_trigger.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-)
kernel/trace/trace.h +7 -0
@@ -1292,6 +1292,12 @@ struct event_trigger_ops {* itself logs to the trace buffer, this flag should be set, * otherwise it can be left unspecified. * +* @needs_rec: A flag that says whether or not this command needs +* access to the trace record in order to perform its function, +* regardless of whether or not it has a filter associated with +* it (filters make a trigger require access to the trace record +* but are not always present). +* * All the methods below, except for @set_filter(), must be * implemented. *
@@ -1332,6 +1338,7 @@ struct event_command {char *name;enum event_trigger_type trigger_type;bool post_trigger; +bool needs_rec;int (*func)(struct event_command *cmd_ops,struct trace_event_file *file,char *glob,char *cmd,char *params);
kernel/trace/trace_events_trigger.c +2 -1
@@ -493,7 +493,8 @@ void update_cond_flag(struct trace_event_file *file)bool set_cond = false;list_for_each_entry_rcu (data, &file->triggers, list) { -if (data->filter || data->cmd_ops->post_trigger) { +if (data->filter || data->cmd_ops->post_trigger || + data->cmd_ops->needs_rec) { set_cond = true;break ; }
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 9/12 tracing: Add an unreg_all() callback to trigger commands
In reply to Steven RostedtFrom: Tom Zanussi <[email protected]>
Add a new unreg_all() callback that can be used to remove all command-specific triggers from an event and arrange to have it called whenever a trigger file is opened with O_TRUNC set.
Commands that don't want truncate semantics, or existing commands that don't implement this function simply do nothing and their triggers remain intact.
--- kernel/trace/trace.h | 9 +++++++-- kernel/trace/trace_events_trigger.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-)
kernel/trace/trace.h +7 -2
@@ -1298,8 +1298,8 @@ struct event_trigger_ops {* it (filters make a trigger require access to the trace record * but are not always present). * -* All the methods below, except for @set_filter(), must be -* implemented. +* All the methods below, except for @set_filter() and @unreg_all(), +* must be implemented. * * @func: The callback function responsible for parsing and * registering the trigger written to the 'trigger' file by the
@@ -1324,6 +1324,10 @@ struct event_trigger_ops {* This is usually implemented by the generic utility function * @unregister_trigger() (see trace_event_triggers.c). * +* @unreg_all: An optional function called to remove all the triggers +* from the list of triggers associated with the event. Called +* when a trigger file is opened in truncate mode. +* * @set_filter: An optional function called to parse and set a filter * for the trigger. If no @set_filter() method is set for the * event command, filters set by the user for the command will be
@@ -1350,6 +1354,7 @@ struct event_command {struct event_trigger_ops *ops, struct event_trigger_data *data, struct trace_event_file *file); +void (*unreg_all)(struct trace_event_file *file);int (*set_filter)(char *filter_str,struct event_trigger_data *data,struct trace_event_file *file);
kernel/trace/trace_events_trigger.c +13 -0
@@ -193,6 +193,19 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file)return -ENODEV ; } +if ((file->f_mode &FMODE_WRITE ) && + (file->f_flags &O_TRUNC )) { +struct trace_event_file *event_file; +struct event_command *p; + + event_file =event_file_data (file); + +list_for_each_entry (p, &trigger_commands, list) { +if (p->unreg_all) + p->unreg_all (event_file); + } + } +if (file->f_mode &FMODE_READ ) { ret =seq_open (file, &event_triggers_seq_ops);if (!ret) {
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 10/12 tracing: Use flags instead of bool in trigger structure
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
gcc isn't known for handling bool in structures. Instead of using bool, use an integer mask and use bit flags instead.
--- kernel/trace/trace.h | 71 +++++++++++++++++++++++-------------- kernel/trace/trace_events_trigger.c | 8 ++--- 2 files changed, 49 insertions(+), 30 deletions(-)
kernel/trace/trace.h +45 -26
@@ -1273,30 +1273,7 @@ struct event_trigger_ops {* values are defined by adding new values to the trigger_type * enum in include/linux/trace_events.h. * -* @post_trigger: A flag that says whether or not this command needs -* to have its action delayed until after the current event has -* been closed. Some triggers need to avoid being invoked while -* an event is currently in the process of being logged, since -* the trigger may itself log data into the trace buffer. Thus -* we make sure the current event is committed before invoking -* those triggers. To do that, the trigger invocation is split -* in two - the first part checks the filter using the current -* trace record; if a command has the @post_trigger flag set, it -* sets a bit for itself in the return value, otherwise it -* directly invokes the trigger. Once all commands have been -* either invoked or set their return flag, the current record is -* either committed or discarded. At that point, if any commands -* have deferred their triggers, those commands are finally -* invoked following the close of the current event. In other -* words, if the event_trigger_ops @func() probe implementation -* itself logs to the trace buffer, this flag should be set, -* otherwise it can be left unspecified. -* -* @needs_rec: A flag that says whether or not this command needs -* access to the trace record in order to perform its function, -* regardless of whether or not it has a filter associated with -* it (filters make a trigger require access to the trace record -* but are not always present). +* @flags: See the enum event_command_flags below. * * All the methods below, except for @set_filter() and @unreg_all(), * must be implemented.
@@ -1341,8 +1318,7 @@ struct event_command {struct list_head list;char *name;enum event_trigger_type trigger_type; -bool post_trigger; -bool needs_rec; +int flags;int (*func)(struct event_command *cmd_ops,struct trace_event_file *file,char *glob,char *cmd,char *params);
@@ -1361,6 +1337,49 @@ struct event_command {struct event_trigger_ops *(*get_trigger_ops)(char *cmd,char *param); }; +/** +* enum event_command_flags - flags for struct event_command +* +* @POST_TRIGGER: A flag that says whether or not this command needs +* to have its action delayed until after the current event has +* been closed. Some triggers need to avoid being invoked while +* an event is currently in the process of being logged, since +* the trigger may itself log data into the trace buffer. Thus +* we make sure the current event is committed before invoking +* those triggers. To do that, the trigger invocation is split +* in two - the first part checks the filter using the current +* trace record; if a command has the @post_trigger flag set, it +* sets a bit for itself in the return value, otherwise it +* directly invokes the trigger. Once all commands have been +* either invoked or set their return flag, the current record is +* either committed or discarded. At that point, if any commands +* have deferred their triggers, those commands are finally +* invoked following the close of the current event. In other +* words, if the event_trigger_ops @func() probe implementation +* itself logs to the trace buffer, this flag should be set, +* otherwise it can be left unspecified. +* +* @NEEDS_REC: A flag that says whether or not this command needs +* access to the trace record in order to perform its function, +* regardless of whether or not it has a filter associated with +* it (filters make a trigger require access to the trace record +* but are not always present). +*/ +enum event_command_flags { +EVENT_CMD_FL_POST_TRIGGER =1 , +EVENT_CMD_FL_NEEDS_REC =2 , +}; + +static inline bool event_command_post_trigger (struct event_command *cmd_ops) +{ +return cmd_ops->flags &EVENT_CMD_FL_POST_TRIGGER ; +} + +static inline bool event_command_needs_rec (struct event_command *cmd_ops) +{ +return cmd_ops->flags &EVENT_CMD_FL_NEEDS_REC ; +} +extern int trace_event_enable_disable (struct trace_event_file *file,int enable,int soft_disable);extern int tracing_alloc_snapshot (void );
kernel/trace/trace_events_trigger.c +4 -4
@@ -81,7 +81,7 @@ event_triggers_call(struct trace_event_file *file, void *rec) filter =rcu_dereference_sched (data->filter);if (filter && !filter_match_preds (filter, rec))continue ; -if (data->cmd_ops->post_trigger) { +if (event_command_post_trigger (data->cmd_ops)) { tt |= data->cmd_ops->trigger_type;continue ; }
@@ -506,8 +506,8 @@ void update_cond_flag(struct trace_event_file *file)bool set_cond = false;list_for_each_entry_rcu (data, &file->triggers, list) { -if (data->filter || data->cmd_ops->post_trigger || - data->cmd_ops->needs_rec) { +if (data->filter ||event_command_post_trigger (data->cmd_ops) || +event_command_needs_rec (data->cmd_ops)) { set_cond = true;break ; }
@@ -1035,7 +1035,7 @@ stacktrace_get_trigger_ops(char *cmd, char *param)static struct event_command trigger_stacktrace_cmd = { .name ="stacktrace" , .trigger_type =ETT_STACKTRACE , - .post_trigger = true, + .flags =EVENT_CMD_FL_POST_TRIGGER , .func = event_trigger_callback, .reg = register_trigger, .unreg = unregister_trigger,
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 11/12 tracing, writeback: Replace cgroup path to cgroup ino
In reply to Steven RostedtFrom: Yang Shi <[email protected]>
commit 5634cc2aa9aebc77bc862992e7805469dcf83dac ("writeback: update writeback tracepoints to report cgroup") made writeback tracepoints print out cgroup path when CGROUP_WRITEBACK is enabled, but it may trigger the below bug on -rt kernel since kernfs_path and kernfs_path_len are called by tracepoints, which acquire spin lock that is sleepable on -rt kernel.
BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:930
in_atomic(): 1, irqs_disabled(): 0, pid: 625, name: kworker/u16:3
INFO: lockdep is turned off.
Preemption disabled at:[<ffffffc000374a5c>] wb_writeback+0xec/0x830
CPU: 7 PID: 625 Comm: kworker/u16:3 Not tainted 4.4.1-rt5 #20 Hardware name: Freescale Layerscape 2085a RDB Board (DT) Workqueue: writeback wb_workfn (flush-7:0) Call trace: [<ffffffc00008d708>] dump_backtrace+0x0/0x200 [<ffffffc00008d92c>] show_stack+0x24/0x30 [<ffffffc0007b0f40>] dump_stack+0x88/0xa8 [<ffffffc000127d74>] ___might_sleep+0x2ec/0x300 [<ffffffc000d5d550>] rt_spin_lock+0x38/0xb8 [<ffffffc0003e0548>] kernfs_path_len+0x30/0x90 [<ffffffc00036b360>] trace_event_raw_event_writeback_work_class+0xe8/0x2e8 [<ffffffc000374f90>] wb_writeback+0x620/0x830 [<ffffffc000376224>] wb_workfn+0x61c/0x950 [<ffffffc000110adc>] process_one_work+0x3ac/0xb30 [<ffffffc0001112fc>] worker_thread+0x9c/0x7a8 [<ffffffc00011a9e8>] kthread+0x190/0x1b0 [<ffffffc000086ca0>] ret_from_fork+0x10/0x30
With unlocked kernfs_* functions, synchronize_sched() has to be called in kernfs_rename which could be called in syscall path, but it is problematic. So, print out cgroup ino instead of path name, which could be converted to path name by userland.
Withouth CGROUP_WRITEBACK enabled, it just prints out root dir. But, root dir ino vary from different filesystems, so printing out -1U to indicate an invalid cgroup ino.
--- include/trace/events/writeback.h | 121 +++++++++++++++------------------------ 1 file changed, 45 insertions(+), 76 deletions(-)
include/trace/events/writeback.h +45 -76
@@ -134,58 +134,28 @@ DEFINE_EVENT(writeback_dirty_inode_template, writeback_dirty_inode,#ifdef CREATE_TRACE_POINTS #ifdef CONFIG_CGROUP_WRITEBACK -static inline size_t __trace_wb_cgroup_size (struct bdi_writeback *wb) +static inline unsigned int __trace_wb_assign_cgroup (struct bdi_writeback *wb) { -return kernfs_path_len (wb->memcg_css->cgroup->kn) +1 ; +return wb->memcg_css->cgroup->kn->ino; } -static inline void __trace_wb_assign_cgroup (char *buf,struct bdi_writeback *wb) -{ -struct cgroup *cgrp = wb->memcg_css->cgroup; -char *path; - - path =cgroup_path (cgrp, buf,kernfs_path_len (cgrp->kn) +1 ); -WARN_ON_ONCE (path != buf); -} - -static inline size_t __trace_wbc_cgroup_size (struct writeback_control *wbc) -{ -if (wbc->wb) -return __trace_wb_cgroup_size (wbc->wb); -else -return 2 ; -} - -static inline void __trace_wbc_assign_cgroup (char *buf, -struct writeback_control *wbc) +static inline unsigned int __trace_wbc_assign_cgroup (struct writeback_control *wbc) {if (wbc->wb) -__trace_wb_assign_cgroup (buf, wbc->wb); +return __trace_wb_assign_cgroup (wbc->wb);else -strcpy (buf,"/" ); +return -1U ; } -#else /* CONFIG_CGROUP_WRITEBACK */ -static inline size_t __trace_wb_cgroup_size (struct bdi_writeback *wb) -{ -return 2 ; -} - -static inline void __trace_wb_assign_cgroup (char *buf,struct bdi_writeback *wb) -{ -strcpy (buf,"/" ); -} - -static inline size_t __trace_wbc_cgroup_size (struct writeback_control *wbc) +static inline unsigned int __trace_wb_assign_cgroup (struct bdi_writeback *wb) { -return 2 ; +return -1U ; } -static inline void __trace_wbc_assign_cgroup (char *buf, -struct writeback_control *wbc) +static inline unsigned int __trace_wbc_assign_cgroup (struct writeback_control *wbc) { -strcpy (buf,"/" ); +return -1U ; }#endif /* CONFIG_CGROUP_WRITEBACK */
@@ -201,7 +171,7 @@ DECLARE_EVENT_CLASS(writeback_write_inode_template, __array(char, name, 32) __field(unsigned long, ino) __field(int, sync_mode) - __dynamic_array(char, cgroup, __trace_wbc_cgroup_size(wbc)) + __field(unsigned int, cgroup_ino) ), TP_fast_assign(
@@ -209,14 +179,14 @@ DECLARE_EVENT_CLASS(writeback_write_inode_template, dev_name(inode_to_bdi(inode)->dev), 32); __entry->ino = inode->i_ino; __entry->sync_mode = wbc->sync_mode; -__trace_wbc_assign_cgroup (__get_str (cgroup), wbc); + __entry->cgroup_ino =__trace_wbc_assign_cgroup (wbc); ), -TP_printk ("bdi %s: ino=%lu sync_mode=%d cgroup=%s" , +TP_printk ("bdi %s: ino=%lu sync_mode=%d cgroup_ino=%u" , __entry->name, __entry->ino, __entry->sync_mode, -__get_str (cgroup) + __entry->cgroup_ino ) );
@@ -246,7 +216,7 @@ DECLARE_EVENT_CLASS(writeback_work_class, __field(int, range_cyclic) __field(int, for_background) __field(int, reason) -__dynamic_array (char, cgroup,__trace_wb_cgroup_size (wb)) + __field(unsigned int, cgroup_ino) ), TP_fast_assign( strncpy(__entry->name,
@@ -258,10 +228,10 @@ DECLARE_EVENT_CLASS(writeback_work_class, __entry->range_cyclic = work->range_cyclic; __entry->for_background = work->for_background; __entry->reason = work->reason; -__trace_wb_assign_cgroup (__get_str (cgroup), wb); + __entry->cgroup_ino =__trace_wb_assign_cgroup (wb); ), TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d " - "kupdate=%d range_cyclic=%d background=%d reason=%s cgroup=%s", + "kupdate=%d range_cyclic=%d background=%d reason=%s cgroup_ino=%u", __entry->name, MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev), __entry->nr_pages,
@@ -270,7 +240,7 @@ DECLARE_EVENT_CLASS(writeback_work_class, __entry->range_cyclic, __entry->for_background,__print_symbolic (__entry->reason,WB_WORK_REASON ), -__get_str (cgroup) + __entry->cgroup_ino ) );#define DEFINE_WRITEBACK_WORK_EVENT (name) \
@@ -300,15 +270,15 @@ DECLARE_EVENT_CLASS(writeback_class,TP_ARGS (wb),TP_STRUCT__entry ( __array(char, name, 32) -__dynamic_array (char, cgroup,__trace_wb_cgroup_size (wb)) + __field(unsigned int, cgroup_ino) ),TP_fast_assign ( strncpy(__entry->name, dev_name(wb->bdi->dev), 32); -__trace_wb_assign_cgroup (__get_str (cgroup), wb); + __entry->cgroup_ino =__trace_wb_assign_cgroup (wb); ), -TP_printk ("bdi %s: cgroup=%s" , +TP_printk ("bdi %s: cgroup_ino=%u" , __entry->name, -__get_str (cgroup) + __entry->cgroup_ino ) );#define DEFINE_WRITEBACK_EVENT (name) \
@@ -347,7 +317,7 @@ DECLARE_EVENT_CLASS(wbc_class, __field(int, range_cyclic) __field(long, range_start) __field(long, range_end) -__dynamic_array (char, cgroup,__trace_wbc_cgroup_size (wbc)) + __field(unsigned int, cgroup_ino) ), TP_fast_assign(
@@ -361,12 +331,12 @@ DECLARE_EVENT_CLASS(wbc_class, __entry->range_cyclic = wbc->range_cyclic; __entry->range_start = (long )wbc->range_start; __entry->range_end = (long )wbc->range_end; -__trace_wbc_assign_cgroup (__get_str (cgroup), wbc); + __entry->cgroup_ino =__trace_wbc_assign_cgroup (wbc); ), TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d " "bgrd=%d reclm=%d cyclic=%d " - "start=0x%lx end=0x%lx cgroup=%s", + "start=0x%lx end=0x%lx cgroup_ino=%u", __entry->name, __entry->nr_to_write, __entry->pages_skipped,
@@ -377,7 +347,7 @@ DECLARE_EVENT_CLASS(wbc_class, __entry->range_cyclic, __entry->range_start, __entry->range_end, -__get_str (cgroup) + __entry->cgroup_ino ) )
@@ -398,7 +368,7 @@ TRACE_EVENT(writeback_queue_io, __field(long, age) __field(int, moved) __field(int, reason) -__dynamic_array (char, cgroup,__trace_wb_cgroup_size (wb)) + __field(unsigned int, cgroup_ino) ),TP_fast_assign ( unsigned long *older_than_this = work->older_than_this;
@@ -408,15 +378,15 @@ TRACE_EVENT(writeback_queue_io, (jiffies - *older_than_this) * 1000 / HZ : -1; __entry->moved = moved; __entry->reason = work->reason; -__trace_wb_assign_cgroup (__get_str (cgroup), wb); + __entry->cgroup_ino =__trace_wb_assign_cgroup (wb); ), -TP_printk ("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup=%s" , +TP_printk ("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup_ino=%u" , __entry->name, __entry->older,/* older_than_this in jiffies */ __entry->age,/* older_than_this in relative milliseconds */ __entry->moved,__print_symbolic (__entry->reason,WB_WORK_REASON ), -__get_str (cgroup) + __entry->cgroup_ino ) );
@@ -484,7 +454,7 @@ TRACE_EVENT(bdi_dirty_ratelimit, __field(unsigned long, dirty_ratelimit) __field(unsigned long, task_ratelimit) __field(unsigned long, balanced_dirty_ratelimit) - __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb)) + __field(unsigned int, cgroup_ino) ), TP_fast_assign(
@@ -496,13 +466,13 @@ TRACE_EVENT(bdi_dirty_ratelimit, __entry->task_ratelimit =KBps (task_ratelimit); __entry->balanced_dirty_ratelimit =KBps (wb->balanced_dirty_ratelimit); -__trace_wb_assign_cgroup (__get_str (cgroup), wb); + __entry->cgroup_ino =__trace_wb_assign_cgroup (wb); ), TP_printk("bdi %s: " "write_bw=%lu awrite_bw=%lu dirty_rate=%lu " "dirty_ratelimit=%lu task_ratelimit=%lu " - "balanced_dirty_ratelimit=%lu cgroup=%s", + "balanced_dirty_ratelimit=%lu cgroup_ino=%u", __entry->bdi, __entry->write_bw, /* write bandwidth */ __entry->avg_write_bw, /* avg write bandwidth */
@@ -510,7 +480,7 @@ TRACE_EVENT(bdi_dirty_ratelimit, __entry->dirty_ratelimit,/* base ratelimit */ __entry->task_ratelimit,/* ratelimit with position control */ __entry->balanced_dirty_ratelimit,/* the balanced ratelimit */ -__get_str (cgroup) + __entry->cgroup_ino ) );
@@ -548,7 +518,7 @@ TRACE_EVENT(balance_dirty_pages, __field( long, pause) __field(unsigned long, period) __field( long, think) - __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb)) + __field(unsigned int, cgroup_ino) ), TP_fast_assign(
@@ -571,7 +541,7 @@ TRACE_EVENT(balance_dirty_pages, __entry->period = period *1000 /HZ ; __entry->pause = pause *1000 /HZ ; __entry->paused = (jiffies - start_time) *1000 /HZ ; -__trace_wb_assign_cgroup (__get_str (cgroup), wb); + __entry->cgroup_ino =__trace_wb_assign_cgroup (wb); ),
@@ -580,7 +550,7 @@ TRACE_EVENT(balance_dirty_pages,"bdi_setpoint=%lu bdi_dirty=%lu " "dirty_ratelimit=%lu task_ratelimit=%lu " "dirtied=%u dirtied_pause=%u " -"paused=%lu pause=%ld period=%lu think=%ld cgroup=%s" , +"paused=%lu pause=%ld period=%lu think=%ld cgroup_ino=%u" , __entry->bdi, __entry->limit, __entry->setpoint,
@@ -595,7 +565,7 @@ TRACE_EVENT(balance_dirty_pages, __entry->pause,/* ms */ __entry->period,/* ms */ __entry->think,/* ms */ -__get_str (cgroup) + __entry->cgroup_ino ) );
@@ -609,8 +579,7 @@ TRACE_EVENT(writeback_sb_inodes_requeue, __field(unsigned long, ino) __field(unsigned long, state) __field(unsigned long, dirtied_when) - __dynamic_array(char, cgroup, - __trace_wb_cgroup_size(inode_to_wb(inode))) + __field(unsigned int, cgroup_ino) ), TP_fast_assign(
@@ -619,16 +588,16 @@ TRACE_EVENT(writeback_sb_inodes_requeue, __entry->ino = inode->i_ino; __entry->state = inode->i_state; __entry->dirtied_when = inode->dirtied_when; -__trace_wb_assign_cgroup (__get_str (cgroup),inode_to_wb (inode)); + __entry->cgroup_ino =__trace_wb_assign_cgroup (inode_to_wb (inode)); ), -TP_printk ("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu cgroup=%s" , +TP_printk ("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu cgroup_ino=%u" , __entry->name, __entry->ino,show_inode_state (__entry->state), __entry->dirtied_when, (jiffies - __entry->dirtied_when) /HZ , -__get_str (cgroup) + __entry->cgroup_ino ) );
@@ -684,7 +653,7 @@ DECLARE_EVENT_CLASS(writeback_single_inode_template, __field(unsigned long, writeback_index) __field(long, nr_to_write) __field(unsigned long, wrote) - __dynamic_array(char, cgroup, __trace_wbc_cgroup_size(wbc)) + __field(unsigned int, cgroup_ino) ), TP_fast_assign(
@@ -696,11 +665,11 @@ DECLARE_EVENT_CLASS(writeback_single_inode_template, __entry->writeback_index = inode->i_mapping->writeback_index; __entry->nr_to_write = nr_to_write; __entry->wrote = nr_to_write - wbc->nr_to_write; -__trace_wbc_assign_cgroup (__get_str (cgroup), wbc); + __entry->cgroup_ino =__trace_wbc_assign_cgroup (wbc); ), TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu " - "index=%lu to_write=%ld wrote=%lu cgroup=%s", + "index=%lu to_write=%ld wrote=%lu cgroup_ino=%u", __entry->name, __entry->ino, show_inode_state(__entry->state),
@@ -709,7 +678,7 @@ DECLARE_EVENT_CLASS(writeback_single_inode_template, __entry->writeback_index, __entry->nr_to_write, __entry->wrote, -__get_str (cgroup) + __entry->cgroup_ino ) );
Signature · 1 line
2.7.0
Steven Rostedt
maintainerPATCH 12/12 tracing: Fix typoes in code comment and printk in trace_nop.c
In reply to Steven RostedtFrom: Chunyu Hu <[email protected]>
echo nop > /sys/kernel/debug/tracing/options/current_tracer echo 1 > /sys/kernel/debug/tracing/options/test_nop_accept echo 0 > /sys/kernel/debug/tracing/options/test_nop_accept echo 1 > /sys/kernel/debug/tracing/options/test_nop_refuse
Before the fix, the dmesg is a bit ugly since a align issue.
[ 191.973081] nop_test_accept flag set to 1: we accept. Now cat trace_options to see the result [ 195.156942] nop_test_refuse flag set to 1: we refuse.Now cat trace_options to see the result
After the fix, the dmesg will show aligned log for nop_test_refuse and nop_test_accept.
[ 2718.032413] nop_test_refuse flag set to 1: we refuse. Now cat trace_options to see the result [ 2734.253360] nop_test_accept flag set to 1: we accept. Now cat trace_options to see the result
--- kernel/trace/trace_nop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_nop.c +2 -2
@@ -56,7 +56,7 @@ static void nop_trace_reset(struct trace_array *tr) }/* It only serves as a signal handler and a callback to -* accept or refuse tthe setting of a flag. +* accept or refuse the setting of a flag. * If you don't implement it, then the flag setting will be * automatically accepted. */
@@ -75,7 +75,7 @@ static int nop_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)if (bit ==TRACE_NOP_OPT_REFUSE ) {printk (KERN_DEBUG "nop_test_refuse flag set to %d: we refuse." -"Now cat trace_options to see the result\n" , +" Now cat trace_options to see the result\n" , set);return -EINVAL ; }
Signature · 1 line
2.7.0