Thread (3 messages) 3 messages, 2 authors, 2023-07-20

Re: [PATCH V2,net-next] net: mana: Add page pool for RX buffers

From: Jakub Kicinski <kuba@kernel.org>
Date: 2023-07-20 04:29:56
Also in: bpf, linux-hyperv, linux-rdma, lkml

On Tue, 18 Jul 2023 21:48:01 +0000 Haiyang Zhang wrote:
Add page pool for RX buffers for faster buffer cycle and reduce CPU
usage.

The standard page pool API is used.
quoted hunk ↗ jump to hunk
@@ -1437,8 +1437,12 @@ static void mana_rx_skb(void *buf_va, struct mana_rxcomp_oob *cqe,
 
 	act = mana_run_xdp(ndev, rxq, &xdp, buf_va, pkt_len);
 
-	if (act == XDP_REDIRECT && !rxq->xdp_rc)
+	if (act == XDP_REDIRECT && !rxq->xdp_rc) {
+		if (from_pool)
+			page_pool_release_page(rxq->page_pool,
+					       virt_to_head_page(buf_va));

IIUC you should pass the page_pool as the last argument to 
xdp_rxq_info_reg_mem_model() and then the page will be recycled
by the core, you shouldn't release it.

Not to mention the potential race in releasing the page _after_
giving its ownership to someone else.
-		page = dev_alloc_page();
+		if (is_napi) {
+			page = page_pool_dev_alloc_pages(rxq->page_pool);
+			*from_pool = true;
+		} else {
+			page = dev_alloc_page();
FWIW if you're only calling this outside NAPI during init, when NAPI
can't yet run, I _think_ it's okay to use page_pool_dev_alloc..
+	pprm.pool_size = RX_BUFFERS_PER_QUEUE;
+	pprm.napi = &cq->napi;
+	pprm.dev = gc->dev;
+	pprm.dma_dir = DMA_FROM_DEVICE;
If you're not setting PP_FLAG_DMA_MAP you don't have to fill in .dev
and .dma_dir
-- 
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help