Skip to content

Commit 74dbc0b

Browse files
committed
io_uring/poll: cache req->apoll_events
Avoid a potential reload of ->apoll_events post vfs_poll() by caching it in a local variable. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 49c21d9 commit 74dbc0b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

io_uring/poll.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,10 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)
276276

277277
/* the mask was stashed in __io_poll_execute */
278278
if (!req->cqe.res) {
279-
struct poll_table_struct pt = { ._key = req->apoll_events };
280-
req->cqe.res = vfs_poll(req->file, &pt) & req->apoll_events;
279+
__poll_t events = req->apoll_events;
280+
struct poll_table_struct pt = { ._key = events };
281+
282+
req->cqe.res = vfs_poll(req->file, &pt) & events;
281283
/*
282284
* We got woken with a mask, but someone else got to
283285
* it first. The above vfs_poll() doesn't add us back
@@ -286,7 +288,7 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)
286288
*/
287289
if (unlikely(!req->cqe.res)) {
288290
/* Multishot armed need not reissue */
289-
if (!(req->apoll_events & EPOLLONESHOT))
291+
if (!(events & EPOLLONESHOT))
290292
continue;
291293
return IOU_POLL_REISSUE;
292294
}

0 commit comments

Comments
 (0)