Home | History | Annotate | Download | only in busy_poll
      1 #!/bin/sh
      2 # Copyright (c) 2015-2016 Oracle and/or its affiliates. All Rights Reserved.
      3 #
      4 # This program is free software; you can redistribute it and/or
      5 # modify it under the terms of the GNU General Public License as
      6 # published by the Free Software Foundation; either version 2 of
      7 # the License, or (at your option) any later version.
      8 #
      9 # This program is distributed in the hope that it would be useful,
     10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 # GNU General Public License for more details.
     13 #
     14 # You should have received a copy of the GNU General Public License
     15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     16 #
     17 # Author: Alexey Kodanev <alexey.kodanev (at] oracle.com>
     18 #
     19 
     20 TST_TOTAL=1
     21 TCID="busy_poll02"
     22 TST_NEEDS_TMPDIR=1
     23 
     24 . test_net.sh
     25 . busy_poll_lib.sh
     26 
     27 cleanup()
     28 {
     29 	tst_rmdir
     30 
     31 	sysctl -q -w net.core.busy_poll=$busy_poll_old
     32 	tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
     33 }
     34 
     35 set_busy_poll()
     36 {
     37 	local value=${1:-"0"}
     38 	ROD_SILENT sysctl -q -w net.core.busy_poll=$value
     39 	tst_rhost_run -s -c "sysctl -q -w net.core.busy_poll=$value"
     40 }
     41 
     42 busy_poll_old="$(cat /proc/sys/net/core/busy_poll)"
     43 rbusy_poll_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_poll')
     44 
     45 TST_CLEANUP="cleanup"
     46 trap "tst_brkm TBROK 'test interrupted'" INT
     47 
     48 for x in 50 0; do
     49 	tst_resm TINFO "set low latency busy poll to $x per socket"
     50 	set_busy_poll $x
     51 	tst_netload -H $(tst_ipaddr rhost) -d res_$x -b $x
     52 done
     53 
     54 poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
     55 
     56 if [ "$poll_cmp" -lt 1 ]; then
     57 	tst_resm TFAIL "busy poll result is '$poll_cmp' %"
     58 else
     59 	tst_resm TPASS "busy poll increased performance by '$poll_cmp' %"
     60 fi
     61 
     62 tst_exit
     63