[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <BL1PR21MB31133BBFFA8C7268175C377DCA3EA@BL1PR21MB3113.namprd21.prod.outlook.com>
Date: Thu, 20 Jul 2023 13:15:36 +0000
From: Haiyang Zhang <haiyangz@...rosoft.com>
To: Jakub Kicinski <kuba@...nel.org>
CC: "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Dexuan Cui <decui@...rosoft.com>,
KY Srinivasan <kys@...rosoft.com>,
Paul Rosswurm <paulros@...rosoft.com>,
"olaf@...fle.de" <olaf@...fle.de>,
"vkuznets@...hat.com" <vkuznets@...hat.com>,
"davem@...emloft.net" <davem@...emloft.net>,
"wei.liu@...nel.org" <wei.liu@...nel.org>,
"edumazet@...gle.com" <edumazet@...gle.com>,
"pabeni@...hat.com" <pabeni@...hat.com>,
"leon@...nel.org" <leon@...nel.org>,
Long Li <longli@...rosoft.com>,
"ssengar@...ux.microsoft.com" <ssengar@...ux.microsoft.com>,
"linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
"daniel@...earbox.net" <daniel@...earbox.net>,
"john.fastabend@...il.com" <john.fastabend@...il.com>,
"bpf@...r.kernel.org" <bpf@...r.kernel.org>,
"ast@...nel.org" <ast@...nel.org>,
Ajay Sharma <sharmaajay@...rosoft.com>,
"hawk@...nel.org" <hawk@...nel.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"shradhagupta@...ux.microsoft.com" <shradhagupta@...ux.microsoft.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH V2,net-next] net: mana: Add page pool for RX buffers
> -----Original Message-----
> From: Jakub Kicinski <kuba@...nel.org>
> Sent: Thursday, July 20, 2023 12:30 AM
> To: Haiyang Zhang <haiyangz@...rosoft.com>
> Cc: linux-hyperv@...r.kernel.org; netdev@...r.kernel.org; Dexuan Cui
> <decui@...rosoft.com>; KY Srinivasan <kys@...rosoft.com>; Paul Rosswurm
> <paulros@...rosoft.com>; olaf@...fle.de; vkuznets@...hat.com;
> davem@...emloft.net; wei.liu@...nel.org; edumazet@...gle.com;
> pabeni@...hat.com; leon@...nel.org; Long Li <longli@...rosoft.com>;
> ssengar@...ux.microsoft.com; linux-rdma@...r.kernel.org;
> daniel@...earbox.net; john.fastabend@...il.com; bpf@...r.kernel.org;
> ast@...nel.org; Ajay Sharma <sharmaajay@...rosoft.com>; hawk@...nel.org;
> tglx@...utronix.de; shradhagupta@...ux.microsoft.com; linux-
> kernel@...r.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:
> > Add page pool for RX buffers for faster buffer cycle and reduce CPU
> > usage.
> >
> > The standard page pool API is used.
>
> > @@ -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
Thank you for the comments.
I will update the patch.
- Haiyang
Powered by blists - more mailing lists