Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * event tracer
0004  *
0005  * Copyright (C) 2022 Google Inc, Steven Rostedt <rostedt@goodmis.org>
0006  */
0007 
0008 #define pr_fmt(fmt) fmt
0009 
0010 #include <linux/trace_events.h>
0011 #include <linux/version.h>
0012 #include <linux/module.h>
0013 #include <linux/sched.h>
0014 
0015 /*
0016  * Must include the event header that the custom event will attach to,
0017  * from the C file, and not in the custom header file.
0018  */
0019 #include <trace/events/sched.h>
0020 
0021 /* Declare CREATE_CUSTOM_TRACE_EVENTS before including custom header */
0022 #define CREATE_CUSTOM_TRACE_EVENTS
0023 
0024 #include "trace_custom_sched.h"
0025 
0026 /*
0027  * As the trace events are not exported to modules, the use of
0028  * for_each_kernel_tracepoint() is needed to find the trace event
0029  * to attach to. The fct() function below, is a callback that
0030  * will be called for every event.
0031  *
0032  * Helper functions are created by the TRACE_CUSTOM_EVENT() macro
0033  * update the event. Those are of the form:
0034  *
0035  *    trace_custom_event_<event>_update()
0036  *
0037  * Where <event> is the event to attach.
0038  */
0039 static void fct(struct tracepoint *tp, void *priv)
0040 {
0041     trace_custom_event_sched_switch_update(tp);
0042     trace_custom_event_sched_waking_update(tp);
0043 }
0044 
0045 static int __init trace_sched_init(void)
0046 {
0047     for_each_kernel_tracepoint(fct, NULL);
0048     return 0;
0049 }
0050 
0051 static void __exit trace_sched_exit(void)
0052 {
0053 }
0054 
0055 module_init(trace_sched_init);
0056 module_exit(trace_sched_exit);
0057 
0058 MODULE_AUTHOR("Steven Rostedt");
0059 MODULE_DESCRIPTION("Custom scheduling events");
0060 MODULE_LICENSE("GPL");