selftests: ublk: improve I/O ordering test with bpftrace
Subsystems (3)
PATCH 1/1 selftests: ublk: improve I/O ordering test with bpftrace
The in-tree approach requires sequential IO maintained in the whole IO stack, which is too strict and may cause false positive because of IO reorder caused by block layer core code, and generic_01 only covers IO order in ublk dispatch code path.
Rework test_generic_01 to verify that ublk dispatch doesn't reorder I/O by comparing request start order with completion order using bpftrace.
The bpftrace script now:
- Tracks each request's start sequence number in a map keyed by sector
- On completion, verifies the request's start order matches expected completion order
- Reports any out-of-order completions detected
The test script:
- Wait bpftrace BEGIN code block is run
- Pins fio to CPU 0 for deterministic behavior
- Uses block_io_start and block_rq_complete tracepoints
- Checks bpftrace output for reordering errors
--- .../testing/selftests/ublk/test_generic_01.sh | 23 ++++++--- tools/testing/selftests/ublk/trace/seq_io.bt | 47 +++++++++++++++---- 2 files changed, 54 insertions(+), 16 deletions(-)
tools/testing/selftests/ublk/test_generic_01.sh +16 -7
@@ -14,7 +14,7 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi -_prep_test "null" "sequential io order" +_prep_test "null" "ublk dispatch won't reorder IO" dev_id=$(_add_ublk_dev -t null) _check_add_dev $TID $?
@@ -22,15 +22,20 @@ _check_add_dev $TID $? dev_t=$(_get_disk_dev_t "$dev_id") bpftrace trace/seq_io.bt "$dev_t" "W" 1 > "$UBLK_TMP" 2>&1 & btrace_pid=$! -sleep 2 -if ! kill -0 "$btrace_pid" > /dev/null 2>&1; then +# Wait for bpftrace probes to be attached (BEGIN block prints BPFTRACE_READY) +for _ in $(seq 100); do + grep -q "BPFTRACE_READY" "$UBLK_TMP" 2>/dev/null && break + sleep 0.1 +done + +if ! kill -0 "$btrace_pid" 2>/dev/null; then _cleanup_test "null" exit "$UBLK_SKIP_CODE" fi -# run fio over this ublk disk -fio --name=write_seq \ +# run fio over this ublk disk (pinned to CPU 0) +taskset -c 0 fio --name=write_seq \ --filename=/dev/ublkb"${dev_id}" \ --ioengine=libaio --iodepth=16 \ --rw=write \
@@ -40,9 +45,13 @@ fio --name=write_seq \ ERR_CODE=$? kill "$btrace_pid" wait -if grep -q "io_out_of_order" "$UBLK_TMP"; then - cat "$UBLK_TMP" + +# Check for out-of-order completions detected by bpftrace +if grep -q "^out_of_order:" "$UBLK_TMP"; then + echo "I/O reordering detected:" + grep "^out_of_order:" "$UBLK_TMP" ERR_CODE=255 fi + _cleanup_test "null" _show_result $TID $ERR_CODE
tools/testing/selftests/ublk/trace/seq_io.bt +38 -9
61 lines not on this page · raw message
Signature · 1 line
2.47.1