Merge pull request #792 from hodgesds/ftrace-perfetto

scripts: Add ftrace perfetto helper scripts
This commit is contained in:
Daniel Hodges 2024-10-13 13:03:47 +00:00 committed by GitHub
commit 03f078ac74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 0 deletions

26
scripts/ftrace_trim Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
import sys
HEADER = "TASK-PID"
BUFF_STARTED = "buffer started ###"
def main():
nproc = int(sys.argv[2]) - 1
seen_header = False
proc_buffer_started = 0
with open(sys.argv[1]) as f:
for line in f:
l = line.replace("\n", "")
if HEADER in l:
seen_header = True
print(l)
if BUFF_STARTED in line:
proc_buffer_started += 1
continue
if proc_buffer_started == nproc or not seen_header:
print(l)
if __name__=="__main__":
main()

12
scripts/sched_ftrace.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
duration=${1:-5}
out=${2:-"$(pwd)/sched.ftrace"}
cd /sys/kernel/debug/tracing
echo 1 > tracing_on
echo 1 > events/sched/sched_switch/enable
timeout "${duration}" cat trace_pipe > "${out}.tmp"
echo 0 > events/sched/sched_switch/enable
echo 0 > tracing_on
cd -
./ftrace_trim "${out}.tmp" `nproc` > "${out}"
rm "${out}.tmp"