diff options
author | Joe Damato <jdamato@fastly.com> | 2022-03-01 23:55:49 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-03-03 09:55:28 +0000 |
commit | 6b95e3388b1ea0ca63500c5a6e39162dbf828433 (patch) | |
tree | 3d15476a44c79f2230e2467afa937193c64341b2 /net | |
parent | ad6fa1e1ab1b8164f1ba296b1b4dc556a483bcad (diff) | |
download | linux-6b95e3388b1ea0ca63500c5a6e39162dbf828433.tar.bz2 |
page_pool: Add function to batch and return stats
Adds a function page_pool_get_stats which can be used by drivers to obtain
stats for a specified page_pool.
Signed-off-by: Joe Damato <jdamato@fastly.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/page_pool.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 3d273cb1ef1c..1943c0f0307d 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -35,6 +35,31 @@ struct page_pool_recycle_stats __percpu *s = pool->recycle_stats; \ this_cpu_inc(s->__stat); \ } while (0) + +bool page_pool_get_stats(struct page_pool *pool, + struct page_pool_stats *stats) +{ + int cpu = 0; + + if (!stats) + return false; + + memcpy(&stats->alloc_stats, &pool->alloc_stats, sizeof(pool->alloc_stats)); + + for_each_possible_cpu(cpu) { + const struct page_pool_recycle_stats *pcpu = + per_cpu_ptr(pool->recycle_stats, cpu); + + stats->recycle_stats.cached += pcpu->cached; + stats->recycle_stats.cache_full += pcpu->cache_full; + stats->recycle_stats.ring += pcpu->ring; + stats->recycle_stats.ring_full += pcpu->ring_full; + stats->recycle_stats.released_refcnt += pcpu->released_refcnt; + } + + return true; +} +EXPORT_SYMBOL(page_pool_get_stats); #else #define alloc_stat_inc(pool, __stat) #define recycle_stat_inc(pool, __stat) |