mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									59bc1ab922
								
							
						
					
					
						commit
						77231d4e46
					
				
					 4 changed files with 26 additions and 4 deletions
				
			
		| 
						 | 
					@ -13,6 +13,7 @@
 | 
				
			||||||
#include "memmap.h"
 | 
					#include "memmap.h"
 | 
				
			||||||
#include "kbuf.h"
 | 
					#include "kbuf.h"
 | 
				
			||||||
#include "rsrc.h"
 | 
					#include "rsrc.h"
 | 
				
			||||||
 | 
					#include "zcrx.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void *io_mem_alloc_compound(struct page **pages, int nr_pages,
 | 
					static void *io_mem_alloc_compound(struct page **pages, int nr_pages,
 | 
				
			||||||
				   size_t size, gfp_t gfp)
 | 
									   size_t size, gfp_t gfp)
 | 
				
			||||||
| 
						 | 
					@ -258,7 +259,8 @@ static struct io_mapped_region *io_mmap_get_region(struct io_ring_ctx *ctx,
 | 
				
			||||||
						   loff_t pgoff)
 | 
											   loff_t pgoff)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	loff_t offset = pgoff << PAGE_SHIFT;
 | 
						loff_t offset = pgoff << PAGE_SHIFT;
 | 
				
			||||||
	unsigned int bgid;
 | 
						unsigned int id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (offset & IORING_OFF_MMAP_MASK) {
 | 
						switch (offset & IORING_OFF_MMAP_MASK) {
 | 
				
			||||||
	case IORING_OFF_SQ_RING:
 | 
						case IORING_OFF_SQ_RING:
 | 
				
			||||||
| 
						 | 
					@ -267,12 +269,13 @@ static struct io_mapped_region *io_mmap_get_region(struct io_ring_ctx *ctx,
 | 
				
			||||||
	case IORING_OFF_SQES:
 | 
						case IORING_OFF_SQES:
 | 
				
			||||||
		return &ctx->sq_region;
 | 
							return &ctx->sq_region;
 | 
				
			||||||
	case IORING_OFF_PBUF_RING:
 | 
						case IORING_OFF_PBUF_RING:
 | 
				
			||||||
		bgid = (offset & ~IORING_OFF_MMAP_MASK) >> IORING_OFF_PBUF_SHIFT;
 | 
							id = (offset & ~IORING_OFF_MMAP_MASK) >> IORING_OFF_PBUF_SHIFT;
 | 
				
			||||||
		return io_pbuf_get_region(ctx, bgid);
 | 
							return io_pbuf_get_region(ctx, id);
 | 
				
			||||||
	case IORING_MAP_OFF_PARAM_REGION:
 | 
						case IORING_MAP_OFF_PARAM_REGION:
 | 
				
			||||||
		return &ctx->param_region;
 | 
							return &ctx->param_region;
 | 
				
			||||||
	case IORING_MAP_OFF_ZCRX_REGION:
 | 
						case IORING_MAP_OFF_ZCRX_REGION:
 | 
				
			||||||
		return &ctx->zcrx_region;
 | 
							id = (offset & ~IORING_OFF_MMAP_MASK) >> IORING_OFF_ZCRX_SHIFT;
 | 
				
			||||||
 | 
							return io_zcrx_get_region(ctx, id);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,8 @@
 | 
				
			||||||
#define IORING_MAP_OFF_PARAM_REGION		0x20000000ULL
 | 
					#define IORING_MAP_OFF_PARAM_REGION		0x20000000ULL
 | 
				
			||||||
#define IORING_MAP_OFF_ZCRX_REGION		0x30000000ULL
 | 
					#define IORING_MAP_OFF_ZCRX_REGION		0x30000000ULL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define IORING_OFF_ZCRX_SHIFT		16
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct page **io_pin_pages(unsigned long ubuf, unsigned long len, int *npages);
 | 
					struct page **io_pin_pages(unsigned long ubuf, unsigned long len, int *npages);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef CONFIG_MMU
 | 
					#ifndef CONFIG_MMU
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -338,6 +338,16 @@ static void io_zcrx_ifq_free(struct io_zcrx_ifq *ifq)
 | 
				
			||||||
	kfree(ifq);
 | 
						kfree(ifq);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct io_mapped_region *io_zcrx_get_region(struct io_ring_ctx *ctx,
 | 
				
			||||||
 | 
										    unsigned int id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						lockdep_assert_held(&ctx->mmap_lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (id != 0)
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						return &ctx->zcrx_region;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
 | 
					int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
 | 
				
			||||||
			  struct io_uring_zcrx_ifq_reg __user *arg)
 | 
								  struct io_uring_zcrx_ifq_reg __user *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,6 +49,8 @@ void io_shutdown_zcrx_ifqs(struct io_ring_ctx *ctx);
 | 
				
			||||||
int io_zcrx_recv(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
 | 
					int io_zcrx_recv(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
 | 
				
			||||||
		 struct socket *sock, unsigned int flags,
 | 
							 struct socket *sock, unsigned int flags,
 | 
				
			||||||
		 unsigned issue_flags, unsigned int *len);
 | 
							 unsigned issue_flags, unsigned int *len);
 | 
				
			||||||
 | 
					struct io_mapped_region *io_zcrx_get_region(struct io_ring_ctx *ctx,
 | 
				
			||||||
 | 
										    unsigned int id);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static inline int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
 | 
					static inline int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
 | 
				
			||||||
					struct io_uring_zcrx_ifq_reg __user *arg)
 | 
										struct io_uring_zcrx_ifq_reg __user *arg)
 | 
				
			||||||
| 
						 | 
					@ -67,6 +69,11 @@ static inline int io_zcrx_recv(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return -EOPNOTSUPP;
 | 
						return -EOPNOTSUPP;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					static inline struct io_mapped_region *io_zcrx_get_region(struct io_ring_ctx *ctx,
 | 
				
			||||||
 | 
												  unsigned int id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int io_recvzc(struct io_kiocb *req, unsigned int issue_flags);
 | 
					int io_recvzc(struct io_kiocb *req, unsigned int issue_flags);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue