[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250509115126.63190-20-byungchul@sk.com>
Date: Fri, 9 May 2025 20:51:26 +0900
From: Byungchul Park <byungchul@...com>
To: willy@...radead.org,
netdev@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
kernel_team@...ynix.com,
kuba@...nel.org,
almasrymina@...gle.com,
ilias.apalodimas@...aro.org,
harry.yoo@...cle.com,
hawk@...nel.org,
akpm@...ux-foundation.org,
ast@...nel.org,
daniel@...earbox.net,
davem@...emloft.net,
john.fastabend@...il.com,
andrew+netdev@...n.ch,
edumazet@...gle.com,
pabeni@...hat.com,
vishal.moola@...il.com
Subject: [RFC 19/19] mm, netmem: remove the page pool members in struct page
Now that all the users of the page pool members in struct page have been
gone, the members can be removed from struct page. However, the space
in struct page needs to be kept using a place holder with the same size,
until struct netmem_desc has its own instance, not overlayed onto struct
page, to avoid conficting with other members within struct page.
Remove the page pool members in struct page and replace with a place
holder. The place holder should be removed once struct netmem_desc has
its own instance.
Signed-off-by: Byungchul Park <byungchul@...com>
---
include/linux/mm_types.h | 13 ++-----------
include/net/netmem.h | 35 +----------------------------------
include/net/netmem_type.h | 22 ++++++++++++++++++++++
3 files changed, 25 insertions(+), 45 deletions(-)
create mode 100644 include/net/netmem_type.h
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index e76bade9ebb12..69904a0855358 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -20,6 +20,7 @@
#include <linux/seqlock.h>
#include <linux/percpu_counter.h>
#include <linux/types.h>
+#include <net/netmem_type.h> /* for page pool */
#include <asm/mmu.h>
@@ -118,17 +119,7 @@ struct page {
*/
unsigned long private;
};
- struct { /* page_pool used by netstack */
- /**
- * @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;
- };
+ struct __netmem_desc place_holder_1; /* for page pool */
struct { /* Tail pages of compound page */
unsigned long compound_head; /* Bit zero is set */
};
diff --git a/include/net/netmem.h b/include/net/netmem.h
index 00064e766b889..c414de6c6ab0d 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -10,6 +10,7 @@
#include <linux/mm.h>
#include <net/net_debug.h>
+#include <net/netmem_type.h>
/* net_iov */
@@ -20,15 +21,6 @@ DECLARE_STATIC_KEY_FALSE(page_pool_mem_providers);
*/
#define NET_IOV 0x01UL
-struct netmem_desc {
- unsigned long __unused_padding;
- unsigned long pp_magic;
- struct page_pool *pp;
- struct net_iov_area *owner;
- unsigned long dma_addr;
- atomic_long_t pp_ref_count;
-};
-
struct net_iov_area {
/* Array of net_iovs for this area. */
struct netmem_desc *niovs;
@@ -38,31 +30,6 @@ struct net_iov_area {
unsigned long base_virtual;
};
-/* 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 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) == \
- offsetof(struct netmem_desc, iov))
-NET_IOV_ASSERT_OFFSET(pp_magic, pp_magic);
-NET_IOV_ASSERT_OFFSET(pp, pp);
-NET_IOV_ASSERT_OFFSET(dma_addr, dma_addr);
-NET_IOV_ASSERT_OFFSET(pp_ref_count, pp_ref_count);
-#undef NET_IOV_ASSERT_OFFSET
-
static inline struct net_iov_area *net_iov_owner(const struct netmem_desc *niov)
{
return niov->owner;
diff --git a/include/net/netmem_type.h b/include/net/netmem_type.h
new file mode 100644
index 0000000000000..6a3ac8e908515
--- /dev/null
+++ b/include/net/netmem_type.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Author: Byungchul Park <max.byungchul.park@...il.com>
+ */
+
+#ifndef _NET_NETMEM_TYPE_H
+#define _NET_NETMEM_TYPE_H
+
+#include <linux/stddef.h>
+
+struct netmem_desc {
+ unsigned long __unused_padding;
+ struct_group_tagged(__netmem_desc, actual_data,
+ unsigned long pp_magic;
+ struct page_pool *pp;
+ struct net_iov_area *owner;
+ unsigned long dma_addr;
+ atomic_long_t pp_ref_count;
+ );
+};
+
+#endif /* _NET_NETMEM_TYPE_H */
--
2.17.1
Powered by blists - more mailing lists