mirror of
https://github.com/JakeHillion/scx.git
synced 2024-11-26 03:20:24 +00:00
Merge pull request #792 from hodgesds/ftrace-perfetto
scripts: Add ftrace perfetto helper scripts
This commit is contained in:
commit
03f078ac74
26
scripts/ftrace_trim
Executable file
26
scripts/ftrace_trim
Executable 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
12
scripts/sched_ftrace.sh
Executable 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"
|
Loading…
Reference in New Issue
Block a user