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>
8 #include <rv/instrumentation.h>
9 #include <rv/da_monitor.h>
11 #define MODULE_NAME "wip"
13 #include <trace/events/rv.h>
14 #include <trace/events/sched.h>
15 #include <trace/events/preemptirq.h>
19 static struct rv_monitor rv_wip;
20 DECLARE_DA_MON_PER_CPU(wip, unsigned char);
22 static void handle_preempt_disable(void *data, unsigned long ip, unsigned long parent_ip)
24 da_handle_event_wip(preempt_disable_wip);
27 static void handle_preempt_enable(void *data, unsigned long ip, unsigned long parent_ip)
29 da_handle_start_event_wip(preempt_enable_wip);
32 static void handle_sched_waking(void *data, struct task_struct *task)
34 da_handle_event_wip(sched_waking_wip);
37 static int enable_wip(void)
41 retval = da_monitor_init_wip();
45 rv_attach_trace_probe("wip", preempt_enable, handle_preempt_enable);
46 rv_attach_trace_probe("wip", sched_waking, handle_sched_waking);
47 rv_attach_trace_probe("wip", preempt_disable, handle_preempt_disable);
52 static void disable_wip(void)
56 rv_detach_trace_probe("wip", preempt_disable, handle_preempt_disable);
57 rv_detach_trace_probe("wip", preempt_enable, handle_preempt_enable);
58 rv_detach_trace_probe("wip", sched_waking, handle_sched_waking);
60 da_monitor_destroy_wip();
63 static struct rv_monitor rv_wip = {
65 .description = "wakeup in preemptive per-cpu testing monitor.",
67 .disable = disable_wip,
68 .reset = da_monitor_reset_all_wip,
72 static int __init register_wip(void)
74 rv_register_monitor(&rv_wip);
78 static void __exit unregister_wip(void)
80 rv_unregister_monitor(&rv_wip);
83 module_init(register_wip);
84 module_exit(unregister_wip);
86 MODULE_LICENSE("GPL");
87 MODULE_AUTHOR("Daniel Bristot de Oliveira <bristot@kernel.org>");
88 MODULE_DESCRIPTION("wip: wakeup in preemptive - per-cpu sample monitor.");