[RFC v3 02/18] netmem: introduce netmem alloc APIs to wrap page alloc APIs

From
Byungchul Park <byungchul@sk.com>
Date
2025-05-29 03:11:05
Also in
bpf, linux-mm, linux-rdma, lkml
Reply to
Byungchul Park, 2025-05-29
To eliminate the use of struct page in page pool, the page pool code
should use netmem descriptor and APIs instead.

As part of the work, introduce netmem alloc APIs allowing the code to
use them rather than the existing APIs for struct page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 net/core/netmem_priv.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/net/core/netmem_priv.h b/net/core/netmem_priv.h
index cd95394399b4..32e390908bb2 100644
--- a/net/core/netmem_priv.h
+++ b/net/core/netmem_priv.h
@@ -59,4 +59,18 @@ static inline void netmem_set_dma_index(netmem_ref netmem,
 	magic = netmem_get_pp_magic(netmem) | (id << PP_DMA_INDEX_SHIFT);
 	__netmem_clear_lsb(netmem)->pp_magic = magic;
 }
+
+static inline netmem_ref alloc_netmems_node(int nid, gfp_t gfp_mask,
+					    unsigned int order)
+{
+	return page_to_netmem(alloc_pages_node(nid, gfp_mask, order));
+}
+
+static inline unsigned long alloc_netmems_bulk_node(gfp_t gfp, int nid,
+						    unsigned long nr_netmems,
+						    netmem_ref *netmem_array)
+{
+	return alloc_pages_bulk_node(gfp, nid, nr_netmems,
+			(struct page **)netmem_array);
+}
 #endif
-- 
2.17.1
Thread (28 messages) 28 messages, 5 authors, last reply 2025-06-03
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