Home | History | Annotate | Download | only in busy_poll
      1 #!/bin/sh
      2 
      3 # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
      4 #
      5 # This program is free software; you can redistribute it and/or
      6 # modify it under the terms of the GNU General Public License as
      7 # published by the Free Software Foundation; either version 2 of
      8 # the License, or (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it would be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU General Public License
     16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     17 #
     18 # Author: Alexey Kodanev <alexey.kodanev (at] oracle.com>
     19 #
     20 
     21 TST_TOTAL=1
     22 TCID="busy_poll02"
     23 
     24 # tst_netload() parameters
     25 clients_num=2
     26 client_requests=500000
     27 # num of requests after which TCP connection is closed
     28 max_requests=500000
     29 
     30 . test_net.sh
     31 
     32 cleanup()
     33 {
     34 	tst_rhost_run -c "pkill -9 tcp_fastopen\$"
     35 	tst_rmdir
     36 
     37 	sysctl -q -w net.core.busy_poll=$busy_poll_old
     38 	tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
     39 }
     40 
     41 tst_require_root
     42 
     43 tst_kvercmp 3 11 0
     44 [ $? -eq 0 ] && tst_brkm TCONF "test must be run with kernel 3.11 or newer"
     45 
     46 if [ ! -f "/proc/sys/net/core/busy_read" -a \
     47      ! -f "/proc/sys/net/core/busy_poll" ]; then
     48 	tst_brkm TCONF "busy poll not configured, CONFIG_NET_RX_BUSY_POLL"
     49 fi
     50 
     51 set_busy_poll()
     52 {
     53 	local value=${1:-"0"}
     54 	ROD_SILENT sysctl -q -w net.core.busy_poll=$value
     55 	tst_rhost_run -s -c "sysctl -q -w net.core.busy_poll=$value"
     56 }
     57 
     58 tst_check_cmds pkill sysctl
     59 
     60 tst_tmpdir
     61 
     62 busy_poll_old="$(cat /proc/sys/net/core/busy_poll)"
     63 rbusy_poll_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_poll')
     64 
     65 TST_CLEANUP="cleanup"
     66 trap "tst_brkm TBROK 'test interrupted'" INT
     67 
     68 for x in 50 0; do
     69 	tst_resm TINFO "set low latency busy poll to $x per socket"
     70 	set_busy_poll $x
     71 	tst_netload $(tst_ipaddr rhost) res_$x TFO -b $x || \
     72 		tst_brkm TBROK "netload() failed"
     73 	tst_resm TINFO "time spent is '$(cat res_$x)' ms"
     74 done
     75 
     76 poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
     77 
     78 if [ "$poll_cmp" -lt 1 ]; then
     79 	tst_resm TFAIL "busy poll result is '$poll_cmp' %"
     80 else
     81 	tst_resm TPASS "busy poll increased performance by '$poll_cmp' %"
     82 fi
     83 
     84 tst_exit
     85