Skip to content

Commit c9def23

Browse files
isilenceaxboe
authored andcommitted
io_uring: separate task_work/waiting cache line
task_work's are typically queued up from IRQ/softirq potentially by a random CPU like in case of networking. Batch ctx fields bouncing as this into a separate cache line. We also move ->cq_timeouts there because waiters have to read and check it. We can also conditionally hide ->cq_timeouts in the future from the CQ wait path as a not really useful rudiment. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/b7f3fcb5b6b9cca0238778262c1fdb7ada6286b7.1692916914.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 18df385 commit c9def23

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

include/linux/io_uring_types.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,25 @@ struct io_ring_ctx {
270270
unsigned cached_cq_tail;
271271
unsigned cq_entries;
272272
struct io_ev_fd __rcu *io_ev_fd;
273-
struct wait_queue_head cq_wait;
274273
unsigned cq_extra;
275274
} ____cacheline_aligned_in_smp;
276275

276+
/*
277+
* task_work and async notification delivery cacheline. Expected to
278+
* regularly bounce b/w CPUs.
279+
*/
280+
struct {
281+
struct llist_head work_llist;
282+
unsigned long check_cq;
283+
atomic_t cq_wait_nr;
284+
atomic_t cq_timeouts;
285+
struct wait_queue_head cq_wait;
286+
} ____cacheline_aligned_in_smp;
287+
277288
struct {
278289
spinlock_t completion_lock;
279290

280291
bool poll_multi_queue;
281-
atomic_t cq_wait_nr;
282292

283293
/*
284294
* ->iopoll_list is protected by the ctx->uring_lock for
@@ -287,14 +297,11 @@ struct io_ring_ctx {
287297
* manipulate the list, hence no extra locking is needed there.
288298
*/
289299
struct io_wq_work_list iopoll_list;
290-
291-
struct llist_head work_llist;
292300
} ____cacheline_aligned_in_smp;
293301

294302
/* timeouts */
295303
struct {
296304
spinlock_t timeout_lock;
297-
atomic_t cq_timeouts;
298305
struct list_head timeout_list;
299306
struct list_head ltimeout_list;
300307
unsigned cq_last_tm_flush;
@@ -314,8 +321,6 @@ struct io_ring_ctx {
314321
struct wait_queue_head sqo_sq_wait;
315322
struct list_head sqd_list;
316323

317-
unsigned long check_cq;
318-
319324
unsigned int file_alloc_start;
320325
unsigned int file_alloc_end;
321326

0 commit comments

Comments
 (0)