diff options
author | Peter Zijlstra <peterz@infradead.org> | 2020-07-10 11:59:59 +0200 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2020-07-10 11:59:59 +0200 |
commit | e1bcad609f5a533da45fac071cf0849b86dbab92 (patch) | |
tree | bc77cb21c81c053b99271c7bac9f6bc071cc56a6 /samples/ftrace/sample-trace-array.c | |
parent | c935cd62d3fe985d7f0ebea185d2759e8992e96f (diff) | |
parent | b037b09b9058d84882fa2c4db3806433e2b0f912 (diff) |
Merge branch 'tip/x86/entry'
Diffstat (limited to 'samples/ftrace/sample-trace-array.c')
-rw-r--r-- | samples/ftrace/sample-trace-array.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/samples/ftrace/sample-trace-array.c b/samples/ftrace/sample-trace-array.c index d523450d73eb..6aba02a31c96 100644 --- a/samples/ftrace/sample-trace-array.c +++ b/samples/ftrace/sample-trace-array.c @@ -6,6 +6,7 @@ #include <linux/timer.h> #include <linux/err.h> #include <linux/jiffies.h> +#include <linux/workqueue.h> /* * Any file that uses trace points, must include the header. @@ -20,6 +21,16 @@ struct trace_array *tr; static void mytimer_handler(struct timer_list *unused); static struct task_struct *simple_tsk; +static void trace_work_fn(struct work_struct *work) +{ + /* + * Disable tracing for event "sample_event". + */ + trace_array_set_clr_event(tr, "sample-subsystem", "sample_event", + false); +} +static DECLARE_WORK(trace_work, trace_work_fn); + /* * mytimer: Timer setup to disable tracing for event "sample_event". This * timer is only for the purposes of the sample module to demonstrate access of @@ -29,11 +40,7 @@ static DEFINE_TIMER(mytimer, mytimer_handler); static void mytimer_handler(struct timer_list *unused) { - /* - * Disable tracing for event "sample_event". - */ - trace_array_set_clr_event(tr, "sample-subsystem", "sample_event", - false); + schedule_work(&trace_work); } static void simple_thread_func(int count) @@ -76,6 +83,7 @@ static int simple_thread(void *arg) simple_thread_func(count++); del_timer(&mytimer); + cancel_work_sync(&trace_work); /* * trace_array_put() decrements the reference counter associated with @@ -107,8 +115,12 @@ static int __init sample_trace_array_init(void) trace_printk_init_buffers(); simple_tsk = kthread_run(simple_thread, NULL, "sample-instance"); - if (IS_ERR(simple_tsk)) + if (IS_ERR(simple_tsk)) { + trace_array_put(tr); + trace_array_destroy(tr); return -1; + } + return 0; } |