Netdev List
 help / color / mirror / Atom feed
From: Yunsheng Lin <linyunsheng@huawei.com>
To: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>, <netdev@vger.kernel.org>,
	<kuba@kernel.org>, <davem@davemloft.net>, <edumazet@google.com>,
	<pabeni@redhat.com>, <hawk@kernel.org>,
	<ilias.apalodimas@linaro.org>, <toke@redhat.com>,
	<aleksander.lobakin@intel.com>
Subject: Re: [PATCH net-next] net: page_pool: fix recycle stats for system page_pool allocator
Date: Sun, 18 Feb 2024 11:49:50 +0800	[thread overview]
Message-ID: <b9fba731-fe69-5eb6-8f9e-a477fe5cc124@huawei.com> (raw)
In-Reply-To: <ZdCR6i85oEvoxMzF@lore-desk>

On 2024/2/17 19:00, Lorenzo Bianconi wrote:
>>>  #ifdef CONFIG_PAGE_POOL_STATS
>>> -	pool->recycle_stats = alloc_percpu(struct page_pool_recycle_stats);
>>> -	if (!pool->recycle_stats)
>>> -		return -ENOMEM;
>>> +	if (!(pool->p.flags & PP_FLAG_SYSTEM_POOL)) {
>>> +		pool->recycle_stats = alloc_percpu(struct page_pool_recycle_stats);
>>> +		if (!pool->recycle_stats)
>>> +			return -ENOMEM;
>>> +	} else {
>>> +		/* For system page pool instance we use a singular stats object
>>> +		 * instead of allocating a separate percpu variable for each
>>> +		 * (also percpu) page pool instance.
>>> +		 */
>>> +		pool->recycle_stats = &pp_system_recycle_stats;
>>
>> Do we need to return -EINVAL here if page_pool_init() is called with
>> pool->p.flags & PP_FLAG_SYSTEM_POOL being true and cpuid being a valid
>> cpu?

My fault, the above "cpuid being a valid cpu" should be "cpuid not being a
valid cpu".
In other word, do we need to protect user from calling page_pool_init()
with PP_FLAG_SYSTEM_POOL flag and cpuid being -1?


>> If yes, it seems we may be able to use the cpuid to decide if we need
>> to allocate a new pool->recycle_stats without adding a new flag.
> 
> for the current use-cases cpuid is set to a valid core id just for system
> page_pool but in the future probably there will not be a 1:1 relation (e.g.
> we would want to pin a per-cpu page_pool instance to a particular CPU?)

if it is a per-cpu page_pool instance, doesn't it run into the similar
problem this patch is trying to fix?

> 
>>
>> If no, the API for page_pool_create_percpu() seems a litte weird as it
>> relies on the user calling it correctly.
>>
>> Also, do we need to enforce that page_pool_create_percpu() is only called
>> once for the same cpu? if no, we may have two page_pool instance sharing
>> the same stats.
> 
> do you mean for the same pp instance? I guess it is not allowed by the APIs.

As above comment, if the user is passing a valid cpuid, the PP_FLAG_SYSTEM_POOL
flag need to be set too? if yes, doesn't the new flag seems somewhat redundant
here?

  reply	other threads:[~2024-02-18  3:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-16  9:25 [PATCH net-next] net: page_pool: fix recycle stats for system page_pool allocator Lorenzo Bianconi
2024-02-16 10:32 ` Alexander Lobakin
2024-02-17  3:46 ` Yunsheng Lin
2024-02-17 11:00   ` Lorenzo Bianconi
2024-02-18  3:49     ` Yunsheng Lin [this message]
2024-02-19 20:50 ` patchwork-bot+netdevbpf

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=b9fba731-fe69-5eb6-8f9e-a477fe5cc124@huawei.com \
    --to=linyunsheng@huawei.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kuba@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --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