On Sun, Jan 25, 2026 at 11:28 PM Ming Lei <[email protected]> wrote:
>
...

> >
> > Fedora 43 default config with some debugging options enabled, but no 
> > changes in schedulers.
> > Test VM storage is on a networked NAS over iSCSI - both boxes VM host and 
> > NAS have two NICs,
> > I get the errors when I load the network. So I believe the requests really 
> > complete out of
> > order due to the network in my case. All tests that have the bpftrace check 
> > fail on occasion.
>
> Can you test the following patch and see if re-order still can happen?
>
>
> diff --git a/tools/testing/selftests/ublk/test_generic_01.sh 
> b/tools/testing/selftests/ublk/test_generic_01.sh
> index 26cf3c7ceeb5..26d5e52ece29 100755
> --- a/tools/testing/selftests/ublk/test_generic_01.sh
> +++ b/tools/testing/selftests/ublk/test_generic_01.sh
> @@ -13,7 +13,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 $?
> @@ -39,9 +39,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
> diff --git a/tools/testing/selftests/ublk/trace/seq_io.bt 
> b/tools/testing/selftests/ublk/trace/seq_io.bt
> index b2f60a92b118..60ac40e66606 100644
> --- a/tools/testing/selftests/ublk/trace/seq_io.bt
> +++ b/tools/testing/selftests/ublk/trace/seq_io.bt
> @@ -2,23 +2,45 @@
>         $1:     dev_t
>         $2:     RWBS
>         $3:     strlen($2)
> +
> +       Track request order between block_io_start and block_rq_complete.
> +       For each request, record its start sequence number and verify
> +       completions happen in the same order.
>  */
> +
>  BEGIN {
> -       @last_rw[$1, str($2)] = (uint64)0;
> +       @start_seq = (uint64)0;
> +       @complete_seq = (uint64)0;
> +       @out_of_order = (uint64)0;
> +}
> +
> +tracepoint:block:block_io_start
> +{
> +       if ((int64)args.dev == $1 && !strncmp(args.rwbs, str($2), $3)) {
> +               @start_order[args.sector] = @start_seq;
> +               @start_seq = @start_seq + 1;
> +       }
>  }
> +
>  tracepoint:block:block_rq_complete
>  {
> -       $dev = $1;
>         if ((int64)args.dev == $1 && !strncmp(args.rwbs, str($2), $3)) {
> -               $last = @last_rw[$dev, str($2)];
> -               if ((uint64)args.sector != $last) {
> -                       printf("io_out_of_order: exp %llu actual %llu\n",
> -                               args.sector, $last);
> +               $expected_order = @start_order[args.sector];
> +               if ($expected_order != @complete_seq) {
> +                       printf("out_of_order: sector %llu started at seq %llu 
> but completed at seq %llu\n",
> +                               args.sector, $expected_order, @complete_seq);
> +                       @out_of_order = @out_of_order + 1;
>                 }
> -               @last_rw[$dev, str($2)] = (args.sector + args.nr_sector);
> +               delete(@start_order[args.sector]);
> +               @complete_seq = @complete_seq + 1;
>         }
>  }
>
>  END {
> -       clear(@last_rw);
> +       printf("total_start: %llu total_complete: %llu out_of_order: %llu\n",
> +               @start_seq, @complete_seq, @out_of_order);
> +       clear(@start_order);
> +       clear(@start_seq);
> +       clear(@complete_seq);
> +       clear(@out_of_order);
>  }

Forget another change, please apply the following delta too:

@@ -28,8 +28,8 @@ if ! kill -0 "$btrace_pid" > /dev/null 2>&1; then
        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 \


Thanks,


Reply via email to