From ea6b2affaadc3ac5af46e015f78a8711f5c89748 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov Date: Mon, 29 Jun 2020 19:18:40 +0300 Subject: [PATCH 2509/2944] io_uring: don't pass def into io_req_work_grab_env fix #32198918 commit 351fd53595a3ceb88756a005e3b864f7c8cb86e4 upstream. Remove struct io_op_def *def parameter from io_req_work_grab_env(), it's trivially deducible from req->opcode and fast. The API is cleaner this way, and also helps the complier to understand that it's a real constant and could be register-cached. Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Joseph Qi Acked-by: Xiaoguang Wang --- fs/io_uring.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 37cdf17..37a2dea 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1090,9 +1090,10 @@ static void __io_commit_cqring(struct io_ring_ctx *ctx) } } -static inline void io_req_work_grab_env(struct io_kiocb *req, - const struct io_op_def *def) +static inline void io_req_work_grab_env(struct io_kiocb *req) { + const struct io_op_def *def = &io_op_defs[req->opcode]; + if (!req->work.mm && def->needs_mm) { mmgrab(current->mm); req->work.mm = current->mm; @@ -1151,7 +1152,7 @@ static inline void io_prep_async_work(struct io_kiocb *req, req->work.flags |= IO_WQ_WORK_UNBOUND; } - io_req_work_grab_env(req, def); + io_req_work_grab_env(req); *link = io_prep_linked_timeout(req); } @@ -5425,7 +5426,7 @@ static int io_req_defer_prep(struct io_kiocb *req, return ret; } - io_req_work_grab_env(req, &io_op_defs[req->opcode]); + io_req_work_grab_env(req); switch (req->opcode) { case IORING_OP_NOP: -- 1.8.3.1