Blame view

samples/tracepoints/tracepoint-probe-sample.c 1.31 KB
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  /*
   * tracepoint-probe-sample.c
   *
   * sample tracepoint probes.
   */
  
  #include <linux/module.h>
  #include <linux/file.h>
  #include <linux/dcache.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...
16
17
  static void probe_subsys_event(void *ignore,
  			       struct inode *inode, struct file *file)
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
18
19
20
21
22
23
24
25
26
  {
  	path_get(&file->f_path);
  	dget(file->f_path.dentry);
  	printk(KERN_INFO "Event is encountered with filename %s
  ",
  		file->f_path.dentry->d_name.name);
  	dput(file->f_path.dentry);
  	path_put(&file->f_path);
  }
38516ab59   Steven Rostedt   tracing: Let trac...
27
  static void probe_subsys_eventb(void *ignore)
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
28
29
30
31
  {
  	printk(KERN_INFO "Event B is encountered
  ");
  }
7ec7fb394   Qinghuang Feng   samples: mark {st...
32
  static int __init tp_sample_trace_init(void)
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
33
34
  {
  	int ret;
38516ab59   Steven Rostedt   tracing: Let trac...
35
  	ret = register_trace_subsys_event(probe_subsys_event, NULL);
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
36
  	WARN_ON(ret);
38516ab59   Steven Rostedt   tracing: Let trac...
37
  	ret = register_trace_subsys_eventb(probe_subsys_eventb, NULL);
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
38
39
40
41
42
43
  	WARN_ON(ret);
  
  	return 0;
  }
  
  module_init(tp_sample_trace_init);
7ec7fb394   Qinghuang Feng   samples: mark {st...
44
  static void __exit tp_sample_trace_exit(void)
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
45
  {
38516ab59   Steven Rostedt   tracing: Let trac...
46
47
  	unregister_trace_subsys_eventb(probe_subsys_eventb, NULL);
  	unregister_trace_subsys_event(probe_subsys_event, NULL);
2504ea5ed   Mathieu Desnoyers   tracepoints: samp...
48
  	tracepoint_synchronize_unregister();
4a0897526   Mathieu Desnoyers   tracing: tracepoi...
49
50
51
52
53
54
55
  }
  
  module_exit(tp_sample_trace_exit);
  
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("Mathieu Desnoyers");
  MODULE_DESCRIPTION("Tracepoint Probes Samples");