imx.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v12 00/12] Split netmem from struct page
@ 2025-07-21  2:18 Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 01/12] netmem: introduce struct netmem_desc mirroring " Byungchul Park
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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 v11:
	1. Rebase on net-next/main as of Jul 21.
	2. Change page_pool_page_is_pp() to check for const type of
	   page.  For now that it's called along with every
	   pp_page_to_nmdesc() call as Pavel suggested,
	   page_pool_page_is_pp() should also cover const type of page.

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/linux/mm.h                            |   4 +-
 include/net/libeth/xdp.h                      |   2 +-
 include/net/netmem.h                          | 153 +++++++++++++++---
 12 files changed, 161 insertions(+), 40 deletions(-)


base-commit: 4701ee5044fb3992f1c910630a9673c2dc600ce5
-- 
2.17.1


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

* [PATCH net-next v12 01/12] netmem: introduce struct netmem_desc mirroring struct page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp() Byungchul Park
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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] 15+ messages in thread

* [PATCH net-next v12 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp()
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 01/12] netmem: introduce struct netmem_desc mirroring " Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 03/12] netmem, mlx4: access ->pp_ref_count through netmem_desc instead of page Byungchul Park
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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] 15+ messages in thread

* [PATCH net-next v12 03/12] netmem, mlx4: access ->pp_ref_count through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 01/12] netmem: introduce struct netmem_desc mirroring " Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp() Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 04/12] netdevsim: access ->pp " Byungchul Park
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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.

Plus, change page_pool_page_is_pp() to check for 'const struct page *'
instead of 'struct page *' since it doesn't modify data and additionally
covers const type.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c |  4 +++-
 include/linux/mm.h                         |  4 ++--
 include/net/netmem.h                       | 17 +++++++++++++++++
 3 files changed, 22 insertions(+), 3 deletions(-)

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/linux/mm.h b/include/linux/mm.h
index fa538feaa8d9..ae50c1641bed 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4178,12 +4178,12 @@ int arch_lock_shadow_stack_status(struct task_struct *t, unsigned long status);
 #define PP_MAGIC_MASK ~(PP_DMA_INDEX_MASK | 0x3UL)
 
 #ifdef CONFIG_PAGE_POOL
-static inline bool page_pool_page_is_pp(struct page *page)
+static inline bool page_pool_page_is_pp(const struct page *page)
 {
 	return (page->pp_magic & PP_MAGIC_MASK) == PP_SIGNATURE;
 }
 #else
-static inline bool page_pool_page_is_pp(struct page *page)
+static inline bool page_pool_page_is_pp(const struct page *page)
 {
 	return false;
 }
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] 15+ messages in thread

* [PATCH net-next v12 04/12] netdevsim: access ->pp through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (2 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 03/12] netmem, mlx4: access ->pp_ref_count through netmem_desc instead of page Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 05/12] mt76: " Byungchul Park
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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 611e7f65291c..2b80591981dc 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -898,7 +898,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;
 	}
 
@@ -1126,7 +1127,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] 15+ messages in thread

* [PATCH net-next v12 05/12] mt76: access ->pp through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (3 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 04/12] netdevsim: access ->pp " Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 06/12] net: fec: " Byungchul Park
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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 2912568612bc..8dd5c29fb75b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1810,7 +1810,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] 15+ messages in thread

* [PATCH net-next v12 06/12] net: fec: access ->pp through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (4 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 05/12] mt76: " Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 07/12] octeontx2-pf: " Byungchul Park
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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 b481ee8ee478..1383918f8a3f 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1045,7 +1045,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;
@@ -1586,7 +1588,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;
@@ -3348,7 +3351,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] 15+ messages in thread

* [PATCH net-next v12 07/12] octeontx2-pf: access ->pp through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (5 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 06/12] net: fec: " Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 08/12] iavf: " Byungchul Park
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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] 15+ messages in thread

* [PATCH net-next v12 08/12] iavf: access ->pp through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (6 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 07/12] octeontx2-pf: " Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 09/12] idpf: " Byungchul Park
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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] 15+ messages in thread

* [PATCH net-next v12 09/12] idpf: access ->pp through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (7 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 08/12] iavf: " Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 10/12] mlx5: " Byungchul Park
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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] 15+ messages in thread

* [PATCH net-next v12 10/12] mlx5: access ->pp through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (8 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 09/12] idpf: " Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 11/12] net: ti: icssg-prueth: " Byungchul Park
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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] 15+ messages in thread

* [PATCH net-next v12 11/12] net: ti: icssg-prueth: access ->pp through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (9 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 10/12] mlx5: " Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-21  2:18 ` [PATCH net-next v12 12/12] libeth: xdp: " Byungchul Park
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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] 15+ messages in thread

* [PATCH net-next v12 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (10 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 11/12] net: ti: icssg-prueth: " Byungchul Park
@ 2025-07-21  2:18 ` Byungchul Park
  2025-07-23  4:49 ` [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
  2025-07-24  2:00 ` patchwork-bot+netdevbpf
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-21  2:18 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] 15+ messages in thread

* Re: [PATCH net-next v12 00/12] Split netmem from struct page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (11 preceding siblings ...)
  2025-07-21  2:18 ` [PATCH net-next v12 12/12] libeth: xdp: " Byungchul Park
@ 2025-07-23  4:49 ` Byungchul Park
  2025-07-24  2:00 ` patchwork-bot+netdevbpf
  13 siblings, 0 replies; 15+ messages in thread
From: Byungchul Park @ 2025-07-23  4:49 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

On Mon, Jul 21, 2025 at 11:18:23AM +0900, Byungchul Park wrote:
> 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 v11:
> 	1. Rebase on net-next/main as of Jul 21.
> 	2. Change page_pool_page_is_pp() to check for const type of
> 	   page.  For now that it's called along with every
> 	   pp_page_to_nmdesc() call as Pavel suggested,
> 	   page_pool_page_is_pp() should also cover const type of page.

I believe the curretn version is good enough.

	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/linux/mm.h                            |   4 +-
>  include/net/libeth/xdp.h                      |   2 +-
>  include/net/netmem.h                          | 153 +++++++++++++++---
>  12 files changed, 161 insertions(+), 40 deletions(-)
> 
> 
> base-commit: 4701ee5044fb3992f1c910630a9673c2dc600ce5
> -- 
> 2.17.1

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

* Re: [PATCH net-next v12 00/12] Split netmem from struct page
  2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
                   ` (12 preceding siblings ...)
  2025-07-23  4:49 ` [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
@ 2025-07-24  2:00 ` patchwork-bot+netdevbpf
  13 siblings, 0 replies; 15+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-24  2:00 UTC (permalink / raw)
  To: Byungchul Park
  Cc: willy, netdev, 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

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 21 Jul 2025 11:18:23 +0900 you wrote:
> 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
> 
> [...]

Here is the summary with links:
  - [net-next,v12,01/12] netmem: introduce struct netmem_desc mirroring struct page
    https://git.kernel.org/netdev/net-next/c/f3d85c9ee510
  - [net-next,v12,02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp()
    https://git.kernel.org/netdev/net-next/c/38a436d4e264
  - [net-next,v12,03/12] netmem, mlx4: access ->pp_ref_count through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/89ade7c73065
  - [net-next,v12,04/12] netdevsim: access ->pp through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/6fd824342a57
  - [net-next,v12,05/12] mt76: access ->pp through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/87dda483e63f
  - [net-next,v12,06/12] net: fec: access ->pp through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/65589e860a80
  - [net-next,v12,07/12] octeontx2-pf: access ->pp through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/58831a178551
  - [net-next,v12,08/12] iavf: access ->pp through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/c8d6830e32eb
  - [net-next,v12,09/12] idpf: access ->pp through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/fc16f6a5877d
  - [net-next,v12,10/12] mlx5: access ->pp through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/5445a5f71209
  - [net-next,v12,11/12] net: ti: icssg-prueth: access ->pp through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/c0bcfabd7752
  - [net-next,v12,12/12] libeth: xdp: access ->pp through netmem_desc instead of page
    https://git.kernel.org/netdev/net-next/c/9dfd871a3e2e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-07-24  2:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21  2:18 [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 01/12] netmem: introduce struct netmem_desc mirroring " Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp() Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 03/12] netmem, mlx4: access ->pp_ref_count through netmem_desc instead of page Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 04/12] netdevsim: access ->pp " Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 05/12] mt76: " Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 06/12] net: fec: " Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 07/12] octeontx2-pf: " Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 08/12] iavf: " Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 09/12] idpf: " Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 10/12] mlx5: " Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 11/12] net: ti: icssg-prueth: " Byungchul Park
2025-07-21  2:18 ` [PATCH net-next v12 12/12] libeth: xdp: " Byungchul Park
2025-07-23  4:49 ` [PATCH net-next v12 00/12] Split netmem from struct page Byungchul Park
2025-07-24  2:00 ` patchwork-bot+netdevbpf

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).