main_per_task.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/ftrace.h>
  3. #include <linux/tracepoint.h>
  4. #include <linux/kernel.h>
  5. #include <linux/module.h>
  6. #include <linux/init.h>
  7. #include <linux/rv.h>
  8. #include <rv/instrumentation.h>
  9. #include <rv/da_monitor.h>
  10. #define MODULE_NAME "MODEL_NAME"
  11. /*
  12. * XXX: include required tracepoint headers, e.g.,
  13. * #include <linux/trace/events/sched.h>
  14. */
  15. #include <trace/events/rv.h>
  16. /*
  17. * This is the self-generated part of the monitor. Generally, there is no need
  18. * to touch this section.
  19. */
  20. #include "MODEL_NAME.h"
  21. /*
  22. * Declare the deterministic automata monitor.
  23. *
  24. * The rv monitor reference is needed for the monitor declaration.
  25. */
  26. static struct rv_monitor rv_MODEL_NAME;
  27. DECLARE_DA_MON_PER_TASK(MODEL_NAME, MIN_TYPE);
  28. /*
  29. * This is the instrumentation part of the monitor.
  30. *
  31. * This is the section where manual work is required. Here the kernel events
  32. * are translated into model's event.
  33. *
  34. */
  35. TRACEPOINT_HANDLERS_SKEL
  36. static int enable_MODEL_NAME(void)
  37. {
  38. int retval;
  39. retval = da_monitor_init_MODEL_NAME();
  40. if (retval)
  41. return retval;
  42. TRACEPOINT_ATTACH
  43. return 0;
  44. }
  45. static void disable_MODEL_NAME(void)
  46. {
  47. rv_MODEL_NAME.enabled = 0;
  48. TRACEPOINT_DETACH
  49. da_monitor_destroy_MODEL_NAME();
  50. }
  51. /*
  52. * This is the monitor register section.
  53. */
  54. static struct rv_monitor rv_MODEL_NAME = {
  55. .name = "MODEL_NAME",
  56. .description = "auto-generated MODEL_NAME",
  57. .enable = enable_MODEL_NAME,
  58. .disable = disable_MODEL_NAME,
  59. .reset = da_monitor_reset_all_MODEL_NAME,
  60. .enabled = 0,
  61. };
  62. static int __init register_MODEL_NAME(void)
  63. {
  64. rv_register_monitor(&rv_MODEL_NAME);
  65. return 0;
  66. }
  67. static void __exit unregister_MODEL_NAME(void)
  68. {
  69. rv_unregister_monitor(&rv_MODEL_NAME);
  70. }
  71. module_init(register_MODEL_NAME);
  72. module_exit(unregister_MODEL_NAME);
  73. MODULE_LICENSE("GPL");
  74. MODULE_AUTHOR("dot2k: auto-generated");
  75. MODULE_DESCRIPTION("MODEL_NAME");