1 /* SPDX-License-Identifier: GPL-2.0 */
4 * Like the headers that use TRACE_EVENT(), the TRACE_CUSTOM_EVENT()
5 * needs a header that allows for multiple inclusions.
7 * Test for a unique name (here we have _TRACE_CUSTOM_SCHED_H),
8 * also allowing to continue if TRACE_CUSTOM_MULTI_READ is defined.
10 #if !defined(_TRACE_CUSTOM_SCHED_H) || defined(TRACE_CUSTOM_MULTI_READ)
11 #define _TRACE_CUSTOM_SCHED_H
13 /* Include linux/trace_events.h for initial defines of TRACE_CUSTOM_EVENT() */
14 #include <linux/trace_events.h>
17 * TRACE_CUSTOM_EVENT() is just like TRACE_EVENT(). The first parameter
18 * is the event name of an existing event where the TRACE_EVENT has been included
19 * in the C file before including this file.
21 TRACE_CUSTOM_EVENT(sched_switch
,
24 * The TP_PROTO() and TP_ARGS must match the trace event
25 * that the custom event is using.
27 TP_PROTO(bool preempt
,
28 struct task_struct
*prev
,
29 struct task_struct
*next
,
30 unsigned int prev_state
),
32 TP_ARGS(preempt
, prev
, next
, prev_state
),
35 * The next fields are where the customization happens.
36 * The TP_STRUCT__entry() defines what will be recorded
37 * in the ring buffer when the custom event triggers.
39 * The rest is just like the TRACE_EVENT() macro except that
40 * it uses the custom entry.
43 __field( unsigned short, prev_prio
)
44 __field( unsigned short, next_prio
)
45 __field( pid_t
, next_pid
)
49 __entry
->prev_prio
= prev
->prio
;
50 __entry
->next_pid
= next
->pid
;
51 __entry
->next_prio
= next
->prio
;
54 TP_printk("prev_prio=%d next_pid=%d next_prio=%d",
55 __entry
->prev_prio
, __entry
->next_pid
, __entry
->next_prio
)
59 TRACE_CUSTOM_EVENT(sched_waking
,
61 TP_PROTO(struct task_struct
*p
),
67 __field( unsigned short, prio
)
71 __entry
->pid
= p
->pid
;
72 __entry
->prio
= p
->prio
;
75 TP_printk("pid=%d prio=%d", __entry
->pid
, __entry
->prio
)
79 * Just like the headers that create TRACE_EVENTs, the below must
80 * be outside the protection of the above #if block.
84 * It is required that the Makefile includes:
85 * CFLAGS_<c_file>.o := -I$(src)
87 #undef TRACE_INCLUDE_PATH
88 #undef TRACE_INCLUDE_FILE
89 #define TRACE_INCLUDE_PATH .
92 * It is requred that the TRACE_INCLUDE_FILE be the same
93 * as this file without the ".h".
95 #define TRACE_INCLUDE_FILE trace_custom_sched
96 #include <trace/define_custom_trace.h>