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_poll01"
     22 
     23 . test_net.sh
     24 . busy_poll_lib.sh
     25 
     26 cleanup()
     27 {
     28 	tst_rmdir
     29 
     30 	sysctl -q -w net.core.busy_read=$busy_read_old
     31 	sysctl -q -w net.core.busy_poll=$busy_poll_old
     32 
     33 	tst_rhost_run -c "sysctl -q -w net.core.busy_read=$rbusy_read_old"
     34 	tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
     35 }
     36 
     37 set_busy_poll()
     38 {
     39 	local value=${1:-"0"}
     40 	ROD_SILENT sysctl -q -w net.core.busy_read=$value
     41 	ROD_SILENT sysctl -q -w net.core.busy_poll=$value
     42 
     43 	tst_rhost_run -s -c "sysctl -q -w net.core.busy_read=$value"
     44 	tst_rhost_run -s -c "sysctl -q -w net.core.busy_poll=$value"
     45 }
     46 
     47 tst_tmpdir
     48 
     49 busy_read_old="$(cat /proc/sys/net/core/busy_read)"
     50 busy_poll_old="$(cat /proc/sys/net/core/busy_poll)"
     51 
     52 rbusy_read_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_read')
     53 rbusy_poll_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_poll')
     54 
     55 TST_CLEANUP="cleanup"
     56 trap "tst_brkm TBROK 'test interrupted'" INT
     57 
     58 for x in 50 0; do
     59 	tst_resm TINFO "set low latency busy poll to $x"
     60 	set_busy_poll $x
     61 	tst_netload -H $(tst_ipaddr rhost) -d res_$x
     62 done
     63 
     64 poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
     65 
     66 if [ "$poll_cmp" -lt 1 ]; then
     67 	tst_resm TFAIL "busy poll result is '$poll_cmp' %"
     68 else
     69 	tst_resm TPASS "busy poll increased performance by '$poll_cmp' %"
     70 fi
     71 
     72 tst_exit
     73