Skip to content

Commit 4cfb25b

Browse files
isilenceaxboe
authored andcommitted
io_uring: optimise hot path restricted checks
Move likely/unlikely from io_check_restriction() to specifically ctx->restricted check, because doesn't do what it supposed to and make the common path take an extra jump. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/22bf70d0a543dfc935d7276bdc73081784e30698.1624739600.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent e5dc480 commit 4cfb25b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/io_uring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6506,7 +6506,7 @@ static inline bool io_check_restriction(struct io_ring_ctx *ctx,
65066506
struct io_kiocb *req,
65076507
unsigned int sqe_flags)
65086508
{
6509-
if (!ctx->restricted)
6509+
if (likely(!ctx->restricted))
65106510
return true;
65116511

65126512
if (!test_bit(req->opcode, ctx->restrictions.sqe_op))
@@ -6549,7 +6549,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
65496549
return -EINVAL;
65506550
if (unlikely(req->opcode >= IORING_OP_LAST))
65516551
return -EINVAL;
6552-
if (unlikely(!io_check_restriction(ctx, req, sqe_flags)))
6552+
if (!io_check_restriction(ctx, req, sqe_flags))
65536553
return -EACCES;
65546554

65556555
if ((sqe_flags & IOSQE_BUFFER_SELECT) &&

0 commit comments

Comments
 (0)