Thread (36 messages) 36 messages, 4 authors, 2022-12-08
STALE1270d

[PATCH 25/26] netpool: Additional utility functions

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Date: 2022-12-06 16:05:46
Also in: linux-mm
Subsystem: networking [general], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

To be folded into earlier commit
---
 include/net/page_pool.h | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/include/net/page_pool.h b/include/net/page_pool.h
index 4878fe30f52c..94bad45ed8d0 100644
--- a/include/net/page_pool.h
+++ b/include/net/page_pool.h
@@ -117,16 +117,28 @@ static inline void *netmem_to_virt(const struct netmem *nmem)
 	return page_to_virt(netmem_page(nmem));
 }
 
+static inline void *netmem_address(const struct netmem *nmem)
+{
+	return page_address(netmem_page(nmem));
+}
+
 static inline int netmem_ref_count(const struct netmem *nmem)
 {
 	return page_ref_count(netmem_page(nmem));
 }
 
+static inline void netmem_get(struct netmem *nmem)
+{
+	struct folio *folio = (struct folio *)nmem;
+
+	folio_get(folio);
+}
+
 static inline void netmem_put(struct netmem *nmem)
 {
 	struct folio *folio = (struct folio *)nmem;
 
-	return folio_put(folio);
+	folio_put(folio);
 }
 
 static inline bool netmem_is_pfmemalloc(const struct netmem *nmem)
@@ -295,6 +307,11 @@ struct page_pool {
 
 struct netmem *page_pool_alloc_netmem(struct page_pool *pool, gfp_t gfp);
 
+static inline struct netmem *page_pool_dev_alloc_netmem(struct page_pool *pool)
+{
+	return page_pool_alloc_netmem(pool, GFP_ATOMIC | __GFP_NOWARN);
+}
+
 static inline
 struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp)
 {
@@ -452,6 +469,12 @@ static inline void page_pool_recycle_direct(struct page_pool *pool,
 	page_pool_put_full_page(pool, page, true);
 }
 
+static inline void page_pool_recycle_netmem(struct page_pool *pool,
+					    struct netmem *nmem)
+{
+	page_pool_put_full_netmem(pool, nmem, true);
+}
+
 #define PAGE_POOL_DMA_USE_PP_FRAG_COUNT	\
 		(sizeof(dma_addr_t) > sizeof(unsigned long))
 
-- 
2.35.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