summaryrefslogtreecommitdiff
path: root/net/core/page_pool_user.c
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2023-11-26 15:07:36 -0800
committerPaolo Abeni <pabeni@redhat.com>2023-11-28 15:48:39 +0100
commit7aee8429eedd0970d8add2fb5b856bfc5f5f1fc1 (patch)
treea42444b0d1849dc8a780e83255e9dcb43b396e3b /net/core/page_pool_user.c
parentd2ef6aa077bdd0b3495dba5dcae6d3f19579b20b (diff)
net: page_pool: report amount of memory held by page pools
Advanced deployments need the ability to check memory use of various system components. It makes it possible to make informed decisions about memory allocation and to find regressions and leaks. Report memory use of page pools. Report both number of references and bytes held. Acked-by: Jesper Dangaard Brouer <hawk@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/core/page_pool_user.c')
-rw-r--r--net/core/page_pool_user.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/core/page_pool_user.c b/net/core/page_pool_user.c
index 1577fef880c9..2db71e718485 100644
--- a/net/core/page_pool_user.c
+++ b/net/core/page_pool_user.c
@@ -110,6 +110,7 @@ static int
page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool,
const struct genl_info *info)
{
+ size_t inflight, refsz;
void *hdr;
hdr = genlmsg_iput(rsp, info);
@@ -127,6 +128,13 @@ page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool,
nla_put_uint(rsp, NETDEV_A_PAGE_POOL_NAPI_ID, pool->user.napi_id))
goto err_cancel;
+ inflight = page_pool_inflight(pool, false);
+ refsz = PAGE_SIZE << pool->p.order;
+ if (nla_put_uint(rsp, NETDEV_A_PAGE_POOL_INFLIGHT, inflight) ||
+ nla_put_uint(rsp, NETDEV_A_PAGE_POOL_INFLIGHT_MEM,
+ inflight * refsz))
+ goto err_cancel;
+
genlmsg_end(rsp, hdr);
return 0;