Commit | Line | Data |
---|---|---|
953c2f05 SRG |
1 | // SPDX-License-Identifier: GPL-2.0 |
2 | /* | |
3 | * event tracer | |
4 | * | |
5 | * Copyright (C) 2022 Google Inc, Steven Rostedt <rostedt@goodmis.org> | |
6 | */ | |
7 | ||
8 | #define pr_fmt(fmt) fmt | |
9 | ||
10 | #include <linux/trace_events.h> | |
11 | #include <linux/version.h> | |
12 | #include <linux/module.h> | |
13 | #include <linux/sched.h> | |
953c2f05 | 14 | |
3a73333f SRG |
15 | /* |
16 | * Must include the event header that the custom event will attach to, | |
17 | * from the C file, and not in the custom header file. | |
18 | */ | |
19 | #include <trace/events/sched.h> | |
953c2f05 | 20 | |
3a73333f SRG |
21 | /* Declare CREATE_CUSTOM_TRACE_EVENTS before including custom header */ |
22 | #define CREATE_CUSTOM_TRACE_EVENTS | |
953c2f05 | 23 | |
3a73333f | 24 | #include "trace_custom_sched.h" |
953c2f05 | 25 | |
3a73333f SRG |
26 | /* |
27 | * As the trace events are not exported to modules, the use of | |
28 | * for_each_kernel_tracepoint() is needed to find the trace event | |
29 | * to attach to. The fct() function below, is a callback that | |
30 | * will be called for every event. | |
31 | * | |
32 | * Helper functions are created by the TRACE_CUSTOM_EVENT() macro | |
33 | * update the event. Those are of the form: | |
34 | * | |
35 | * trace_custom_event_<event>_update() | |
36 | * | |
37 | * Where <event> is the event to attach. | |
38 | */ | |
953c2f05 SRG |
39 | static void fct(struct tracepoint *tp, void *priv) |
40 | { | |
3a73333f SRG |
41 | trace_custom_event_sched_switch_update(tp); |
42 | trace_custom_event_sched_waking_update(tp); | |
953c2f05 SRG |
43 | } |
44 | ||
45 | static int __init trace_sched_init(void) | |
46 | { | |
953c2f05 | 47 | for_each_kernel_tracepoint(fct, NULL); |
3a73333f | 48 | return 0; |
953c2f05 SRG |
49 | } |
50 | ||
51 | static void __exit trace_sched_exit(void) | |
52 | { | |
953c2f05 SRG |
53 | } |
54 | ||
55 | module_init(trace_sched_init); | |
56 | module_exit(trace_sched_exit); | |
57 | ||
58 | MODULE_AUTHOR("Steven Rostedt"); | |
59 | MODULE_DESCRIPTION("Custom scheduling events"); | |
60 | MODULE_LICENSE("GPL"); |