FILE
scpd.c
File preview with syntax highlighting.
linux-6.19.14/kernel/trace/rv/monitors/scpd/scpd.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 "scpd" 12 13#include <trace/events/sched.h> 14#include <trace/events/preemptirq.h> 15#include <rv_trace.h> 16#include <monitors/sched/sched.h> 17 18#include "scpd.h" 19 20static struct rv_monitor rv_scpd; 21DECLARE_DA_MON_PER_CPU(scpd, unsigned char); 22 23static void handle_preempt_disable(void *data, unsigned long ip, unsigned long parent_ip) 24{ 25 da_handle_event_scpd(preempt_disable_scpd); 26} 27 28static void handle_preempt_enable(void *data, unsigned long ip, unsigned long parent_ip) 29{ 30 da_handle_start_event_scpd(preempt_enable_scpd); 31} 32 33static void handle_schedule_entry(void *data, bool preempt) 34{ 35 da_handle_event_scpd(schedule_entry_scpd); 36} 37 38static void handle_schedule_exit(void *data, bool is_switch) 39{ 40 da_handle_event_scpd(schedule_exit_scpd); 41} 42 43static int enable_scpd(void) 44{ 45 int retval; 46 47 retval = da_monitor_init_scpd(); 48 if (retval) 49 return retval; 50 51 rv_attach_trace_probe("scpd", preempt_disable, handle_preempt_disable); 52 rv_attach_trace_probe("scpd", preempt_enable, handle_preempt_enable); 53 rv_attach_trace_probe("scpd", sched_entry_tp, handle_schedule_entry); 54 rv_attach_trace_probe("scpd", sched_exit_tp, handle_schedule_exit); 55 56 return 0; 57} 58 59static void disable_scpd(void) 60{ 61 rv_scpd.enabled = 0; 62 63 rv_detach_trace_probe("scpd", preempt_disable, handle_preempt_disable); 64 rv_detach_trace_probe("scpd", preempt_enable, handle_preempt_enable); 65 rv_detach_trace_probe("scpd", sched_entry_tp, handle_schedule_entry); 66 rv_detach_trace_probe("scpd", sched_exit_tp, handle_schedule_exit); 67 68 da_monitor_destroy_scpd(); 69} 70 71static struct rv_monitor rv_scpd = { 72 .name = "scpd", 73 .description = "schedule called with preemption disabled.", 74 .enable = enable_scpd, 75 .disable = disable_scpd, 76 .reset = da_monitor_reset_all_scpd, 77 .enabled = 0, 78}; 79 80static int __init register_scpd(void) 81{ 82 return rv_register_monitor(&rv_scpd, &rv_sched); 83} 84 85static void __exit unregister_scpd(void) 86{ 87 rv_unregister_monitor(&rv_scpd); 88} 89 90module_init(register_scpd); 91module_exit(unregister_scpd); 92 93MODULE_LICENSE("GPL"); 94MODULE_AUTHOR("Gabriele Monaco <gmonaco@redhat.com>"); 95MODULE_DESCRIPTION("scpd: schedule called with preemption disabled.");
~/
Read-only file preview.