xref: /dflybsd-src/test/sysperf/ipitest (revision 7189f6289a3b88d170ce03a6ad88b35f038caeb4)
12c08e360SMatthew Dillon#!/bin/csh
22c08e360SMatthew Dillon#
32c08e360SMatthew Dillon# ipitest [ Cmode ]
42c08e360SMatthew Dillon#
52c08e360SMatthew Dillon# NOTE: Run from current directory as ./ipitest, output in ipitest.out
62c08e360SMatthew Dillon#
72c08e360SMatthew Dillon# NOTE: Running powerd during this test is not recommended.
82c08e360SMatthew Dillon
92c08e360SMatthew Dillon# Force test to run from cpu 0
102c08e360SMatthew Dillon#
112c08e360SMatthew Dillonif ( $?DIDUSCHED == 0 ) then
122c08e360SMatthew Dillon	setenv DIDUSCHED ok
132c08e360SMatthew Dillon	usched :1 ./ipitest $argv
142c08e360SMatthew Dillon	exit 0
152c08e360SMatthew Dillonendif
162c08e360SMatthew Dillon
172c08e360SMatthew Dillon# CX mode can be specified on the command line, if not
182c08e360SMatthew Dillon# specified test all available CX modes.
192c08e360SMatthew Dillon#
202c08e360SMatthew Dillonif ( $#argv == 0 ) then
212c08e360SMatthew Dillon    set modes = "`sysctl -n machdep.mwait.CX.supported`"
222c08e360SMatthew Dillonelse
232c08e360SMatthew Dillon    set modes = "$argv"
242c08e360SMatthew Dillonendif
252c08e360SMatthew Dillon
26*7189f628SSepherosa Ziehauset ncpus = "`sysctl -n hw.ncpu`"
27*7189f628SSepherosa Ziehauset cpus = "`seq 1 $ncpus`"
28*7189f628SSepherosa Ziehau
292c08e360SMatthew Dillon# Start test.  Use a sleep to give other cpus time to go
302c08e360SMatthew Dillon# idle.  Try to avoid being on a hardclock boundary.
312c08e360SMatthew Dillon#
322c08e360SMatthew Dillonset file = "ipitest.out"
332c08e360SMatthew Dillonecho "Testing $modes"
342c08e360SMatthew Dillon
352c08e360SMatthew Dillonfgrep CPU /var/run/dmesg.boot | fgrep @ | head -1 > ${file}
362c08e360SMatthew Dillondate >> ${file}
372c08e360SMatthew Dillon
382c08e360SMatthew Dillonforeach mode ( $modes )
392c08e360SMatthew Dillon    echo "Testing mode $mode"
402c08e360SMatthew Dillon    sysctl machdep.mwait.CX.idle=$mode
41*7189f628SSepherosa Ziehau    foreach i ( $cpus )
422c08e360SMatthew Dillon	foreach j ( x x x x x x x x x )
432c08e360SMatthew Dillon		sleep 0.200010
442c08e360SMatthew Dillon		sysctl debug.ipiq.latency_test=$i >& /dev/null
452c08e360SMatthew Dillon	end
462c08e360SMatthew Dillon    end
472c08e360SMatthew Dillon    sleep 0.2
482c08e360SMatthew Dillon    echo "Testing mode $mode" >> ${file}
492c08e360SMatthew Dillon    sysctl debug.ipiq >> ${file}
502c08e360SMatthew Dillon    echo ""
512c08e360SMatthew Dillonend
52