Path: blob/master/samples/trace_events/trace-events-sample.c
10818 views
#include <linux/module.h>1#include <linux/kthread.h>23/*4* Any file that uses trace points, must include the header.5* But only one file, must include the header by defining6* CREATE_TRACE_POINTS first. This will make the C code that7* creates the handles for the trace points.8*/9#define CREATE_TRACE_POINTS10#include "trace-events-sample.h"111213static void simple_thread_func(int cnt)14{15set_current_state(TASK_INTERRUPTIBLE);16schedule_timeout(HZ);17trace_foo_bar("hello", cnt);18}1920static int simple_thread(void *arg)21{22int cnt = 0;2324while (!kthread_should_stop())25simple_thread_func(cnt++);2627return 0;28}2930static struct task_struct *simple_tsk;3132static int __init trace_event_init(void)33{34simple_tsk = kthread_run(simple_thread, NULL, "event-sample");35if (IS_ERR(simple_tsk))36return -1;3738return 0;39}4041static void __exit trace_event_exit(void)42{43kthread_stop(simple_tsk);44}4546module_init(trace_event_init);47module_exit(trace_event_exit);4849MODULE_AUTHOR("Steven Rostedt");50MODULE_DESCRIPTION("trace-events-sample");51MODULE_LICENSE("GPL");525354