net: page_pool: stash the NAPI ID for easier access
authorJakub Kicinski <kuba@kernel.org>
Sun, 26 Nov 2023 23:07:31 +0000 (15:07 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 28 Nov 2023 14:48:39 +0000 (15:48 +0100)
To avoid any issues with race conditions on accessing napi
and having to think about the lifetime of NAPI objects
in netlink GET - stash the napi_id to which page pool
was linked at creation time.

Reviewed-by: Eric Dumazet <edumazet@google.com>
Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/page_pool/types.h
net/core/page_pool_user.c

index b258a571201e7f76b3d26fff19d2ec95edac713c..7e47d7bb2c1edbedff928ee88e06b38500ef7ddf 100644 (file)
@@ -193,6 +193,7 @@ struct page_pool {
        /* User-facing fields, protected by page_pools_lock */
        struct {
                struct hlist_node list;
+               u32 napi_id;
                u32 id;
        } user;
 };
index e5c7f078fbd4ee082cb92b6faad2a3a3b480ac62..2888aa8dd3e4f81802061ac8b1d4c857ab317b7c 100644 (file)
@@ -37,9 +37,11 @@ int page_pool_list(struct page_pool *pool)
        if (err < 0)
                goto err_unlock;
 
-       if (pool->slow.netdev)
+       if (pool->slow.netdev) {
                hlist_add_head(&pool->user.list,
                               &pool->slow.netdev->page_pools);
+               pool->user.napi_id = pool->p.napi ? pool->p.napi->napi_id : 0;
+       }
 
        mutex_unlock(&page_pools_lock);
        return 0;