Path: blob/master/samples/trace_events/trace_custom_sched.h
26285 views
/* SPDX-License-Identifier: GPL-2.0 */12/*3* Like the headers that use TRACE_EVENT(), the TRACE_CUSTOM_EVENT()4* needs a header that allows for multiple inclusions.5*6* Test for a unique name (here we have _TRACE_CUSTOM_SCHED_H),7* also allowing to continue if TRACE_CUSTOM_MULTI_READ is defined.8*/9#if !defined(_TRACE_CUSTOM_SCHED_H) || defined(TRACE_CUSTOM_MULTI_READ)10#define _TRACE_CUSTOM_SCHED_H1112/* Include linux/trace_events.h for initial defines of TRACE_CUSTOM_EVENT() */13#include <linux/trace_events.h>1415/*16* TRACE_CUSTOM_EVENT() is just like TRACE_EVENT(). The first parameter17* is the event name of an existing event where the TRACE_EVENT has been included18* in the C file before including this file.19*/20TRACE_CUSTOM_EVENT(sched_switch,2122/*23* The TP_PROTO() and TP_ARGS must match the trace event24* that the custom event is using.25*/26TP_PROTO(bool preempt,27struct task_struct *prev,28struct task_struct *next,29unsigned int prev_state),3031TP_ARGS(preempt, prev, next, prev_state),3233/*34* The next fields are where the customization happens.35* The TP_STRUCT__entry() defines what will be recorded36* in the ring buffer when the custom event triggers.37*38* The rest is just like the TRACE_EVENT() macro except that39* it uses the custom entry.40*/41TP_STRUCT__entry(42__field( unsigned short, prev_prio )43__field( unsigned short, next_prio )44__field( pid_t, next_pid )45),4647TP_fast_assign(48__entry->prev_prio = prev->prio;49__entry->next_pid = next->pid;50__entry->next_prio = next->prio;51),5253TP_printk("prev_prio=%d next_pid=%d next_prio=%d",54__entry->prev_prio, __entry->next_pid, __entry->next_prio)55)565758TRACE_CUSTOM_EVENT(sched_waking,5960TP_PROTO(struct task_struct *p),6162TP_ARGS(p),6364TP_STRUCT__entry(65__field( pid_t, pid )66__field( unsigned short, prio )67),6869TP_fast_assign(70__entry->pid = p->pid;71__entry->prio = p->prio;72),7374TP_printk("pid=%d prio=%d", __entry->pid, __entry->prio)75)76#endif77/*78* Just like the headers that create TRACE_EVENTs, the below must79* be outside the protection of the above #if block.80*/8182/*83* It is required that the Makefile includes:84* CFLAGS_<c_file>.o := -I$(src)85*/86#undef TRACE_INCLUDE_PATH87#undef TRACE_INCLUDE_FILE88#define TRACE_INCLUDE_PATH .8990/*91* It is requred that the TRACE_INCLUDE_FILE be the same92* as this file without the ".h".93*/94#define TRACE_INCLUDE_FILE trace_custom_sched95#include <trace/define_custom_trace.h>969798