tracepoint-sample.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* tracepoint-sample.c
  2. *
  3. * Executes a tracepoint when /proc/tracepoint-sample is opened.
  4. *
  5. * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
  6. *
  7. * This file is released under the GPLv2.
  8. * See the file COPYING for more details.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/sched.h>
  12. #include <linux/proc_fs.h>
  13. #include "tp-samples-trace.h"
  14. DEFINE_TRACE(subsys_event);
  15. DEFINE_TRACE(subsys_eventb);
  16. struct proc_dir_entry *pentry_sample;
  17. static int my_open(struct inode *inode, struct file *file)
  18. {
  19. int i;
  20. trace_subsys_event(inode, file);
  21. for (i = 0; i < 10; i++)
  22. trace_subsys_eventb();
  23. return -EPERM;
  24. }
  25. static const struct file_operations mark_ops = {
  26. .open = my_open,
  27. .llseek = noop_llseek,
  28. };
  29. static int __init sample_init(void)
  30. {
  31. printk(KERN_ALERT "sample init\n");
  32. pentry_sample = proc_create("tracepoint-sample", 0444, NULL,
  33. &mark_ops);
  34. if (!pentry_sample)
  35. return -EPERM;
  36. return 0;
  37. }
  38. static void __exit sample_exit(void)
  39. {
  40. printk(KERN_ALERT "sample exit\n");
  41. remove_proc_entry("tracepoint-sample", NULL);
  42. }
  43. module_init(sample_init)
  44. module_exit(sample_exit)
  45. MODULE_LICENSE("GPL");
  46. MODULE_AUTHOR("Mathieu Desnoyers");
  47. MODULE_DESCRIPTION("Tracepoint sample");