Debian Codegraph @

tools/genwqe_parallel_echo

raw
1 #!/bin/bash
2
3 #
4 # Copyright 2015, 2016, International Business Machines
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19 #
20 # This testcase processes significant interrupt stress. Run that for a day
21 # and you will know if your device driver and software can surive sudden
22 # abborts while running a lot of interrupt stress.
23 #
24 # Start N echos and kill them after a couple of seconds.
25 #
26
27 card=0
28 tools_dir=tools
29 verbose=0
30 iterations=100000
31 processes=160
32 killtimeout=2
33 preload=1
34 runpids=""
35 polling=""
36 count=""
37 tracing=0
38 trace_file="genwqe_parallel_echo.log"
39 PLATFORM=`uname -p`
40 start_time=`date`
41 do_build=0
42
43 # Set default accelerator based on platform we are running on
44 if [ ${PLATFORM} == "ppc64le" ]; then
45 accelerator=CAPI
46 else
47 accelerator=GENWQE
48 fi
49
50 function usage() {
51 echo "Usage:"
52 echo " genwqe_parallel_echo"
53 echo " -A <accelerator> GENWQE|CAPI"
54 echo " -C <card> card to be used for the test"
55 echo " -c <count> send <count> echos and than stop"
56 echo " -i <iterations> repeat multiple times for more testing"
57 echo " -p <processes> how many processed in parallel"
58 echo " -k <seconds> kill timeout"
59 echo " -l <N> send <N> echos in one shot N <= 64"
60 echo " -P run echo in experimental polling mode (CAPI only)"
61 echo " -T start traces (CAPI only)"
62 echo " -t <dir> directory where the tools are located"
63 echo " -b build the code before running the test"
64 echo
65 echo "Example:"
66 echo " Repro the CAPI bitstream interrupt loss problem:"
67 echo " ./scripts/parallel_echo.sh -ACAPI -C0 -i1000 -p160 -k3"
68 echo
69 }
70
71 function start_job {
72 # echo "Starting: $*"
73 echo "$*" > echo_$s.cmd
74
75 exec $* $parms &
76 newpid=$!
77 # echo "NewPID: $newpid"
78 runpids=$runpids" "$newpid
79 # echo "RunPIDs: $runpids"
80 }
81
82 function stop_jobs {
83 echo "Running: "`jobs -rp`
84 echo "Expected: ${runpids}"
85 kill -SIGKILL `jobs -rp`
86 wait
87 echo "Still running: "`jobs -rp`
88 runpids=""
89 }
90
91 function cleanup {
92 echo "Stopping all jobs ..."
93 stop_jobs
94 sleep 1
95 echo "done"
96 stop_cxl_traces
97 exit 0
98 }
99
100 function start_cxl_traces {
101 if [ ${accelerator} == "CAPI" -a ${tracing} -eq 1 ]; then
102 echo "Starting CXL tracing ...";
103 sudo sh -c 'echo 1 > /sys/kernel/debug/tracing/events/cxl/enable';
104 fi
105 }
106
107 function stop_cxl_traces {
108 if [ ${accelerator} == "CAPI" -a ${tracing} -eq 1 ]; then
109 echo "Stopping CXL tracing ...";
110 sudo sh -c 'echo 0 > /sys/kernel/debug/tracing/events/cxl/enable';
111 fi
112 }
113
114 function collect_cxl_traces {
115 if [ ${accelerator} == "CAPI" -a ${tracing} -eq 1 ]; then
116 echo "Collect CXL traces ...";
117 sudo sh -c 'cat /sys/kernel/debug/tracing/trace_pipe > $trace_file';
118 fi
119 }
120
121 trap cleanup SIGINT
122 trap cleanup SIGKILL
123 trap cleanup SIGTERM
124
125 while getopts "TPA:C:c:p:i:k:l:t:bh" opt; do
126 case $opt in
127 A)
128 accelerator=$OPTARG;
129 ;;
130 C)
131 card=$OPTARG;
132 ;;
133 c)
134 count="-c $OPTARG";
135 ;;
136 i)
137 iterations=$OPTARG;
138 ;;
139 p)
140 processes=$OPTARG;
141 ;;
142 k)
143 killtimeout=$OPTARG;
144 ;;
145 l)
146 preload=$OPTARG;
147 ;;
148 T)
149 tracing=1;
150 ;;
151 P)
152 polling="-p"
153 ;;
154 h)
155 usage;
156 exit 0;
157 ;;
158 b)
159 do_build=1;
160 ;;
161 t)
162 tools_dir=$OPTARG;
163 ;;
164 \?)
165 echo "Invalid option: -$OPTARG" >&2
166 ;;
167 esac
168 done
169
170 function test_echo ()
171 {
172 ### Start in background ...
173 echo "Starting genwqe_echo in the background ... "
174 for s in `seq 1 $processes` ; do
175 start_job $tools_dir/genwqe_echo -A ${accelerator} -C ${card} \
176 -l ${preload} ${count} -f ${polling} \
177 > echo_$s.stdout.log 2> echo_$s.stderr.log
178 done
179 echo "ok"
180
181 if [ ${killtimeout} -ne -1 ]; then
182 echo "Waiting ${killtimeout} seconds ..."
183 for s in `seq 0 ${killtimeout}` ; do
184 sleep 1;
185 echo -n "."
186 done
187 echo " ok"
188 echo "Sending SIGKILL to all ... "
189 stop_jobs
190 echo "ok"
191 else
192 echo "Skipp killing processes but wait until they terminate ..."
193 fi
194 }
195
196 # Check if we have to do a build
197 if [ ${do_build} -eq 1 ]; then
198 echo "Build code ..."
199 make -s -j32 || exit 1
200 fi
201
202 echo "********************************************************************"
203 echo "Parallel echo TEST for ${accelerator} card ${card} starting ${processes}"
204 echo "********************************************************************"
205 echo
206
207 echo "********************************************************************"
208 echo "Hardware Version"
209 echo "********************************************************************"
210 echo
211 $tools_dir/genwqe_echo -A ${accelerator} -C ${card} --hardware-version
212
213 echo "********************************************************************"
214 echo "Remove old logfiles ..."
215 echo "********************************************************************"
216 echo
217 rm -f echo_*.cmd echo_*.stdout.log echo_*.stderr.log
218
219 start_cxl_traces
220
221 for i in `seq 1 ${iterations}` ; do
222
223 echo -n "(1) Check if card is replying to an echo request ($i) ... "
224 date
225
226 $tools_dir/genwqe_echo -A ${accelerator} -C ${card} -i0 -c5
227 if [ $? -ne 0 ]; then
228 echo "Single echo took to long, please review results!"
229 collect_cxl_traces
230 stop_cxl_traces
231 exit 1
232 fi
233
234 echo "(2) Perform massive interrupt stress and killing applications ..."
235 test_echo;
236
237 echo "(3) Check logfiles for string \"err\" ..."
238 grep err echo_*.stderr.log
239 if [ $? -ne 1 ]; then
240 echo "Found potential errors ... please check logfiles"
241 collect_cxl_traces
242 stop_cxl_traces
243 exit 2
244 fi
245
246 echo "(4) Check if card is still replying to an echo request ..."
247 $tools_dir/genwqe_echo -A ${accelerator} -C ${card} -i0 -c5
248 if [ $? -ne 0 ]; then
249 echo "Single echo took to long, please review results!"
250 collect_cxl_traces
251 stop_cxl_traces
252 exit 3
253 fi
254
255 echo "(5) Remove old logfiles ..."
256 rm -f echo_*.cmd echo_*.stdout.log echo_*.stderr.log
257
258 echo "Running since ${start_time} until now `date` ($i)"
259 echo
260 done
261
262 stop_cxl_traces
263 exit 0