Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Yunsheng Lin <linyunsheng@huawei.com>
Cc: linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Eric Dumazet <edumazet@google.com>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	Leon Romanovsky <leon@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Simon Horman <horms@kernel.org>, Tariq Toukan <tariqt@nvidia.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH net-next 1/2] page_pool: Convert page_pool_recycle_stats to u64_stats_t.
Date: Wed, 26 Feb 2025 10:28:57 +0100	[thread overview]
Message-ID: <20250226092857.La2UyrrB@linutronix.de> (raw)
In-Reply-To: <307939b7-8f51-437a-b5b2-ac5342630504@huawei.com>

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

  parent reply	other threads:[~2025-02-26  9:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-21 11:52 [PATCH net-next 0/2] page_pool: Convert stats to u64_stats_t Sebastian Andrzej Siewior
2025-02-21 11:52 ` [PATCH net-next 1/2] page_pool: Convert page_pool_recycle_stats " Sebastian Andrzej Siewior
2025-02-21 17:21   ` Joe Damato
2025-02-26 12:06     ` Sebastian Andrzej Siewior
2025-02-22  8:13   ` Yunsheng Lin
2025-02-25 11:27     ` Paolo Abeni
2025-02-26  9:28     ` Sebastian Andrzej Siewior [this message]
2025-02-21 11:52 ` [PATCH net-next 2/2] page_pool: Convert page_pool_alloc_stats " Sebastian Andrzej Siewior
2025-02-21 17:30   ` Joe Damato
2025-02-22  8:13   ` Yunsheng Lin
2025-02-21 17:10 ` [PATCH net-next 0/2] page_pool: Convert stats " Joe Damato
2025-02-26 10:27   ` Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250226092857.La2UyrrB@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linyunsheng@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox