blob: aabc4e97091126cbf51b43e0e7e47005ab99267b [file] [log] [blame]
Steven Rostedt9cfe06f2009-04-14 21:37:03 -04001#include <linux/module.h>
2#include <linux/kthread.h>
3
4/*
5 * Any file that uses trace points, must include the header.
6 * But only one file, must include the header by defining
7 * CREATE_TRACE_POINTS first. This will make the C code that
8 * creates the handles for the trace points.
9 */
10#define CREATE_TRACE_POINTS
11#include "trace-events-sample.h"
12
13
14static void simple_thread_func(int cnt)
15{
16 set_current_state(TASK_INTERRUPTIBLE);
17 schedule_timeout(HZ);
18 trace_foo_bar("hello", cnt);
Steven Rostedt9cfe06f2009-04-14 21:37:03 -040019}
20
21static int simple_thread(void *arg)
22{
23 int cnt = 0;
24
25 while (!kthread_should_stop())
26 simple_thread_func(cnt++);
27
28 return 0;
29}
30
31static struct task_struct *simple_tsk;
32
33static int __init trace_event_init(void)
34{
35 simple_tsk = kthread_run(simple_thread, NULL, "event-sample");
36 if (IS_ERR(simple_tsk))
37 return -1;
38
39 return 0;
40}
41
42static void __exit trace_event_exit(void)
43{
44 kthread_stop(simple_tsk);
45}
46
47module_init(trace_event_init);
48module_exit(trace_event_exit);
49
50MODULE_AUTHOR("Steven Rostedt");
51MODULE_DESCRIPTION("trace-events-sample");
52MODULE_LICENSE("GPL");