[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250226092857.La2UyrrB@linutronix.de>
Date: Wed, 26 Feb 2025 10:28:57 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Yunsheng Lin <linyunsheng@...wei.com>
Cc: linux-rdma@...r.kernel.org, netdev@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>,
Andrew Lunn <andrew+netdev@...n.ch>,
Eric Dumazet <edumazet@...gle.com>,
Ilias Apalodimas <ilias.apalodimas@...aro.org>,
Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
Leon Romanovsky <leon@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Saeed Mahameed <saeedm@...dia.com>, Simon Horman <horms@...nel.org>,
Tariq Toukan <tariqt@...dia.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH net-next 1/2] page_pool: Convert page_pool_recycle_stats
to u64_stats_t.
On 2025-02-22 16:13:35 [+0800], Yunsheng Lin wrote:
> > @@ -99,11 +106,19 @@ bool page_pool_get_stats(const struct page_pool *pool,
> > const struct page_pool_recycle_stats *pcpu =
> > per_cpu_ptr(pool->recycle_stats, cpu);
> >
> > - stats->recycle_stats.cached += pcpu->cached;
> > - stats->recycle_stats.cache_full += pcpu->cache_full;
> > - stats->recycle_stats.ring += pcpu->ring;
> > - stats->recycle_stats.ring_full += pcpu->ring_full;
> > - stats->recycle_stats.released_refcnt += pcpu->released_refcnt;
> > + do {
> > + start = u64_stats_fetch_begin(&pcpu->syncp);
> > + u64_stats_add(&stats->recycle_stats.cached,
> > + u64_stats_read(&pcpu->cached));
> > + u64_stats_add(&stats->recycle_stats.cache_full,
> > + u64_stats_read(&pcpu->cache_full));
> > + u64_stats_add(&stats->recycle_stats.ring,
> > + u64_stats_read(&pcpu->ring));
> > + u64_stats_add(&stats->recycle_stats.ring_full,
> > + u64_stats_read(&pcpu->ring_full));
> > + u64_stats_add(&stats->recycle_stats.released_refcnt,
> > + u64_stats_read(&pcpu->released_refcnt));
>
> It seems the above u64_stats_add() may be called more than one time
> if the below u64_stats_fetch_retry() returns true, which might mean
> the stats is added more than it is needed.
>
> It seems more correct to me that pool->alloc_stats is read into a
> local varible in the while loop and then do the addition outside
> the while loop?
indeed, indeed, what was I thinking…
>
> > + } while (u64_stats_fetch_retry(&pcpu->syncp, start));
> > }
> >
> > return true;
Sebastian
Powered by blists - more mailing lists