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/zcrx: move zcrx region to struct io_zcrx_ifq

Refill queue region is a part of zcrx and should stay in struct
io_zcrx_ifq. We can't have multiple queues without it, so move it there.

As a result there is no context global zcrx region anymore, and the
region is looked up together with its ifq. To protect a concurrent mmap
from seeing an inconsistent region we were protecting changes to
->zcrx_region with mmap_lock, but now it protect the publishing of the
ifq.

Reviewed-by: David Wei <dw@davidwei.uk>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/24f1a728fc03d0166f16d099575457e10d9d90f2.1745141261.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
632b3186 77231d4e

+13 -10
-2
include/linux/io_uring_types.h
··· 448 448 struct io_mapped_region ring_region; 449 449 /* used for optimised request parameter and wait argument passing */ 450 450 struct io_mapped_region param_region; 451 - /* just one zcrx per ring for now, will move to io_zcrx_ifq eventually */ 452 - struct io_mapped_region zcrx_region; 453 451 }; 454 452 455 453 /*
+12 -8
io_uring/zcrx.c
··· 167 167 if (size > rd->size) 168 168 return -EINVAL; 169 169 170 - ret = io_create_region_mmap_safe(ifq->ctx, &ifq->ctx->zcrx_region, rd, 171 - IORING_MAP_OFF_ZCRX_REGION); 170 + ret = io_create_region(ifq->ctx, &ifq->region, rd, IORING_MAP_OFF_ZCRX_REGION); 172 171 if (ret < 0) 173 172 return ret; 174 173 175 - ptr = io_region_get_ptr(&ifq->ctx->zcrx_region); 174 + ptr = io_region_get_ptr(&ifq->region); 176 175 ifq->rq_ring = (struct io_uring *)ptr; 177 176 ifq->rqes = (struct io_uring_zcrx_rqe *)(ptr + off); 178 177 return 0; ··· 179 180 180 181 static void io_free_rbuf_ring(struct io_zcrx_ifq *ifq) 181 182 { 182 - io_free_region(ifq->ctx, &ifq->ctx->zcrx_region); 183 + if (WARN_ON_ONCE(ifq->ctx->ifq)) 184 + return; 185 + 186 + io_free_region(ifq->ctx, &ifq->region); 183 187 ifq->rq_ring = NULL; 184 188 ifq->rqes = NULL; 185 189 } ··· 345 343 { 346 344 lockdep_assert_held(&ctx->mmap_lock); 347 345 348 - if (id != 0) 346 + if (id != 0 || !ctx->ifq) 349 347 return NULL; 350 - return &ctx->zcrx_region; 348 + return &ctx->ifq->region; 351 349 } 352 350 353 351 int io_register_zcrx_ifq(struct io_ring_ctx *ctx, ··· 435 433 ret = -EFAULT; 436 434 goto err; 437 435 } 438 - ctx->ifq = ifq; 436 + scoped_guard(mutex, &ctx->mmap_lock) 437 + ctx->ifq = ifq; 439 438 return 0; 440 439 err: 441 440 io_zcrx_ifq_free(ifq); ··· 452 449 if (!ifq) 453 450 return; 454 451 455 - ctx->ifq = NULL; 452 + scoped_guard(mutex, &ctx->mmap_lock) 453 + ctx->ifq = NULL; 456 454 io_zcrx_ifq_free(ifq); 457 455 } 458 456
+1
io_uring/zcrx.h
··· 39 39 netdevice_tracker netdev_tracker; 40 40 spinlock_t lock; 41 41 struct mutex dma_lock; 42 + struct io_mapped_region region; 42 43 }; 43 44 44 45 #if defined(CONFIG_IO_URING_ZCRX)