]> Gentwo Git Trees - linux/.git/commitdiff
io_uring/zcrx: count zcrx users
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 13 Nov 2025 10:46:14 +0000 (10:46 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Nov 2025 18:19:37 +0000 (11:19 -0700)
zcrx tries to detach ifq / terminate page pools when the io_uring ctx
owning it is being destroyed. There will be multiple io_uring instances
attached to it in the future, so add a separate counter to track the
users. Note, refs can't be reused for this purpose as it only used to
prevent zcrx and rings destruction, and also used by page pools to keep
it alive.

Signed-off-by: David Wei <dw@davidwei.uk>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/zcrx.c
io_uring/zcrx.h

index 08c103af69bcddf89000b0a2b19aefe349c5556b..2335f140ff19097bddfa88b3172d254de284246c 100644 (file)
@@ -482,6 +482,7 @@ static struct io_zcrx_ifq *io_zcrx_ifq_alloc(struct io_ring_ctx *ctx)
        spin_lock_init(&ifq->rq_lock);
        mutex_init(&ifq->pp_lock);
        refcount_set(&ifq->refs, 1);
+       refcount_set(&ifq->user_refs, 1);
        return ifq;
 }
 
@@ -742,8 +743,10 @@ void io_unregister_zcrx_ifqs(struct io_ring_ctx *ctx)
                if (!ifq)
                        break;
 
-               io_close_queue(ifq);
-               io_zcrx_scrub(ifq);
+               if (refcount_dec_and_test(&ifq->user_refs)) {
+                       io_close_queue(ifq);
+                       io_zcrx_scrub(ifq);
+               }
                io_put_zcrx_ifq(ifq);
        }
 
index f29edc22c91f06e1b3965603f4e6e8f0ce26bdda..32ab95b2cb811a74785d45eb65a67db947330815 100644 (file)
@@ -55,6 +55,8 @@ struct io_zcrx_ifq {
        struct net_device               *netdev;
        netdevice_tracker               netdev_tracker;
        refcount_t                      refs;
+       /* counts userspace facing users like io_uring */
+       refcount_t                      user_refs;
 
        /*
         * Page pool and net configuration lock, can be taken deeper in the