mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
3a73333fb3
To make it really easy to add custom events from modules, add a TRACE_CUSTOM_EVENT() macro that acts just like the TRACE_EVENT() macro, but creates a custom event to an already existing tracepoint. The trace_custom_sched.[ch] has been updated to use this new macro to show how simple it is. Link: https://lkml.kernel.org/r/20220303220625.738622494@goodmis.org Cc: Ingo Molnar <mingo@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Joel Fernandes <joel@joelfernandes.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Tom Zanussi <zanussi@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
61 lines
1.4 KiB
C
61 lines
1.4 KiB
C
// 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/version.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");
|