aboutsummaryrefslogtreecommitdiffstats
path: root/st-trace-schedule
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2016-03-22 15:55:20 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2016-03-22 16:00:44 -0400
commit37aea5e4e06d30267c01ae3d078be34fb07fcfd3 (patch)
tree1be56f7d9a77791e94ffc894ce934ec0bc680536 /st-trace-schedule
parent27474dfff59e40e1abf33e0b5dfe7a16dc73f4b1 (diff)
rename st_trace -> st-trace-schedule
Let's use consistent tool names...
Diffstat (limited to 'st-trace-schedule')
-rwxr-xr-xst-trace-schedule105
1 files changed, 105 insertions, 0 deletions
diff --git a/st-trace-schedule b/st-trace-schedule
new file mode 100755
index 0000000..680772e
--- /dev/null
+++ b/st-trace-schedule
@@ -0,0 +1,105 @@
1#!/bin/bash
2
3PATH_TO_SCRIPT=`dirname $0`
4function find_helper()
5{
6 IN_PATH=`which $1`
7 REL_TO_PATH="$PATH_TO_SCRIPT/$2"
8 if [ -z "$IN_PATH" ] && [ ! -z "$PATH_TO_SCRIPT" ] && [ -x "$PATH_TO_SCRIPT/$1" ]
9 then
10 echo "$PATH_TO_SCRIPT/$1"
11 elif [ -z "$IN_PATH" ] && [ ! -z "$PATH_TO_SCRIPT" ] && [ -x "$REL_TO_PATH/$1" ]
12 then
13 echo "$REL_TO_PATH/$1"
14 else
15 echo "$IN_PATH"
16 fi
17}
18
19function die()
20{
21 echo "Error: $*"
22 exit 1
23}
24
25
26[ -z "$FTCAT" ] && FTCAT=`find_helper ftcat ../ft_tools`
27[ -z "$FTCAT" ] && die "Can't find 'ftcat' utility."
28[ -z "$FTDEV" ] && FTDEV=/dev/litmus/sched_trace
29
30if [ "$1" == "-s" ]
31then
32 AUTO=1
33 shift
34fi
35
36PIDS=""
37
38# signal that we're done gathering data and clean up
39on_finish()
40{
41 echo "Ending Trace..."
42 kill $PIDS
43 wait $PIDS
44
45 exit 0
46}
47
48# register shutdown signal handler
49trap 'on_finish' SIGUSR1
50
51
52
53# Setup up sched_trace tracing.
54
55# works for sparc64 and Intel x86 if all CPUs are online
56NUM_CPUS=`egrep -c '^processor|online' /proc/cpuinfo`
57
58# Trace ID Key:
59# 501 - sched_trace_task_name
60# 502 - sched_trace_task_param
61# 503 - sched_trace_task_release
62# 504 - sched_trace_task_switch_to
63# 505 - sched_trace_task_switch_away
64# 506 - sched_trace_task_completion
65# 507 - sched_trace_task_block
66# 508 - sched_trace_task_resume
67# 509 - sched_trace_action
68# 510 - sched_trace_sys_release
69ST_IDS="501 502 503 504 505 506 507 508 509 510"
70
71DIR=`mktemp -d` || die "mktemp failed"
72
73TAG=$1
74PIDS=""
75COUNT=0
76for x in `seq 0 $(($NUM_CPUS - 1))`
77do
78 TARGET="st-${TAG}_cpu=${x}.bin"
79 echo -n "CPU $x: "
80 $FTCAT -p "$DIR/cpu${x}.pid" "$FTDEV$x" $ST_IDS > "$TARGET" &
81 PIDS="$PIDS $!"
82 echo $! "> $TARGET [$?]"
83 COUNT=$((COUNT + 1))
84done
85
86READY=`ls $DIR/*.pid | wc -l`
87while [[ $READY != $COUNT ]]
88do
89 sleep 0.5
90 READY=`ls $DIR/*.pid | wc -l`
91done
92
93rm $DIR/*.pid
94rmdir $DIR
95
96if [[ $AUTO != 1 ]]
97then
98 echo "Press Enter to end tracing..."
99 read
100 on_finish
101else
102 # wait for SIGUSR1 to terminate
103 echo "Waiting for SIGUSR1 to end tracing..."
104 wait $PIDS
105fi