]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
io_uring/poll: cache req->apoll_events
authorJens Axboe <axboe@kernel.dk>
Tue, 17 Mar 2026 20:10:19 +0000 (14:10 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 17 Mar 2026 20:34:51 +0000 (14:34 -0600)
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>
io_uring/poll.c

index b671b84657d9d3d049dd41bb075f2e9befc4dad8..4175e63b9edf55ad6e1875d833b8b06d5e900af2 100644 (file)
@@ -276,8 +276,10 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)
 
                /* the mask was stashed in __io_poll_execute */
                if (!req->cqe.res) {
-                       struct poll_table_struct pt = { ._key = req->apoll_events };
-                       req->cqe.res = vfs_poll(req->file, &pt) & req->apoll_events;
+                       __poll_t events = req->apoll_events;
+                       struct poll_table_struct pt = { ._key = events };
+
+                       req->cqe.res = vfs_poll(req->file, &pt) & events;
                        /*
                         * We got woken with a mask, but someone else got to
                         * 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)
                         */
                        if (unlikely(!req->cqe.res)) {
                                /* Multishot armed need not reissue */
-                               if (!(req->apoll_events & EPOLLONESHOT))
+                               if (!(events & EPOLLONESHOT))
                                        continue;
                                return IOU_POLL_REISSUE;
                        }