Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/napi: protect concurrent io_napi_entry timeout accesses

io_napi_entry timeout value can be updated while accessed from the poll
functions.

Its concurrent accesses are wrapped with READ_ONCE()/WRITE_ONCE() macros
to avoid incorrect compiler optimizations.

Signed-off-by: Olivier Langlois <olivier@trillion01.com>
Link: https://lore.kernel.org/r/3de3087563cf98f75266fd9f85fdba063a8720db.1728828877.git.olivier@trillion01.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Olivier Langlois and committed by
Jens Axboe
2f3cc8e4 48324271

+3 -3
+3 -3
io_uring/napi.c
··· 60 60 rcu_read_lock(); 61 61 e = io_napi_hash_find(hash_list, napi_id); 62 62 if (e) { 63 - e->timeout = jiffies + NAPI_TIMEOUT; 63 + WRITE_ONCE(e->timeout, jiffies + NAPI_TIMEOUT); 64 64 rcu_read_unlock(); 65 65 return; 66 66 } ··· 92 92 93 93 spin_lock(&ctx->napi_lock); 94 94 hash_for_each(ctx->napi_ht, i, e, node) { 95 - if (time_after(jiffies, e->timeout)) { 95 + if (time_after(jiffies, READ_ONCE(e->timeout))) { 96 96 list_del(&e->list); 97 97 hash_del_rcu(&e->node); 98 98 kfree_rcu(e, rcu); ··· 150 150 napi_busy_loop_rcu(e->napi_id, loop_end, loop_end_arg, 151 151 ctx->napi_prefer_busy_poll, BUSY_POLL_BUDGET); 152 152 153 - if (time_after(jiffies, e->timeout)) 153 + if (time_after(jiffies, READ_ONCE(e->timeout))) 154 154 is_stale = true; 155 155 } 156 156