From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Yunsheng Lin <linyunsheng@huawei.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
hawk@kernel.org, john.fastabend@gmail.com, ast@kernel.org,
daniel@iogearbox.net
Subject: Re: [PATCH v2 net-next 1/2] net: veth: add page_pool for page recycling
Date: Sun, 23 Apr 2023 16:20:46 +0200 [thread overview]
Message-ID: <ZEU+vospFdm08IeE@localhost.localdomain> (raw)
In-Reply-To: <4f008243-49d0-77aa-0e7f-d20be3a68f3c@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 2729 bytes --]
> On 2023/4/23 2:54, Lorenzo Bianconi wrote:
> > struct veth_priv {
> > @@ -727,17 +729,20 @@ static int veth_convert_skb_to_xdp_buff(struct veth_rq *rq,
> > goto drop;
> >
> > /* Allocate skb head */
> > - page = alloc_page(GFP_ATOMIC | __GFP_NOWARN);
> > + page = page_pool_dev_alloc_pages(rq->page_pool);
> > if (!page)
> > goto drop;
> >
> > nskb = build_skb(page_address(page), PAGE_SIZE);
>
> If page pool is used with PP_FLAG_PAGE_FRAG, maybe there is some additional
> improvement for the MTU 1500B case, it seem a 4K page is able to hold two skb.
> And we can reduce the memory usage too, which is a significant saving if page
> size is 64K.
please correct if I am wrong but I think the 1500B MTU case does not fit in the
half-page buffer size since we need to take into account VETH_XDP_HEADROOM.
In particular:
- VETH_BUF_SIZE = 2048
- VETH_XDP_HEADROOM = 256 + 2 = 258
- max_headsize = SKB_WITH_OVERHEAD(VETH_BUF_SIZE - VETH_XDP_HEADROOM) = 1470
Even in this case we will need the consume a full page. In fact, performances
are a little bit worse:
MTU 1500: tcp throughput ~ 8.3Gbps
Do you agree or am I missing something?
Regards,
Lorenzo
>
>
> > if (!nskb) {
> > - put_page(page);
> > + page_pool_put_full_page(rq->page_pool, page, true);
> > goto drop;
> > }
> >
> > skb_reserve(nskb, VETH_XDP_HEADROOM);
> > + skb_copy_header(nskb, skb);
> > + skb_mark_for_recycle(nskb);
> > +
> > size = min_t(u32, skb->len, max_head_size);
> > if (skb_copy_bits(skb, 0, nskb->data, size)) {
> > consume_skb(nskb);
> > @@ -745,7 +750,6 @@ static int veth_convert_skb_to_xdp_buff(struct veth_rq *rq,
> > }
> > skb_put(nskb, size);
> >
> > - skb_copy_header(nskb, skb);
> > head_off = skb_headroom(nskb) - skb_headroom(skb);
> > skb_headers_offset_update(nskb, head_off);
> >
> > @@ -754,7 +758,7 @@ static int veth_convert_skb_to_xdp_buff(struct veth_rq *rq,
> > len = skb->len - off;
> >
> > for (i = 0; i < MAX_SKB_FRAGS && off < skb->len; i++) {
> > - page = alloc_page(GFP_ATOMIC | __GFP_NOWARN);
> > + page = page_pool_dev_alloc_pages(rq->page_pool);
> > if (!page) {
> > consume_skb(nskb);
> > goto drop;
> > @@ -1002,11 +1006,37 @@ static int veth_poll(struct napi_struct *napi, int budget)
> > return done;
> > }
> >
> > +static int veth_create_page_pool(struct veth_rq *rq)
> > +{
> > + struct page_pool_params pp_params = {
> > + .order = 0,
> > + .pool_size = VETH_RING_SIZE,
>
> It seems better to allocate different poo_size according to
> the mtu, so that the best proformance is achiced using the
> least memory?
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-04-23 14:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-22 18:54 [PATCH v2 net-next 0/2] add page_pool support for page recycling in veth driver Lorenzo Bianconi
2023-04-22 18:54 ` [PATCH v2 net-next 1/2] net: veth: add page_pool for page recycling Lorenzo Bianconi
2023-04-23 12:17 ` Yunsheng Lin
2023-04-23 14:20 ` Lorenzo Bianconi [this message]
2023-04-24 2:29 ` Yunsheng Lin
2023-04-24 9:17 ` Lorenzo Bianconi
2023-04-24 11:58 ` Yunsheng Lin
2023-04-24 13:04 ` Jesper Dangaard Brouer
2023-04-24 13:06 ` Lorenzo Bianconi
2023-04-24 13:10 ` Maciej Fijalkowski
2023-04-24 13:41 ` Lorenzo Bianconi
2023-04-25 11:19 ` Yunsheng Lin
2023-04-25 14:13 ` Lorenzo Bianconi
2023-04-22 18:54 ` [PATCH v2 net-next 2/2] net: veth: add page_pool stats Lorenzo Bianconi
2023-04-25 1:10 ` [PATCH v2 net-next 0/2] add page_pool support for page recycling in veth driver 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=ZEU+vospFdm08IeE@localhost.localdomain \
--to=lorenzo.bianconi@redhat.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linyunsheng@huawei.com \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@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).