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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871q9een8q.fsf@toke.dk>
Date: Wed, 14 Feb 2024 22:42:45 +0100
From: Toke Høiland-Jørgensen <toke@...hat.com>
To: Lorenzo Bianconi <lorenzo@...nel.org>, netdev@...r.kernel.org
Cc: lorenzo.bianconi@...hat.com, kuba@...nel.org, davem@...emloft.net,
 edumazet@...gle.com, pabeni@...hat.com, hawk@...nel.org,
 ilias.apalodimas@...aro.org, linyunsheng@...wei.com
Subject: Re: [RFC net-next] net: page_pool: fix recycle stats for percpu
 page_pool allocator

Lorenzo Bianconi <lorenzo@...nel.org> writes:

> Use global page_pool_recycle_stats percpu counter for percpu page_pool
> allocator.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@...nel.org>

Neat trick with just referencing the pointer to the global object inside
the page_pool. With just a few nits below:

Reviewed-by: Toke Høiland-Jørgensen <toke@...hat.com>

> ---
>  net/core/page_pool.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index 6e0753e6a95b..1bb83b6e7a61 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -31,6 +31,8 @@
>  #define BIAS_MAX	(LONG_MAX >> 1)
>  
>  #ifdef CONFIG_PAGE_POOL_STATS
> +static DEFINE_PER_CPU(struct page_pool_recycle_stats, pp_recycle_stats);

Should we call this pp_system_recycle_stats to be consistent with the
naming of the other global variable?

>  /* alloc_stat_inc is intended to be used in softirq context */
>  #define alloc_stat_inc(pool, __stat)	(pool->alloc_stats.__stat++)
>  /* recycle_stat_inc is safe to use when preemption is possible. */
> @@ -220,14 +222,19 @@ static int page_pool_init(struct page_pool *pool,
>  	pool->has_init_callback = !!pool->slow.init_callback;
>  
>  #ifdef CONFIG_PAGE_POOL_STATS
> -	pool->recycle_stats = alloc_percpu(struct page_pool_recycle_stats);
> -	if (!pool->recycle_stats)
> -		return -ENOMEM;
> +	if (cpuid < 0) {
> +		pool->recycle_stats = alloc_percpu(struct page_pool_recycle_stats);
> +		if (!pool->recycle_stats)
> +			return -ENOMEM;
> +	} else {

Maybe add a short comment here to explain what's going on? Something
like:

/* When a cpuid is supplied, we're initialising the percpu system page pool
 * instance, so use a singular stats object instead of allocating a
 * separate percpu variable for each (also percpu) page pool instance.
 */

-Toke


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ