busy_poll01.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. . busy_poll_lib.sh
  7. cleanup()
  8. {
  9. [ -n "$busy_read_old" ] && \
  10. sysctl -q -w net.core.busy_read=$busy_read_old
  11. [ -n "$busy_poll_old" ] && \
  12. sysctl -q -w net.core.busy_poll=$busy_poll_old
  13. [ -n "$rbusy_read_old" ] && \
  14. tst_rhost_run -c "sysctl -q -w net.core.busy_read=$rbusy_read_old"
  15. [ -n "$rbusy_poll_old" ] && \
  16. tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
  17. }
  18. set_busy_poll()
  19. {
  20. local value=${1:-"0"}
  21. ROD_SILENT sysctl -q -w net.core.busy_read=$value
  22. ROD_SILENT sysctl -q -w net.core.busy_poll=$value
  23. tst_rhost_run -s -c "sysctl -q -w net.core.busy_read=$value"
  24. tst_rhost_run -s -c "sysctl -q -w net.core.busy_poll=$value"
  25. }
  26. setup()
  27. {
  28. busy_poll_check_config
  29. busy_read_old="$(cat /proc/sys/net/core/busy_read)"
  30. busy_poll_old="$(cat /proc/sys/net/core/busy_poll)"
  31. rbusy_read_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_read')
  32. rbusy_poll_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_poll')
  33. }
  34. test()
  35. {
  36. for x in 50 0; do
  37. tst_res TINFO "set low latency busy poll to $x"
  38. set_busy_poll $x
  39. tst_netload -H $(tst_ipaddr rhost) -n 10 -N 10 -d res_$x
  40. done
  41. local poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
  42. if [ "$poll_cmp" -lt 1 ]; then
  43. tst_res TFAIL "busy poll result is '$poll_cmp' %"
  44. else
  45. tst_res TPASS "busy poll increased performance by '$poll_cmp' %"
  46. fi
  47. }
  48. tst_run