Thread (24 messages) 24 messages, 5 authors, 2025-07-15
STALE347d REVIEWED: 4 (2M)
Revisions (9)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v1 [diff vs current]
  4. v6 [diff vs current]
  5. v7 current
  6. v9 [diff vs current]
  7. v10 [diff vs current]
  8. v11 [diff vs current]
  9. v12 [diff vs current]

[PATCH net-next v7 7/7] netmem: introduce a netmem API, virt_to_head_netmem()

From: Byungchul Park <byungchul@sk.com>
Date: 2025-06-25 04:34:07
Also in: bpf, linux-mm, linux-rdma, lkml
Subsystem: networking [general], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

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 a netmem API to convert a virtual address
to a head netmem allowing the code to use it rather than the existing
API, virt_to_head_page() for struct page.

Signed-off-by: Byungchul Park <byungchul@sk.com>
Reviewed-by: Toke Høiland-Jørgensen <redacted>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Mina Almasry <redacted>
---
 include/net/netmem.h | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/include/net/netmem.h b/include/net/netmem.h
index 535cf17b9134..c7b1fc4b6c28 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -314,6 +314,13 @@ static inline netmem_ref netmem_compound_head(netmem_ref netmem)
 	return page_to_netmem(compound_head(netmem_to_page(netmem)));
 }
 
+static inline netmem_ref virt_to_head_netmem(const void *x)
+{
+	netmem_ref netmem = virt_to_netmem(x);
+
+	return netmem_compound_head(netmem);
+}
+
 /**
  * __netmem_address - unsafely get pointer to the memory backing @netmem
  * @netmem: netmem reference to get the pointer for
-- 
2.17.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help