FILE
sco.c
File preview with syntax highlighting.
linux-6.19.14/kernel/trace/rv/monitors/sco/sco.c
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 11#define MODULE_NAME "sco" 12 13#include <trace/events/sched.h> 14#include <rv_trace.h> 15#include <monitors/sched/sched.h> 16 17#include "sco.h" 18 19static struct rv_monitor rv_sco; 20DECLARE_DA_MON_PER_CPU(sco, unsigned char); 21 22static void handle_sched_set_state(void *data, struct task_struct *tsk, int state) 23{ 24 da_handle_start_event_sco(sched_set_state_sco); 25} 26 27static void handle_schedule_entry(void *data, bool preempt) 28{ 29 da_handle_event_sco(schedule_entry_sco); 30} 31 32static void handle_schedule_exit(void *data, bool is_switch) 33{ 34 da_handle_start_event_sco(schedule_exit_sco); 35} 36 37static int enable_sco(void) 38{ 39 int retval; 40 41 retval = da_monitor_init_sco(); 42 if (retval) 43 return retval; 44 45 rv_attach_trace_probe("sco", sched_set_state_tp, handle_sched_set_state); 46 rv_attach_trace_probe("sco", sched_entry_tp, handle_schedule_entry); 47 rv_attach_trace_probe("sco", sched_exit_tp, handle_schedule_exit); 48 49 return 0; 50} 51 52static void disable_sco(void) 53{ 54 rv_sco.enabled = 0; 55 56 rv_detach_trace_probe("sco", sched_set_state_tp, handle_sched_set_state); 57 rv_detach_trace_probe("sco", sched_entry_tp, handle_schedule_entry); 58 rv_detach_trace_probe("sco", sched_exit_tp, handle_schedule_exit); 59 60 da_monitor_destroy_sco(); 61} 62 63static struct rv_monitor rv_sco = { 64 .name = "sco", 65 .description = "scheduling context operations.", 66 .enable = enable_sco, 67 .disable = disable_sco, 68 .reset = da_monitor_reset_all_sco, 69 .enabled = 0, 70}; 71 72static int __init register_sco(void) 73{ 74 return rv_register_monitor(&rv_sco, &rv_sched); 75} 76 77static void __exit unregister_sco(void) 78{ 79 rv_unregister_monitor(&rv_sco); 80} 81 82module_init(register_sco); 83module_exit(unregister_sco); 84 85MODULE_LICENSE("GPL"); 86MODULE_AUTHOR("Gabriele Monaco <gmonaco@redhat.com>"); 87MODULE_DESCRIPTION("sco: scheduling context operations.");
~/
Read-only file preview.