File Index
Files and directories
Sign in
FILE

snroc.c

File preview with syntax highlighting.

linux-6.19.14/kernel/trace/rv/monitors/snroc/snroc.c 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 "snroc"
12
13#include <trace/events/sched.h>
14#include <rv_trace.h>
15#include <monitors/sched/sched.h>
16
17#include "snroc.h"
18
19static struct rv_monitor rv_snroc;
20DECLARE_DA_MON_PER_TASK(snroc, unsigned char);
21
22static void handle_sched_set_state(void *data, struct task_struct *tsk, int state)
23{
24	da_handle_event_snroc(tsk, sched_set_state_snroc);
25}
26
27static void handle_sched_switch(void *data, bool preempt,
28				struct task_struct *prev,
29				struct task_struct *next,
30				unsigned int prev_state)
31{
32	da_handle_start_event_snroc(prev, sched_switch_out_snroc);
33	da_handle_event_snroc(next, sched_switch_in_snroc);
34}
35
36static int enable_snroc(void)
37{
38	int retval;
39
40	retval = da_monitor_init_snroc();
41	if (retval)
42		return retval;
43
44	rv_attach_trace_probe("snroc", sched_set_state_tp, handle_sched_set_state);
45	rv_attach_trace_probe("snroc", sched_switch, handle_sched_switch);
46
47	return 0;
48}
49
50static void disable_snroc(void)
51{
52	rv_snroc.enabled = 0;
53
54	rv_detach_trace_probe("snroc", sched_set_state_tp, handle_sched_set_state);
55	rv_detach_trace_probe("snroc", sched_switch, handle_sched_switch);
56
57	da_monitor_destroy_snroc();
58}
59
60static struct rv_monitor rv_snroc = {
61	.name = "snroc",
62	.description = "set non runnable on its own context.",
63	.enable = enable_snroc,
64	.disable = disable_snroc,
65	.reset = da_monitor_reset_all_snroc,
66	.enabled = 0,
67};
68
69static int __init register_snroc(void)
70{
71	return rv_register_monitor(&rv_snroc, &rv_sched);
72}
73
74static void __exit unregister_snroc(void)
75{
76	rv_unregister_monitor(&rv_snroc);
77}
78
79module_init(register_snroc);
80module_exit(unregister_snroc);
81
82MODULE_LICENSE("GPL");
83MODULE_AUTHOR("Gabriele Monaco <gmonaco@redhat.com>");
84MODULE_DESCRIPTION("snroc: set non runnable on its own context.");
~/ Read-only file preview.