Debian Codegraph @

scripts/trace_syscalls.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 duration of sendto() and recvfrom() system calls for TSN High threads.
9 //
10
11 BEGIN
12 {
13 printf("Tracing system calls execution times for TSN High... Hit Ctrl-C to end.\n");
14 }
15
16 tracepoint:syscalls:sys_enter_recvfrom
17 /comm == "TsnHighRxThread"/
18 {
19 @recvfrom_start[tid] = nsecs;
20 }
21
22 tracepoint:syscalls:sys_exit_recvfrom
23 /comm == "TsnHighRxThread"/
24 {
25 @recvfrom = lhist((nsecs - @recvfrom_start[tid]) / 1000, 0, 100, 5);
26 delete(@recvfrom_start[tid]);
27 }
28
29 tracepoint:syscalls:sys_enter_sendto
30 /comm == "TsnHighTxThread"/
31 {
32 @sendto_start[tid] = nsecs;
33 }
34
35 tracepoint:syscalls:sys_exit_sendto
36 /comm == "TsnHighTxThread"/
37 {
38 @sendto = lhist((nsecs - @sendto_start[tid]) / 1000, 0, 100, 5);
39 delete(@sendto_start[tid]);
40 }
41
42 END
43 {
44 clear(@recvfrom_start);
45 clear(@sendto_start);
46 }