test_generic_12.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
  4. ERR_CODE=0
  5. if ! _have_program bpftrace; then
  6. exit "$UBLK_SKIP_CODE"
  7. fi
  8. if ! _have_program fio; then
  9. exit "$UBLK_SKIP_CODE"
  10. fi
  11. _prep_test "null" "do imbalanced load, it should be balanced over I/O threads"
  12. NTHREADS=6
  13. dev_id=$(_add_ublk_dev -t null -q 4 -d 16 --nthreads $NTHREADS --per_io_tasks)
  14. _check_add_dev $TID $?
  15. dev_t=$(_get_disk_dev_t "$dev_id")
  16. bpftrace trace/count_ios_per_tid.bt "$dev_t" > "$UBLK_TMP" 2>&1 &
  17. btrace_pid=$!
  18. sleep 2
  19. if ! kill -0 "$btrace_pid" > /dev/null 2>&1; then
  20. _cleanup_test "null"
  21. exit "$UBLK_SKIP_CODE"
  22. fi
  23. # do imbalanced I/O on the ublk device
  24. # pin to cpu 0 to prevent migration/only target one queue
  25. fio --name=write_seq \
  26. --filename=/dev/ublkb"${dev_id}" \
  27. --ioengine=libaio --iodepth=16 \
  28. --rw=write \
  29. --size=512M \
  30. --direct=1 \
  31. --bs=4k \
  32. --cpus_allowed=0 > /dev/null 2>&1
  33. ERR_CODE=$?
  34. kill "$btrace_pid"
  35. wait
  36. # check that every task handles some I/O, even though all I/O was issued
  37. # from a single CPU. when ublk gets support for round-robin tag
  38. # allocation, this check can be strengthened to assert that every thread
  39. # handles the same number of I/Os
  40. NR_THREADS_THAT_HANDLED_IO=$(grep -c '@' ${UBLK_TMP})
  41. if [[ $NR_THREADS_THAT_HANDLED_IO -ne $NTHREADS ]]; then
  42. echo "only $NR_THREADS_THAT_HANDLED_IO handled I/O! expected $NTHREADS"
  43. cat "$UBLK_TMP"
  44. ERR_CODE=255
  45. fi
  46. _cleanup_test "null"
  47. _show_result $TID $ERR_CODE