From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, davem@davemloft.net,
edumazet@google.com, pabeni@redhat.com, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
toke@redhat.com, mtahhan@redhat.com, lorenzo.bianconi@redhat.com
Subject: Re: [PATCH net-next 1/2] net: veth: add page_pool for page recycling
Date: Sat, 22 Apr 2023 20:49:58 +0200 [thread overview]
Message-ID: <ZEQsViN6HI+S6Y2O@localhost.localdomain> (raw)
In-Reply-To: <20230421202230.2fa44cca@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]
> On Thu, 20 Apr 2023 13:16:21 +0200 Lorenzo Bianconi wrote:
> > @@ -727,17 +729,21 @@ static int veth_convert_skb_to_xdp_buff(struct veth_rq *rq,
> > goto drop;
> >
> > /* Allocate skb head */
> > - page = alloc_page(GFP_ATOMIC | __GFP_NOWARN);
> > + if (rq->page_pool)
>
> There's some condition under which we can get to XDP enabled but no
> pool?
ack, since we destroy the page_pool after disabling the rq napi we can get rid
of 'if (rq->page_pool)' checks here.
>
> > + page = page_pool_dev_alloc_pages(rq->page_pool);
> > if (!page)
> > goto drop;
> >
> > nskb = build_skb(page_address(page), PAGE_SIZE);
> > if (!nskb) {
> > - put_page(page);
> > + page_pool_put_full_page(rq->page_pool, page, false);
>
> You can recycle direct, AFAIU the basic rule of thumb is that it's
> always safe to recycle direct from the context which allocates from
> the pool.
ack, I will fix it.
>
> > 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,16 +751,17 @@ 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);
> >
> > /* Allocate paged area of new skb */
> > off = size;
> > len = skb->len - off;
> > + page = NULL;
>
> Why do you clear the page pointer?
since we do not need 'if (rq->page_pool)' checks anymore we can get rid of it.
Regards,
Lorenzo
>
> --
> pw-bot: cr
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-04-22 18:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 11:16 [PATCH net-next 0/2] add page_pool support for page recycling in veth driver Lorenzo Bianconi
2023-04-20 11:16 ` [PATCH net-next 1/2] net: veth: add page_pool for page recycling Lorenzo Bianconi
2023-04-22 3:22 ` Jakub Kicinski
2023-04-22 18:49 ` Lorenzo Bianconi [this message]
2023-04-20 11:16 ` [PATCH net-next 2/2] net: veth: add page_pool stats 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=ZEQsViN6HI+S6Y2O@localhost.localdomain \
--to=lorenzo@kernel.org \
--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=lorenzo.bianconi@redhat.com \
--cc=mtahhan@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).