linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v11 00/12] Split netmem from struct page
@ 2025-07-17  7:00 Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 01/12] netmem: introduce struct netmem_desc mirroring " Byungchul Park
                   ` (11 more replies)
  0 siblings, 12 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

Hi all,

The MM subsystem is trying to reduce struct page to a single pointer.
See the following link for your information:

   https://kernelnewbies.org/MatthewWilcox/Memdescs/Path

The first step towards that is splitting struct page by its individual
users, as has already been done with folio and slab.  This patchset does
that for page pool.

Matthew Wilcox tried and stopped the same work, you can see in:

   https://lore.kernel.org/linux-mm/20230111042214.907030-1-willy@infradead.org/

I focused on removing the page pool members in struct page this time,
not moving the allocation code of page pool from net to mm.  It can be
done later if needed.

The final patch that removes the page pool fields will be posted once
all the conversions are completed.

	Byungchul
---
Changes from v10:
	1. Introduce __netmem_to_nmdesc() and use it in
	   __netmem_get_pp(). (feedbacked by Mina)
	2. Fix a bug that fails on casting 'const page -> const
	   netmem_desc', by using macros and _Generic. (feedbacked by
	   test robot)
	3. Add comment on pp_page_to_nmdesc() to ask for more attention
	   before using the helper. (feedbacked by Mina)

Changes from v9:
	1. Remove the patch 'page_pool: access ->pp_magic through
	   netmem_desc in page_pool_page_is_pp()' and decide to wait for
	   Pavel's work of PageNetpp() to identify page type for page
	   pool, that doesn't need to access ->pp_magic.
	2. Rename page_to_nmdesc() to pp_page_to_nmdesc() and add
	   DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(page)) in it,
	   just in case. (feedbacked by Pavel)
	3. Apply just simple casting from page to netmem_desc for
	   accessing ->pp and ->pp_ref_count, instead of full converting
	   page to netmem_ref for network drivers e.g. mlx4, netdevsim,
	   and mt76.
	4. Expand the support for drivers to access ->pp and
	   ->pp_ref_count to fec, octeontx2-pf, iavf, idpf, mlx5, ti,
	   and xdp.
	5. Squash each helper with its first user. (feedbacked by Mina)

Changes from v8:
	1. Rebase on net-next/main as of Jul 10.
	2. Exclude non-controversial patches that have already been
	   merged to net-next.
	3. Re-add the patches that focus on removing accessing the page
	   pool fields in struct page.
	4. Add utility APIs e.g. casting, to use struct netmem_desc as
	   descriptor, to support __netmem_get_pp() that has started to
	   be used again e.g. by libeth.

Changes from v7 (no actual updates):
	1. Exclude "netmem: introduce struct netmem_desc mirroring
	   struct page" that might be controversial.
	2. Exclude "netmem: introduce a netmem API,
	   virt_to_head_netmem()" since there are no users.

Changes from v6 (no actual updates):
	1. Rebase on net-next/main as of Jun 25.
	2. Supplement a comment describing struct net_iov.
	3. Exclude a controversial patch, "page_pool: access ->pp_magic
	   through struct netmem_desc in page_pool_page_is_pp()".
	4. Exclude "netmem: remove __netmem_get_pp()" since the API
	   started to be used again by libeth.

Changes from v5 (no actual updates):
	1. Rebase on net-next/main as of Jun 20.
	2. Add given 'Reviewed-by's and 'Acked-by's, thanks to all.
	3. Add missing cc's.

Changes from v4:
	1. Add given 'Reviewed-by's, thanks to all.
	2. Exclude potentially controversial patches.

Changes from v3:
	1. Relocates ->owner and ->type of net_iov out of netmem_desc
	   and make them be net_iov specific.
	2. Remove __force when casting struct page to struct netmem_desc.

Changes from v2:
	1. Introduce a netmem API, virt_to_head_netmem(), and use it
	   when it's needed.
	2. Introduce struct netmem_desc as a new struct and union'ed
	   with the existing fields in struct net_iov.
	3. Make page_pool_page_is_pp() access ->pp_magic through struct
	   netmem_desc instead of struct page.
	4. Move netmem alloc APIs from include/net/netmem.h to
	   net/core/netmem_priv.h.
	5. Apply trivial feedbacks, thanks to Mina, Pavel, and Toke.
	6. Add given 'Reviewed-by's, thanks to Mina.

Changes from v1:
	1. Rebase on net-next's main as of May 26.
	2. Check checkpatch.pl, feedbacked by SJ Park.
	3. Add converting of page to netmem in mt76.
	4. Revert 'mlx5: use netmem descriptor and APIs for page pool'
	   since it's on-going by Tariq Toukan.  I will wait for his
	   work to be done.
	5. Revert 'page_pool: use netmem APIs to access page->pp_magic
	   in page_pool_page_is_pp()' since we need more discussion.
	6. Revert 'mm, netmem: remove the page pool members in struct
	   page' since there are some prerequisite works to remove the
	   page pool fields from struct page.  I can submit this patch
	   separatedly later.
	7. Cancel relocating a page pool member in struct page.
	8. Modify static assert for offests and size of struct
	   netmem_desc.

Changes from rfc:
	1. Rebase on net-next's main branch.
	   https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/
	2. Fix a build error reported by kernel test robot.
	   https://lore.kernel.org/all/202505100932.uzAMBW1y-lkp@intel.com/
	3. Add given 'Reviewed-by's, thanks to Mina and Ilias.
	4. Do static_assert() on the size of struct netmem_desc instead
	   of placing place-holder in struct page, feedbacked by
	   Matthew.
	5. Do struct_group_tagged(netmem_desc) on struct net_iov instead
	   of wholly renaming it to strcut netmem_desc, feedbacked by
	   Mina and Pavel.

Byungchul Park (12):
  netmem: introduce struct netmem_desc mirroring struct page
  netmem: use netmem_desc instead of page to access ->pp in
    __netmem_get_pp()
  netmem, mlx4: access ->pp_ref_count through netmem_desc instead of
    page
  netdevsim: access ->pp through netmem_desc instead of page
  mt76: access ->pp through netmem_desc instead of page
  net: fec: access ->pp through netmem_desc instead of page
  octeontx2-pf: access ->pp through netmem_desc instead of page
  iavf: access ->pp through netmem_desc instead of page
  idpf: access ->pp through netmem_desc instead of page
  mlx5: access ->pp through netmem_desc instead of page
  net: ti: icssg-prueth: access ->pp through netmem_desc instead of page
  libeth: xdp: access ->pp through netmem_desc instead of page

 drivers/net/ethernet/freescale/fec_main.c     |  10 +-
 drivers/net/ethernet/intel/iavf/iavf_txrx.c   |   2 +-
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   |   8 +-
 .../marvell/octeontx2/nic/otx2_txrx.c         |   2 +-
 drivers/net/ethernet/mellanox/mlx4/en_rx.c    |   4 +-
 .../net/ethernet/mellanox/mlx5/core/en/xdp.c  |   3 +-
 .../net/ethernet/ti/icssg/icssg_prueth_sr1.c  |   4 +-
 drivers/net/netdevsim/netdev.c                |   6 +-
 drivers/net/wireless/mediatek/mt76/mt76.h     |   3 +-
 include/net/libeth/xdp.h                      |   2 +-
 include/net/netmem.h                          | 153 +++++++++++++++---
 11 files changed, 159 insertions(+), 38 deletions(-)


base-commit: c65d34296b2252897e37835d6007bbd01b255742
-- 
2.17.1



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 01/12] netmem: introduce struct netmem_desc mirroring struct page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp() Byungchul Park
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To simplify struct page, the page pool members of struct page should be
moved to other, allowing these members to be removed from struct page.

Introduce a network memory descriptor to store the members, struct
netmem_desc, and make it union'ed with the existing fields in struct
net_iov, allowing to organize the fields of struct net_iov.

Signed-off-by: Byungchul Park <byungchul@sk.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Mina Almasry <almasrymina@google.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Harry Yoo <harry.yoo@oracle.com>
---
 include/net/netmem.h | 116 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 95 insertions(+), 21 deletions(-)

diff --git a/include/net/netmem.h b/include/net/netmem.h
index de1d95f04076..535cf17b9134 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -12,6 +12,50 @@
 #include <linux/mm.h>
 #include <net/net_debug.h>
 
+/* These fields in struct page are used by the page_pool and net stack:
+ *
+ *        struct {
+ *                unsigned long pp_magic;
+ *                struct page_pool *pp;
+ *                unsigned long _pp_mapping_pad;
+ *                unsigned long dma_addr;
+ *                atomic_long_t pp_ref_count;
+ *        };
+ *
+ * We mirror the page_pool fields here so the page_pool can access these
+ * fields without worrying whether the underlying fields belong to a
+ * page or netmem_desc.
+ *
+ * CAUTION: Do not update the fields in netmem_desc without also
+ * updating the anonymous aliasing union in struct net_iov.
+ */
+struct netmem_desc {
+	unsigned long _flags;
+	unsigned long pp_magic;
+	struct page_pool *pp;
+	unsigned long _pp_mapping_pad;
+	unsigned long dma_addr;
+	atomic_long_t pp_ref_count;
+};
+
+#define NETMEM_DESC_ASSERT_OFFSET(pg, desc)        \
+	static_assert(offsetof(struct page, pg) == \
+		      offsetof(struct netmem_desc, desc))
+NETMEM_DESC_ASSERT_OFFSET(flags, _flags);
+NETMEM_DESC_ASSERT_OFFSET(pp_magic, pp_magic);
+NETMEM_DESC_ASSERT_OFFSET(pp, pp);
+NETMEM_DESC_ASSERT_OFFSET(_pp_mapping_pad, _pp_mapping_pad);
+NETMEM_DESC_ASSERT_OFFSET(dma_addr, dma_addr);
+NETMEM_DESC_ASSERT_OFFSET(pp_ref_count, pp_ref_count);
+#undef NETMEM_DESC_ASSERT_OFFSET
+
+/*
+ * Since struct netmem_desc uses the space in struct page, the size
+ * should be checked, until struct netmem_desc has its own instance from
+ * slab, to avoid conflicting with other members within struct page.
+ */
+static_assert(sizeof(struct netmem_desc) <= offsetof(struct page, _refcount));
+
 /* net_iov */
 
 DECLARE_STATIC_KEY_FALSE(page_pool_mem_providers);
@@ -30,13 +74,48 @@ enum net_iov_type {
 	NET_IOV_MAX = ULONG_MAX
 };
 
+/* A memory descriptor representing abstract networking I/O vectors,
+ * generally for non-pages memory that doesn't have its corresponding
+ * struct page and needs to be explicitly allocated through slab.
+ *
+ * net_iovs are allocated and used by networking code, and the size of
+ * the chunk is PAGE_SIZE.
+ *
+ * This memory can be any form of non-struct paged memory.  Examples
+ * include imported dmabuf memory and imported io_uring memory.  See
+ * net_iov_type for all the supported types.
+ *
+ * @pp_magic:	pp field, similar to the one in struct page/struct
+ *		netmem_desc.
+ * @pp:		the pp this net_iov belongs to, if any.
+ * @dma_addr:	the dma addrs of the net_iov. Needed for the network
+ *		card to send/receive this net_iov.
+ * @pp_ref_count: the pp ref count of this net_iov, exactly the same
+ *		usage as struct page/struct netmem_desc.
+ * @owner:	the net_iov_area this net_iov belongs to, if any.
+ * @type:	the type of the memory.  Different types of net_iovs are
+ *		supported.
+ */
 struct net_iov {
-	enum net_iov_type type;
-	unsigned long pp_magic;
-	struct page_pool *pp;
+	union {
+		struct netmem_desc desc;
+
+		/* XXX: The following part should be removed once all
+		 * the references to them are converted so as to be
+		 * accessed via netmem_desc e.g. niov->desc.pp instead
+		 * of niov->pp.
+		 */
+		struct {
+			unsigned long _flags;
+			unsigned long pp_magic;
+			struct page_pool *pp;
+			unsigned long _pp_mapping_pad;
+			unsigned long dma_addr;
+			atomic_long_t pp_ref_count;
+		};
+	};
 	struct net_iov_area *owner;
-	unsigned long dma_addr;
-	atomic_long_t pp_ref_count;
+	enum net_iov_type type;
 };
 
 struct net_iov_area {
@@ -48,27 +127,22 @@ struct net_iov_area {
 	unsigned long base_virtual;
 };
 
-/* These fields in struct page are used by the page_pool and net stack:
+/* net_iov is union'ed with struct netmem_desc mirroring struct page, so
+ * the page_pool can access these fields without worrying whether the
+ * underlying fields are accessed via netmem_desc or directly via
+ * net_iov, until all the references to them are converted so as to be
+ * accessed via netmem_desc e.g. niov->desc.pp instead of niov->pp.
  *
- *        struct {
- *                unsigned long pp_magic;
- *                struct page_pool *pp;
- *                unsigned long _pp_mapping_pad;
- *                unsigned long dma_addr;
- *                atomic_long_t pp_ref_count;
- *        };
- *
- * We mirror the page_pool fields here so the page_pool can access these fields
- * without worrying whether the underlying fields belong to a page or net_iov.
- *
- * The non-net stack fields of struct page are private to the mm stack and must
- * never be mirrored to net_iov.
+ * The non-net stack fields of struct page are private to the mm stack
+ * and must never be mirrored to net_iov.
  */
-#define NET_IOV_ASSERT_OFFSET(pg, iov)             \
-	static_assert(offsetof(struct page, pg) == \
+#define NET_IOV_ASSERT_OFFSET(desc, iov)                    \
+	static_assert(offsetof(struct netmem_desc, desc) == \
 		      offsetof(struct net_iov, iov))
+NET_IOV_ASSERT_OFFSET(_flags, _flags);
 NET_IOV_ASSERT_OFFSET(pp_magic, pp_magic);
 NET_IOV_ASSERT_OFFSET(pp, pp);
+NET_IOV_ASSERT_OFFSET(_pp_mapping_pad, _pp_mapping_pad);
 NET_IOV_ASSERT_OFFSET(dma_addr, dma_addr);
 NET_IOV_ASSERT_OFFSET(pp_ref_count, pp_ref_count);
 #undef NET_IOV_ASSERT_OFFSET
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp()
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 01/12] netmem: introduce struct netmem_desc mirroring " Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 03/12] netmem, mlx4: access ->pp_ref_count through netmem_desc instead of page Byungchul Park
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of the page pool fields in struct page, the page
pool code should use netmem descriptor and APIs instead.

However, __netmem_get_pp() still accesses ->pp via struct page.  So
change it to use struct netmem_desc instead, since ->pp no longer will
be available in struct page.

While at it, add a helper, __netmem_to_nmdesc(), that can be used to
unsafely get pointer to netmem_desc backing the netmem_ref, only when
the netmem_ref is always backed by system memory.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 include/net/netmem.h | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/net/netmem.h b/include/net/netmem.h
index 535cf17b9134..097bc74d9555 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -247,6 +247,24 @@ static inline unsigned long netmem_pfn_trace(netmem_ref netmem)
 	return page_to_pfn(netmem_to_page(netmem));
 }
 
+/**
+ * __netmem_to_nmdesc - unsafely get pointer to the &netmem_desc backing
+ * @netmem
+ * @netmem: netmem reference to convert
+ *
+ * Unsafe version that can be used only when @netmem is always backed by
+ * system memory, performs faster and generates smaller object code (no
+ * check for the LSB, no WARN). When @netmem points to IOV, provokes
+ * undefined behaviour.
+ *
+ * Return: pointer to the &netmem_desc (garbage if @netmem is not backed
+ * by system memory).
+ */
+static inline struct netmem_desc *__netmem_to_nmdesc(netmem_ref netmem)
+{
+	return (__force struct netmem_desc *)netmem;
+}
+
 /* __netmem_clear_lsb - convert netmem_ref to struct net_iov * for access to
  * common fields.
  * @netmem: netmem reference to extract as net_iov.
@@ -280,7 +298,7 @@ static inline struct net_iov *__netmem_clear_lsb(netmem_ref netmem)
  */
 static inline struct page_pool *__netmem_get_pp(netmem_ref netmem)
 {
-	return __netmem_to_page(netmem)->pp;
+	return __netmem_to_nmdesc(netmem)->pp;
 }
 
 static inline struct page_pool *netmem_get_pp(netmem_ref netmem)
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 03/12] netmem, mlx4: access ->pp_ref_count through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 01/12] netmem: introduce struct netmem_desc mirroring " Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp() Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 04/12] netdevsim: access ->pp " Byungchul Park
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make mlx4 access ->pp_ref_count through netmem_desc instead of page.

While at it, add a helper, pp_page_to_nmdesc() and __pp_page_to_nmdesc(),
that can be used to get netmem_desc from page only if it's a pp page.
For now that netmem_desc overlays on page, it can be achieved by just
casting, and use macro and _Generic to cover const casting as well.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c |  4 +++-
 include/net/netmem.h                       | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index b33285d755b9..92a16ddb7d86 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -460,9 +460,11 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv,
 
 		truesize += frag_info->frag_stride;
 		if (frag_info->frag_stride == PAGE_SIZE / 2) {
+			struct netmem_desc *desc = pp_page_to_nmdesc(page);
+
 			frags->page_offset ^= PAGE_SIZE / 2;
 			release = page_count(page) != 1 ||
-				  atomic_long_read(&page->pp_ref_count) != 1 ||
+				  atomic_long_read(&desc->pp_ref_count) != 1 ||
 				  page_is_pfmemalloc(page) ||
 				  page_to_nid(page) != numa_mem_id();
 		} else if (!priv->rx_headroom) {
diff --git a/include/net/netmem.h b/include/net/netmem.h
index 097bc74d9555..f7dacc9e75fd 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -285,6 +285,23 @@ static inline struct net_iov *__netmem_clear_lsb(netmem_ref netmem)
 	return (struct net_iov *)((__force unsigned long)netmem & ~NET_IOV);
 }
 
+/* XXX: How to extract netmem_desc from page must be changed, once
+ * netmem_desc no longer overlays on page and will be allocated through
+ * slab.
+ */
+#define __pp_page_to_nmdesc(p)	(_Generic((p),				\
+	const struct page * :	(const struct netmem_desc *)(p),	\
+	struct page * :		(struct netmem_desc *)(p)))
+
+/* CAUTION: Check if the page is a pp page before calling this helper or
+ * know it's a pp page.
+ */
+#define pp_page_to_nmdesc(p)						\
+({									\
+	DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p));		\
+	__pp_page_to_nmdesc(p);						\
+})
+
 /**
  * __netmem_get_pp - unsafely get pointer to the &page_pool backing @netmem
  * @netmem: netmem reference to get the pointer from
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 04/12] netdevsim: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
                   ` (2 preceding siblings ...)
  2025-07-17  7:00 ` [PATCH net-next v11 03/12] netmem, mlx4: access ->pp_ref_count through netmem_desc instead of page Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 05/12] mt76: " Byungchul Park
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make netdevsim access ->pp through netmem_desc instead of page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/netdevsim/netdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index e36d3e846c2d..d6b3a7755f14 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -842,7 +842,8 @@ nsim_pp_hold_write(struct file *file, const char __user *data,
 		if (!ns->page)
 			ret = -ENOMEM;
 	} else {
-		page_pool_put_full_page(ns->page->pp, ns->page, false);
+		page_pool_put_full_page(pp_page_to_nmdesc(ns->page)->pp,
+					ns->page, false);
 		ns->page = NULL;
 	}
 
@@ -1069,7 +1070,8 @@ void nsim_destroy(struct netdevsim *ns)
 
 	/* Put this intentionally late to exercise the orphaning path */
 	if (ns->page) {
-		page_pool_put_full_page(ns->page->pp, ns->page, false);
+		page_pool_put_full_page(pp_page_to_nmdesc(ns->page)->pp,
+					ns->page, false);
 		ns->page = NULL;
 	}
 
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 05/12] mt76: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
                   ` (3 preceding siblings ...)
  2025-07-17  7:00 ` [PATCH net-next v11 04/12] netdevsim: access ->pp " Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 06/12] net: fec: " Byungchul Park
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make mt76 access ->pp through netmem_desc instead of page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/wireless/mediatek/mt76/mt76.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 14927a92f9d1..7e9ddf91b822 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1798,7 +1798,8 @@ static inline void mt76_put_page_pool_buf(void *buf, bool allow_direct)
 {
 	struct page *page = virt_to_head_page(buf);
 
-	page_pool_put_full_page(page->pp, page, allow_direct);
+	page_pool_put_full_page(pp_page_to_nmdesc(page)->pp, page,
+				allow_direct);
 }
 
 static inline void *
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 06/12] net: fec: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
                   ` (4 preceding siblings ...)
  2025-07-17  7:00 ` [PATCH net-next v11 05/12] mt76: " Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 07/12] octeontx2-pf: " Byungchul Park
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make fec access ->pp through netmem_desc instead of page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index d4eed252ad40..1d0bd6f75368 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1043,7 +1043,9 @@ static void fec_enet_bd_init(struct net_device *dev)
 				struct page *page = txq->tx_buf[i].buf_p;
 
 				if (page)
-					page_pool_put_page(page->pp, page, 0, false);
+					page_pool_put_page(pp_page_to_nmdesc(page)->pp,
+							   page, 0,
+							   false);
 			}
 
 			txq->tx_buf[i].buf_p = NULL;
@@ -1581,7 +1583,8 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id, int budget)
 			xdp_return_frame_rx_napi(xdpf);
 		} else { /* recycle pages of XDP_TX frames */
 			/* The dma_sync_size = 0 as XDP_TX has already synced DMA for_device */
-			page_pool_put_page(page->pp, page, 0, true);
+			page_pool_put_page(pp_page_to_nmdesc(page)->pp, page,
+					   0, true);
 		}
 
 		txq->tx_buf[index].buf_p = NULL;
@@ -3343,7 +3346,8 @@ static void fec_enet_free_buffers(struct net_device *ndev)
 			} else {
 				struct page *page = txq->tx_buf[i].buf_p;
 
-				page_pool_put_page(page->pp, page, 0, false);
+				page_pool_put_page(pp_page_to_nmdesc(page)->pp,
+						   page, 0, false);
 			}
 
 			txq->tx_buf[i].buf_p = NULL;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 07/12] octeontx2-pf: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
                   ` (5 preceding siblings ...)
  2025-07-17  7:00 ` [PATCH net-next v11 06/12] net: fec: " Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 08/12] iavf: " Byungchul Park
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make octeontx2-pf access ->pp through netmem_desc instead of page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
index 99ace381cc78..625bb5a05344 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
@@ -1571,7 +1571,7 @@ static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf,
 		cq->pool_ptrs++;
 		if (xsk_buff) {
 			xsk_buff_free(xsk_buff);
-		} else if (page->pp) {
+		} else if (pp_page_to_nmdesc(page)->pp) {
 			page_pool_recycle_direct(pool->page_pool, page);
 		} else {
 			otx2_dma_unmap_page(pfvf, iova, pfvf->rbsize,
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 08/12] iavf: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
                   ` (6 preceding siblings ...)
  2025-07-17  7:00 ` [PATCH net-next v11 07/12] octeontx2-pf: " Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 09/12] idpf: " Byungchul Park
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make iavf access ->pp through netmem_desc instead of page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
index aaf70c625655..363c42bf3dcf 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
@@ -1216,7 +1216,7 @@ static struct sk_buff *iavf_build_skb(const struct libeth_fqe *rx_buffer,
 				      unsigned int size)
 {
 	struct page *buf_page = __netmem_to_page(rx_buffer->netmem);
-	u32 hr = buf_page->pp->p.offset;
+	u32 hr = pp_page_to_nmdesc(buf_page)->pp->p.offset;
 	struct sk_buff *skb;
 	void *va;
 
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 09/12] idpf: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
                   ` (7 preceding siblings ...)
  2025-07-17  7:00 ` [PATCH net-next v11 08/12] iavf: " Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 10/12] mlx5: " Byungchul Park
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make idpf access ->pp through netmem_desc instead of page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index cef9dfb877e8..6b5f440aede3 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -3276,8 +3276,10 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
 
 	hdr_page = __netmem_to_page(hdr->netmem);
 	buf_page = __netmem_to_page(buf->netmem);
-	dst = page_address(hdr_page) + hdr->offset + hdr_page->pp->p.offset;
-	src = page_address(buf_page) + buf->offset + buf_page->pp->p.offset;
+	dst = page_address(hdr_page) + hdr->offset +
+		pp_page_to_nmdesc(hdr_page)->pp->p.offset;
+	src = page_address(buf_page) + buf->offset +
+		pp_page_to_nmdesc(buf_page)->pp->p.offset;
 
 	memcpy(dst, src, LARGEST_ALIGN(copy));
 	buf->offset += copy;
@@ -3296,7 +3298,7 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
 struct sk_buff *idpf_rx_build_skb(const struct libeth_fqe *buf, u32 size)
 {
 	struct page *buf_page = __netmem_to_page(buf->netmem);
-	u32 hr = buf_page->pp->p.offset;
+	u32 hr = pp_page_to_nmdesc(buf_page)->pp->p.offset;
 	struct sk_buff *skb;
 	void *va;
 
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 10/12] mlx5: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
                   ` (8 preceding siblings ...)
  2025-07-17  7:00 ` [PATCH net-next v11 09/12] idpf: " Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 11/12] net: ti: icssg-prueth: " Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 12/12] libeth: xdp: " Byungchul Park
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make mlx5 access ->pp through netmem_desc instead of page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
index 5ce1b463b7a8..5d51600935a6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
@@ -710,7 +710,8 @@ static void mlx5e_free_xdpsq_desc(struct mlx5e_xdpsq *sq,
 				/* No need to check page_pool_page_is_pp() as we
 				 * know this is a page_pool page.
 				 */
-				page_pool_recycle_direct(page->pp, page);
+				page_pool_recycle_direct(pp_page_to_nmdesc(page)->pp,
+							 page);
 			} while (++n < num);
 
 			break;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 11/12] net: ti: icssg-prueth: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
                   ` (9 preceding siblings ...)
  2025-07-17  7:00 ` [PATCH net-next v11 10/12] mlx5: " Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17  7:00 ` [PATCH net-next v11 12/12] libeth: xdp: " Byungchul Park
  11 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make icssg-prueth access ->pp through netmem_desc instead of page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
index ff5f41bf499e..5e225310c9de 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
@@ -367,7 +367,7 @@ static irqreturn_t prueth_rx_mgm_ts_thread_sr1(int irq, void *dev_id)
 		return IRQ_NONE;
 
 	prueth_tx_ts_sr1(emac, (void *)page_address(page));
-	page_pool_recycle_direct(page->pp, page);
+	page_pool_recycle_direct(pp_page_to_nmdesc(page)->pp, page);
 
 	return IRQ_HANDLED;
 }
@@ -392,7 +392,7 @@ static irqreturn_t prueth_rx_mgm_rsp_thread(int irq, void *dev_id)
 		complete(&emac->cmd_complete);
 	}
 
-	page_pool_recycle_direct(page->pp, page);
+	page_pool_recycle_direct(pp_page_to_nmdesc(page)->pp, page);
 
 	return IRQ_HANDLED;
 }
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
                   ` (10 preceding siblings ...)
  2025-07-17  7:00 ` [PATCH net-next v11 11/12] net: ti: icssg-prueth: " Byungchul Park
@ 2025-07-17  7:00 ` Byungchul Park
  2025-07-17 17:42   ` [Intel-wired-lan] " kernel test robot
  11 siblings, 1 reply; 19+ messages in thread
From: Byungchul Park @ 2025-07-17  7:00 UTC (permalink / raw)
  To: willy, netdev
  Cc: linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba, pabeni,
	anthony.l.nguyen, przemyslaw.kitszel, sgoutham, gakula, sbhatta,
	hkelam, bbhushan2, tariqt, ast, daniel, hawk, john.fastabend, sdf,
	saeedm, leon, mbloch, danishanwar, rogerq, nbd, lorenzo,
	ryder.lee, shayne.chen, sean.wang, matthias.bgg,
	angelogioacchino.delregno, aleksander.lobakin, horms, m-malladi,
	krzysztof.kozlowski, matthias.schiffer, robh, imx,
	intel-wired-lan, linux-arm-kernel, linux-wireless, linux-mediatek

To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.

Make xdp access ->pp through netmem_desc instead of page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 include/net/libeth/xdp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/libeth/xdp.h b/include/net/libeth/xdp.h
index 6ce6aec6884c..f4880b50e804 100644
--- a/include/net/libeth/xdp.h
+++ b/include/net/libeth/xdp.h
@@ -1292,7 +1292,7 @@ static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,
 	xdp_init_buff(&xdp->base, fqe->truesize, xdp->base.rxq);
 #endif
 	xdp_prepare_buff(&xdp->base, page_address(page) + fqe->offset,
-			 page->pp->p.offset, len, true);
+			 pp_page_to_nmdesc(page)->pp->p.offset, len, true);
 }
 
 /**
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
  2025-07-17  7:00 ` [PATCH net-next v11 12/12] libeth: xdp: " Byungchul Park
@ 2025-07-17 17:42   ` kernel test robot
  2025-07-18  0:43     ` Byungchul Park
  0 siblings, 1 reply; 19+ messages in thread
From: kernel test robot @ 2025-07-17 17:42 UTC (permalink / raw)
  To: Byungchul Park, willy, netdev
  Cc: oe-kbuild-all, linux-kernel, linux-mm, kernel_team, almasrymina,
	ilias.apalodimas, harry.yoo, akpm, andrew+netdev, asml.silence,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba

Hi Byungchul,

kernel test robot noticed the following build warnings:

[auto build test WARNING on c65d34296b2252897e37835d6007bbd01b255742]

url:    https://github.com/intel-lab-lkp/linux/commits/Byungchul-Park/netmem-introduce-struct-netmem_desc-mirroring-struct-page/20250717-150253
base:   c65d34296b2252897e37835d6007bbd01b255742
patch link:    https://lore.kernel.org/r/20250717070052.6358-13-byungchul%40sk.com
patch subject: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
config: arm-randconfig-r072-20250717 (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507180111.jygqJHzk-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from include/linux/container_of.h:5,
                    from include/linux/list.h:5,
                    from include/linux/timer.h:5,
                    from include/linux/netdevice.h:24,
                    from include/trace/events/xdp.h:8,
                    from include/linux/bpf_trace.h:5,
                    from include/net/libeth/xdp.h:7,
                    from drivers/net/ethernet/intel/libeth/tx.c:6:
   include/net/libeth/xdp.h: In function 'libeth_xdp_prepare_buff':
>> include/net/libeth/xdp.h:1295:23: warning: passing argument 1 of 'page_pool_page_is_pp' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
        pp_page_to_nmdesc(page)->pp->p.offset, len, true);
                          ^~~~
   include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
    #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
                                                                  ^
   include/net/netmem.h:301:2: note: in expansion of macro 'DEBUG_NET_WARN_ON_ONCE'
     DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p));  \
     ^~~~~~~~~~~~~~~~~~~~~~
   include/net/libeth/xdp.h:1295:5: note: in expansion of macro 'pp_page_to_nmdesc'
        pp_page_to_nmdesc(page)->pp->p.offset, len, true);
        ^~~~~~~~~~~~~~~~~
   In file included from arch/arm/include/asm/cacheflush.h:10,
                    from include/linux/cacheflush.h:5,
                    from include/linux/highmem.h:8,
                    from include/linux/bvec.h:10,
                    from include/linux/skbuff.h:17,
                    from include/net/net_namespace.h:43,
                    from include/linux/netdevice.h:38,
                    from include/trace/events/xdp.h:8,
                    from include/linux/bpf_trace.h:5,
                    from include/net/libeth/xdp.h:7,
                    from drivers/net/ethernet/intel/libeth/tx.c:6:
   include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *'
    static inline bool page_pool_page_is_pp(struct page *page)
                                            ~~~~~~~~~~~~~^~~~


vim +1295 include/net/libeth/xdp.h

  1263	
  1264	bool libeth_xdp_buff_add_frag(struct libeth_xdp_buff *xdp,
  1265				      const struct libeth_fqe *fqe,
  1266				      u32 len);
  1267	
  1268	/**
  1269	 * libeth_xdp_prepare_buff - fill &libeth_xdp_buff with head FQE data
  1270	 * @xdp: XDP buffer to attach the head to
  1271	 * @fqe: FQE containing the head buffer
  1272	 * @len: buffer len passed from HW
  1273	 *
  1274	 * Internal, use libeth_xdp_process_buff() instead. Initializes XDP buffer
  1275	 * head with the Rx buffer data: data pointer, length, headroom, and
  1276	 * truesize/tailroom. Zeroes the flags.
  1277	 * Uses faster single u64 write instead of per-field access.
  1278	 */
  1279	static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,
  1280						   const struct libeth_fqe *fqe,
  1281						   u32 len)
  1282	{
  1283		const struct page *page = __netmem_to_page(fqe->netmem);
  1284	
  1285	#ifdef __LIBETH_WORD_ACCESS
  1286		static_assert(offsetofend(typeof(xdp->base), flags) -
  1287			      offsetof(typeof(xdp->base), frame_sz) ==
  1288			      sizeof(u64));
  1289	
  1290		*(u64 *)&xdp->base.frame_sz = fqe->truesize;
  1291	#else
  1292		xdp_init_buff(&xdp->base, fqe->truesize, xdp->base.rxq);
  1293	#endif
  1294		xdp_prepare_buff(&xdp->base, page_address(page) + fqe->offset,
> 1295				 pp_page_to_nmdesc(page)->pp->p.offset, len, true);
  1296	}
  1297	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
  2025-07-17 17:42   ` [Intel-wired-lan] " kernel test robot
@ 2025-07-18  0:43     ` Byungchul Park
  2025-07-18  1:14       ` Byungchul Park
  0 siblings, 1 reply; 19+ messages in thread
From: Byungchul Park @ 2025-07-18  0:43 UTC (permalink / raw)
  To: kernel test robot
  Cc: willy, netdev, oe-kbuild-all, linux-kernel, linux-mm, kernel_team,
	almasrymina, ilias.apalodimas, harry.yoo, akpm, andrew+netdev,
	asml.silence, toke, david, Liam.Howlett, vbabka, rppt, surenb,
	mhocko, linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb,
	wei.fang, shenwei.wang, xiaoning.wang, davem, edumazet, kuba

On Fri, Jul 18, 2025 at 01:42:38AM +0800, kernel test robot wrote:
> Hi Byungchul,
> 
> kernel test robot noticed the following build warnings:
> 
> [auto build test WARNING on c65d34296b2252897e37835d6007bbd01b255742]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Byungchul-Park/netmem-introduce-struct-netmem_desc-mirroring-struct-page/20250717-150253
> base:   c65d34296b2252897e37835d6007bbd01b255742
> patch link:    https://lore.kernel.org/r/20250717070052.6358-13-byungchul%40sk.com
> patch subject: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
> config: arm-randconfig-r072-20250717 (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/config)
> compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202507180111.jygqJHzk-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/container_of.h:5,
>                     from include/linux/list.h:5,
>                     from include/linux/timer.h:5,
>                     from include/linux/netdevice.h:24,
>                     from include/trace/events/xdp.h:8,
>                     from include/linux/bpf_trace.h:5,
>                     from include/net/libeth/xdp.h:7,
>                     from drivers/net/ethernet/intel/libeth/tx.c:6:
>    include/net/libeth/xdp.h: In function 'libeth_xdp_prepare_buff':
> >> include/net/libeth/xdp.h:1295:23: warning: passing argument 1 of 'page_pool_page_is_pp' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
>         pp_page_to_nmdesc(page)->pp->p.offset, len, true);
>                           ^~~~
>    include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
>     #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
>                                                                   ^
>    include/net/netmem.h:301:2: note: in expansion of macro 'DEBUG_NET_WARN_ON_ONCE'
>      DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p));  \
>      ^~~~~~~~~~~~~~~~~~~~~~
>    include/net/libeth/xdp.h:1295:5: note: in expansion of macro 'pp_page_to_nmdesc'
>         pp_page_to_nmdesc(page)->pp->p.offset, len, true);
>         ^~~~~~~~~~~~~~~~~
>    In file included from arch/arm/include/asm/cacheflush.h:10,
>                     from include/linux/cacheflush.h:5,
>                     from include/linux/highmem.h:8,
>                     from include/linux/bvec.h:10,
>                     from include/linux/skbuff.h:17,
>                     from include/net/net_namespace.h:43,
>                     from include/linux/netdevice.h:38,
>                     from include/trace/events/xdp.h:8,
>                     from include/linux/bpf_trace.h:5,
>                     from include/net/libeth/xdp.h:7,
>                     from drivers/net/ethernet/intel/libeth/tx.c:6:
>    include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *'
>     static inline bool page_pool_page_is_pp(struct page *page)
>                                             ~~~~~~~~~~~~~^~~~

Oh.  page_pool_page_is_pp() in the mainline code already has this issue
that the helper cannot take const struct page * as argument.

How should we resolve the issue?  Changing page_pool_page_is_pp() to
macro and using _Generic again looks too much.  Or should we?  Any idea?

	Byungchul

> vim +1295 include/net/libeth/xdp.h
> 
>   1263
>   1264  bool libeth_xdp_buff_add_frag(struct libeth_xdp_buff *xdp,
>   1265                                const struct libeth_fqe *fqe,
>   1266                                u32 len);
>   1267
>   1268  /**
>   1269   * libeth_xdp_prepare_buff - fill &libeth_xdp_buff with head FQE data
>   1270   * @xdp: XDP buffer to attach the head to
>   1271   * @fqe: FQE containing the head buffer
>   1272   * @len: buffer len passed from HW
>   1273   *
>   1274   * Internal, use libeth_xdp_process_buff() instead. Initializes XDP buffer
>   1275   * head with the Rx buffer data: data pointer, length, headroom, and
>   1276   * truesize/tailroom. Zeroes the flags.
>   1277   * Uses faster single u64 write instead of per-field access.
>   1278   */
>   1279  static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,
>   1280                                             const struct libeth_fqe *fqe,
>   1281                                             u32 len)
>   1282  {
>   1283          const struct page *page = __netmem_to_page(fqe->netmem);
>   1284
>   1285  #ifdef __LIBETH_WORD_ACCESS
>   1286          static_assert(offsetofend(typeof(xdp->base), flags) -
>   1287                        offsetof(typeof(xdp->base), frame_sz) ==
>   1288                        sizeof(u64));
>   1289
>   1290          *(u64 *)&xdp->base.frame_sz = fqe->truesize;
>   1291  #else
>   1292          xdp_init_buff(&xdp->base, fqe->truesize, xdp->base.rxq);
>   1293  #endif
>   1294          xdp_prepare_buff(&xdp->base, page_address(page) + fqe->offset,
> > 1295                           pp_page_to_nmdesc(page)->pp->p.offset, len, true);
>   1296  }
>   1297
> 
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
  2025-07-18  0:43     ` Byungchul Park
@ 2025-07-18  1:14       ` Byungchul Park
  2025-07-18  9:18         ` Pavel Begunkov
  0 siblings, 1 reply; 19+ messages in thread
From: Byungchul Park @ 2025-07-18  1:14 UTC (permalink / raw)
  To: kernel test robot
  Cc: willy, netdev, oe-kbuild-all, linux-kernel, linux-mm, kernel_team,
	almasrymina, ilias.apalodimas, harry.yoo, akpm, andrew+netdev,
	asml.silence, toke, david, Liam.Howlett, vbabka, rppt, surenb,
	mhocko, linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb,
	wei.fang, shenwei.wang, xiaoning.wang, davem, edumazet, kuba

On Fri, Jul 18, 2025 at 09:43:46AM +0900, Byungchul Park wrote:
> On Fri, Jul 18, 2025 at 01:42:38AM +0800, kernel test robot wrote:
> > Hi Byungchul,
> > 
> > kernel test robot noticed the following build warnings:
> > 
> > [auto build test WARNING on c65d34296b2252897e37835d6007bbd01b255742]
> > 
> > url:    https://github.com/intel-lab-lkp/linux/commits/Byungchul-Park/netmem-introduce-struct-netmem_desc-mirroring-struct-page/20250717-150253
> > base:   c65d34296b2252897e37835d6007bbd01b255742
> > patch link:    https://lore.kernel.org/r/20250717070052.6358-13-byungchul%40sk.com
> > patch subject: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
> > config: arm-randconfig-r072-20250717 (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/config)
> > compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202507180111.jygqJHzk-lkp@intel.com/
> > 
> > All warnings (new ones prefixed by >>):
> > 
> >    In file included from include/linux/container_of.h:5,
> >                     from include/linux/list.h:5,
> >                     from include/linux/timer.h:5,
> >                     from include/linux/netdevice.h:24,
> >                     from include/trace/events/xdp.h:8,
> >                     from include/linux/bpf_trace.h:5,
> >                     from include/net/libeth/xdp.h:7,
> >                     from drivers/net/ethernet/intel/libeth/tx.c:6:
> >    include/net/libeth/xdp.h: In function 'libeth_xdp_prepare_buff':
> > >> include/net/libeth/xdp.h:1295:23: warning: passing argument 1 of 'page_pool_page_is_pp' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
> >         pp_page_to_nmdesc(page)->pp->p.offset, len, true);
> >                           ^~~~
> >    include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
> >     #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
> >                                                                   ^
> >    include/net/netmem.h:301:2: note: in expansion of macro 'DEBUG_NET_WARN_ON_ONCE'
> >      DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p));  \
> >      ^~~~~~~~~~~~~~~~~~~~~~
> >    include/net/libeth/xdp.h:1295:5: note: in expansion of macro 'pp_page_to_nmdesc'
> >         pp_page_to_nmdesc(page)->pp->p.offset, len, true);
> >         ^~~~~~~~~~~~~~~~~
> >    In file included from arch/arm/include/asm/cacheflush.h:10,
> >                     from include/linux/cacheflush.h:5,
> >                     from include/linux/highmem.h:8,
> >                     from include/linux/bvec.h:10,
> >                     from include/linux/skbuff.h:17,
> >                     from include/net/net_namespace.h:43,
> >                     from include/linux/netdevice.h:38,
> >                     from include/trace/events/xdp.h:8,
> >                     from include/linux/bpf_trace.h:5,
> >                     from include/net/libeth/xdp.h:7,
> >                     from drivers/net/ethernet/intel/libeth/tx.c:6:
> >    include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *'
> >     static inline bool page_pool_page_is_pp(struct page *page)
> >                                             ~~~~~~~~~~~~~^~~~
> 
> Oh.  page_pool_page_is_pp() in the mainline code already has this issue
> that the helper cannot take const struct page * as argument.
> 
> How should we resolve the issue?  Changing page_pool_page_is_pp() to
> macro and using _Generic again looks too much.  Or should we?  Any idea?

option 1. Remove 'const' on declaration of struct page in
	  libeth_xdp_prepare_buff() but maybe bad.

option 2. Use __pp_page_to_nmdesc() instead of pp_page_to_nmdesc() in
	  libeth_xdp_prepare_buff() to skip checking if it's a pp page.

option 3. Change page_pool_page_is_pp() to macro and use _Generic to
	  cover const casting.

More?

	Byungchul

> 	Byungchul
> 
> > vim +1295 include/net/libeth/xdp.h
> > 
> >   1263
> >   1264  bool libeth_xdp_buff_add_frag(struct libeth_xdp_buff *xdp,
> >   1265                                const struct libeth_fqe *fqe,
> >   1266                                u32 len);
> >   1267
> >   1268  /**
> >   1269   * libeth_xdp_prepare_buff - fill &libeth_xdp_buff with head FQE data
> >   1270   * @xdp: XDP buffer to attach the head to
> >   1271   * @fqe: FQE containing the head buffer
> >   1272   * @len: buffer len passed from HW
> >   1273   *
> >   1274   * Internal, use libeth_xdp_process_buff() instead. Initializes XDP buffer
> >   1275   * head with the Rx buffer data: data pointer, length, headroom, and
> >   1276   * truesize/tailroom. Zeroes the flags.
> >   1277   * Uses faster single u64 write instead of per-field access.
> >   1278   */
> >   1279  static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,
> >   1280                                             const struct libeth_fqe *fqe,
> >   1281                                             u32 len)
> >   1282  {
> >   1283          const struct page *page = __netmem_to_page(fqe->netmem);
> >   1284
> >   1285  #ifdef __LIBETH_WORD_ACCESS
> >   1286          static_assert(offsetofend(typeof(xdp->base), flags) -
> >   1287                        offsetof(typeof(xdp->base), frame_sz) ==
> >   1288                        sizeof(u64));
> >   1289
> >   1290          *(u64 *)&xdp->base.frame_sz = fqe->truesize;
> >   1291  #else
> >   1292          xdp_init_buff(&xdp->base, fqe->truesize, xdp->base.rxq);
> >   1293  #endif
> >   1294          xdp_prepare_buff(&xdp->base, page_address(page) + fqe->offset,
> > > 1295                           pp_page_to_nmdesc(page)->pp->p.offset, len, true);
> >   1296  }
> >   1297
> > 
> > --
> > 0-DAY CI Kernel Test Service
> > https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
  2025-07-18  1:14       ` Byungchul Park
@ 2025-07-18  9:18         ` Pavel Begunkov
  2025-07-18  9:32           ` Pavel Begunkov
  0 siblings, 1 reply; 19+ messages in thread
From: Pavel Begunkov @ 2025-07-18  9:18 UTC (permalink / raw)
  To: Byungchul Park, kernel test robot
  Cc: willy, netdev, oe-kbuild-all, linux-kernel, linux-mm, kernel_team,
	almasrymina, ilias.apalodimas, harry.yoo, akpm, andrew+netdev,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba

On 7/18/25 02:14, Byungchul Park wrote:
...>>>
>>>     In file included from include/linux/container_of.h:5,
>>>                      from include/linux/list.h:5,
>>>                      from include/linux/timer.h:5,
>>>                      from include/linux/netdevice.h:24,
>>>                      from include/trace/events/xdp.h:8,
>>>                      from include/linux/bpf_trace.h:5,
>>>                      from include/net/libeth/xdp.h:7,
>>>                      from drivers/net/ethernet/intel/libeth/tx.c:6:
>>>     include/net/libeth/xdp.h: In function 'libeth_xdp_prepare_buff':
>>>>> include/net/libeth/xdp.h:1295:23: warning: passing argument 1 of 'page_pool_page_is_pp' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
>>>          pp_page_to_nmdesc(page)->pp->p.offset, len, true);
>>>                            ^~~~
>>>     include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
>>>      #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
>>>                                                                    ^
>>>     include/net/netmem.h:301:2: note: in expansion of macro 'DEBUG_NET_WARN_ON_ONCE'
>>>       DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p));  \
>>>       ^~~~~~~~~~~~~~~~~~~~~~
>>>     include/net/libeth/xdp.h:1295:5: note: in expansion of macro 'pp_page_to_nmdesc'
>>>          pp_page_to_nmdesc(page)->pp->p.offset, len, true);
>>>          ^~~~~~~~~~~~~~~~~
>>>     In file included from arch/arm/include/asm/cacheflush.h:10,
>>>                      from include/linux/cacheflush.h:5,
>>>                      from include/linux/highmem.h:8,
>>>                      from include/linux/bvec.h:10,
>>>                      from include/linux/skbuff.h:17,
>>>                      from include/net/net_namespace.h:43,
>>>                      from include/linux/netdevice.h:38,
>>>                      from include/trace/events/xdp.h:8,
>>>                      from include/linux/bpf_trace.h:5,
>>>                      from include/net/libeth/xdp.h:7,
>>>                      from drivers/net/ethernet/intel/libeth/tx.c:6:
>>>     include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *'
>>>      static inline bool page_pool_page_is_pp(struct page *page)
>>>                                              ~~~~~~~~~~~~~^~~~
>>
>> Oh.  page_pool_page_is_pp() in the mainline code already has this issue
>> that the helper cannot take const struct page * as argument.

Probably not, and probably for wrong reasons. netmem_ref is define
as an integer, compilers cast away such const unlike const pointers.

>> How should we resolve the issue?  Changing page_pool_page_is_pp() to
>> macro and using _Generic again looks too much.  Or should we?  Any idea?

page_pool_page_is_pp() doesn't change the page, just make the
argument const.

bool page_pool_page_is_pp(const struct page *page)

-- 
Pavel Begunkov



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
  2025-07-18  9:18         ` Pavel Begunkov
@ 2025-07-18  9:32           ` Pavel Begunkov
  2025-07-21  1:03             ` Byungchul Park
  0 siblings, 1 reply; 19+ messages in thread
From: Pavel Begunkov @ 2025-07-18  9:32 UTC (permalink / raw)
  To: Byungchul Park, kernel test robot
  Cc: willy, netdev, oe-kbuild-all, linux-kernel, linux-mm, kernel_team,
	almasrymina, ilias.apalodimas, harry.yoo, akpm, andrew+netdev,
	toke, david, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-rdma, bpf, vishal.moola, hannes, ziy, jackmanb, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, kuba

On 7/18/25 10:18, Pavel Begunkov wrote:
> On 7/18/25 02:14, Byungchul Park wrote:
...>>>>     include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *'
>>>>      static inline bool page_pool_page_is_pp(struct page *page)
>>>>                                              ~~~~~~~~~~~~~^~~~
>>>
>>> Oh.  page_pool_page_is_pp() in the mainline code already has this issue
>>> that the helper cannot take const struct page * as argument.
> 
> Probably not, and probably for wrong reasons. netmem_ref is define
> as an integer, compilers cast away such const unlike const pointers.

Taking a look libeth, at least at the reported spot it does
page->pp->p.offset, that should be fine. And your problem
is caused by the is_pp check in pp_page_to_nmdesc().

-- 
Pavel Begunkov



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
  2025-07-18  9:32           ` Pavel Begunkov
@ 2025-07-21  1:03             ` Byungchul Park
  0 siblings, 0 replies; 19+ messages in thread
From: Byungchul Park @ 2025-07-21  1:03 UTC (permalink / raw)
  To: Pavel Begunkov
  Cc: kernel test robot, willy, netdev, oe-kbuild-all, linux-kernel,
	linux-mm, kernel_team, almasrymina, ilias.apalodimas, harry.yoo,
	akpm, andrew+netdev, toke, david, Liam.Howlett, vbabka, rppt,
	surenb, mhocko, linux-rdma, bpf, vishal.moola, hannes, ziy,
	jackmanb, wei.fang, shenwei.wang, xiaoning.wang, davem, edumazet,
	kuba

On Fri, Jul 18, 2025 at 10:32:38AM +0100, Pavel Begunkov wrote:
> On 7/18/25 10:18, Pavel Begunkov wrote:
> > On 7/18/25 02:14, Byungchul Park wrote:
> ...>>>>     include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *'
> > > > >      static inline bool page_pool_page_is_pp(struct page *page)
> > > > >                                              ~~~~~~~~~~~~~^~~~
> > > > 
> > > > Oh.  page_pool_page_is_pp() in the mainline code already has this issue
> > > > that the helper cannot take const struct page * as argument.
> > 
> > Probably not, and probably for wrong reasons. netmem_ref is define
> > as an integer, compilers cast away such const unlike const pointers.
> 
> Taking a look libeth, at least at the reported spot it does
> page->pp->p.offset, that should be fine. And your problem
> is caused by the is_pp check in pp_page_to_nmdesc().

Exactly, but you asked me to add the check,
DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p)) in pp_page_to_nmdesc().

What I meant was, in order to apply that, page_pool_page_is_pp() should
take 'const struct page *' as argument.

I think it's good idea to change the proto type like, as you said:

   static inline bool page_pool_page_is_pp(const struct page *page);

Thanks.

	Byungchul
> 
> --
> Pavel Begunkov
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-07-21  1:03 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-17  7:00 [PATCH net-next v11 00/12] Split netmem from struct page Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 01/12] netmem: introduce struct netmem_desc mirroring " Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp() Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 03/12] netmem, mlx4: access ->pp_ref_count through netmem_desc instead of page Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 04/12] netdevsim: access ->pp " Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 05/12] mt76: " Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 06/12] net: fec: " Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 07/12] octeontx2-pf: " Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 08/12] iavf: " Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 09/12] idpf: " Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 10/12] mlx5: " Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 11/12] net: ti: icssg-prueth: " Byungchul Park
2025-07-17  7:00 ` [PATCH net-next v11 12/12] libeth: xdp: " Byungchul Park
2025-07-17 17:42   ` [Intel-wired-lan] " kernel test robot
2025-07-18  0:43     ` Byungchul Park
2025-07-18  1:14       ` Byungchul Park
2025-07-18  9:18         ` Pavel Begunkov
2025-07-18  9:32           ` Pavel Begunkov
2025-07-21  1:03             ` Byungchul Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).