Blame view

samples/tracepoints/tracepoint-probe-sample2.c 963 Bytes
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  /*
   * tracepoint-probe-sample2.c
   *
   * 2nd sample tracepoint probes.
   */
  
  #include <linux/module.h>
  #include <linux/fs.h>
  #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.
   */
38516ab59   Steven Rostedt   tracing: Let trac...
15
16
  static void probe_subsys_event(void *ignore,
  			       struct inode *inode, struct file *file)
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
17
18
19
20
21
  {
  	printk(KERN_INFO "Event is encountered with inode number %lu
  ",
  		inode->i_ino);
  }
7ec7fb394   Qinghuang Feng   samples: mark {st...
22
  static int __init tp_sample_trace_init(void)
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
23
24
  {
  	int ret;
38516ab59   Steven Rostedt   tracing: Let trac...
25
  	ret = register_trace_subsys_event(probe_subsys_event, NULL);
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
26
27
28
29
30
31
  	WARN_ON(ret);
  
  	return 0;
  }
  
  module_init(tp_sample_trace_init);
7ec7fb394   Qinghuang Feng   samples: mark {st...
32
  static void __exit tp_sample_trace_exit(void)
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
33
  {
38516ab59   Steven Rostedt   tracing: Let trac...
34
  	unregister_trace_subsys_event(probe_subsys_event, NULL);
2504ea5ed   Mathieu Desnoyers   tracepoints: samp...
35
  	tracepoint_synchronize_unregister();
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
36
37
38
39
40
41
42
  }
  
  module_exit(tp_sample_trace_exit);
  
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("Mathieu Desnoyers");
  MODULE_DESCRIPTION("Tracepoint Probes Samples");