]> bbs.cooldavid.org Git - net-next-2.6.git/blame - samples/tracepoints/tracepoint-probe-sample.c
tracing: Let tracepoints have data passed to tracepoint callbacks
[net-next-2.6.git] / samples / tracepoints / tracepoint-probe-sample.c
CommitLineData
4a089752
MD
1/*
2 * tracepoint-probe-sample.c
3 *
4 * sample tracepoint probes.
5 */
6
7#include <linux/module.h>
8#include <linux/file.h>
9#include <linux/dcache.h>
10#include "tp-samples-trace.h"
11
12/*
13 * Here the caller only guarantees locking for struct file and struct inode.
14 * Locking must therefore be done in the probe to use the dentry.
15 */
38516ab5
SR
16static void probe_subsys_event(void *ignore,
17 struct inode *inode, struct file *file)
4a089752
MD
18{
19 path_get(&file->f_path);
20 dget(file->f_path.dentry);
21 printk(KERN_INFO "Event is encountered with filename %s\n",
22 file->f_path.dentry->d_name.name);
23 dput(file->f_path.dentry);
24 path_put(&file->f_path);
25}
26
38516ab5 27static void probe_subsys_eventb(void *ignore)
4a089752
MD
28{
29 printk(KERN_INFO "Event B is encountered\n");
30}
31
7ec7fb39 32static int __init tp_sample_trace_init(void)
4a089752
MD
33{
34 int ret;
35
38516ab5 36 ret = register_trace_subsys_event(probe_subsys_event, NULL);
4a089752 37 WARN_ON(ret);
38516ab5 38 ret = register_trace_subsys_eventb(probe_subsys_eventb, NULL);
4a089752
MD
39 WARN_ON(ret);
40
41 return 0;
42}
43
44module_init(tp_sample_trace_init);
45
7ec7fb39 46static void __exit tp_sample_trace_exit(void)
4a089752 47{
38516ab5
SR
48 unregister_trace_subsys_eventb(probe_subsys_eventb, NULL);
49 unregister_trace_subsys_event(probe_subsys_event, NULL);
2504ea5e 50 tracepoint_synchronize_unregister();
4a089752
MD
51}
52
53module_exit(tp_sample_trace_exit);
54
55MODULE_LICENSE("GPL");
56MODULE_AUTHOR("Mathieu Desnoyers");
57MODULE_DESCRIPTION("Tracepoint Probes Samples");