Skip to content

Commit 9eb3c57

Browse files
isilenceaxboe
authored andcommitted
io_uring/zcrx: improve rqe cache alignment
Refill queue entries are 16B structures, but because of the ring header placement, they're 8B aligned but not naturally / 16B aligned, which means some of them span across 2 cache lines. Push rqes to a new cache line. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1b3aa39 commit 9eb3c57

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

io_uring/zcrx.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int io_allocate_rbuf_ring(struct io_zcrx_ifq *ifq,
352352
void *ptr;
353353
int ret;
354354

355-
off = sizeof(struct io_uring);
355+
off = ALIGN(sizeof(struct io_uring), L1_CACHE_BYTES);
356356
size = off + sizeof(struct io_uring_zcrx_rqe) * reg->rq_entries;
357357
if (size > rd->size)
358358
return -EINVAL;
@@ -367,6 +367,10 @@ static int io_allocate_rbuf_ring(struct io_zcrx_ifq *ifq,
367367
ptr = io_region_get_ptr(&ifq->region);
368368
ifq->rq_ring = (struct io_uring *)ptr;
369369
ifq->rqes = (struct io_uring_zcrx_rqe *)(ptr + off);
370+
371+
reg->offsets.head = offsetof(struct io_uring, head);
372+
reg->offsets.tail = offsetof(struct io_uring, tail);
373+
reg->offsets.rqes = off;
370374
return 0;
371375
}
372376

@@ -618,9 +622,6 @@ int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
618622
goto err;
619623
ifq->if_rxq = reg.if_rxq;
620624

621-
reg.offsets.rqes = sizeof(struct io_uring);
622-
reg.offsets.head = offsetof(struct io_uring, head);
623-
reg.offsets.tail = offsetof(struct io_uring, tail);
624625
reg.zcrx_id = id;
625626

626627
scoped_guard(mutex, &ctx->mmap_lock) {

0 commit comments

Comments
 (0)