Skip to content

Commit 82733d1

Browse files
committed
io_uring: stop using io_wq_work as an fd placeholder
There are two reasons why this isn't the best idea: - It's an odd area to grab a bit of storage space, hence it's an odd area to grab storage from. - It puts the 3rd io_kiocb cacheline into the hot path, where normal hot path just needs the first two. Use 'cflags' for joint fd/cflags storage. We only need fd until we successfully issue, and we only need cflags once a request is done and is completed. Fixes: 6bf9c47 ("io_uring: defer file assignment") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2804ecd commit 82733d1

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

fs/io-wq.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ struct io_wq_work_node *wq_stack_extract(struct io_wq_work_node *stack)
155155
struct io_wq_work {
156156
struct io_wq_work_node list;
157157
unsigned flags;
158-
int fd;
159158
};
160159

161160
static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)

fs/io_uring.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,11 @@ struct io_kiocb {
907907

908908
u64 user_data;
909909
u32 result;
910-
u32 cflags;
910+
/* fd initially, then cflags for completion */
911+
union {
912+
u32 cflags;
913+
int fd;
914+
};
911915

912916
struct io_ring_ctx *ctx;
913917
struct task_struct *task;
@@ -7090,9 +7094,9 @@ static bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags)
70907094
return true;
70917095

70927096
if (req->flags & REQ_F_FIXED_FILE)
7093-
req->file = io_file_get_fixed(req, req->work.fd, issue_flags);
7097+
req->file = io_file_get_fixed(req, req->fd, issue_flags);
70947098
else
7095-
req->file = io_file_get_normal(req, req->work.fd);
7099+
req->file = io_file_get_normal(req, req->fd);
70967100
if (req->file)
70977101
return true;
70987102

@@ -7630,7 +7634,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
76307634
if (io_op_defs[opcode].needs_file) {
76317635
struct io_submit_state *state = &ctx->submit_state;
76327636

7633-
req->work.fd = READ_ONCE(sqe->fd);
7637+
req->fd = READ_ONCE(sqe->fd);
76347638

76357639
/*
76367640
* Plug now if we have more than 2 IO left after this, and the

0 commit comments

Comments
 (0)