Re: [PATCH v4 net-next 2/5] net: page_pool: add bulk support for ptr_ring

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

 



> On Fri,  6 Nov 2020 19:19:08 +0100
> Lorenzo Bianconi <lorenzo@xxxxxxxxxx> wrote:
> 
[...]
> 
> I don't like this comment.  This function is also used by non-bulking
> case.  Reaching this point means the page is ready or fulfill the
> requirement for being recycled into the ptr_ring.
> 
> I suggest (as before):
> 		/* Page found as candidate for recycling */

ack, I will fix it in v5.

Regards,
Lorenzo

> 
> > +		return page;
> >  	}
> >  	/* Fallback/non-XDP mode: API user have elevated refcnt.
> >  	 *
> > @@ -405,9 +405,55 @@ void page_pool_put_page(struct page_pool *pool, struct page *page,
> >  	/* Do not replace this with page_pool_return_page() */
> >  	page_pool_release_page(pool, page);
> >  	put_page(page);
> > +
> > +	return NULL;
> > +}
> > +
> > +void page_pool_put_page(struct page_pool *pool, struct page *page,
> > +			unsigned int dma_sync_size, bool allow_direct)
> > +{
> > +	page = __page_pool_put_page(pool, page, dma_sync_size, allow_direct);
> > +	if (page && !page_pool_recycle_in_ring(pool, page)) {
> > +		/* Cache full, fallback to free pages */
> > +		page_pool_return_page(pool, page);
> > +	}
> >  }
> >  EXPORT_SYMBOL(page_pool_put_page);
> >  
> > +/* Caller must not use data area after call, as this function overwrites it */
> > +void page_pool_put_page_bulk(struct page_pool *pool, void **data,
> > +			     int count)
> > +{
> > +	int i, bulk_len = 0, pa_len = 0;
> > +
> > +	for (i = 0; i < count; i++) {
> > +		struct page *page = virt_to_head_page(data[i]);
> > +
> > +		page = __page_pool_put_page(pool, page, -1, false);
> > +		/* Approved for bulk recycling in ptr_ring cache */
> > +		if (page)
> > +			data[bulk_len++] = page;
> > +	}
> > +
> > +	if (!bulk_len)
> > +		return;
> > +
> > +	/* Bulk producer into ptr_ring page_pool cache */
> > +	page_pool_ring_lock(pool);
> > +	for (i = 0; i < bulk_len; i++) {
> > +		if (__ptr_ring_produce(&pool->ring, data[i]))
> > +			data[pa_len++] = data[i];
> > +	}
> > +	page_pool_ring_unlock(pool);
> > +
> > +	/* ptr_ring cache full, free pages outside producer lock since
> > +	 * put_page() with refcnt == 1 can be an expensive operation
> > +	 */
> > +	for (i = 0; i < pa_len; i++)
> > +		page_pool_return_page(pool, data[i]);
> > +}
> > +EXPORT_SYMBOL(page_pool_put_page_bulk);
> 
> Rest looks okay :-)
> -- 
> Best regards,
>   Jesper Dangaard Brouer
>   MSc.CS, Principal Kernel Engineer at Red Hat
>   LinkedIn: http://www.linkedin.com/in/brouer
> 

Attachment: signature.asc
Description: PGP signature


[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