-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftrace_events.h
387 lines (303 loc) · 10.7 KB
/
ftrace_events.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM lisa
#define MAX_SPAN_SIZE 128
#if !defined(_FTRACE_EVENTS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _FTRACE_EVENTS_H
#define PATH_SIZE 64
#define __SPAN_SIZE (round_up(NR_CPUS, 4)/4)
#define SPAN_SIZE (__SPAN_SIZE > MAX_SPAN_SIZE ? MAX_SPAN_SIZE : __SPAN_SIZE)
#include <linux/version.h>
#include <linux/tracepoint.h>
#include <linux/version.h>
#include "sched_helpers.h"
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,6,0)
#define RBL_LOAD_ENTRY rbl_load
#define RBL_LOAD_MEMBER runnable_load_avg
#define RBL_LOAD_STR "rbl_load"
#else
#define RBL_LOAD_ENTRY runnable
#define RBL_LOAD_MEMBER runnable_avg
#define RBL_LOAD_STR "runnable"
#endif
TRACE_EVENT(lisa__sched_pelt_cfs,
TP_PROTO(int cpu, char *path, const struct sched_avg *avg),
TP_ARGS(cpu, path, avg),
TP_STRUCT__entry(
__field( int, cpu )
__array( char, path, PATH_SIZE )
__field( unsigned long, load )
__field( unsigned long, RBL_LOAD_ENTRY )
__field( unsigned long, util )
__field( unsigned long long, update_time )
),
TP_fast_assign(
__entry->cpu = cpu;
strlcpy(__entry->path, path, PATH_SIZE);
__entry->load = avg->load_avg;
__entry->RBL_LOAD_ENTRY = avg->RBL_LOAD_MEMBER;
__entry->util = avg->util_avg;
__entry->update_time = avg->last_update_time;
),
TP_printk("cpu=%d path=%s load=%lu " RBL_LOAD_STR "=%lu util=%lu update_time=%llu",
__entry->cpu, __entry->path, __entry->load,
__entry->RBL_LOAD_ENTRY,__entry->util, __entry->update_time)
);
DECLARE_EVENT_CLASS(lisa__sched_pelt_rq_template,
TP_PROTO(int cpu, const struct sched_avg *avg),
TP_ARGS(cpu, avg),
TP_STRUCT__entry(
__field( int, cpu )
__field( unsigned long, load )
__field( unsigned long, RBL_LOAD_ENTRY )
__field( unsigned long, util )
__field( unsigned long long, update_time )
),
TP_fast_assign(
__entry->cpu = cpu;
__entry->load = avg->load_avg;
__entry->RBL_LOAD_ENTRY = avg->RBL_LOAD_MEMBER;
__entry->util = avg->util_avg;
__entry->update_time = avg->last_update_time;
),
TP_printk("cpu=%d load=%lu " RBL_LOAD_STR "=%lu util=%lu update_time=%llu",
__entry->cpu, __entry->load,
__entry->RBL_LOAD_ENTRY,__entry->util, __entry->update_time)
);
DEFINE_EVENT(lisa__sched_pelt_rq_template, lisa__sched_pelt_rt,
TP_PROTO(int cpu, const struct sched_avg *avg),
TP_ARGS(cpu, avg));
DEFINE_EVENT(lisa__sched_pelt_rq_template, lisa__sched_pelt_dl,
TP_PROTO(int cpu, const struct sched_avg *avg),
TP_ARGS(cpu, avg));
DEFINE_EVENT(lisa__sched_pelt_rq_template, lisa__sched_pelt_irq,
TP_PROTO(int cpu, const struct sched_avg *avg),
TP_ARGS(cpu, avg));
TRACE_EVENT(lisa__sched_pelt_se,
TP_PROTO(int cpu, char *path, char *comm, int pid, const struct sched_avg *avg),
TP_ARGS(cpu, path, comm, pid, avg),
TP_STRUCT__entry(
__field( int, cpu )
__array( char, path, PATH_SIZE )
__array( char, comm, TASK_COMM_LEN )
__field( int, pid )
__field( unsigned long, load )
__field( unsigned long, RBL_LOAD_ENTRY )
__field( unsigned long, util )
__field( unsigned long long, update_time )
),
TP_fast_assign(
__entry->cpu = cpu;
strlcpy(__entry->path, path, PATH_SIZE);
strlcpy(__entry->comm, comm, TASK_COMM_LEN);
__entry->pid = pid;
__entry->load = avg->load_avg;
__entry->RBL_LOAD_ENTRY = avg->RBL_LOAD_MEMBER;
__entry->util = avg->util_avg;
__entry->update_time = avg->last_update_time;
),
TP_printk("cpu=%d path=%s comm=%s pid=%d load=%lu " RBL_LOAD_STR "=%lu util=%lu update_time=%llu",
__entry->cpu, __entry->path, __entry->comm, __entry->pid,
__entry->load, __entry->RBL_LOAD_ENTRY,__entry->util, __entry->update_time)
);
TRACE_EVENT(lisa__sched_overutilized,
TP_PROTO(int overutilized, char *span),
TP_ARGS(overutilized, span),
TP_STRUCT__entry(
__field( int, overutilized )
__array( char, span, SPAN_SIZE )
),
TP_fast_assign(
__entry->overutilized = overutilized;
strlcpy(__entry->span, span, SPAN_SIZE);
),
TP_printk("overutilized=%d span=0x%s",
__entry->overutilized, __entry->span)
);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
TRACE_EVENT(lisa__sched_update_nr_running,
TP_PROTO(int cpu, int change, unsigned int nr_running),
TP_ARGS(cpu, change, nr_running),
TP_STRUCT__entry(
__field( int, cpu )
__field( int, change )
__field(unsigned int, nr_running )
),
TP_fast_assign(
__entry->cpu = cpu;
__entry->change = change;
__entry->nr_running = nr_running;
),
TP_printk("cpu=%d change=%d nr_running=%d", __entry->cpu, __entry->change, __entry->nr_running)
);
TRACE_EVENT(lisa__sched_util_est_se,
TP_PROTO(int cpu, char *path, char *comm, int pid,
const struct sched_avg *avg),
TP_ARGS(cpu, path, comm, pid, avg),
TP_STRUCT__entry(
__field( int, cpu )
__array( char, path, PATH_SIZE )
__array( char, comm, TASK_COMM_LEN )
__field( int, pid )
__field( unsigned int, enqueued )
__field( unsigned int, ewma )
__field( unsigned long, util )
),
TP_fast_assign(
__entry->cpu = cpu;
strlcpy(__entry->path, path, PATH_SIZE);
strlcpy(__entry->comm, comm, TASK_COMM_LEN);
__entry->pid = pid;
__entry->enqueued = avg->util_est.enqueued & ~UTIL_AVG_UNCHANGED;
__entry->ewma = avg->util_est.ewma;
__entry->util = avg->util_avg;
),
TP_printk("cpu=%d path=%s comm=%s pid=%d enqueued=%u ewma=%u util=%lu",
__entry->cpu, __entry->path, __entry->comm, __entry->pid,
__entry->enqueued, __entry->ewma, __entry->util)
);
TRACE_EVENT(lisa__sched_util_est_cfs,
TP_PROTO(int cpu, char *path, const struct sched_avg *avg),
TP_ARGS(cpu, path, avg),
TP_STRUCT__entry(
__field( int, cpu )
__array( char, path, PATH_SIZE )
__field( unsigned int, enqueued )
__field( unsigned int, ewma )
__field( unsigned long, util )
),
TP_fast_assign(
__entry->cpu = cpu;
strlcpy(__entry->path, path, PATH_SIZE);
__entry->enqueued = avg->util_est.enqueued;
__entry->ewma = avg->util_est.ewma;
__entry->util = avg->util_avg;
),
TP_printk("cpu=%d path=%s enqueued=%u ewma=%u util=%lu",
__entry->cpu, __entry->path, __entry->enqueued,
__entry->ewma, __entry->util)
);
#endif
#ifdef CONFIG_UCLAMP_TASK
TRACE_EVENT_CONDITION(lisa__uclamp_util_se,
TP_PROTO(bool is_task, struct task_struct *p, struct rq *rq),
TP_ARGS(is_task, p, rq),
TP_CONDITION(is_task),
TP_STRUCT__entry(
__field( pid_t, pid )
__array( char, comm, TASK_COMM_LEN )
__field( int, cpu )
__field(unsigned long, util_avg )
__field(unsigned long, uclamp_avg )
__field(unsigned long, uclamp_min )
__field(unsigned long, uclamp_max )
),
TP_fast_assign(
__entry->pid = p->pid;
memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
__entry->cpu = lisa_rq_cpu(rq);
__entry->util_avg = p->se.avg.util_avg;
__entry->uclamp_avg = uclamp_rq_util_with(rq, p->se.avg.util_avg, NULL);
__entry->uclamp_min = rq->uclamp[UCLAMP_MIN].value;
__entry->uclamp_max = rq->uclamp[UCLAMP_MAX].value;
),
TP_printk("pid=%d comm=%s cpu=%d util_avg=%lu uclamp_avg=%lu "
"uclamp_min=%lu uclamp_max=%lu",
__entry->pid, __entry->comm, __entry->cpu,
__entry->util_avg, __entry->uclamp_avg,
__entry->uclamp_min, __entry->uclamp_max)
);
TRACE_EVENT_CONDITION(lisa__uclamp_util_cfs,
TP_PROTO(bool is_root, struct rq *rq, struct cfs_rq *cfs_rq),
TP_ARGS(is_root, rq, cfs_rq),
TP_CONDITION(is_root),
TP_STRUCT__entry(
__field( int, cpu )
__field(unsigned long, util_avg )
__field(unsigned long, uclamp_avg )
__field(unsigned long, uclamp_min )
__field(unsigned long, uclamp_max )
),
TP_fast_assign(
__entry->cpu = lisa_rq_cpu(rq);
__entry->util_avg = cfs_rq->avg.util_avg;
__entry->uclamp_avg = uclamp_rq_util_with(rq, cfs_rq->avg.util_avg, NULL);
__entry->uclamp_min = rq->uclamp[UCLAMP_MIN].value;
__entry->uclamp_max = rq->uclamp[UCLAMP_MAX].value;
),
TP_printk("cpu=%d util_avg=%lu uclamp_avg=%lu "
"uclamp_min=%lu uclamp_max=%lu",
__entry->cpu, __entry->util_avg, __entry->uclamp_avg,
__entry->uclamp_min, __entry->uclamp_max)
);
#else
#define trace_lisa__uclamp_util_se(is_task, p, rq) while(false) {}
#define trace_lisa__uclamp_util_se_enabled() false
#define trace_lisa__uclamp_util_cfs(is_root, cpu, cfs_rq) while(false) {}
#define trace_lisa__uclamp_util_cfs_enabled() false
#endif /* CONFIG_UCLAMP_TASK */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0) && (defined(CONFIG_ARM64) || defined(CONFIG_ARM))
TRACE_EVENT(lisa__sched_cpu_capacity,
TP_PROTO(struct rq *rq),
TP_ARGS(rq),
TP_STRUCT__entry(
__field( int, cpu )
__field( unsigned long, capacity )
__field( unsigned long, capacity_orig )
__field( unsigned long, capacity_curr )
),
unsigned long scale_cpu = rq->cpu_capacity_orig;
unsigned long scale_freq = arch_scale_freq_capacity(rq->cpu);
TP_fast_assign(
__entry->cpu = rq->cpu;
__entry->capacity = rq->cpu_capacity;
__entry->capacity_orig = scale_cpu;
__entry->capacity_curr = cap_scale(scale_cpu, scale_freq);
),
TP_printk("cpu=%d capacity=%lu capacity_orig=%lu capacity_curr=%lu",
__entry->cpu, __entry->capacity, __entry->capacity_orig, __entry->capacity_curr)
);
#endif
#define PIXEL6_EMETER_CHAN_NAME_MAX_SIZE 64
TRACE_EVENT(lisa__pixel6_emeter,
TP_PROTO(unsigned long ts, unsigned int device, unsigned int chan, char *chan_name, unsigned long value),
TP_ARGS(ts, device, chan, chan_name, value),
TP_STRUCT__entry(
__field(unsigned long, ts )
__field(unsigned long, value )
__field(unsigned int, device )
__field(unsigned int, chan )
__array(char, chan_name, PIXEL6_EMETER_CHAN_NAME_MAX_SIZE )
),
TP_fast_assign(
__entry->ts = ts;
__entry->device = device;
__entry->chan = chan;
__entry->value = value;
strlcpy(__entry->chan_name, chan_name, PIXEL6_EMETER_CHAN_NAME_MAX_SIZE);
),
TP_printk("ts=%lu device=%u chan=%u chan_name=%s value=%lu",
__entry->ts, __entry->device, __entry->chan, __entry->chan_name, __entry->value)
);
TRACE_EVENT(perf_counter,
TP_PROTO(unsigned int cpu, unsigned int counter_id, u64 value),
TP_ARGS(cpu, counter_id, value),
TP_STRUCT__entry(
__field( unsigned int, cpu )
__field( unsigned int, counter_id )
__field( u64, value )
),
TP_fast_assign(
__entry->cpu = cpu;
__entry->counter_id = counter_id;
__entry->value = value;
),
TP_printk("cpu=%u counter_id=%u value=%llu",
__entry->cpu, __entry->counter_id, __entry->value)
);
#endif /* _FTRACE_EVENTS_H */
/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE ftrace_events
#include <trace/define_trace.h>