diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2015-08-03 09:54:38 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2015-08-03 09:54:38 -0400 |
commit | 033c51950c1c1385292a7b8bbe52d396bc41aaeb (patch) | |
tree | ee9b65b506fba80f895c4f2711d000f830ba6cbc | |
parent | 13861f451170ff6de60f9cf53b75f5d33a9290fd (diff) |
Add ft-trace-overheads wrapper script
A more convenient interface to say "trace all overheads."
Update .gitignore while at it...
-rw-r--r-- | .gitignore | 4 | ||||
-rwxr-xr-x | ft-trace-overheads | 112 |
2 files changed, 115 insertions, 1 deletions
@@ -1,7 +1,9 @@ | |||
1 | .sconsign.dblite | 1 | .sconsign.dblite |
2 | *.o | 2 | *.o |
3 | *.d | ||
3 | ~* | 4 | ~* |
5 | *~ | ||
4 | ftcat | 6 | ftcat |
5 | ft2csv | 7 | ft2csv |
6 | ftdump | 8 | ftdump |
7 | 9 | ftsort | |
diff --git a/ft-trace-overheads b/ft-trace-overheads new file mode 100755 index 0000000..f651f50 --- /dev/null +++ b/ft-trace-overheads | |||
@@ -0,0 +1,112 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | PATH_TO_SCRIPT=`dirname $0` | ||
4 | function 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 | |||
19 | function die() | ||
20 | { | ||
21 | echo "[EE] $*" | ||
22 | exit 1 | ||
23 | } | ||
24 | |||
25 | [ -z "$FTCAT" ] && FTCAT=`find_helper ftcat ../ft_tools` | ||
26 | [ -z "$FTCAT" ] && die "Can't find 'ftcat' utility." | ||
27 | |||
28 | if [ "$1" == "-s" ] | ||
29 | then | ||
30 | AUTO=1 | ||
31 | shift | ||
32 | fi | ||
33 | |||
34 | PIDS="" | ||
35 | |||
36 | # signal that we're done gathering data and clean up | ||
37 | on_finish() | ||
38 | { | ||
39 | echo "Ending Trace..." | ||
40 | kill $PIDS | ||
41 | wait $PIDS | ||
42 | |||
43 | exit 0 | ||
44 | } | ||
45 | |||
46 | # register shutdown signal handler | ||
47 | trap 'on_finish' SIGUSR1 | ||
48 | |||
49 | |||
50 | CPU_FILES=`ls /dev/litmus/ft_cpu_trace* 2>/dev/null` | ||
51 | MSG_FILES=`ls /dev/litmus/ft_msg_trace* 2>/dev/null` | ||
52 | |||
53 | if [ -z "${CPU_FILES}${MSG_FILES}" ] | ||
54 | then | ||
55 | echo "[EE] Could not find any trace files in /dev/litmus/." | ||
56 | echo " Is this a LITMUS^RT kernel?" | ||
57 | echo " If so, is CONFIG_SCHED_OVERHEAD_TRACE enabled?" | ||
58 | die "No trace files found." | ||
59 | fi | ||
60 | |||
61 | NAME=$1 | ||
62 | shift | ||
63 | |||
64 | [ -z "${NAME}" ] && die "No name specified. Run as 'ft-trace-overheads <NAME>'." | ||
65 | |||
66 | |||
67 | SCHED_EVENTS="SCHED2 SCHED CXS TICK RELEASE" | ||
68 | |||
69 | CPU_EVENTS= | ||
70 | for x in $SCHED_EVENTS | ||
71 | do | ||
72 | CPU_EVENTS="$CPU_EVENTS ${x}_END ${x}_START" | ||
73 | done | ||
74 | CPU_EVENTS="$CPU_EVENTS RELEASE_LATENCY" | ||
75 | |||
76 | IPI_EVENTS="SEND_RESCHED" | ||
77 | MSG_EVENTS= | ||
78 | for x in $IPI_EVENTS | ||
79 | do | ||
80 | MSG_EVENTS="$MSG_EVENTS ${x}_END ${x}_START" | ||
81 | done | ||
82 | |||
83 | NAME=${NAME//[ \/]/-} | ||
84 | for dev in $CPU_FILES | ||
85 | do | ||
86 | CPU=`basename ${dev} | sed 's/ft_cpu_trace//'` | ||
87 | TRACE="overheads_host=`hostname`_trace=${NAME}_cpu=${CPU}.bin" | ||
88 | echo "[II] Recording $dev -> $TRACE" | ||
89 | $FTCAT $dev $CPU_EVENTS > $TRACE & | ||
90 | PIDS="$PIDS $!" | ||
91 | done | ||
92 | |||
93 | for dev in $MSG_FILES | ||
94 | do | ||
95 | CPU=`basename ${dev} | sed 's/ft_msg_trace//'` | ||
96 | TRACE="overheads_host=`hostname`_trace=${NAME}_msg=${CPU}.bin" | ||
97 | echo "[II] Recording $dev -> $TRACE" | ||
98 | $FTCAT $dev $MSG_EVENTS > $TRACE & | ||
99 | PIDS="$PIDS $!" | ||
100 | done | ||
101 | |||
102 | |||
103 | if [[ $AUTO != 1 ]] | ||
104 | then | ||
105 | echo "Press Enter to end tracing..." | ||
106 | read | ||
107 | on_finish | ||
108 | else | ||
109 | # wait for SIGUSR1 to terminate | ||
110 | echo "Waiting for SIGUSR1 to end tracing..." | ||
111 | while [ 1 ]; do sleep 10; done | ||
112 | fi | ||