follow up zcrx fixes
Subsystems (4)
Pavel Begunkov
maintainercover follow up zcrx fixes
Follow up fixes for the recent update flagged by review.
Pavel Begunkov (4):
io_uring/zcrx: don't use mark0 for allocating xarray io_uring/zcrx: don't clear not allocated niovs io_uring/zcrx: use dma_len for chunk size calculation io_uring/zcrx: use correct mmap off constants
io_uring/zcrx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
Signature · 1 line
2.53.0
Pavel Begunkov
maintainerPATCH 1/4 io_uring/zcrx: don't use mark0 for allocating xarray
XA_MARK_0 is not compatible with xarray allocating entries, use XA_MARK_1.
--- io_uring/zcrx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
io_uring/zcrx.c +2 -2
@@ -927,12 +927,12 @@ int io_register_zcrx(struct io_ring_ctx *ctx,static inline bool is_zcrx_entry_marked (struct io_ring_ctx *ctx,unsigned long id) { -return xa_get_mark (&ctx->zcrx_ctxs, id,XA_MARK_0 ); +return xa_get_mark (&ctx->zcrx_ctxs, id,XA_MARK_1 ); }static inline void set_zcrx_entry_mark (struct io_ring_ctx *ctx,unsigned long id) { -xa_set_mark (&ctx->zcrx_ctxs, id,XA_MARK_0 ); +xa_set_mark (&ctx->zcrx_ctxs, id,XA_MARK_1 ); }void io_terminate_zcrx (struct io_ring_ctx *ctx)
Signature · 1 line
2.53.0
Pavel Begunkov
maintainerPATCH 2/4 io_uring/zcrx: don't clear not allocated niovs
In reply to Pavel BegunkovNow that area->is_mapped is set earlier before niovs array is allocated, io_zcrx_free_area -> io_zcrx_unmap_area in an error path can try to clear dma addresses for unallocated niovs, fix it.
--- io_uring/zcrx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
io_uring/zcrx.c +4 -2
@@ -289,8 +289,10 @@ static void io_zcrx_unmap_area(struct io_zcrx_ifq *ifq,return ; area->is_mapped = false; -for (i =0 ; i < area->nia.num_niovs; i++) -net_mp_niov_set_dma_addr (&area->nia.niovs[i],0 ); +if (area->nia.niovs) { +for (i =0 ; i < area->nia.num_niovs; i++) +net_mp_niov_set_dma_addr (&area->nia.niovs[i],0 ); + }if (area->mem.is_dmabuf) {io_release_dmabuf (&area->mem);
Signature · 1 line
2.53.0
Pavel Begunkov
maintainerPATCH 3/4 io_uring/zcrx: use dma_len for chunk size calculation
In reply to Pavel BegunkovBuffers are now dma-mapped earlier and we can sg_dma_len(), otherwise, since it's walking with for_each_sgtable_dma_sg(), it might wrongfully reject some configurations. As a bonus, it'd now be able to use larger chunks if dma addresses are coalesced e.g by iommu.
--- io_uring/zcrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/zcrx.c +1 -1
@@ -63,7 +63,7 @@ static int io_area_max_shift(struct io_zcrx_mem *mem)unsigned i;for_each_sgtable_dma_sg (sgt, sg, i) - shift =min (shift,__ffs (sg->length)); + shift =min (shift,__ffs (sg_dma_len (sg)));return shift; }
Signature · 1 line
2.53.0
Pavel Begunkov
maintainerPATCH 4/4 io_uring/zcrx: use correct mmap off constants
In reply to Pavel Begunkovzcrx was using IORING_OFF_PBUF_SHIFT during first iterations, but there is now a separate constant it should use. Both are 16 so it doesn't change anything, but improve it for the future.
--- io_uring/zcrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/zcrx.c +1 -1
@@ -386,7 +386,7 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,return -EINVAL ; mmap_offset =IORING_MAP_OFF_ZCRX_REGION ; - mmap_offset += id <<IORING_OFF_PBUF_SHIFT ; + mmap_offset += id <<IORING_OFF_ZCRX_SHIFT ; ret =io_create_region (ctx, &ifq->rq_region, rd, mmap_offset);if (ret <0 )
Signature · 1 line
2.53.0
Pavel Begunkov
maintainerQuoted 1 line · Pavel Begunkov
Follow up fixes for the recent update flagged by review.
Actually, I'm not happy how it interacts with the nodev mode, I'll send a v2
Signature · 1 line
Pavel Begunkov