Skip to content

Commit 2804ecd

Browse files
committed
io_uring: move apoll->events cache
In preparation for fixing a regression with pulling in an extra cacheline for IO that doesn't usually touch the last cacheline of the io_kiocb, move the cached location of apoll->events to space shared with some other completion data. Like cflags, this isn't used until after the request has been completed, so we can piggy back on top of comp_list. Fixes: 8145935 ("io_uring: cache req->apoll->events in req->cflags") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 6f83ab2 commit 2804ecd

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

fs/io_uring.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,12 @@ struct io_kiocb {
916916
/* store used ubuf, so we can prevent reloading */
917917
struct io_mapped_ubuf *imu;
918918

919-
/* used by request caches, completion batching and iopoll */
920-
struct io_wq_work_node comp_list;
919+
union {
920+
/* used by request caches, completion batching and iopoll */
921+
struct io_wq_work_node comp_list;
922+
/* cache ->apoll->events */
923+
int apoll_events;
924+
};
921925
atomic_t refs;
922926
atomic_t poll_refs;
923927
struct io_task_work io_task_work;
@@ -5833,7 +5837,6 @@ static void io_poll_remove_entries(struct io_kiocb *req)
58335837
static int io_poll_check_events(struct io_kiocb *req, bool locked)
58345838
{
58355839
struct io_ring_ctx *ctx = req->ctx;
5836-
struct io_poll_iocb *poll = io_poll_get_single(req);
58375840
int v;
58385841

58395842
/* req->task == current here, checking PF_EXITING is safe */
@@ -5850,17 +5853,17 @@ static int io_poll_check_events(struct io_kiocb *req, bool locked)
58505853
return -ECANCELED;
58515854

58525855
if (!req->result) {
5853-
struct poll_table_struct pt = { ._key = req->cflags };
5856+
struct poll_table_struct pt = { ._key = req->apoll_events };
58545857

58555858
if (unlikely(!io_assign_file(req, IO_URING_F_UNLOCKED)))
58565859
req->result = -EBADF;
58575860
else
5858-
req->result = vfs_poll(req->file, &pt) & req->cflags;
5861+
req->result = vfs_poll(req->file, &pt) & req->apoll_events;
58595862
}
58605863

58615864
/* multishot, just fill an CQE and proceed */
5862-
if (req->result && !(req->cflags & EPOLLONESHOT)) {
5863-
__poll_t mask = mangle_poll(req->result & poll->events);
5865+
if (req->result && !(req->apoll_events & EPOLLONESHOT)) {
5866+
__poll_t mask = mangle_poll(req->result & req->apoll_events);
58645867
bool filled;
58655868

58665869
spin_lock(&ctx->completion_lock);
@@ -5938,7 +5941,7 @@ static void __io_poll_execute(struct io_kiocb *req, int mask, int events)
59385941
* CPU. We want to avoid pulling in req->apoll->events for that
59395942
* case.
59405943
*/
5941-
req->cflags = events;
5944+
req->apoll_events = events;
59425945
if (req->opcode == IORING_OP_POLL_ADD)
59435946
req->io_task_work.func = io_poll_task_func;
59445947
else
@@ -6330,7 +6333,7 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
63306333
return -EINVAL;
63316334

63326335
io_req_set_refcount(req);
6333-
req->cflags = poll->events = io_poll_parse_events(sqe, flags);
6336+
req->apoll_events = poll->events = io_poll_parse_events(sqe, flags);
63346337
return 0;
63356338
}
63366339

0 commit comments

Comments
 (0)