tracepoint-probe-sample2.c 927 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * tracepoint-probe-sample2.c
  3. *
  4. * 2nd sample tracepoint probes.
  5. */
  6. #include <linux/module.h>
  7. #include <linux/fs.h>
  8. #include "tp-samples-trace.h"
  9. /*
  10. * Here the caller only guarantees locking for struct file and struct inode.
  11. * Locking must therefore be done in the probe to use the dentry.
  12. */
  13. static void probe_subsys_event(struct inode *inode, struct file *file)
  14. {
  15. printk(KERN_INFO "Event is encountered with inode number %lu\n",
  16. inode->i_ino);
  17. }
  18. static int __init tp_sample_trace_init(void)
  19. {
  20. int ret;
  21. ret = register_trace_subsys_event(probe_subsys_event);
  22. WARN_ON(ret);
  23. return 0;
  24. }
  25. module_init(tp_sample_trace_init);
  26. static void __exit tp_sample_trace_exit(void)
  27. {
  28. unregister_trace_subsys_event(probe_subsys_event);
  29. tracepoint_synchronize_unregister();
  30. }
  31. module_exit(tp_sample_trace_exit);
  32. MODULE_LICENSE("GPL");
  33. MODULE_AUTHOR("Mathieu Desnoyers");
  34. MODULE_DESCRIPTION("Tracepoint Probes Samples");