Skip to contentSkip to conversation

docs: page_pool: tweaks and updates

PATCH Applied Jakub Kicinski 4 participants 11 messages May 26 – May 29

Subsystems (6)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

cover docs: page_pool: tweaks and updates

I'm hoping to start feeding our docs into the AI review tools, instead of maintaining a separate repo with review prompts. To experiment with that we have to refresh the docs a little bit.

This set exclusively focuses on the page pool API. First patch is a straightforward fix for information which is now out of date. Second one attempts to clarify the NAPI linking requirements. Third drops the dedicated section about the stats; the document is primarily developer-facing and the stats should require no development effort in most cases. Last but not least minor API cleanup.

Jakub Kicinski (4):
docs: net: page_pool: drop reference to removed PP_FLAG_PAGE_FRAG
docs: clarify page pool NAPI consumer requirement
docs: page_pool: drop the mention of the legacy stats API
net: make page_pool_get_stats() void

 Documentation/networking/page_pool.rst        | 60 +++++++------------
 include/net/page_pool/helpers.h               |  2 +-
 .../ethernet/mellanox/mlx5/core/en_stats.c    |  3 +-
 net/core/page_pool.c                          | 10 ++--
 net/core/page_pool_user.c                     |  3 +-
 5 files changed, 28 insertions(+), 50 deletions(-)
Signature · 1 line
2.54.0
author maintainer
#1 lore raw

PATCH 1/4 docs: net: page_pool: drop reference to removed PP_FLAG_PAGE_FRAG

The flag was removed in commit 09d96ee5674a ("page_pool: remove PP_FLAG_PAGE_FRAG"), but the documentation still mentions it when describing fragment usage. Drop the stale reference; the fragment API does not require any opt-in flag.

---
 Documentation/networking/page_pool.rst | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Documentation/networking/page_pool.rst +2 -3
index 9d958128a57c..6e43e1953218 100644
@@ -98,9 +98,8 @@ If in doubt set ``offset`` to 0, ``max_len`` to ``PAGE_SIZE`` and
 pass -1 as ``dma_sync_size``. That combination of arguments is always
 correct.
 
-Note that the syncing parameters are for the entire page.
-This is important to remember when using fragments (``PP_FLAG_PAGE_FRAG``),
-where allocated buffers may be smaller than a full page.
+Note that the syncing parameters are for the **entire page**, even if
+the driver allocates fragments (e.g. via ``page_pool_dev_alloc_frag()``).
 Unless the driver author really understands page pool internals
 it's recommended to always use ``offset = 0``, ``max_len = PAGE_SIZE``
 with fragmented page pools.
Signature · 1 line
2.54.0
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH net-next 1/4] docs: net: page_pool: drop reference to removed PP_FLAG_PAGE_FRAG

Quoted 9 lines · Jakub Kicinski

The flag was removed in commit 09d96ee5674a ("page_pool: remove PP_FLAG_PAGE_FRAG"), but the documentation still mentions it when describing fragment usage. Drop the stale reference; the fragment API does not require any opt-in flag.

---

[...]

author maintainer
#3 lore raw

PATCH 2/4 docs: clarify page pool NAPI consumer requirement

In reply to Jakub Kicinski

The comment about requirements when to set the NAPI pointer may not be super clear. Add more words.

---
 Documentation/networking/page_pool.rst | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Documentation/networking/page_pool.rst +7 -2
index 6e43e1953218..5409c68be3fc 100644
@@ -48,13 +48,18 @@ genetlink family (see Documentation/netlink/specs/netdev.yaml).
 
 API interface
 =============
-The number of pools created **must** match the number of hardware queues
+The number of pools created **must** match the number of NAPI contexts / queues
 unless hardware restrictions make that impossible. This would otherwise beat the
 purpose of page pool, which is allocate pages fast from cache without locking.
 This lockless guarantee naturally comes from running under a NAPI softirq.
 The protection doesn't strictly have to be NAPI, any guarantee that allocating
 a page will cause no race conditions is enough.
 
+If ``params.napi`` is set, the NAPI instance must be the sole consumer
+context for pages allocated from the pool. In other words, when running in
+that NAPI context, the page pool may safely access consumer-side resources
+**without any additional locking**.
+
 .. kernel-doc:: net/core/page_pool.c
    :identifiers: page_pool_create
 
@@ -139,7 +144,7 @@ Registration
     pp_params.pool_size = DESC_NUM;
     pp_params.nid = NUMA_NO_NODE;
     pp_params.dev = priv->dev;
-    pp_params.napi = napi; /* only if locking is tied to NAPI */
+    pp_params.napi = napi; /* only if this NAPI is the sole consumer, see above */
     pp_params.dma_dir = xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE;
     page_pool = page_pool_create(&pp_params);
 
Signature · 1 line
2.54.0
author maintainer
#5 lore raw

PATCH 3/4 docs: page_pool: drop the mention of the legacy stats API

In reply to Jakub Kicinski

The Netlink support for querying page pool stats has been proven out in production, let's remove the mention of the helper meant for dumping page pool stats into ethtool -S from the docs.

Call out in the kdoc that this API is deprecated. Some drivers may not be able to use the Netlink API (if page pool is shared across netdevs). So the old API is not _completely_ dead. But we shouldn't advertise it.

---
 Documentation/networking/page_pool.rst | 46 +++++++-------------------
 net/core/page_pool.c                   |  3 ++
 2 files changed, 15 insertions(+), 34 deletions(-)
Documentation/networking/page_pool.rst +12 -34
index 5409c68be3fc..817f8b78d246 100644
@@ -43,8 +43,17 @@ Architecture overview
 
 Monitoring
 ==========
-Information about page pools on the system can be accessed via the netdev
-genetlink family (see Documentation/netlink/specs/netdev.yaml).
+Information about allocated page pools, their memory use, recycling statistics
+etc. can be accessed via the netdev genetlink family
+(see Documentation/netlink/specs/netdev.yaml).
+
+Statistics
+----------
+
+.. kernel-doc:: include/net/page_pool/types.h
+   :identifiers: struct page_pool_recycle_stats
+		 struct page_pool_alloc_stats
+		 struct page_pool_stats
 
 API interface
 =============
@@ -74,7 +83,7 @@ that NAPI context, the page pool may safely access consumer-side resources
 		 page_pool_get_dma_addr page_pool_get_dma_dir
 
 .. kernel-doc:: net/core/page_pool.c
-   :identifiers: page_pool_put_page_bulk page_pool_get_stats
+   :identifiers: page_pool_put_page_bulk
 
 DMA sync
 --------
@@ -109,22 +118,6 @@ Unless the driver author really understands page pool internals
 it's recommended to always use ``offset = 0``, ``max_len = PAGE_SIZE``
 with fragmented page pools.
 
-Stats API and structures
-------------------------
-If the kernel is configured with ``CONFIG_PAGE_POOL_STATS=y``, the API
-page_pool_get_stats() and structures described below are available.
-It takes a  pointer to a ``struct page_pool`` and a pointer to a struct
-page_pool_stats allocated by the caller.
-
-Older drivers expose page pool statistics via ethtool or debugfs.
-The same statistics are accessible via the netlink netdev family
-in a driver-independent fashion.
-
-.. kernel-doc:: include/net/page_pool/types.h
-   :identifiers: struct page_pool_recycle_stats
-		 struct page_pool_alloc_stats
-		 struct page_pool_stats
-
 Coding examples
 ===============
 
@@ -178,21 +171,6 @@ NAPI poller
         }
     }
 
-Stats
------
-
-.. code-block:: c
-
-	#ifdef CONFIG_PAGE_POOL_STATS
-	/* retrieve stats */
-	struct page_pool_stats stats = { 0 };
-	if (page_pool_get_stats(page_pool, &stats)) {
-		/* perhaps the driver reports statistics with ethool */
-		ethtool_print_allocation_stats(&stats.alloc_stats);
-		ethtool_print_recycle_stats(&stats.recycle_stats);
-	}
-	#endif
-
 Driver unload
 -------------
 
net/core/page_pool.c +3 -0
index 6e576dec80db..9a87062134d4 100644
@@ -76,6 +76,9 @@ static const char pp_stats[][ETH_GSTRING_LEN] = {
  * @pool:	pool from which page was allocated
  * @stats:	struct page_pool_stats to fill in
  *
+ * Deprecated driver API for querying stats. Page pool stats can be queried
+ * via netdev Netlink.
+ *
  * Retrieve statistics about the page_pool. This API is only available
  * if the kernel has been configured with ``CONFIG_PAGE_POOL_STATS=y``.
  * A pointer to a caller allocated struct page_pool_stats structure
Signature · 1 line
2.54.0
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH net-next 3/4] docs: page_pool: drop the mention of the legacy stats API

Quoted 5 lines · Jakub Kicinski

The Netlink support for querying page pool stats has been proven out in production, let's remove the mention of the helper meant for dumping page pool stats into ethtool -S from the docs.

Quoted 8 lines

Call out in the kdoc that this API is deprecated. Some drivers may not be able to use the Netlink API (if page pool is shared across netdevs). So the old API is not _completely_ dead. But we shouldn't advertise it.

[...]

author maintainer
#7 lore raw

PATCH 4/4 net: make page_pool_get_stats() void

In reply to Jakub Kicinski

The kdoc for page_pool_get_stats() is missing a Returns: statement. Looking at this function, I have no idea what is the purpose of the bool it returns. My guess was that maybe the static inline stub returns false if CONFIG_PAGE_POOL_STATS=n but such static inline helper doesn't exist at all. All callers pass a pointer to a struct on the stack. Make this function void.

---
 include/net/page_pool/helpers.h                    | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 3 +--
 net/core/page_pool.c                               | 7 +------
 net/core/page_pool_user.c                          | 3 +--
 4 files changed, 4 insertions(+), 11 deletions(-)
include/net/page_pool/helpers.h +1 -1
index 3247026e096a..e2730dd273b2 100644
@@ -64,7 +64,7 @@ int page_pool_ethtool_stats_get_count(void);
 u8 *page_pool_ethtool_stats_get_strings(u8 *data);
 u64 *page_pool_ethtool_stats_get(u64 *data, const void *stats);
 
-bool page_pool_get_stats(const struct page_pool *pool,
+void page_pool_get_stats(const struct page_pool *pool,
 			 struct page_pool_stats *stats);
 #else
 static inline int page_pool_ethtool_stats_get_count(void)
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +1 -2
index 1a3ecf073913..7f33261ba655 100644
@@ -496,8 +496,7 @@ static void mlx5e_stats_update_stats_rq_page_pool(struct mlx5e_channel *c)
 	struct page_pool *pool = c->rq.page_pool;
 	struct page_pool_stats stats = { 0 };
 
-	if (!page_pool_get_stats(pool, &stats))
-		return;
+	page_pool_get_stats(pool, &stats);
 
 	rq_stats->pp_alloc_fast = stats.alloc_stats.fast;
 	rq_stats->pp_alloc_slow = stats.alloc_stats.slow;
net/core/page_pool.c +1 -6
index 9a87062134d4..84ec603d1bb3 100644
@@ -85,14 +85,11 @@ static const char pp_stats[][ETH_GSTRING_LEN] = {
  * is passed to this API which is filled in. The caller can then report
  * those stats to the user (perhaps via ethtool, debugfs, etc.).
  */
-bool page_pool_get_stats(const struct page_pool *pool,
+void page_pool_get_stats(const struct page_pool *pool,
 			 struct page_pool_stats *stats)
 {
 	int cpu = 0;
 
-	if (!stats)
-		return false;
-
 	/* The caller is responsible to initialize stats. */
 	stats->alloc_stats.fast += pool->alloc_stats.fast;
 	stats->alloc_stats.slow += pool->alloc_stats.slow;
@@ -111,8 +108,6 @@ bool page_pool_get_stats(const struct page_pool *pool,
 		stats->recycle_stats.ring_full += pcpu->ring_full;
 		stats->recycle_stats.released_refcnt += pcpu->released_refcnt;
 	}
-
-	return true;
 }
 EXPORT_SYMBOL(page_pool_get_stats);
 
net/core/page_pool_user.c +1 -2
index 01509d1b3cba..fb5d3f9de936 100644
@@ -127,8 +127,7 @@ page_pool_nl_stats_fill(struct sk_buff *rsp, const struct page_pool *pool,
 	struct nlattr *nest;
 	void *hdr;
 
-	if (!page_pool_get_stats(pool, &stats))
-		return 0;
+	page_pool_get_stats(pool, &stats);
 
 	hdr = genlmsg_iput(rsp, info);
 	if (!hdr)
Signature · 1 line
2.54.0
Reviewed-by on v1 4/4
#8 lore raw

Re: [PATCH net-next 4/4] net: make page_pool_get_stats() void

Quoted 11 lines · Jakub Kicinski

The kdoc for page_pool_get_stats() is missing a Returns: statement. Looking at this function, I have no idea what is the purpose of the bool it returns. My guess was that maybe the static inline stub returns false if CONFIG_PAGE_POOL_STATS=n but such static inline helper doesn't exist at all. All callers pass a pointer to a struct on the stack. Make this function void.

---

[...]

maintainer Reviewed-by on the v1 series
#9 lore raw
In reply to Jakub Kicinski
Quoted 18 lines · Jakub Kicinski

I'm hoping to start feeding our docs into the AI review tools, instead of maintaining a separate repo with review prompts. To experiment with that we have to refresh the docs a little bit.

This set exclusively focuses on the page pool API. First patch is a straightforward fix for information which is now out of date. Second one attempts to clarify the NAPI linking requirements. Third drops the dedicated section about the stats; the document is primarily developer-facing and the stats should require no development effort in most cases. Last but not least minor API cleanup.

Jakub Kicinski (4):
docs: net: page_pool: drop reference to removed PP_FLAG_PAGE_FRAG
docs: clarify page pool NAPI consumer requirement
docs: page_pool: drop the mention of the legacy stats API
net: make page_pool_get_stats() void

Quoted 7 lines
  Documentation/networking/page_pool.rst        | 60 +++++++------------
  include/net/page_pool/helpers.h               |  2 +-
  .../ethernet/mellanox/mlx5/core/en_stats.c    |  3 +-
  net/core/page_pool.c                          | 10 ++--
  net/core/page_pool_user.c                     |  3 +-
  5 files changed, 28 insertions(+), 50 deletions(-)

For the series:

Thanks.

#10 lore raw
In reply to Jakub Kicinski
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 12 lines · On Tue, 26 May 2026 08:57:18 -0700 you wrote:

I'm hoping to start feeding our docs into the AI review tools, instead of maintaining a separate repo with review prompts. To experiment with that we have to refresh the docs a little bit.

This set exclusively focuses on the page pool API. First patch is a straightforward fix for information which is now out of date. Second one attempts to clarify the NAPI linking requirements. Third drops the dedicated section about the stats; the document is primarily developer-facing and the stats should require no development effort in most cases. Last but not least minor API cleanup.

Quoted 1 line

[...]

Here is the summary with links:
- [net-next,1/4] docs: net: page_pool: drop reference to removed PP_FLAG_PAGE_FRAG

    https://git.kernel.org/netdev/net-next/c/63c4530050d0
  - [net-next,2/4] docs: clarify page pool NAPI consumer requirement
    https://git.kernel.org/netdev/net-next/c/bbf2313cbeaf
  - [net-next,3/4] docs: page_pool: drop the mention of the legacy stats API
    https://git.kernel.org/netdev/net-next/c/ac0056e4f14b
  - [net-next,4/4] net: make page_pool_get_stats() void
    https://git.kernel.org/netdev/net-next/c/81a4d039537a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html