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

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

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: 2023-07-20 13:15:45
Also in: bpf, linux-hyperv, linux-rdma, lkml

-----Original Message-----
From: Jakub Kicinski <kuba@kernel.org>
Sent: Thursday, July 20, 2023 12:30 AM
To: Haiyang Zhang <haiyangz@microsoft.com>
Cc: linux-hyperv@vger.kernel.org; netdev@vger.kernel.org; Dexuan Cui
[off-list ref]; KY Srinivasan [off-list ref]; Paul Rosswurm
[off-list ref]; olaf@aepfle.de; vkuznets@redhat.com;
davem@davemloft.net; wei.liu@kernel.org; edumazet@google.com;
pabeni@redhat.com; leon@kernel.org; Long Li [off-list ref];
ssengar@linux.microsoft.com; linux-rdma@vger.kernel.org;
daniel@iogearbox.net; john.fastabend@gmail.com; bpf@vger.kernel.org;
ast@kernel.org; Ajay Sharma [off-list ref]; hawk@kernel.org;
tglx@linutronix.de; shradhagupta@linux.microsoft.com; linux-
kernel@vger.kernel.org
Subject: Re: [PATCH V2,net-next] net: mana: Add page pool for RX buffers

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

The standard page pool API is used.
quoted
@@ -1437,8 +1437,12 @@ static void mana_rx_skb(void *buf_va, struct
mana_rxcomp_oob *cqe,
quoted
 	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.
quoted
-		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..
quoted
+	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
Thank you for the comments.
I will update the patch.

- Haiyang
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help