[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230111042214.907030-19-willy@infradead.org>
Date: Wed, 11 Jan 2023 04:22:06 +0000
From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
To: Jesper Dangaard Brouer <hawk@...nel.org>,
Ilias Apalodimas <ilias.apalodimas@...aro.org>
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
netdev@...r.kernel.org, linux-mm@...ck.org,
Shakeel Butt <shakeelb@...gle.com>,
Jesse Brandeburg <jesse.brandeburg@...el.com>
Subject: [PATCH v3 18/26] page_pool: Allow page_pool_recycle_direct() to take a netmem or a page
With no better name for a variant of page_pool_recycle_direct() which
takes a netmem instead of a page, use _Generic() to allow it to take
either a page or a netmem argument. It's a bit ugly, but maybe not
the worst alternative?
Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@...el.com>
---
include/net/page_pool.h | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/net/page_pool.h b/include/net/page_pool.h
index e205eaed21a5..64ac397dcd9f 100644
--- a/include/net/page_pool.h
+++ b/include/net/page_pool.h
@@ -482,12 +482,22 @@ static inline void page_pool_put_full_page(struct page_pool *pool,
}
/* Same as above but the caller must guarantee safe context. e.g NAPI */
-static inline void page_pool_recycle_direct(struct page_pool *pool,
+static inline void __page_pool_recycle_direct(struct page_pool *pool,
+ struct netmem *nmem)
+{
+ page_pool_put_full_netmem(pool, nmem, true);
+}
+
+static inline void __page_pool_recycle_page_direct(struct page_pool *pool,
struct page *page)
{
- page_pool_put_full_page(pool, page, true);
+ page_pool_put_full_netmem(pool, page_netmem(page), true);
}
+#define page_pool_recycle_direct(pool, mem) _Generic((mem), \
+ struct netmem *: __page_pool_recycle_direct(pool, (struct netmem *)mem), \
+ struct page *: __page_pool_recycle_page_direct(pool, (struct page *)mem))
+
#define PAGE_POOL_DMA_USE_PP_FRAG_COUNT \
(sizeof(dma_addr_t) > sizeof(unsigned long))
--
2.35.1
Powered by blists - more mailing lists