tracing updates for 2.6.32
Subsystems (3)
Hi Ingo, Thomas,
Here are some fixes and enhancements for the 2.6.32 tracing tree.
Impacts:
- A spurious warning in the lockless ring buffer had been shutdown
- Simplifications of various ftrace code areas resulting in more deletions than additions.
These changes have been based against tip:tracing/core
Thanks,
Frederic.
The following changes since commit e202687927c132b1e1ff36b526b5e78ac33de840:
Ingo Molnar (1):
Merge branch 'tip/tracing/ring-buffer-3' of git://git.kernel.org/.../rostedt/linux-2.6-trace into tracing/core
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git tracing/core
Lai Jiangshan (1):
ring_buffer: Fix warning while ignoring cmpxchg return value
Xiao Guangrong (3):
tracing/function: Simplify __ftrace_replace_code() tracing/trace_stack: Cleanup for trace_lookup_stack() tracing/function: Cleanup for function tracer
kernel/trace/ftrace.c | 89 +++++++++------------------------------ kernel/trace/ring_buffer.c | 9 +++- kernel/trace/trace_functions.c | 4 +- kernel/trace/trace_stack.c | 9 +---- 4 files changed, 30 insertions(+), 81 deletions(-)
PATCH 1/4 ring_buffer: Fix warning while ignoring cmpxchg return value
From: Lai Jiangshan <[email protected]>
kernel/trace/ring_buffer.c: In function 'rb_tail_page_update':kernel/trace/ring_buffer.c:849: warning: value computed is not used kernel/trace/ring_buffer.c:850: warning: value computed is not used
Add "(void)"s to fix this warning, because we don't need here to handle the fail case of cmpxchg, it's fine if an interrupt already did the job.
Changed from V1:
Add a comment(which is written by Steven) for it.
--- kernel/trace/ring_buffer.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
kernel/trace/ring_buffer.c +7 -2
@@ -845,9 +845,14 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,* This will only succeed if an interrupt did * not come in and change it. In which case, we * do not want to modify it. +* +* We add (void) to let the compiler know that we do not care +* about the return value of these functions. We use the +* cmpxchg to only update if an interrupt did not already +* do it for us. If the cmpxchg fails, we don't care. */ -local_cmpxchg (&next_page->write, old_write, val); -local_cmpxchg (&next_page->entries, old_entries, eval); + (void )local_cmpxchg (&next_page->write, old_write, val); + (void )local_cmpxchg (&next_page->entries, old_entries, eval);/* * No need to worry about races with clearing out the commit.
Signature · 1 line
1.6.2.3
PATCH 2/4 tracing/function: Simplify __ftrace_replace_code()
In reply to Frederic WeisbeckerFrom: Xiao Guangrong <[email protected]>
Rewrite the __ftrace_replace_code() function, simplify it, but don't change the code's logic.
First, we get the state we want to set, if the record has the same state, then do nothing, otherwise enable/disable it.
--- kernel/trace/ftrace.c | 72 ++++++++++++------------------------------------ 1 files changed, 18 insertions(+), 54 deletions(-)
kernel/trace/ftrace.c +18 -54
@@ -1017,71 +1017,35 @@ static int __ftrace_replace_code(struct dyn_ftrace *rec, int enable) {unsigned long ftrace_addr; -unsigned long ip, fl; +unsigned long flag =0UL ; ftrace_addr = (unsigned long )FTRACE_ADDR ; - ip = rec->ip; -/* -* If this record is not to be traced and -* it is not enabled then do nothing. +* If this record is not to be traced or we want to disable it, +* then disable it. * -* If this record is not to be traced and -* it is enabled then disable it. +* If we want to enable it and filtering is off, then enable it. * +* If we want to enable it and filtering is on, enable it only if +* it's filtered */ -if (rec->flags &FTRACE_FL_NOTRACE ) { -if (rec->flags &FTRACE_FL_ENABLED ) - rec->flags &= ~FTRACE_FL_ENABLED ; -else -return 0 ; - - }else if (ftrace_filtered && enable) { -/* -* Filtering is on: -*/ - - fl = rec->flags & (FTRACE_FL_FILTER |FTRACE_FL_ENABLED ); - -/* Record is filtered and enabled, do nothing */ -if (fl == (FTRACE_FL_FILTER |FTRACE_FL_ENABLED )) -return 0 ; - -/* Record is not filtered or enabled, do nothing */ -if (!fl) -return 0 ; - -/* Record is not filtered but enabled, disable it */ -if (fl ==FTRACE_FL_ENABLED ) - rec->flags &= ~FTRACE_FL_ENABLED ; -else -/* Otherwise record is filtered but not enabled, enable it */ - rec->flags |=FTRACE_FL_ENABLED ; - }else { -/* Disable or not filtered */ - -if (enable) { -/* if record is enabled, do nothing */ -if (rec->flags &FTRACE_FL_ENABLED ) -return 0 ; - - rec->flags |=FTRACE_FL_ENABLED ; - - }else { +if (enable && !(rec->flags &FTRACE_FL_NOTRACE )) { +if (!ftrace_filtered || (rec->flags &FTRACE_FL_FILTER )) + flag =FTRACE_FL_ENABLED ; + } -/* if record is not enabled, do nothing */ -if (!(rec->flags &FTRACE_FL_ENABLED )) -return 0 ; +/* If the state of this record hasn't changed, then do nothing */ +if ((rec->flags &FTRACE_FL_ENABLED ) == flag) +return 0 ; - rec->flags &= ~FTRACE_FL_ENABLED ; - } +if (flag) { + rec->flags |=FTRACE_FL_ENABLED ; +return ftrace_make_call (rec, ftrace_addr); } -if (rec->flags &FTRACE_FL_ENABLED ) -return ftrace_make_call (rec, ftrace_addr); -else -return ftrace_make_nop (NULL , rec, ftrace_addr); + rec->flags &= ~FTRACE_FL_ENABLED ; +return ftrace_make_nop (NULL , rec, ftrace_addr); }static void ftrace_replace_code (int enable)
Signature · 1 line
1.6.2.3
PATCH 3/4 tracing/trace_stack: Cleanup for trace_lookup_stack()
In reply to Frederic WeisbeckerFrom: Xiao Guangrong <[email protected]>
We can directly use %pF input format instead of sprint_symbol() and %s input format.
--- kernel/trace/trace_stack.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
kernel/trace/trace_stack.c +1 -8
@@ -234,15 +234,8 @@ static void t_stop(struct seq_file *m, void *p)static int trace_lookup_stack (struct seq_file *m,long i) {unsigned long addr = stack_dump_trace[i]; -#ifdef CONFIG_KALLSYMS -char str[KSYM_SYMBOL_LEN ]; -sprint_symbol (str, addr); - -return seq_printf (m,"%s\n" , str); -#else -return seq_printf (m,"%p\n" , (void *)addr); -#endif +return seq_printf (m,"%pF\n" , (void *)addr); }static void print_disabled (struct seq_file *m)
Signature · 1 line
1.6.2.3
PATCH 4/4 tracing/function: Cleanup for function tracer
In reply to Frederic WeisbeckerFrom: Xiao Guangrong <[email protected]>
We can directly use %pf input format instead of kallsyms_lookup() and %s input format
--- kernel/trace/ftrace.c | 17 +++-------------- kernel/trace/trace_functions.c | 4 +--- 2 files changed, 4 insertions(+), 17 deletions(-)
kernel/trace/ftrace.c +3 -14
@@ -1403,18 +1403,13 @@ static int t_hash_show(struct seq_file *m, void *v) {struct ftrace_func_probe *rec;struct hlist_node *hnd = v; -char str[KSYM_SYMBOL_LEN ]; rec = hlist_entry(hnd, struct ftrace_func_probe, node);if (rec->ops->print)return rec->ops->kallsyms_lookup (rec->ip,NULL ,NULL ,NULL , str); -seq_printf (m,"%s:" , str); - -kallsyms_lookup ((unsigned long )rec->ops->func,NULL ,NULL ,NULL , str); -seq_printf (m,"%s" , str); +seq_printf (m,"%pf:%pf" , (void *)rec->ip, (void *)rec->ops->func);if (rec->data)seq_printf (m,":%p" , rec->data);
@@ -1512,7 +1507,6 @@ static int t_show(struct seq_file *m, void *v) {struct ftrace_iterator *iter = m->private;struct dyn_ftrace *rec = v; -char str[KSYM_SYMBOL_LEN ];if (iter->flags &FTRACE_ITER_HASH )return t_hash_show (m, v);
@@ -1525,9 +1519,7 @@ static int t_show(struct seq_file *m, void *v)if (!rec)return 0 ; -kallsyms_lookup (rec->ip,NULL ,NULL ,NULL , str); - -seq_printf (m,"%s\n" , str); +seq_printf (m,"%pf\n" , (void *)rec->ip);return 0 ; }
@@ -2508,7 +2500,6 @@ static void g_stop(struct seq_file *m, void *p)static int g_show (struct seq_file *m,void *v) {unsigned long *ptr = v; -char str[KSYM_SYMBOL_LEN ];if (!ptr)return 0 ;
@@ -2518,9 +2509,7 @@ static int g_show(struct seq_file *m, void *v)return 0 ; } -kallsyms_lookup (*ptr,NULL ,NULL ,NULL , str); - -seq_printf (m,"%s\n" , str); +seq_printf (m,"%pf\n" , v);return 0 ; }
kernel/trace/trace_functions.c +1 -3
@@ -288,11 +288,9 @@ static int ftrace_trace_onoff_print(struct seq_file *m, unsigned long ip, struct ftrace_probe_ops *ops, void *data) { - char str[KSYM_SYMBOL_LEN]; long count = (long)data; -kallsyms_lookup (ip,NULL ,NULL ,NULL , str); -seq_printf (m,"%s:" , str); +seq_printf (m,"%pf:" , (void *)ip);if (ops == &traceon_probe_ops)seq_printf (m,"traceon" );
Signature · 1 line
1.6.2.3
Quoted 33 lines · Frederic Weisbecker
Hi Ingo, Thomas,
Here are some fixes and enhancements for the 2.6.32 tracing tree.
Impacts:
- A spurious warning in the lockless ring buffer had been shutdown
- Simplifications of various ftrace code areas resulting in more deletions than additions.These changes have been based against tip:tracing/core
Thanks,
Frederic.
The following changes since commit
e202687927c132b1e1ff36b526b5e78ac33de840:
Ingo Molnar (1):
Merge branch 'tip/tracing/ring-buffer-3' ofgit://git.kernel.org/.../rostedt/linux-2.6-traceinto tracing/coreare available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.gittracing/coreLai Jiangshan (1):
ring_buffer: Fix warning while ignoring cmpxchg return valueXiao Guangrong (3):
tracing/function: Simplify__ftrace_replace_code()tracing/trace_stack: Cleanup fortrace_lookup_stack()tracing/function: Cleanup for function tracer
Quoted 5 lines
kernel/trace/ftrace.c | 89 +++++++++------------------------------ kernel/trace/ring_buffer.c | 9 +++- kernel/trace/trace_functions.c | 4 +- kernel/trace/trace_stack.c | 9 +---- 4 files changed, 30 insertions(+), 81 deletions(-)
Pulled, thanks a lot Frederic!
Ingo