Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 /*
0004  * Like the headers that use TRACE_EVENT(), the TRACE_CUSTOM_EVENT()
0005  * needs a header that allows for multiple inclusions.
0006  *
0007  * Test for a unique name (here we have _TRACE_CUSTOM_SCHED_H),
0008  * also allowing to continue if TRACE_CUSTOM_MULTI_READ is defined.
0009  */
0010 #if !defined(_TRACE_CUSTOM_SCHED_H) || defined(TRACE_CUSTOM_MULTI_READ)
0011 #define _TRACE_CUSTOM_SCHED_H
0012 
0013 /* Include linux/trace_events.h for initial defines of TRACE_CUSTOM_EVENT() */
0014 #include <linux/trace_events.h>
0015 
0016 /*
0017  * TRACE_CUSTOM_EVENT() is just like TRACE_EVENT(). The first parameter
0018  * is the event name of an existing event where the TRACE_EVENT has been included
0019  * in the C file before including this file.
0020  */
0021 TRACE_CUSTOM_EVENT(sched_switch,
0022 
0023     /*
0024      * The TP_PROTO() and TP_ARGS must match the trace event
0025      * that the custom event is using.
0026      */
0027     TP_PROTO(bool preempt,
0028          struct task_struct *prev,
0029          struct task_struct *next,
0030          unsigned int prev_state),
0031 
0032     TP_ARGS(preempt, prev, next, prev_state),
0033 
0034     /*
0035      * The next fields are where the customization happens.
0036      * The TP_STRUCT__entry() defines what will be recorded
0037      * in the ring buffer when the custom event triggers.
0038      *
0039      * The rest is just like the TRACE_EVENT() macro except that
0040      * it uses the custom entry.
0041      */
0042     TP_STRUCT__entry(
0043         __field(    unsigned short,     prev_prio   )
0044         __field(    unsigned short,     next_prio   )
0045         __field(    pid_t,  next_pid            )
0046     ),
0047 
0048     TP_fast_assign(
0049         __entry->prev_prio  = prev->prio;
0050         __entry->next_pid   = next->pid;
0051         __entry->next_prio  = next->prio;
0052     ),
0053 
0054     TP_printk("prev_prio=%d next_pid=%d next_prio=%d",
0055           __entry->prev_prio, __entry->next_pid, __entry->next_prio)
0056 )
0057 
0058 
0059 TRACE_CUSTOM_EVENT(sched_waking,
0060 
0061     TP_PROTO(struct task_struct *p),
0062 
0063     TP_ARGS(p),
0064 
0065     TP_STRUCT__entry(
0066         __field(    pid_t,          pid )
0067         __field(    unsigned short,     prio    )
0068     ),
0069 
0070     TP_fast_assign(
0071         __entry->pid    = p->pid;
0072         __entry->prio   = p->prio;
0073     ),
0074 
0075     TP_printk("pid=%d prio=%d", __entry->pid, __entry->prio)
0076 )
0077 #endif
0078 /*
0079  * Just like the headers that create TRACE_EVENTs, the below must
0080  * be outside the protection of the above #if block.
0081  */
0082 
0083 /*
0084  * It is required that the Makefile includes:
0085  *    CFLAGS_<c_file>.o := -I$(src)
0086  */
0087 #undef TRACE_INCLUDE_PATH
0088 #undef TRACE_INCLUDE_FILE
0089 #define TRACE_INCLUDE_PATH .
0090 
0091 /*
0092  * It is requred that the TRACE_INCLUDE_FILE be the same
0093  * as this file without the ".h".
0094  */
0095 #define TRACE_INCLUDE_FILE trace_custom_sched
0096 #include <trace/define_custom_trace.h>