File: trace_custom_sched.c

package info (click to toggle)
linux 6.16.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,724,628 kB
  • sloc: ansic: 26,562,645; asm: 271,329; sh: 144,039; python: 72,469; makefile: 57,135; perl: 36,821; xml: 19,553; cpp: 5,820; yacc: 4,915; lex: 2,955; awk: 1,667; sed: 28; ruby: 25
file content (59 lines) | stat: -rw-r--r-- 1,442 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-License-Identifier: GPL-2.0
/*
 * event tracer
 *
 * Copyright (C) 2022 Google Inc, Steven Rostedt <rostedt@goodmis.org>
 */

#define pr_fmt(fmt) fmt

#include <linux/trace_events.h>
#include <linux/module.h>
#include <linux/sched.h>

/*
 * Must include the event header that the custom event will attach to,
 * from the C file, and not in the custom header file.
 */
#include <trace/events/sched.h>

/* Declare CREATE_CUSTOM_TRACE_EVENTS before including custom header */
#define CREATE_CUSTOM_TRACE_EVENTS

#include "trace_custom_sched.h"

/*
 * As the trace events are not exported to modules, the use of
 * for_each_kernel_tracepoint() is needed to find the trace event
 * to attach to. The fct() function below, is a callback that
 * will be called for every event.
 *
 * Helper functions are created by the TRACE_CUSTOM_EVENT() macro
 * update the event. Those are of the form:
 *
 *    trace_custom_event_<event>_update()
 *
 * Where <event> is the event to attach.
 */
static void fct(struct tracepoint *tp, void *priv)
{
	trace_custom_event_sched_switch_update(tp);
	trace_custom_event_sched_waking_update(tp);
}

static int __init trace_sched_init(void)
{
	for_each_kernel_tracepoint(fct, NULL);
	return 0;
}

static void __exit trace_sched_exit(void)
{
}

module_init(trace_sched_init);
module_exit(trace_sched_exit);

MODULE_AUTHOR("Steven Rostedt");
MODULE_DESCRIPTION("Custom scheduling events");
MODULE_LICENSE("GPL");