blob: f33b3ba744ac87add2cf25199ea3d1608a47e2c0 [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);
19
20 if (!(cnt % 10))
21 /* It is really important that I say "hi!" */
22 printk(KERN_EMERG "hi!\n");
23}
24
25static int simple_thread(void *arg)
26{
27 int cnt = 0;
28
29 while (!kthread_should_stop())
30 simple_thread_func(cnt++);
31
32 return 0;
33}
34
35static struct task_struct *simple_tsk;
36
37static int __init trace_event_init(void)
38{
39 simple_tsk = kthread_run(simple_thread, NULL, "event-sample");
40 if (IS_ERR(simple_tsk))
41 return -1;
42
43 return 0;
44}
45
46static void __exit trace_event_exit(void)
47{
48 kthread_stop(simple_tsk);
49}
50
51module_init(trace_event_init);
52module_exit(trace_event_exit);
53
54MODULE_AUTHOR("Steven Rostedt");
55MODULE_DESCRIPTION("trace-events-sample");
56MODULE_LICENSE("GPL");