io_uring: mark the need to lock/unlock the ring as unlikely
authorJens Axboe <axboe@kernel.dk>
Mon, 29 Jan 2024 03:32:52 +0000 (20:32 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 8 Feb 2024 20:27:06 +0000 (13:27 -0700)
Any of the fast paths will already have this locked, this helper only
exists to deal with io-wq invoking request issue where we do not have
the ctx->uring_lock held already. This means that any common or fast
path will already have this locked, mark it as such.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.h

index 2952551fe345597b328c02287e46cb027725fd61..46795ee462dfbdd6f8eed870fe305e7110be6297 100644 (file)
@@ -208,7 +208,7 @@ static inline void io_ring_submit_unlock(struct io_ring_ctx *ctx,
                                         unsigned issue_flags)
 {
        lockdep_assert_held(&ctx->uring_lock);
-       if (issue_flags & IO_URING_F_UNLOCKED)
+       if (unlikely(issue_flags & IO_URING_F_UNLOCKED))
                mutex_unlock(&ctx->uring_lock);
 }
 
@@ -221,7 +221,7 @@ static inline void io_ring_submit_lock(struct io_ring_ctx *ctx,
         * The only exception is when we've detached the request and issue it
         * from an async worker thread, grab the lock for that case.
         */
-       if (issue_flags & IO_URING_F_UNLOCKED)
+       if (unlikely(issue_flags & IO_URING_F_UNLOCKED))
                mutex_lock(&ctx->uring_lock);
        lockdep_assert_held(&ctx->uring_lock);
 }