tracing: Some last minute updates for 3.20
Subsystems (2)
Steven Rostedt
maintainercover tracing: Some last minute updates for 3.20
Some last minute updates for this merge window. Mostly documentantion and sample code changes. Nothing risky. But they went through my entire test suite anyway.
There is also an urgent patch that got lost in my inbox that I added.
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: 7215853e985a4bef1a6c14e00e89dfec84f1e457
Steven Rostedt (Red Hat) (4):
tracing: Update the TRACE_EVENT fields available in the sample code
tracing: Add TRACE_EVENT_CONDITION sample
tracing: Add TRACE_EVENT_FN example
tracing: Add samples of DECLARE_EVENT_CLASS() and DEFINE_EVENT()
Vikram Mulukutla (1):
tracing: Fix unmapping loop in tracing_mark_write
----
kernel/trace/trace.c | 2 +- samples/trace_events/trace-events-sample.c | 80 ++++++- samples/trace_events/trace-events-sample.h | 328 +++++++++++++++++++++++++++-- 3 files changed, 395 insertions(+), 15 deletions(-)
Steven Rostedt
maintainerPATCH 1/5 tracing: Update the TRACE_EVENT fields available in the sample code
From: "Steven Rostedt (Red Hat)" <[email protected]>
The sample code in samples/trace_events/ is extremely out of date and does not show all the new fields that have been added since the sample code was written. As most people are unaware of these new fields, adding sample code and explanations of those fields should help out.
--- samples/trace_events/trace-events-sample.c | 19 +++- samples/trace_events/trace-events-sample.h | 145 ++++++++++++++++++++++++++--- 2 files changed, 150 insertions(+), 14 deletions(-)
samples/trace_events/trace-events-sample.c +18 -1
@@ -10,12 +10,29 @@#define CREATE_TRACE_POINTS #include "trace-events-sample.h" +static const char *random_strings[] = { +"Mother Goose" , +"Snoopy" , +"Gandalf" , +"Frodo" , +"One ring to rule them all" +};static void simple_thread_func (int cnt) { +int array[6 ]; +int len = cnt %5 ; +int i; +set_current_state (TASK_INTERRUPTIBLE );schedule_timeout (HZ ); -trace_foo_bar ("hello" , cnt); + +for (i =0 ; i < len; i++) + array[i] = i +1 ; + array[i] =0 ; + +trace_foo_bar ("hello" , cnt, array, random_strings[len], +tsk_cpus_allowed (current)); }static int simple_thread (void *arg)
samples/trace_events/trace-events-sample.h +132 -13
182 lines not on this page · raw message
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 2/5 tracing: Add TRACE_EVENT_CONDITION sample
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The sample code lacks an example of TRACE_EVENT_CONDITION, and it has been expressed to me that this feature for TRACE_EVENT is not well known and not used when it could be.
--- samples/trace_events/trace-events-sample.c | 3 ++ samples/trace_events/trace-events-sample.h | 58 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+)
samples/trace_events/trace-events-sample.c +3 -0
@@ -31,8 +31,11 @@ static void simple_thread_func(int cnt) array[i] = i +1 ; array[i] =0 ; +/* Silly tracepoints */ trace_foo_bar ("hello" , cnt, array, random_strings[len],tsk_cpus_allowed (current)); + +trace_foo_bar_with_cond ("Some times print" , cnt); }static int simple_thread (void *arg)
samples/trace_events/trace-events-sample.h +58 -0
64 lines not on this page · raw message
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 3/5 tracing: Add TRACE_EVENT_FN example
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
If a function should be called before a tracepoint is enabled and/or after it is disabled, the TRACE_EVENT_FN() serves this purpose. But it is not well documented. Having it as a sample would help developers to know how to use it.
--- samples/trace_events/trace-events-sample.c | 51 ++++++++++++++++++++++++++++++ samples/trace_events/trace-events-sample.h | 44 ++++++++++++++++++++++++++ 2 files changed, 95 insertions(+)
samples/trace_events/trace-events-sample.c +51 -0
@@ -49,6 +49,52 @@ static int simple_thread(void *arg) }static struct task_struct *simple_tsk; +static struct task_struct *simple_tsk_fn; + +static void simple_thread_func_fn (int cnt) +{ +set_current_state (TASK_INTERRUPTIBLE ); +schedule_timeout (HZ ); + +/* More silly tracepoints */ +trace_foo_bar_with_fn ("Look at me" , cnt); +} + +static int simple_thread_fn (void *arg) +{ +int cnt =0 ; + +while (!kthread_should_stop ()) +simple_thread_func_fn (cnt++); + +return 0 ; +} + +static DEFINE_MUTEX (thread_mutex); + +void foo_bar_reg (void ) +{ +pr_info ("Starting thread for foo_bar_fn\n" ); +/* +* We shouldn't be able to start a trace when the module is +* unloading (there's other locks to prevent that). But +* for consistency sake, we still take the thread_mutex. +*/ +mutex_lock (&thread_mutex); + simple_tsk_fn =kthread_run (simple_thread_fn,NULL ,"event-sample-fn" ); +mutex_unlock (&thread_mutex); +} + +void foo_bar_unreg (void ) +{ +pr_info ("Killing thread for foo_bar_fn\n" ); +/* protect against module unloading */ +mutex_lock (&thread_mutex); +if (simple_tsk_fn) +kthread_stop (simple_tsk_fn); + simple_tsk_fn =NULL ; +mutex_unlock (&thread_mutex); +}static int __init trace_event_init (void ) {
@@ -62,6 +108,11 @@ static int __init trace_event_init(void) static void __exit trace_event_exit(void) {kthread_stop (simple_tsk); +mutex_lock (&thread_mutex); +if (simple_tsk_fn) +kthread_stop (simple_tsk_fn); + simple_tsk_fn =NULL ; +mutex_unlock (&thread_mutex); }module_init (trace_event_init);
samples/trace_events/trace-events-sample.h +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 4/5 tracing: Add samples of DECLARE_EVENT_CLASS() and DEFINE_EVENT()
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Add to samples/trace_events/ the macros DECLARE_EVENT_CLASS() and DEFINE_EVENT() and recommend using them over multiple TRACE_EVENT() macros if the multiple events have the same format.
--- samples/trace_events/trace-events-sample.c | 7 +++ samples/trace_events/trace-events-sample.h | 81 ++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+)
samples/trace_events/trace-events-sample.c +7 -0
@@ -35,7 +35,13 @@ static void simple_thread_func(int cnt)trace_foo_bar ("hello" , cnt, array, random_strings[len],tsk_cpus_allowed (current)); +trace_foo_with_template_simple ("HELLO" , cnt); +trace_foo_bar_with_cond ("Some times print" , cnt); + +trace_foo_with_template_cond ("prints other times" , cnt); + +trace_foo_with_template_print ("I have to be different" , cnt); }static int simple_thread (void *arg)
@@ -58,6 +64,7 @@ static void simple_thread_func_fn(int cnt)/* More silly tracepoints */ trace_foo_bar_with_fn ("Look at me" , cnt); +trace_foo_with_template_fn ("Look at me too" , cnt); }static int simple_thread_fn (void *arg)
samples/trace_events/trace-events-sample.h +81 -0
87 lines not on this page · raw message
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 5/5 tracing: Fix unmapping loop in tracing_mark_write
In reply to Steven RostedtFrom: Vikram Mulukutla <[email protected]>
Commit 6edb2a8a385f0cdef51dae37ff23e74d76d8a6ce introduced an array map_pages that contains the addresses returned by kmap_atomic. However, when unmapping those pages, map_pages[0] is unmapped before map_pages[1], breaking the nesting requirement as specified in the documentation for kmap_atomic/kunmap_atomic.
This was caught by the highmem debug code present in kunmap_atomic. Fix the loop to do the unmapping properly.
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -4928,7 +4928,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, *fpos += written; out_unlock: -for (i =0 ; i < nr_pages; i++){ +for (i = nr_pages -1 ; i >=0 ; i--) {kunmap_atomic (map_page[i]);put_page (pages[i]); }
Signature · 1 line
2.1.4