net: page_pool: report amount of memory held by page pools
JIRA: https://issues.redhat.com/browse/RHEL-31941 Upstream commit(s): commit 7aee8429eedd0970d8add2fb5b856bfc5f5f1fc1 Author: Jakub Kicinski <kuba@kernel.org> Date: Sun Nov 26 15:07:36 2023 -0800 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> Signed-off-by: Petr Oros <poros@redhat.com>
This commit is contained in:
parent
3060573558
commit
acb72c024e
|
@ -114,6 +114,19 @@ attribute-sets:
|
||||||
checks:
|
checks:
|
||||||
min: 1
|
min: 1
|
||||||
max: u32-max
|
max: u32-max
|
||||||
|
-
|
||||||
|
name: inflight
|
||||||
|
type: uint
|
||||||
|
doc: |
|
||||||
|
Number of outstanding references to this page pool (allocated
|
||||||
|
but yet to be freed pages). Allocated pages may be held in
|
||||||
|
socket receive queues, driver receive ring, page pool recycling
|
||||||
|
ring, the page pool cache, etc.
|
||||||
|
-
|
||||||
|
name: inflight-mem
|
||||||
|
type: uint
|
||||||
|
doc: |
|
||||||
|
Amount of memory held by inflight pages.
|
||||||
|
|
||||||
operations:
|
operations:
|
||||||
list:
|
list:
|
||||||
|
@ -163,6 +176,8 @@ operations:
|
||||||
- id
|
- id
|
||||||
- ifindex
|
- ifindex
|
||||||
- napi-id
|
- napi-id
|
||||||
|
- inflight
|
||||||
|
- inflight-mem
|
||||||
dump:
|
dump:
|
||||||
reply: *pp-reply
|
reply: *pp-reply
|
||||||
config-cond: page-pool
|
config-cond: page-pool
|
||||||
|
|
|
@ -68,6 +68,8 @@ enum {
|
||||||
NETDEV_A_PAGE_POOL_ID = 1,
|
NETDEV_A_PAGE_POOL_ID = 1,
|
||||||
NETDEV_A_PAGE_POOL_IFINDEX,
|
NETDEV_A_PAGE_POOL_IFINDEX,
|
||||||
NETDEV_A_PAGE_POOL_NAPI_ID,
|
NETDEV_A_PAGE_POOL_NAPI_ID,
|
||||||
|
NETDEV_A_PAGE_POOL_INFLIGHT,
|
||||||
|
NETDEV_A_PAGE_POOL_INFLIGHT_MEM,
|
||||||
|
|
||||||
__NETDEV_A_PAGE_POOL_MAX,
|
__NETDEV_A_PAGE_POOL_MAX,
|
||||||
NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1)
|
NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1)
|
||||||
|
|
|
@ -529,7 +529,7 @@ EXPORT_SYMBOL(page_pool_alloc_pages);
|
||||||
*/
|
*/
|
||||||
#define _distance(a, b) (s32)((a) - (b))
|
#define _distance(a, b) (s32)((a) - (b))
|
||||||
|
|
||||||
static s32 page_pool_inflight(struct page_pool *pool)
|
s32 page_pool_inflight(const struct page_pool *pool, bool strict)
|
||||||
{
|
{
|
||||||
u32 release_cnt = atomic_read(&pool->pages_state_release_cnt);
|
u32 release_cnt = atomic_read(&pool->pages_state_release_cnt);
|
||||||
u32 hold_cnt = READ_ONCE(pool->pages_state_hold_cnt);
|
u32 hold_cnt = READ_ONCE(pool->pages_state_hold_cnt);
|
||||||
|
@ -537,8 +537,13 @@ static s32 page_pool_inflight(struct page_pool *pool)
|
||||||
|
|
||||||
inflight = _distance(hold_cnt, release_cnt);
|
inflight = _distance(hold_cnt, release_cnt);
|
||||||
|
|
||||||
trace_page_pool_release(pool, inflight, hold_cnt, release_cnt);
|
if (strict) {
|
||||||
WARN(inflight < 0, "Negative(%d) inflight packet-pages", inflight);
|
trace_page_pool_release(pool, inflight, hold_cnt, release_cnt);
|
||||||
|
WARN(inflight < 0, "Negative(%d) inflight packet-pages",
|
||||||
|
inflight);
|
||||||
|
} else {
|
||||||
|
inflight = max(0, inflight);
|
||||||
|
}
|
||||||
|
|
||||||
return inflight;
|
return inflight;
|
||||||
}
|
}
|
||||||
|
@ -881,7 +886,7 @@ static int page_pool_release(struct page_pool *pool)
|
||||||
int inflight;
|
int inflight;
|
||||||
|
|
||||||
page_pool_scrub(pool);
|
page_pool_scrub(pool);
|
||||||
inflight = page_pool_inflight(pool);
|
inflight = page_pool_inflight(pool, true);
|
||||||
if (!inflight)
|
if (!inflight)
|
||||||
__page_pool_destroy(pool);
|
__page_pool_destroy(pool);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#ifndef __PAGE_POOL_PRIV_H
|
#ifndef __PAGE_POOL_PRIV_H
|
||||||
#define __PAGE_POOL_PRIV_H
|
#define __PAGE_POOL_PRIV_H
|
||||||
|
|
||||||
|
s32 page_pool_inflight(const struct page_pool *pool, bool strict);
|
||||||
|
|
||||||
int page_pool_list(struct page_pool *pool);
|
int page_pool_list(struct page_pool *pool);
|
||||||
void page_pool_unlist(struct page_pool *pool);
|
void page_pool_unlist(struct page_pool *pool);
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,7 @@ static int
|
||||||
page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool,
|
page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool,
|
||||||
const struct genl_info *info)
|
const struct genl_info *info)
|
||||||
{
|
{
|
||||||
|
size_t inflight, refsz;
|
||||||
void *hdr;
|
void *hdr;
|
||||||
|
|
||||||
hdr = genlmsg_iput(rsp, info);
|
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))
|
nla_put_uint(rsp, NETDEV_A_PAGE_POOL_NAPI_ID, pool->user.napi_id))
|
||||||
goto err_cancel;
|
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);
|
genlmsg_end(rsp, hdr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue