• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM rtg
4 
5 #if !defined(_TRACE_RTG_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_RTG_H
7 
8 #include <linux/trace_seq.h>
9 #include <linux/tracepoint.h>
10 #include <linux/sched/frame_rtg.h>
11 
12 struct rq;
13 
14 TRACE_EVENT(find_rtg_cpu,
15 
16 	TP_PROTO(struct task_struct *p, const struct cpumask *perferred_cpumask,
17 		 char *msg, int cpu),
18 
19 	TP_ARGS(p, perferred_cpumask, msg, cpu),
20 
21 	TP_STRUCT__entry(
22 		__array(char, comm, TASK_COMM_LEN)
23 		__field(pid_t, pid)
24 		__bitmask(cpus,	num_possible_cpus())
25 		__array(char, msg, TASK_COMM_LEN)
26 		__field(int, cpu)
27 	),
28 
29 	TP_fast_assign(
30 		__entry->pid = p->pid;
31 		memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
32 		__assign_bitmask(cpus, cpumask_bits(perferred_cpumask), num_possible_cpus());
33 		memcpy(__entry->msg, msg, min((size_t)TASK_COMM_LEN, strlen(msg)+1));
34 		__entry->cpu = cpu;
35 	),
36 
37 	TP_printk("comm=%s pid=%d perferred_cpus=%s reason=%s target_cpu=%d",
38 		__entry->comm, __entry->pid, __get_bitmask(cpus), __entry->msg, __entry->cpu)
39 );
40 
41 TRACE_EVENT(sched_rtg_task_each,
42 
43 	TP_PROTO(unsigned int id, unsigned int nr_running, struct task_struct *task),
44 
45 	TP_ARGS(id, nr_running, task),
46 
47 	TP_STRUCT__entry(
48 		__field(unsigned int,	id)
49 		__field(unsigned int,	nr_running)
50 		__array(char,	comm,	TASK_COMM_LEN)
51 		__field(pid_t,		pid)
52 		__field(int,		prio)
53 		__bitmask(allowed, num_possible_cpus())
54 		__field(int,		cpu)
55 		__field(int,		state)
56 		__field(bool,		on_rq)
57 		__field(int,		on_cpu)
58 	),
59 
60 	TP_fast_assign(
61 		__entry->id		= id;
62 		__entry->nr_running	= nr_running;
63 		memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
64 		__entry->pid		= task->pid;
65 		__entry->prio		= task->prio;
66 		__assign_bitmask(allowed, cpumask_bits(&task->cpus_mask), num_possible_cpus());
67 		__entry->cpu		= task_cpu(task);
68 		__entry->state		= task->state;
69 		__entry->on_rq		= task->on_rq;
70 		__entry->on_cpu		= task->on_cpu;
71 	),
72 
73 	TP_printk("comm=%s pid=%d prio=%d allowed=%s cpu=%d state=%s%s on_rq=%d on_cpu=%d",
74 		__entry->comm, __entry->pid, __entry->prio, __get_bitmask(allowed), __entry->cpu,
75 		__entry->state & (TASK_REPORT_MAX) ?
76 		__print_flags(__entry->state & (TASK_REPORT_MAX), "|",
77 				{ TASK_INTERRUPTIBLE, "S" },
78 				{ TASK_UNINTERRUPTIBLE, "D" },
79 				{ __TASK_STOPPED, "T" },
80 				{ __TASK_TRACED, "t" },
81 				{ EXIT_DEAD, "X" },
82 				{ EXIT_ZOMBIE, "Z" },
83 				{ TASK_DEAD, "x" },
84 				{ TASK_WAKEKILL, "K"},
85 				{ TASK_WAKING, "W"}) : "R",
86 		__entry->state & TASK_STATE_MAX ? "+" : "",
87 		__entry->on_rq, __entry->on_cpu)
88 );
89 
90 TRACE_EVENT(sched_rtg_valid_normalized_util,
91 
92 	TP_PROTO(unsigned int id, unsigned int nr_running,
93 		 const struct cpumask *rtg_cpus, unsigned int valid),
94 
95 	TP_ARGS(id, nr_running, rtg_cpus, valid),
96 
97 	TP_STRUCT__entry(
98 		__field(unsigned int,	id)
99 		__field(unsigned int,	nr_running)
100 		__bitmask(cpus,	num_possible_cpus())
101 		__field(unsigned int,	valid)
102 	),
103 
104 	TP_fast_assign(
105 		__entry->id		= id;
106 		__entry->nr_running	= nr_running;
107 		__assign_bitmask(cpus, cpumask_bits(rtg_cpus), num_possible_cpus());
108 		__entry->valid		= valid;
109 	),
110 
111 	TP_printk("id=%d nr_running=%d cpus=%s valid=%d",
112 		__entry->id, __entry->nr_running,
113 		__get_bitmask(cpus), __entry->valid)
114 );
115 
116 #ifdef CONFIG_SCHED_RTG_FRAME
117 TRACE_EVENT(rtg_frame_sched,
118 
119 	TP_PROTO(int rtgid, const char *s, s64 value),
120 
121 	TP_ARGS(rtgid, s, value),
122 	TP_STRUCT__entry(
123 		__field(int, rtgid)
124 		__field(struct frame_info *, frame)
125 		__field(pid_t, pid)
126 		__string(str, s)
127 		__field(s64, value)
128 	),
129 
130 	TP_fast_assign(
131 		__assign_str(str, s);
132 		__entry->rtgid = rtgid != -1 ? rtgid : (current->grp ? current->grp->id : 0);
133 		__entry->frame = rtg_frame_info(rtgid);
134 		__entry->pid = __entry->frame ? ((__entry->frame->thread[0]) ?
135 						 ((__entry->frame->thread[0])->pid) :
136 						 current->tgid) : current->tgid;
137 		__entry->value = value;
138 	),
139 	TP_printk("C|%d|%s_%d|%lld", __entry->pid, __get_str(str), __entry->rtgid, __entry->value)
140 );
141 #endif
142 #endif /* _TRACE_RTG_H */
143 
144 /* This part must be outside protection */
145 #include <trace/define_trace.h>
146