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: let zcrx choose region for mmaping

In preparation for adding multiple ifqs, add a helper returning a region
for mmaping zcrx refill queue. For now it's trivial and returns the same
ctx global ->zcrx_region.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/d9006e2ef8cd5e5b337c2ba2228ede8409eb60f2.1745141261.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
77231d4e 59bc1ab9

+26 -4
+7 -4
io_uring/memmap.c
··· 13 13 #include "memmap.h" 14 14 #include "kbuf.h" 15 15 #include "rsrc.h" 16 + #include "zcrx.h" 16 17 17 18 static void *io_mem_alloc_compound(struct page **pages, int nr_pages, 18 19 size_t size, gfp_t gfp) ··· 259 258 loff_t pgoff) 260 259 { 261 260 loff_t offset = pgoff << PAGE_SHIFT; 262 - unsigned int bgid; 261 + unsigned int id; 262 + 263 263 264 264 switch (offset & IORING_OFF_MMAP_MASK) { 265 265 case IORING_OFF_SQ_RING: ··· 269 267 case IORING_OFF_SQES: 270 268 return &ctx->sq_region; 271 269 case IORING_OFF_PBUF_RING: 272 - bgid = (offset & ~IORING_OFF_MMAP_MASK) >> IORING_OFF_PBUF_SHIFT; 273 - return io_pbuf_get_region(ctx, bgid); 270 + id = (offset & ~IORING_OFF_MMAP_MASK) >> IORING_OFF_PBUF_SHIFT; 271 + return io_pbuf_get_region(ctx, id); 274 272 case IORING_MAP_OFF_PARAM_REGION: 275 273 return &ctx->param_region; 276 274 case IORING_MAP_OFF_ZCRX_REGION: 277 - return &ctx->zcrx_region; 275 + id = (offset & ~IORING_OFF_MMAP_MASK) >> IORING_OFF_ZCRX_SHIFT; 276 + return io_zcrx_get_region(ctx, id); 278 277 } 279 278 return NULL; 280 279 }
+2
io_uring/memmap.h
··· 4 4 #define IORING_MAP_OFF_PARAM_REGION 0x20000000ULL 5 5 #define IORING_MAP_OFF_ZCRX_REGION 0x30000000ULL 6 6 7 + #define IORING_OFF_ZCRX_SHIFT 16 8 + 7 9 struct page **io_pin_pages(unsigned long ubuf, unsigned long len, int *npages); 8 10 9 11 #ifndef CONFIG_MMU
+10
io_uring/zcrx.c
··· 338 338 kfree(ifq); 339 339 } 340 340 341 + struct io_mapped_region *io_zcrx_get_region(struct io_ring_ctx *ctx, 342 + unsigned int id) 343 + { 344 + lockdep_assert_held(&ctx->mmap_lock); 345 + 346 + if (id != 0) 347 + return NULL; 348 + return &ctx->zcrx_region; 349 + } 350 + 341 351 int io_register_zcrx_ifq(struct io_ring_ctx *ctx, 342 352 struct io_uring_zcrx_ifq_reg __user *arg) 343 353 {
+7
io_uring/zcrx.h
··· 49 49 int io_zcrx_recv(struct io_kiocb *req, struct io_zcrx_ifq *ifq, 50 50 struct socket *sock, unsigned int flags, 51 51 unsigned issue_flags, unsigned int *len); 52 + struct io_mapped_region *io_zcrx_get_region(struct io_ring_ctx *ctx, 53 + unsigned int id); 52 54 #else 53 55 static inline int io_register_zcrx_ifq(struct io_ring_ctx *ctx, 54 56 struct io_uring_zcrx_ifq_reg __user *arg) ··· 68 66 unsigned issue_flags, unsigned int *len) 69 67 { 70 68 return -EOPNOTSUPP; 69 + } 70 + static inline struct io_mapped_region *io_zcrx_get_region(struct io_ring_ctx *ctx, 71 + unsigned int id) 72 + { 73 + return NULL; 71 74 } 72 75 #endif 73 76