From: Tyler Stachecki <stachecki.tyler@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: edward.cree@amd.com, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, Edward Cree <ecree.xilinx@gmail.com>,
netdev@vger.kernel.org, Martin Habets <habetsm.xilinx@gmail.com>
Subject: Re: [RFC PATCH net] net-gro: restore check for NULL skb in napi_gro_frags
Date: Fri, 4 Aug 2023 12:32:19 -0400 [thread overview]
Message-ID: <ZM0oE98EpPgAilda@luigi.stachecki.net> (raw)
In-Reply-To: <CANn89i+VYvOrXPFNgqKjTJ+EeMUngXrVzoppynkn2HBnYAdqEQ@mail.gmail.com>
On Fri, Aug 04, 2023 at 04:45:13PM +0200, Eric Dumazet wrote:
> This is already done, a compiler should already infer this from this code:
>
> if (unlikely(skb_gro_header_hard(skb, hlen))) {
> eth = skb_gro_header_slow(skb, hlen, 0);
> if (unlikely(!eth)) {
> net_warn_ratelimited("%s: dropping impossible skb from %s\n",
> __func__, napi->dev->name);
> napi_reuse_skb(napi, skb);
> return NULL;
> }
It is a good point - though, FWIW, at least with clang-16 I am observing that
it does not leverage this fact (fully?). Mostly for my own curiosity, I took a
look...
In both cases, the generated code for the NULL check is emitted as a a forward
branch, meaning that (at least on x86), the branch direction hint is rendered
as desired.
However, without unlikely(...), the code for the taken branch is clumped
roughly after the inlined code for napi_frags_finish and before the (hot paths
of) napi_frags_skb.
With unlikely added, the code for the taken NULL check is seated right next to
the code generated for the unlikely paths in your comment. So, it does seem to
have an effect, however minor!
---
Anyways: perhaps the more important note here is that, at least with clang-16,
I can confirm that everything is still inlined with this change.
prev parent reply other threads:[~2023-08-04 16:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 9:23 [RFC PATCH net] net-gro: restore check for NULL skb in napi_gro_frags edward.cree
2023-08-02 10:22 ` Eric Dumazet
2023-08-16 17:46 ` Edward Cree
2023-08-16 17:59 ` Eric Dumazet
2023-08-04 14:36 ` Tyler Stachecki
2023-08-04 14:45 ` Eric Dumazet
2023-08-04 16:32 ` Tyler Stachecki [this message]
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=ZM0oE98EpPgAilda@luigi.stachecki.net \
--to=stachecki.tyler@gmail.com \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=edward.cree@amd.com \
--cc=habetsm.xilinx@gmail.com \
--cc=kuba@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).