kernel: refresh backport-5.15 patches
[openwrt/staging/noltari.git] / target / linux / generic / backport-5.15 / 603-v5.19-page_pool-Add-recycle-stats-to-page_pool_put_page_bu.patch
1 From 590032a4d2133ecc10d3078a8db1d85a4842f12c Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Mon, 11 Apr 2022 16:05:26 +0200
4 Subject: [PATCH] page_pool: Add recycle stats to page_pool_put_page_bulk
5
6 Add missing recycle stats to page_pool_put_page_bulk routine.
7
8 Reviewed-by: Joe Damato <jdamato@fastly.com>
9 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
10 Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
11 Link: https://lore.kernel.org/r/3712178b51c007cfaed910ea80e68f00c916b1fa.1649685634.git.lorenzo@kernel.org
12 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
13 ---
14 net/core/page_pool.c | 15 +++++++++++++--
15 1 file changed, 13 insertions(+), 2 deletions(-)
16
17 --- a/net/core/page_pool.c
18 +++ b/net/core/page_pool.c
19 @@ -36,6 +36,12 @@
20 this_cpu_inc(s->__stat); \
21 } while (0)
22
23 +#define recycle_stat_add(pool, __stat, val) \
24 + do { \
25 + struct page_pool_recycle_stats __percpu *s = pool->recycle_stats; \
26 + this_cpu_add(s->__stat, val); \
27 + } while (0)
28 +
29 bool page_pool_get_stats(struct page_pool *pool,
30 struct page_pool_stats *stats)
31 {
32 @@ -63,6 +69,7 @@ EXPORT_SYMBOL(page_pool_get_stats);
33 #else
34 #define alloc_stat_inc(pool, __stat)
35 #define recycle_stat_inc(pool, __stat)
36 +#define recycle_stat_add(pool, __stat, val)
37 #endif
38
39 static int page_pool_init(struct page_pool *pool,
40 @@ -569,9 +576,13 @@ void page_pool_put_page_bulk(struct page
41 /* Bulk producer into ptr_ring page_pool cache */
42 page_pool_ring_lock(pool);
43 for (i = 0; i < bulk_len; i++) {
44 - if (__ptr_ring_produce(&pool->ring, data[i]))
45 - break; /* ring full */
46 + if (__ptr_ring_produce(&pool->ring, data[i])) {
47 + /* ring full */
48 + recycle_stat_inc(pool, ring_full);
49 + break;
50 + }
51 }
52 + recycle_stat_add(pool, ring, i);
53 page_pool_ring_unlock(pool);
54
55 /* Hopefully all pages was return into ptr_ring */