generic: Convert incorrect generic/5.10 patches
[openwrt/staging/ansuel.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 diff --git a/net/core/page_pool.c b/net/core/page_pool.c
18 index 1943c0f0307d..4af55d28ffa3 100644
19 --- a/net/core/page_pool.c
20 +++ b/net/core/page_pool.c
21 @@ -36,6 +36,12 @@
22 this_cpu_inc(s->__stat); \
23 } while (0)
24
25 +#define recycle_stat_add(pool, __stat, val) \
26 + do { \
27 + struct page_pool_recycle_stats __percpu *s = pool->recycle_stats; \
28 + this_cpu_add(s->__stat, val); \
29 + } while (0)
30 +
31 bool page_pool_get_stats(struct page_pool *pool,
32 struct page_pool_stats *stats)
33 {
34 @@ -63,6 +69,7 @@ EXPORT_SYMBOL(page_pool_get_stats);
35 #else
36 #define alloc_stat_inc(pool, __stat)
37 #define recycle_stat_inc(pool, __stat)
38 +#define recycle_stat_add(pool, __stat, val)
39 #endif
40
41 static int page_pool_init(struct page_pool *pool,
42 @@ -569,9 +576,13 @@ void page_pool_put_page_bulk(struct page
43 /* Bulk producer into ptr_ring page_pool cache */
44 page_pool_ring_lock(pool);
45 for (i = 0; i < bulk_len; i++) {
46 - if (__ptr_ring_produce(&pool->ring, data[i]))
47 - break; /* ring full */
48 + if (__ptr_ring_produce(&pool->ring, data[i])) {
49 + /* ring full */
50 + recycle_stat_inc(pool, ring_full);
51 + break;
52 + }
53 }
54 + recycle_stat_add(pool, ring, i);
55 page_pool_ring_unlock(pool);
56
57 /* Hopefully all pages was return into ptr_ring */