busy_poll03.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-or-later
  3. # Copyright (c) 2016-2018 Oracle and/or its affiliates.
  4. #
  5. # Author: Alexey Kodanev <alexey.kodanev@oracle.com>
  6. TST_TEST_DATA="udp udp_lite"
  7. . busy_poll_lib.sh
  8. cleanup()
  9. {
  10. [ -n "$busy_poll_old" ] && \
  11. sysctl -q -w net.core.busy_poll=$busy_poll_old
  12. [ -n "$rbusy_poll_old" ] && \
  13. tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
  14. }
  15. set_busy_poll()
  16. {
  17. local value=${1:-"0"}
  18. ROD_SILENT sysctl -q -w net.core.busy_poll=$value
  19. tst_rhost_run -s -c "sysctl -q -w net.core.busy_poll=$value"
  20. }
  21. setup()
  22. {
  23. busy_poll_check_config
  24. busy_poll_old="$(cat /proc/sys/net/core/busy_poll)"
  25. rbusy_poll_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_poll')
  26. }
  27. test()
  28. {
  29. for x in 50 0; do
  30. tst_res TINFO "set low latency busy poll to $x per $2 socket"
  31. set_busy_poll $x
  32. tst_netload -H $(tst_ipaddr rhost) -n 10 -N 10 -d res_$x \
  33. -b $x -T $2
  34. done
  35. local poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
  36. if [ "$poll_cmp" -lt 1 ]; then
  37. tst_res TFAIL "busy poll result is '$poll_cmp' %"
  38. else
  39. tst_res TPASS "busy poll increased performance by '$poll_cmp' %"
  40. fi
  41. }
  42. tst_run