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 10 #define MODULE_NAME "da_perobj_parent" 11 12 /* 13 * XXX: include required tracepoint headers, e.g., 14 * #include <trace/events/sched.h> 15 */ 16 #include <rv_trace.h> 17 #include <monitors/parent_mon/parent_mon.h> 18 19 /* 20 * This is the self-generated part of the monitor. Generally, there is no need 21 * to touch this section. 22 */ 23 #define RV_MON_TYPE RV_MON_PER_OBJ 24 typedef /* XXX: define the target type */ *monitor_target; 25 #include "da_perobj_parent.h" 26 #include <rv/da_monitor.h> 27 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 static void handle_event_1(void *data, /* XXX: fill header */) 36 { 37 /* XXX: validate that this event is only valid in the initial state */ 38 int id = /* XXX: how do I get the id? */; 39 monitor_target t = /* XXX: how do I get t? */; 40 da_handle_start_run_event(id, t, event_1_da_perobj_parent); 41 } 42 43 static void handle_event_2(void *data, /* XXX: fill header */) 44 { 45 int id = /* XXX: how do I get the id? */; 46 monitor_target t = /* XXX: how do I get t? */; 47 da_handle_event(id, t, event_2_da_perobj_parent); 48 } 49 50 static void handle_event_3(void *data, /* XXX: fill header */) 51 { 52 int id = /* XXX: how do I get the id? */; 53 monitor_target t = /* XXX: how do I get t? */; 54 da_handle_event(id, t, event_3_da_perobj_parent); 55 } 56 57 /* XXX: obj is being destroyed, remove if not required (e.g. obj is static) */ 58 static void handle_obj_cleanup(void *data, /* XXX: fill header */) 59 { 60 int id = /* XXX: how do I get the id? */; 61 da_destroy_storage(id); 62 } 63 64 static int enable_da_perobj_parent(void) 65 { 66 int retval; 67 68 retval = da_monitor_init(); 69 if (retval) 70 return retval; 71 72 rv_attach_trace_probe("da_perobj_parent", /* XXX: tracepoint */, handle_event_1); 73 rv_attach_trace_probe("da_perobj_parent", /* XXX: tracepoint */, handle_event_2); 74 rv_attach_trace_probe("da_perobj_parent", /* XXX: tracepoint */, handle_event_3); 75 rv_attach_trace_probe("da_perobj_parent", /* XXX: cleanup tracepoint */, handle_obj_cleanup); 76 77 return 0; 78 } 79 80 static void disable_da_perobj_parent(void) 81 { 82 rv_this.enabled = 0; 83 84 rv_detach_trace_probe("da_perobj_parent", /* XXX: tracepoint */, handle_event_1); 85 rv_detach_trace_probe("da_perobj_parent", /* XXX: tracepoint */, handle_event_2); 86 rv_detach_trace_probe("da_perobj_parent", /* XXX: tracepoint */, handle_event_3); 87 rv_detach_trace_probe("da_perobj_parent", /* XXX: cleanup tracepoint */, handle_obj_cleanup); 88 89 da_monitor_destroy(); 90 } 91 92 /* 93 * This is the monitor register section. 94 */ 95 static struct rv_monitor rv_this = { 96 .name = "da_perobj_parent", 97 .description = "auto-generated", 98 .enable = enable_da_perobj_parent, 99 .disable = disable_da_perobj_parent, 100 .reset = da_monitor_reset_all, 101 .enabled = 0, 102 }; 103 104 static int __init register_da_perobj_parent(void) 105 { 106 return rv_register_monitor(&rv_this, &rv_parent_mon); 107 } 108 109 static void __exit unregister_da_perobj_parent(void) 110 { 111 rv_unregister_monitor(&rv_this); 112 } 113 114 module_init(register_da_perobj_parent); 115 module_exit(unregister_da_perobj_parent); 116 117 MODULE_LICENSE("GPL"); 118 MODULE_AUTHOR("rvgen: auto-generated"); 119 MODULE_DESCRIPTION("da_perobj_parent: auto-generated"); 120