On Mon, Aug 25, 2025 at 09:53:27PM -0700, Caleb Sander Mateos wrote: > On Mon, Aug 25, 2025 at 5:49 AM Ming Lei <ming.lei@xxxxxxxxxx> wrote: > > > > Add a new command line option --no_ublk_fixed_fd that excludes the ublk > > control device (/dev/ublkcN) from io_uring's registered files array. > > When this option is used, only backing files are registered starting > > from index 1, while the ublk control device is accessed using its raw > > file descriptor. > > > > Add ublk_get_registered_fd() helper function that returns the appropriate > > file descriptor for use with io_uring operations, taking ublk_queue * > > parameter instead of ublk_thread * for better performance. > > > > Key optimizations implemented: > > - Cache UBLKS_Q_NO_UBLK_FIXED_FD flag in ublk_queue.flags to avoid > > reading dev->no_ublk_fixed_fd in fast path > > - Cache ublk char device fd in ublk_queue.ublk_fd for fast access > > - Update ublk_get_registered_fd() to use ublk_queue * parameter > > - Update io_uring_prep_buf_register/unregister() to use ublk_queue * > > - Replace ublk_device * access with ublk_queue * access in fast paths > > > > This improves performance by: > > - Eliminating device structure traversal in hot paths > > - Better cache locality with queue-local data access > > - Reduced indirection for flag and fd lookups > > Are you saying that performance is better when using the raw > /dev/ublkcN fd instead of an io_uring registered file? That would be > really surprising to me, since the whole point of io_uring file > registration is to avoid the file reference counting in the I/O path. No, here it just describes one implementation detail by caching per-device flag(no_ublk_fixed_fd) in queue's flag. The test can trigger hang with patch V1 by passing --no_ublk_fixed_fd because /dev/ublkcN and io_uring closes can be depended, both are run from task work context in current task. Thanks, Ming