Debian Codegraph @

scripts/trace_rtc.bt

raw
1 #!/usr/bin/bpftrace
2 //
3 // Copyright (C) 2024 Linutronix GmbH
4 // Author Kurt Kanzenbach <[email protected]>
5 //
6 // SPDX-License-Identifier: BSD-2-Clause
7 //
8 // Trace CPU run times of Rtc real time tasks.
9 //
10
11 BEGIN
12 {
13 printf("Tracing RtcThread(s) execution times... Hit Ctrl-C to end.\n");
14 }
15
16 tracepoint:sched:sched_switch
17 /args->next_comm == "RtcRxThread"/
18 {
19 @rx[args->next_pid] = nsecs;
20 }
21
22 tracepoint:sched:sched_switch
23 /args->next_comm == "RtcTxThread"/
24 {
25 @tx[args->next_pid] = nsecs;
26 }
27
28 tracepoint:sched:sched_switch
29 /args->prev_comm == "RtcRxThread"/
30 {
31 $ns = @rx[args->prev_pid];
32 if ($ns) {
33 @rxruntime = lhist((nsecs - $ns) / 1000, 0, 1000, 1);
34 }
35 delete(@rx[args->prev_pid]);
36 }
37
38 tracepoint:sched:sched_switch
39 /args->prev_comm == "RtcTxThread"/
40 {
41 $ns = @tx[args->prev_pid];
42 if ($ns) {
43 @txruntime = lhist((nsecs - $ns) / 1000, 0, 1000, 1);
44 }
45 delete(@tx[args->prev_pid]);
46 }
47
48 END
49 {
50 clear(@rx);
51 clear(@tx);
52 }