0001
0002 #include <linux/ftrace.h>
0003 #include <linux/tracepoint.h>
0004 #include <linux/kernel.h>
0005 #include <linux/module.h>
0006 #include <linux/init.h>
0007 #include <linux/rv.h>
0008 #include <rv/instrumentation.h>
0009 #include <rv/da_monitor.h>
0010
0011 #define MODULE_NAME "wip"
0012
0013 #include <trace/events/rv.h>
0014 #include <trace/events/sched.h>
0015 #include <trace/events/preemptirq.h>
0016
0017 #include "wip.h"
0018
0019 struct rv_monitor rv_wip;
0020 DECLARE_DA_MON_PER_CPU(wip, unsigned char);
0021
0022 static void handle_preempt_disable(void *data, unsigned long ip, unsigned long parent_ip)
0023 {
0024 da_handle_event_wip(preempt_disable_wip);
0025 }
0026
0027 static void handle_preempt_enable(void *data, unsigned long ip, unsigned long parent_ip)
0028 {
0029 da_handle_start_event_wip(preempt_enable_wip);
0030 }
0031
0032 static void handle_sched_waking(void *data, struct task_struct *task)
0033 {
0034 da_handle_event_wip(sched_waking_wip);
0035 }
0036
0037 static int enable_wip(void)
0038 {
0039 int retval;
0040
0041 retval = da_monitor_init_wip();
0042 if (retval)
0043 return retval;
0044
0045 rv_attach_trace_probe("wip", preempt_enable, handle_preempt_enable);
0046 rv_attach_trace_probe("wip", sched_waking, handle_sched_waking);
0047 rv_attach_trace_probe("wip", preempt_disable, handle_preempt_disable);
0048
0049 return 0;
0050 }
0051
0052 static void disable_wip(void)
0053 {
0054 rv_wip.enabled = 0;
0055
0056 rv_detach_trace_probe("wip", preempt_disable, handle_preempt_disable);
0057 rv_detach_trace_probe("wip", preempt_enable, handle_preempt_enable);
0058 rv_detach_trace_probe("wip", sched_waking, handle_sched_waking);
0059
0060 da_monitor_destroy_wip();
0061 }
0062
0063 struct rv_monitor rv_wip = {
0064 .name = "wip",
0065 .description = "wakeup in preemptive per-cpu testing monitor.",
0066 .enable = enable_wip,
0067 .disable = disable_wip,
0068 .reset = da_monitor_reset_all_wip,
0069 .enabled = 0,
0070 };
0071
0072 static int register_wip(void)
0073 {
0074 rv_register_monitor(&rv_wip);
0075 return 0;
0076 }
0077
0078 static void unregister_wip(void)
0079 {
0080 rv_unregister_monitor(&rv_wip);
0081 }
0082
0083 module_init(register_wip);
0084 module_exit(unregister_wip);
0085
0086 MODULE_LICENSE("GPL");
0087 MODULE_AUTHOR("Daniel Bristot de Oliveira <bristot@kernel.org>");
0088 MODULE_DESCRIPTION("wip: wakeup in preemptive - per-cpu sample monitor.");