diff options
| author | Jens Axboe <axboe@kernel.dk> | 2026-03-14 17:46:17 +0300 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-03-17 00:33:10 +0300 |
| commit | 8c557449199e8267bc969ae7e1d70b343b6a646d (patch) | |
| tree | 7e24c81405ff50803bacc383ee5adfb00b856a5e | |
| parent | f1a424e21c15993db0f9594cda17ef5d516ab3e9 (diff) | |
| download | linux-8c557449199e8267bc969ae7e1d70b343b6a646d.tar.xz | |
io_uring: mark known and harmless racy ctx->int_flags uses
There are a few of these, where flags are read outside of the
uring_lock, yet it's harmless to race on them.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
| -rw-r--r-- | io_uring/io_uring.c | 2 | ||||
| -rw-r--r-- | io_uring/io_uring.h | 7 | ||||
| -rw-r--r-- | io_uring/tw.c | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index bfeb3bc3849d..fb5a263706be 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2242,7 +2242,7 @@ static __poll_t io_uring_poll(struct file *file, poll_table *wait) struct io_ring_ctx *ctx = file->private_data; __poll_t mask = 0; - if (unlikely(!(ctx->int_flags & IO_RING_F_POLL_ACTIVATED))) + if (unlikely(!(data_race(ctx->int_flags) & IO_RING_F_POLL_ACTIVATED))) io_activate_pollwq(ctx); /* * provides mb() which pairs with barrier from wq_has_sleeper diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index 5cb1983043cd..91cf67b5d85b 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -470,11 +470,12 @@ static inline void io_req_complete_defer(struct io_kiocb *req) wq_list_add_tail(&req->comp_list, &state->compl_reqs); } +#define SHOULD_FLUSH_MASK (IO_RING_F_OFF_TIMEOUT_USED | \ + IO_RING_F_HAS_EVFD | IO_RING_F_POLL_ACTIVATED) + static inline void io_commit_cqring_flush(struct io_ring_ctx *ctx) { - if (unlikely(ctx->int_flags & (IO_RING_F_OFF_TIMEOUT_USED | - IO_RING_F_HAS_EVFD | - IO_RING_F_POLL_ACTIVATED))) + if (unlikely(data_race(ctx->int_flags) & SHOULD_FLUSH_MASK)) __io_commit_cqring_flush(ctx); } diff --git a/io_uring/tw.c b/io_uring/tw.c index 022fe8753c19..fdff81eebc95 100644 --- a/io_uring/tw.c +++ b/io_uring/tw.c @@ -222,7 +222,7 @@ void io_req_local_work_add(struct io_kiocb *req, unsigned flags) if (!head) { io_ctx_mark_taskrun(ctx); - if (ctx->int_flags & IO_RING_F_HAS_EVFD) + if (data_race(ctx->int_flags) & IO_RING_F_HAS_EVFD) io_eventfd_signal(ctx, false); } |
