Re: [PATCH net-next v8 07/17] net: page_pool: introduce page_pool_mp_return_in_cache

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

 



On 12/10/24 03:40, Jakub Kicinski wrote:
On Wed,  4 Dec 2024 09:21:46 -0800 David Wei wrote:
+/*
+ * page_pool_mp_return_in_cache() - return a netmem to the allocation cache.
+ * @pool:	pool from which pages were allocated
+ * @netmem:	netmem to return
+ *
+ * Return already allocated and accounted netmem to the page pool's allocation
+ * cache. The function doesn't provide synchronisation and must only be called
+ * from the napi context.

NAPI is irrelevant, this helper, IIUC, has to be called down the call
chain from mp_ops->alloc().

+ */
+void page_pool_mp_return_in_cache(struct page_pool *pool, netmem_ref netmem)
+{
+	if (WARN_ON_ONCE(pool->alloc.count >= PP_ALLOC_CACHE_REFILL))
+		return;

I'd

	return false;

without a warning.

+	page_pool_dma_sync_for_device(pool, netmem, -1);
+	page_pool_fragment_netmem(netmem, 1);
+	pool->alloc.cache[pool->alloc.count++] = netmem;

and here:

	return true;

this say mps can use return value as a stop condition in a do {} while()
loop, without having to duplicate the check.

	do {
		netmem = alloc...
		... logic;
	} while (page_pool_mp_alloc_refill(pp, netmem));

	/* last netmem didn't fit in the cache */
	return netmem;

That last netmem is a problem. Returning it is not a bad option,
but it doesn't feel right. Providers should rather converge to
one way of returning buffers and batching here is needed.

I'd rather prefer this one then

while (pp_has_space()) {
	netmem = alloc();
	pp_push(netmem);
}

Any thoughts on that?

--
Pavel Begunkov





[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