netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: netdev@vger.kernel.org, lorenzo.bianconi@redhat.com,
	kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, hawk@kernel.org, ilias.apalodimas@linaro.org,
	linyunsheng@huawei.com
Subject: Re: [RFC net-next] net: page_pool: fix recycle stats for percpu page_pool allocator
Date: Wed, 14 Feb 2024 23:46:05 +0100	[thread overview]
Message-ID: <Zc1CrXyLYRR2w9RX@lore-desk> (raw)
In-Reply-To: <871q9een8q.fsf@toke.dk>

[-- Attachment #1: Type: text/plain, Size: 2098 bytes --]

> Lorenzo Bianconi <lorenzo@kernel.org> writes:
> 
> > Use global page_pool_recycle_stats percpu counter for percpu page_pool
> > allocator.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.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@redhat.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?

ack, I agree.

> 
> >  /* 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
> 

sure, I will add it.

Regards,
Lorenzo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2024-02-14 22:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 18:08 [RFC net-next] net: page_pool: fix recycle stats for percpu page_pool allocator Lorenzo Bianconi
2024-02-14 21:42 ` Toke Høiland-Jørgensen
2024-02-14 22:46   ` Lorenzo Bianconi [this message]
2024-02-15 13:41 ` Alexander Lobakin
2024-02-15 13:51   ` Lorenzo Bianconi
2024-02-15 15:04   ` Jakub Kicinski
2024-02-15 15:31     ` Lorenzo Bianconi

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=Zc1CrXyLYRR2w9RX@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linyunsheng@huawei.com \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=toke@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).