Skip to content

Commit 5c727ce

Browse files
isilenceaxboe
authored andcommitted
io_uring/zcrx: cache fallback availability in zcrx ctx
Store a flag in struct io_zcrx_ifq telling if the backing memory is normal page or dmabuf based. It was looking it up from the area, however it logically allocates from the zcrx ctx and not a particular area, and once we add more than one area it'll become a mess. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://patch.msgid.link/65e75408a7758fe7e60fae89b7a8d5ae4857f515.1774261953.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent f0b9220 commit 5c727ce

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

io_uring/zcrx.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,13 @@ static void io_zcrx_free_area(struct io_zcrx_ifq *ifq,
423423
static int io_zcrx_append_area(struct io_zcrx_ifq *ifq,
424424
struct io_zcrx_area *area)
425425
{
426+
bool kern_readable = !area->mem.is_dmabuf;
427+
426428
if (WARN_ON_ONCE(ifq->area))
427429
return -EINVAL;
430+
if (WARN_ON_ONCE(ifq->kern_readable != kern_readable))
431+
return -EINVAL;
432+
428433
ifq->area = area;
429434
return 0;
430435
}
@@ -882,6 +887,8 @@ int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
882887
if (ret)
883888
goto err;
884889

890+
ifq->kern_readable = !(area.flags & IORING_ZCRX_AREA_DMABUF);
891+
885892
if (!(reg.flags & ZCRX_REG_NODEV)) {
886893
ret = zcrx_register_netdev(ifq, &reg, &area);
887894
if (ret)
@@ -1298,7 +1305,7 @@ static struct net_iov *io_alloc_fallback_niov(struct io_zcrx_ifq *ifq)
12981305
struct io_zcrx_area *area = ifq->area;
12991306
struct net_iov *niov = NULL;
13001307

1301-
if (area->mem.is_dmabuf)
1308+
if (!ifq->kern_readable)
13021309
return NULL;
13031310

13041311
scoped_guard(spinlock_bh, &area->freelist_lock)

io_uring/zcrx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct io_zcrx_ifq {
5454
unsigned niov_shift;
5555
struct user_struct *user;
5656
struct mm_struct *mm_account;
57+
bool kern_readable;
5758

5859
struct zcrx_rq rq ____cacheline_aligned_in_smp;
5960

0 commit comments

Comments
 (0)