ublk: optimize UBLK_IO_UNREGISTER_IO_BUF on daemon task
authorCaleb Sander Mateos <csander@purestorage.com>
Fri, 20 Jun 2025 15:10:06 +0000 (09:10 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 1 Jul 2025 02:13:42 +0000 (20:13 -0600)
commit1ceeedb5974937a6d881fd0d92f143ca16f55577
tree1ef427642c64de78e0eb628a8c911702e55f348b
parent8a8fe42d765bb22cc0e91b053bfebf0fbdec3b5a
ublk: optimize UBLK_IO_UNREGISTER_IO_BUF on daemon task

ublk_io_release() performs an expensive atomic refcount decrement. This
atomic operation is unnecessary in the common case where the request's
buffer is registered and unregistered on the daemon task before handling
UBLK_IO_COMMIT_AND_FETCH_REQ for the I/O. So if ublk_io_release() is
called on the daemon task and task_registered_buffers is positive, just
decrement task_registered_buffers (nonatomically). ublk_sub_req_ref()
will apply this decrement when it atomically subtracts from io->ref.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250620151008.3976463-13-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c