Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v1] page_pool: make page_pool_alloc_pages() static inline
@ 2026-12-04 21:11 Mina Almasry
  0 siblings, 0 replies; only message in thread
From: Mina Almasry @ 2026-12-04 21:11 UTC (permalink / raw)
  To: netdev
  Cc: Mina Almasry, Jesper Dangaard Brouer, Ilias Apalodimas,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman

page_pool_alloc_pages() is a one-line wrapper around
netmem_to_page(page_pool_alloc_netmems(pool, gfp)). Keeping it as an
out-of-line exported symbol adds an unnecessary call/return hop on
every page allocation, since the trailing netmem_to_page() check
prevents tail-calling page_pool_alloc_netmems().

Make page_pool_alloc_pages() a static inline wrapper in
include/net/page_pool/types.h (where callers such as xen-netfront.c
that only include types.h can reach it) and remove the out-of-line
definition from net/core/page_pool.c. Callers now call
page_pool_alloc_netmems() directly with the net_iov check inlined
(placing the WARN_ON_ONCE trap out-of-line in the cold path), and
ALLOW_ERROR_INJECTION(page_pool_alloc_netmems, NULL) continues to apply.

Benchmarked with tools/testing/selftests/net/bench/page_pool
(bench_page_pool_simple.c: time_bench_page_pool01_fast_path,
time_bench_page_pool02_ptr_ring, and time_bench_page_pool03_slow) on an
Intel Xeon Platinum 8581C host under hardware KVM (cloud-hypervisor)
with vCPU 0 pinned to a dedicated physical core (SMT sibling offlined),
core clock locked to the nominal 2.1 GHz TSC clock (1 TSC tick = 1
exact core cycle, no HWP/Turbo stepping), guest memory bound to NUMA
node 0, nokaslr, CONFIG_DEBUG_NET=n, 2x10M warmup runs, and 3
interleaved passes (forward, reverse, forward) x 11 runs = 33 runs at
loops=20000000 (median [IQR], core cycles per element):

  Benchmark                   Before [IQR]    After [IQR]           Delta
  -----------------------------------------------------------------------
  fast_path (direct recycle)  25.45 [1.33]   19.10 [0.08]  -6.35 (-25.0%)
  ptr_ring (ring recycle)     49.56 [0.07]   48.48 [0.01]  -1.07 ( -2.2%)
  slow_path (page allocator) 175.42 [0.22]  174.47 [0.14]  -0.95 ( -0.5%)

perf stat on fast_path (50M loops): 79.1 -> 76.1 insns/iter (-3.0),
23.0 -> 21.0 branches/iter (-2.0), IPC 2.93 -> 4.02 (+37%).

Signed-off-by: Mina Almasry <almasrymina@google.com>
---
 include/net/page_pool/types.h | 8 +++++++-
 net/core/page_pool.c          | 6 ------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h
index 5306e34105eb..26d4246f049e 100644
--- a/include/net/page_pool/types.h
+++ b/include/net/page_pool/types.h
@@ -263,8 +263,14 @@ struct page_pool {
 	} user;
 };
 
-struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp);
 netmem_ref page_pool_alloc_netmems(struct page_pool *pool, gfp_t gfp);
+
+static inline struct page *page_pool_alloc_pages(struct page_pool *pool,
+						 gfp_t gfp)
+{
+	return netmem_to_page(page_pool_alloc_netmems(pool, gfp));
+}
+
 struct page *page_pool_alloc_frag(struct page_pool *pool, unsigned int *offset,
 				  unsigned int size, gfp_t gfp);
 netmem_ref page_pool_alloc_frag_netmem(struct page_pool *pool,
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index d7c88c0b67e5..23855275fffc 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -691,12 +691,6 @@ netmem_ref page_pool_alloc_netmems(struct page_pool *pool, gfp_t gfp)
 EXPORT_SYMBOL(page_pool_alloc_netmems);
 ALLOW_ERROR_INJECTION(page_pool_alloc_netmems, NULL);
 
-struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp)
-{
-	return netmem_to_page(page_pool_alloc_netmems(pool, gfp));
-}
-EXPORT_SYMBOL(page_pool_alloc_pages);
-
 /* Calculate distance between two u32 values, valid if distance is below 2^(31)
  *  https://en.wikipedia.org/wiki/Serial_number_arithmetic#General_Solution
  */

base-commit: d5cf954cebe4f175dfd834e1dc471a3aa203ec7d
-- 
2.56.1.915.g69d5ec7298-goog


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-04 21:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 21:11 [PATCH net-next v1] page_pool: make page_pool_alloc_pages() static inline Mina Almasry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox