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