netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <hawk@kernel.org>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Lorenzo Bianconi" <lorenzo.bianconi@redhat.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>,
	netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	edumazet@google.com, pabeni@redhat.com, bpf@vger.kernel.org,
	willemdebruijn.kernel@gmail.com, jasowang@redhat.com,
	sdf@google.com, ilias.apalodimas@linaro.org,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: [PATCH v6 net-next 1/5] net: add generic per-cpu page_pool allocator
Date: Wed, 31 Jan 2024 13:51:28 +0100	[thread overview]
Message-ID: <32f93a3e-5c4f-4f32-8158-4755f08b5ed4@kernel.org> (raw)
In-Reply-To: <87bk9416vq.fsf@toke.dk>



On 29/01/2024 16.44, Toke Høiland-Jørgensen wrote:
> Lorenzo Bianconi <lorenzo.bianconi@redhat.com> writes:
> 
>>> Lorenzo Bianconi <lorenzo@kernel.org> writes:
>>>
>>>> Introduce generic percpu page_pools allocator.
>>>> Moreover add page_pool_create_percpu() and cpuid filed in page_pool struct
>>>> in order to recycle the page in the page_pool "hot" cache if
>>>> napi_pp_put_page() is running on the same cpu.
>>>> This is a preliminary patch to add xdp multi-buff support for xdp running
>>>> in generic mode.
>>>>
>>>> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>>>> ---
>>>>   include/net/page_pool/types.h |  3 +++
>>>>   net/core/dev.c                | 40 +++++++++++++++++++++++++++++++++++
>>>>   net/core/page_pool.c          | 23 ++++++++++++++++----
>>>>   net/core/skbuff.c             |  5 +++--
>>>>   4 files changed, 65 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h
>>>> index 76481c465375..3828396ae60c 100644
>>>> --- a/include/net/page_pool/types.h
>>>> +++ b/include/net/page_pool/types.h
>>>> @@ -128,6 +128,7 @@ struct page_pool_stats {
>>>>   struct page_pool {
>>>>   	struct page_pool_params_fast p;
>>>>   
>>>> +	int cpuid;
>>>>   	bool has_init_callback;
>>>>   
>>>>   	long frag_users;
>>>> @@ -203,6 +204,8 @@ struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp);
>>>>   struct page *page_pool_alloc_frag(struct page_pool *pool, unsigned int *offset,
>>>>   				  unsigned int size, gfp_t gfp);
>>>>   struct page_pool *page_pool_create(const struct page_pool_params *params);
>>>> +struct page_pool *page_pool_create_percpu(const struct page_pool_params *params,
>>>> +					  int cpuid);
>>>>   
>>>>   struct xdp_mem_info;
>>>>   
>>>> diff --git a/net/core/dev.c b/net/core/dev.c
>>>> index cb2dab0feee0..bf9ec740b09a 100644
>>>> --- a/net/core/dev.c
>>>> +++ b/net/core/dev.c
>>>> @@ -153,6 +153,8 @@
>>>>   #include <linux/prandom.h>
>>>>   #include <linux/once_lite.h>
>>>>   #include <net/netdev_rx_queue.h>
>>>> +#include <net/page_pool/types.h>
>>>> +#include <net/page_pool/helpers.h>
>>>>   
>>>>   #include "dev.h"
>>>>   #include "net-sysfs.h"
>>>> @@ -442,6 +444,8 @@ static RAW_NOTIFIER_HEAD(netdev_chain);
>>>>   DEFINE_PER_CPU_ALIGNED(struct softnet_data, softnet_data);
>>>>   EXPORT_PER_CPU_SYMBOL(softnet_data);
>>>>   
>>>> +DEFINE_PER_CPU_ALIGNED(struct page_pool *, page_pool);
>>>
>>> I think we should come up with a better name than just "page_pool" for
>>> this global var. In the code below it looks like it's a local variable
>>> that's being referenced. Maybe "global_page_pool" or "system_page_pool"
>>> or something along those lines?
>>
>> ack, I will fix it. system_page_pool seems better, agree?
> 
> Yeah, agreed :)

Naming it "system_page_pool" is good by me.

Should we add some comments about concurrency expectations when using this?
Or is this implied by "PER_CPU" define?

PP alloc side have a lockless array/stack, and the per_cpu stuff do
already imply only one CPU is accessing this, and implicitly (also) we
cannot handle reentrance cause by preemption.  So, the caller have the
responsibility to call this from appropriate context.

--Jesper

  reply	other threads:[~2024-01-31 12:51 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-28 14:20 [PATCH v6 net-next 0/5] add multi-buff support for xdp running in generic mode Lorenzo Bianconi
2024-01-28 14:20 ` [PATCH v6 net-next 1/5] net: add generic per-cpu page_pool allocator Lorenzo Bianconi
2024-01-29  6:37   ` kernel test robot
2024-01-29 12:05   ` Yunsheng Lin
2024-01-29 13:04     ` Lorenzo Bianconi
2024-01-30 11:02       ` Yunsheng Lin
2024-01-30 14:26         ` Lorenzo Bianconi
2024-02-01 11:49           ` Lorenzo Bianconi
2024-02-01 12:14             ` Yunsheng Lin
2024-01-29 12:45   ` Toke Høiland-Jørgensen
2024-01-29 12:52     ` Lorenzo Bianconi
2024-01-29 15:44       ` Toke Høiland-Jørgensen
2024-01-31 12:51         ` Jesper Dangaard Brouer [this message]
2024-01-31 12:28   ` Jesper Dangaard Brouer
2024-01-31 13:36     ` Lorenzo Bianconi
2024-01-28 14:20 ` [PATCH v6 net-next 2/5] xdp: rely on skb pointer reference in do_xdp_generic and netif_receive_generic_xdp Lorenzo Bianconi
2024-01-29  8:05   ` Ilias Apalodimas
2024-01-29  9:58     ` Lorenzo Bianconi
2024-01-28 14:20 ` [PATCH v6 net-next 3/5] xdp: add multi-buff support for xdp running in generic mode Lorenzo Bianconi
2024-01-31 23:47   ` Jakub Kicinski
2024-02-01 11:34     ` Lorenzo Bianconi
2024-02-01 15:15       ` Jakub Kicinski
2024-02-01 16:41         ` Lorenzo Bianconi
2024-01-28 14:20 ` [PATCH v6 net-next 4/5] net: page_pool: make stats available just for global pools Lorenzo Bianconi
2024-01-29 12:06   ` Yunsheng Lin
2024-01-29 13:07     ` Lorenzo Bianconi
2024-01-30 11:23       ` Yunsheng Lin
2024-01-30 13:52         ` Lorenzo Bianconi
2024-01-30 15:11           ` Jesper Dangaard Brouer
2024-01-30 16:01             ` Lorenzo Bianconi
2024-01-31 15:32               ` Toke Høiland-Jørgensen
2024-01-31 23:52                 ` Jakub Kicinski
2024-02-01 10:54                   ` Lorenzo Bianconi
2024-01-28 14:20 ` [PATCH v6 net-next 5/5] veth: rely on netif_skb_segment_for_xdp utility routine Lorenzo Bianconi
2024-01-29 12:43 ` [PATCH v6 net-next 0/5] add multi-buff support for xdp running in generic mode Toke Høiland-Jørgensen
2024-01-29 13:05   ` 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=32f93a3e-5c4f-4f32-8158-4755f08b5ed4@kernel.org \
    --to=hawk@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@google.com \
    --cc=toke@redhat.com \
    --cc=willemdebruijn.kernel@gmail.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).