Skip to content

Commit

Permalink
net: page_pool: stash the NAPI ID for easier access
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jakub Kicinski authored and Paolo Abeni committed Nov 28, 2023
1 parent 083772c commit 02b3de8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/net/page_pool/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 3 additions & 1 deletion net/core/page_pool_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 02b3de8

Please sign in to comment.