• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2015-2018 Oracle and/or its affiliates. All Rights Reserved.
4#
5# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
6
7. busy_poll_lib.sh
8
9cleanup()
10{
11	[ -n "$busy_read_old" ] && \
12		sysctl -q -w net.core.busy_read=$busy_read_old
13	[ -n "$busy_poll_old" ] && \
14		sysctl -q -w net.core.busy_poll=$busy_poll_old
15	[ -n "$rbusy_read_old" ] && \
16		tst_rhost_run -c "sysctl -q -w net.core.busy_read=$rbusy_read_old"
17	[ -n "$rbusy_poll_old" ] && \
18		tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
19}
20
21set_busy_poll()
22{
23	local value=${1:-"0"}
24	ROD_SILENT sysctl -q -w net.core.busy_read=$value
25	ROD_SILENT sysctl -q -w net.core.busy_poll=$value
26
27	tst_rhost_run -s -c "sysctl -q -w net.core.busy_read=$value"
28	tst_rhost_run -s -c "sysctl -q -w net.core.busy_poll=$value"
29}
30
31setup()
32{
33	busy_poll_check_config
34
35	busy_read_old="$(cat /proc/sys/net/core/busy_read)"
36	busy_poll_old="$(cat /proc/sys/net/core/busy_poll)"
37
38	rbusy_read_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_read')
39	rbusy_poll_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_poll')
40}
41
42test()
43{
44	for x in 50 0; do
45		tst_res TINFO "set low latency busy poll to $x"
46		set_busy_poll $x
47		tst_netload -H $(tst_ipaddr rhost) -n 10 -N 10 -d res_$x
48	done
49
50	local poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
51
52	if [ "$poll_cmp" -lt 1 ]; then
53		tst_res TFAIL "busy poll result is '$poll_cmp' %"
54	else
55		tst_res TPASS "busy poll increased performance by '$poll_cmp' %"
56	fi
57}
58
59tst_run
60