From 4a0897526bbc5c6ac0df80b16b8c60339e717ae2 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 18 Jul 2008 12:16:16 -0400 Subject: tracing: tracepoints, samples Tracepoint example code under samples/. Signed-off-by: Mathieu Desnoyers Acked-by: 'Peter Zijlstra' Signed-off-by: Ingo Molnar --- samples/tracepoints/tracepoint-probe-sample2.c | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 samples/tracepoints/tracepoint-probe-sample2.c (limited to 'samples/tracepoints/tracepoint-probe-sample2.c') diff --git a/samples/tracepoints/tracepoint-probe-sample2.c b/samples/tracepoints/tracepoint-probe-sample2.c new file mode 100644 index 000000000000..5e9fcf4afffe --- /dev/null +++ b/samples/tracepoints/tracepoint-probe-sample2.c @@ -0,0 +1,42 @@ +/* + * tracepoint-probe-sample2.c + * + * 2nd sample tracepoint probes. + */ + +#include +#include +#include "tp-samples-trace.h" + +/* + * Here the caller only guarantees locking for struct file and struct inode. + * Locking must therefore be done in the probe to use the dentry. + */ +static void probe_subsys_event(struct inode *inode, struct file *file) +{ + printk(KERN_INFO "Event is encountered with inode number %lu\n", + inode->i_ino); +} + +int __init tp_sample_trace_init(void) +{ + int ret; + + ret = register_trace_subsys_event(probe_subsys_event); + WARN_ON(ret); + + return 0; +} + +module_init(tp_sample_trace_init); + +void __exit tp_sample_trace_exit(void) +{ + unregister_trace_subsys_event(probe_subsys_event); +} + +module_exit(tp_sample_trace_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("Tracepoint Probes Samples"); -- cgit v1.2.3-59-g8ed1b