diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-01-29 04:08:24 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-02-08 21:27:06 +0100 |
commit | 95041b93e90a06bb613ec4bef9cd4d61570f68e4 (patch) | |
tree | a40378fc60c611affd5f48bfe2efa56c9c00e157 /io_uring/io_uring.h | |
parent | io_uring/cancel: don't default to setting req->work.cancel_seq (diff) | |
download | linux-95041b93e90a06bb613ec4bef9cd4d61570f68e4.tar.xz linux-95041b93e90a06bb613ec4bef9cd4d61570f68e4.zip |
io_uring: add io_file_can_poll() helper
This adds a flag to avoid dipping dereferencing file and then f_op to
figure out if the file has a poll handler defined or not. We generally
call this at least twice for networked workloads, and if using ring
provided buffers, we do it on every buffer selection. Particularly the
latter is troublesome, as it's otherwise a very fast operation.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/io_uring.h')
-rw-r--r-- | io_uring/io_uring.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index d5495710c178..2952551fe345 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -5,6 +5,7 @@ #include <linux/lockdep.h> #include <linux/resume_user_mode.h> #include <linux/kasan.h> +#include <linux/poll.h> #include <linux/io_uring_types.h> #include <uapi/linux/eventpoll.h> #include "io-wq.h" @@ -398,4 +399,15 @@ static inline size_t uring_sqe_size(struct io_ring_ctx *ctx) return 2 * sizeof(struct io_uring_sqe); return sizeof(struct io_uring_sqe); } + +static inline bool io_file_can_poll(struct io_kiocb *req) +{ + if (req->flags & REQ_F_CAN_POLL) + return true; + if (file_can_poll(req->file)) { + req->flags |= REQ_F_CAN_POLL; + return true; + } + return false; +} #endif |