From: Mina Almasry <almasrymina@google.com>
To: netdev@vger.kernel.org
Cc: Mina Almasry <almasrymina@google.com>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>
Subject: [PATCH net-next v1] page_pool: make page_pool_alloc_pages() static inline
Date: Fri, 4 Dec 2026 21:11:43 +0000 [thread overview]
Message-ID: <20261204211143.3017484-1-almasrymina@google.com> (raw)
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
reply other threads:[~2026-12-04 21:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204211143.3017484-1-almasrymina@google.com \
--to=almasrymina@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox