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]

 



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
-- 
pw-bot: cr



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux