lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fc1715f6-c123-43c6-9562-f84c7aab4ed2@gmail.com>
Date: Tue, 10 Dec 2024 04:31:53 +0000
From: Pavel Begunkov <asml.silence@...il.com>
To: Jakub Kicinski <kuba@...nel.org>, David Wei <dw@...idwei.uk>
Cc: io-uring@...r.kernel.org, netdev@...r.kernel.org,
 Jens Axboe <axboe@...nel.dk>, Paolo Abeni <pabeni@...hat.com>,
 "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
 Jesper Dangaard Brouer <hawk@...nel.org>, David Ahern <dsahern@...nel.org>,
 Mina Almasry <almasrymina@...gle.com>,
 Stanislav Fomichev <stfomichev@...il.com>, Joe Damato <jdamato@...tly.com>,
 Pedro Tammela <pctammela@...atatu.com>
Subject: Re: [PATCH net-next v8 07/17] net: page_pool: introduce
 page_pool_mp_return_in_cache

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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ