From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: Alexander Lobakin <alexandr.lobakin@intel.com>,
netdev@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
Kees Cook <keescook@chromium.org>
Subject: Re: [RFC PATCH 2/3] net: gro: minor optimization for dev_gro_receive()
Date: Tue, 18 Jan 2022 18:39:03 +0100 [thread overview]
Message-ID: <20220118173903.31823-1-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <c262125543e39d6b869e522da0ed59044eb07722.camel@redhat.com>
From: Paolo Abeni <pabeni@redhat.com>
Date: Tue, 18 Jan 2022 17:31:00 +0100
> On Tue, 2022-01-18 at 16:56 +0100, Alexander Lobakin wrote:
> > From: Paolo Abeni <pabeni@redhat.com>
> > Date: Tue, 18 Jan 2022 16:24:19 +0100
> >
> > > While inspecting some perf report, I noticed that the compiler
> > > emits suboptimal code for the napi CB initialization, fetching
> > > and storing multiple times the memory for flags bitfield.
> > > This is with gcc 10.3.1, but I observed the same with older compiler
> > > versions.
> > >
> > > We can help the compiler to do a nicer work e.g. initially setting
> > > all the bitfield to 0 using an u16 alias. The generated code is quite
> > > smaller, with the same number of conditional
> > >
> > > Before:
> > > objdump -t net/core/gro.o | grep " F .text"
> > > 0000000000000bb0 l F .text 0000000000000357 dev_gro_receive
> > >
> > > After:
> > > 0000000000000bb0 l F .text 000000000000033c dev_gro_receive
> > >
> > > Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> > > ---
> > > include/net/gro.h | 13 +++++++++----
> > > net/core/gro.c | 16 +++++-----------
> > > 2 files changed, 14 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/include/net/gro.h b/include/net/gro.h
> > > index 8f75802d50fd..a068b27d341f 100644
> > > --- a/include/net/gro.h
> > > +++ b/include/net/gro.h
> > > @@ -29,14 +29,17 @@ struct napi_gro_cb {
> > > /* Number of segments aggregated. */
> > > u16 count;
> > >
> > > - /* Start offset for remote checksum offload */
> > > - u16 gro_remcsum_start;
> > > + /* Used in ipv6_gro_receive() and foo-over-udp */
> > > + u16 proto;
> > >
> > > /* jiffies when first packet was created/queued */
> > > unsigned long age;
> > >
> > > - /* Used in ipv6_gro_receive() and foo-over-udp */
> > > - u16 proto;
> > > + /* portion of the cb set to zero at every gro iteration */
> > > + u32 zeroed_start[0];
> > > +
> > > + /* Start offset for remote checksum offload */
> > > + u16 gro_remcsum_start;
> > >
> > > /* This is non-zero if the packet may be of the same flow. */
> > > u8 same_flow:1;
> > > @@ -70,6 +73,8 @@ struct napi_gro_cb {
> > > /* GRO is done by frag_list pointer chaining. */
> > > u8 is_flist:1;
> > >
> > > + u32 zeroed_end[0];
> >
> > This should be wrapped in struct_group() I believe, or compilers
> > will start complaining soon. See [0] for the details.
> > Adding Kees to the CCs.
>
> Thank you for the reference. That really slipped-off my mind.
>
> This patch does not use memcpy() or similar, just a single direct
> assignement. Would that still require struct_group()?
Oof, sorry, I saw start/end and overlooked that it's only for
a single assignment.
Then it shouldn't cause warnings, but maybe use an anonymous
union instead?
union {
u32 zeroed;
struct {
u16 gro_remcsum_start;
...
};
};
__wsum csum;
Use can still use a BUILD_BUG_ON() in this case, like
sizeof(zeroed) != offsetof(csum) - offsetof(zeroed).
>
> Thanks!
>
> Paolo
Thanks,
Al
next prev parent reply other threads:[~2022-01-18 17:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-18 15:24 [RFC PATCH 0/3] gro: some minor optimizations Paolo Abeni
2022-01-18 15:24 ` [RFC PATCH 1/3] net: gro: avoid re-computing truesize twice on recycle Paolo Abeni
2022-01-18 15:24 ` [RFC PATCH 2/3] net: gro: minor optimization for dev_gro_receive() Paolo Abeni
2022-01-18 15:56 ` Alexander Lobakin
2022-01-18 16:31 ` Paolo Abeni
2022-01-18 17:39 ` Alexander Lobakin [this message]
2022-02-02 10:09 ` Paolo Abeni
2022-02-02 12:08 ` Alexander Lobakin
2022-02-07 2:53 ` Kees Cook
2022-01-18 15:24 ` [RFC PATCH 3/3] net: gro: register gso and gro offload on separate lists Paolo Abeni
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=20220118173903.31823-1-alexandr.lobakin@intel.com \
--to=alexandr.lobakin@intel.com \
--cc=edumazet@google.com \
--cc=keescook@chromium.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