netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, netdev <netdev@vger.kernel.org>,
	Alexander Duyck <alexanderduyck@fb.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Greg Thelen <gthelen@google.com>
Subject: Re: [PATCH net] net: avoid 32 x truesize under-estimation for tiny skbs
Date: Thu, 8 Sep 2022 09:00:48 -0700	[thread overview]
Message-ID: <CANn89iL7iHOvkCYG1iGDpHkx1vg1KeDqh_FtrPa5mvxeo3JJtw@mail.gmail.com> (raw)
In-Reply-To: <0ad4ba2bc157a2d1fa8a898056bea431fc244122.camel@redhat.com>

On Thu, Sep 8, 2022 at 7:26 AM Paolo Abeni <pabeni@redhat.com> wrote:
>
> On Thu, 2022-09-08 at 05:20 -0700, Eric Dumazet wrote:
> > On Thu, Sep 8, 2022 at 3:48 AM Paolo Abeni <pabeni@redhat.com> wrote:
> > > On Wed, 2022-09-07 at 13:40 -0700, Eric Dumazet wrote:
> > > > On 9/7/22 13:19, Paolo Abeni wrote:
> > > > > reviving an old thread...
> > > > > On Wed, 2021-01-13 at 08:18 -0800, Eric Dumazet wrote:
> > > > > > While using page fragments instead of a kmalloc backed skb->head might give
> > > > > > a small performance improvement in some cases, there is a huge risk of
> > > > > > under estimating memory usage.
> > > > > [...]
> > > > >
> > > > > > Note that we might in the future use the sk_buff napi cache,
> > > > > > instead of going through a more expensive __alloc_skb()
> > > > > >
> > > > > > Another idea would be to use separate page sizes depending
> > > > > > on the allocated length (to never have more than 4 frags per page)
> > > > > I'm investigating a couple of performance regressions pointing to this
> > > > > change and I'd like to have a try to the 2nd suggestion above.
> > > > >
> > > > > If I read correctly, it means:
> > > > > - extend the page_frag_cache alloc API to allow forcing max order==0
> > > > > - add a 2nd page_frag_cache into napi_alloc_cache (say page_order0 or
> > > > > page_small)
> > > > > - in __napi_alloc_skb(), when len <= SKB_WITH_OVERHEAD(1024), use the
> > > > > page_small cache with order 0 allocation.
> > > > > (all the above constrained to host with 4K pages)
> > > > >
> > > > > I'm not quite sure about the "never have more than 4 frags per page"
> > > > > part.
> > > > >
> > > > > What outlined above will allow for 10 min size frags in page_order0, as
> > > > > (SKB_DATA_ALIGN(0) + SKB_DATA_ALIGN(struct skb_shared_info) == 384. I'm
> > > > > not sure that anything will allocate such small frags.
> > > > > With a more reasonable GRO_MAX_HEAD, there will be 6 frags per page.
> > > >
> > > > Well, some arches have PAGE_SIZE=65536 :/
> > >
> > > Yes, the idea is to implement all the above only for arches with
> > > PAGE_SIZE==4K. Would that be reasonable?
> >
> > Well, we also have changed MAX_SKB_FRAGS from 17 to 45 for BIG TCP.
> >
> > And locally we have
> >
> > #define GRO_MAX_HEAD 192
>
> default allocation size for napi_get_frags() is ~960b in google kernel,
> right? It looks like it should fit the above quite nicely with 4 frags
> per page?!?
>

Yes, using order-0 pages on x86 would avoid problems.
But if this adds yet another tests in fast path, increasing icache
pressure, I am unsure.
So I will comment when I see actual code/implementation.

("Extending" page_frag_cache alloc API seems overkill to me. Just use
separate code maybe ?)

> Vanilla kernel may hit a larger number of fragments per page, even if
> very likely not as high as the theoretical maximum mentioned in my
> previous email (as noted by Alex).
>
> If in that case excessive truesize underestimation would still be
> problematic (with a order0 4k page) __napi_alloc_skb() could be patched
> to increase smaller sizes to some reasonable minimum.
>
> Likely there is some point in your reply I did not get. Luckily LPC is
> coming :)
>
> > Reference:
> >
> > commit fd9ea57f4e9514f9d0f0dec505eefd99a8faa148
> > Author: Eric Dumazet <edumazet@google.com>
> > Date:   Wed Jun 8 09:04:38 2022 -0700
> >
> >     net: add napi_get_frags_check() helper
>
> I guess such check should be revisited with all the above.
>
> Thanks,
>
> Paolo
>

  reply	other threads:[~2022-09-08 16:01 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13 16:18 [PATCH net] net: avoid 32 x truesize under-estimation for tiny skbs Eric Dumazet
2021-01-13 18:00 ` Alexander Duyck
2021-01-13 19:19 ` Michael S. Tsirkin
2021-01-13 22:23 ` David Laight
2021-01-14  5:16   ` Eric Dumazet
2021-01-14  9:29     ` David Laight
2021-01-14 19:00 ` patchwork-bot+netdevbpf
     [not found] ` <1617007696.5731978-1-xuanzhuo@linux.alibaba.com>
2021-03-29  9:06   ` Eric Dumazet
2021-03-31  8:11     ` Michael S. Tsirkin
2021-03-31  8:36       ` Eric Dumazet
2021-03-31  8:46         ` Eric Dumazet
2021-03-31  8:49           ` Eric Dumazet
2021-03-31  8:54             ` Eric Dumazet
     [not found]               ` <1617248264.4993114-2-xuanzhuo@linux.alibaba.com>
2021-04-01  5:06                 ` Eric Dumazet
     [not found]                   ` <1617357110.3822439-1-xuanzhuo@linux.alibaba.com>
2021-04-02 12:52                     ` Eric Dumazet
2021-04-01 13:51         ` Michael S. Tsirkin
2021-04-01 14:08           ` Eric Dumazet
2021-04-01  7:14       ` Jason Wang
     [not found]         ` <1617267183.5697193-1-xuanzhuo@linux.alibaba.com>
2021-04-01  9:58           ` Eric Dumazet
2021-04-02  2:52             ` Jason Wang
     [not found]               ` <1617361253.1788838-2-xuanzhuo@linux.alibaba.com>
2021-04-02 12:53                 ` Eric Dumazet
2021-04-06  2:04                 ` Jason Wang
     [not found]       ` <1617190239.1035674-1-xuanzhuo@linux.alibaba.com>
2021-03-31 12:08         ` Eric Dumazet
2021-04-01 13:36         ` Michael S. Tsirkin
2022-09-07 20:19 ` Paolo Abeni
2022-09-07 20:40   ` Eric Dumazet
2022-09-08 10:48     ` Paolo Abeni
2022-09-08 12:20       ` Eric Dumazet
2022-09-08 14:26         ` Paolo Abeni
2022-09-08 16:00           ` Eric Dumazet [this message]
2022-09-07 21:36   ` Alexander H Duyck
2022-09-08 11:00     ` Paolo Abeni
2022-09-08 14:53       ` Alexander H Duyck
2022-09-08 18:01         ` Paolo Abeni
2022-09-08 19:26           ` Alexander Duyck

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=CANn89iL7iHOvkCYG1iGDpHkx1vg1KeDqh_FtrPa5mvxeo3JJtw@mail.gmail.com \
    --to=edumazet@google.com \
    --cc=alexanderduyck@fb.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=gthelen@google.com \
    --cc=kuba@kernel.org \
    --cc=mst@redhat.com \
    --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).