Re: [PATCH 01/18] netmem: introduce struct netmem_desc struct_group_tagged()'ed on struct net_iov

From
Byungchul Park <byungchul@sk.com>
Date
2025-05-27 02:50:53
Also in
bpf, linux-mm, linux-rdma, lkml
Reply to
Byungchul Park, 2025-05-23
On Fri, May 23, 2025 at 12:25:52PM +0900, Byungchul Park wrote:
quoted hunk ↗ jump to hunk
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, reusing struct net_iov that already mirrored struct page.

While at it, relocate _pp_mapping_pad to group struct net_iov's fields.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 include/linux/mm_types.h |  2 +-
 include/net/netmem.h     | 43 +++++++++++++++++++++++++++++++++-------
 2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 56d07edd01f9..873e820e1521 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -120,13 +120,13 @@ struct page {
 			unsigned long private;
 		};
 		struct {	/* page_pool used by netstack */
+			unsigned long _pp_mapping_pad;
 			/**
 			 * @pp_magic: magic value to avoid recycling non
 			 * page_pool allocated pages.
 			 */
 			unsigned long pp_magic;
 			struct page_pool *pp;
-			unsigned long _pp_mapping_pad;
 			unsigned long dma_addr;
 			atomic_long_t pp_ref_count;
 		};
diff --git a/include/net/netmem.h b/include/net/netmem.h
index 386164fb9c18..08e9d76cdf14 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -31,12 +31,41 @@ enum net_iov_type {
 };
 
 struct net_iov {
-	enum net_iov_type type;
-	unsigned long pp_magic;
-	struct page_pool *pp;
-	struct net_iov_area *owner;
-	unsigned long dma_addr;
-	atomic_long_t pp_ref_count;
+	/*
+	 * XXX: Now that struct netmem_desc overlays on struct page,
+	 * struct_group_tagged() should cover all of them.  However,
+	 * a separate struct netmem_desc should be declared and embedded,
+	 * once struct netmem_desc is no longer overlayed but it has its
+	 * own instance from slab.  The final form should be:
+	 *
+	 *    struct netmem_desc {
+	 *	   unsigned long pp_magic;
+	 *	   struct page_pool *pp;
+	 *	   unsigned long dma_addr;
+	 *	   atomic_long_t pp_ref_count;
+	 *    };
+	 *
+	 *    struct net_iov {
+	 *	   enum net_iov_type type;
+	 *	   struct net_iov_area *owner;
+	 *	   struct netmem_desc;
+	 *    };
+	 */
+	struct_group_tagged(netmem_desc, desc,
So..  For now, this is the best option we can pick.  We can do all that
you told me once struct netmem_desc has it own instance from slab.

Again, it's because the page pool fields (or netmem things) from struct
page will be gone by this series.

Mina, thoughts?

	Byungchul
quoted hunk ↗ jump to hunk
+		/*
+		 * only for struct net_iov
+		 */
+		enum net_iov_type type;
+		struct net_iov_area *owner;
+
+		/*
+		 * actually for struct netmem_desc
+		 */
+		unsigned long pp_magic;
+		struct page_pool *pp;
+		unsigned long dma_addr;
+		atomic_long_t pp_ref_count;
+	);
 };
 
 struct net_iov_area {
@@ -51,9 +80,9 @@ struct net_iov_area {
 /* These fields in struct page are used by the page_pool and net stack:
  *
  *        struct {
+ *                unsigned long _pp_mapping_pad;
  *                unsigned long pp_magic;
  *                struct page_pool *pp;
- *                unsigned long _pp_mapping_pad;
  *                unsigned long dma_addr;
  *                atomic_long_t pp_ref_count;
  *        };
-- 
2.17.1
Thread (72 messages) 72 messages, 7 authors, last reply 2025-05-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help