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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Jakub Kicinski <kuba@xxxxxxxxxx>
> Sent: Thursday, July 20, 2023 12:30 AM
> To: Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>
> Cc: linux-hyperv@xxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; Dexuan Cui
> <decui@xxxxxxxxxxxxx>; KY Srinivasan <kys@xxxxxxxxxxxxx>; Paul Rosswurm
> <paulros@xxxxxxxxxxxxx>; olaf@xxxxxxxxx; vkuznets@xxxxxxxxxx;
> davem@xxxxxxxxxxxxx; wei.liu@xxxxxxxxxx; edumazet@xxxxxxxxxx;
> pabeni@xxxxxxxxxx; leon@xxxxxxxxxx; Long Li <longli@xxxxxxxxxxxxx>;
> ssengar@xxxxxxxxxxxxxxxxxxx; linux-rdma@xxxxxxxxxxxxxxx;
> daniel@xxxxxxxxxxxxx; john.fastabend@xxxxxxxxx; bpf@xxxxxxxxxxxxxxx;
> ast@xxxxxxxxxx; Ajay Sharma <sharmaajay@xxxxxxxxxxxxx>; hawk@xxxxxxxxxx;
> tglx@xxxxxxxxxxxxx; shradhagupta@xxxxxxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx
> 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




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux