From: Menglong Dong <menglong8.dong@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: miguel.ojeda.sandonis@gmail.com, ojeda@kernel.org,
ndesaulniers@google.com, davem@davemloft.net,
edumazet@google.com, pabeni@redhat.com, asml.silence@gmail.com,
imagedong@tencent.com, luiz.von.dentz@intel.com,
vasily.averin@linux.dev, jk@codeconstruct.com.au,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH net-next v4] net: skb: prevent the split of kfree_skb_reason() by gcc
Date: Fri, 19 Aug 2022 23:17:04 +0800 [thread overview]
Message-ID: <CADxym3YCp3KyjOLWg_zj9scLjzN0SsyR99cTnp9b4i_pfxBxSQ@mail.gmail.com> (raw)
In-Reply-To: <20220818100946.6ad96b06@kernel.org>
On Fri, Aug 19, 2022 at 1:09 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Tue, 16 Aug 2022 11:28:46 +0800 menglong8.dong@gmail.com wrote:
> > From: Menglong Dong <imagedong@tencent.com>
> >
[...]
>
> Sorry for a late and possibly off-topic chime in, is the compiler
> splitting it because it thinks that skb_unref() is going to return
> true? I don't think that's the likely case, so maybe we're better
> off wrapping that skb_unref() in unlikely()?
I think your thought is totally right, considering the instruction
that I disassembled:
ffffffff819fea20 <kfree_skb_reason>:
ffffffff819fea20: e8 cb 2c 40 00 call
ffffffff81e016f0 <__fentry__>
ffffffff819fea25: 48 85 ff test %rdi,%rdi
ffffffff819fea28: 74 25 je
ffffffff819fea4f <kfree_skb_reason+0x2f>
ffffffff819fea2a: 8b 87 d4 00 00 00 mov 0xd4(%rdi),%eax
/* this is just the instruction that compiled from skb_unref() */
ffffffff819fea30: 83 f8 01 cmp $0x1,%eax
ffffffff819fea33: 75 0b jne
ffffffff819fea40 <kfree_skb_reason+0x20>
ffffffff819fea35: 55 push %rbp
ffffffff819fea36: 48 89 e5 mov %rsp,%rbp
ffffffff819fea39: e8 42 ff ff ff call
ffffffff819fe980 <kfree_skb_reason.part.0>
ffffffff819fea3e: 5d pop %rbp
ffffffff819fea3f: c3 ret
ffffffff819fea40: f0 ff 8f d4 00 00 00 lock decl 0xd4(%rdi)
ffffffff819fea47: 0f 88 e5 44 27 00 js
ffffffff81c72f32 <__noinstr_text_end+0x255d>
ffffffff819fea4d: 74 e6 je
ffffffff819fea35 <kfree_skb_reason+0x15>
ffffffff819fea4f: c3 ret
The compiler just splits the code after skb_unref() to another.
After I warp the skb_unref() in unlinkly(), this function is not
splitted any more.
Yeah, I think we can make skb_unref() wrapped by unlikely()
by the way.
Thanks!
Menglong Dong
prev parent reply other threads:[~2022-08-19 15:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 3:28 [PATCH net-next v4] net: skb: prevent the split of kfree_skb_reason() by gcc menglong8.dong
2022-08-16 9:02 ` Miguel Ojeda
2022-08-17 2:20 ` Menglong Dong
2022-08-17 5:54 ` Miguel Ojeda
2022-08-17 15:54 ` Nick Desaulniers
2022-08-18 16:31 ` Menglong Dong
2022-08-18 16:58 ` Segher Boessenkool
2022-08-19 14:55 ` Menglong Dong
2022-08-19 15:21 ` Segher Boessenkool
2022-08-20 11:00 ` Menglong Dong
2022-08-22 8:01 ` Florian Weimer
2022-08-23 16:23 ` Menglong Dong
2022-09-06 12:37 ` Florian Weimer
2022-09-06 15:30 ` Segher Boessenkool
2022-09-07 18:59 ` Florian Weimer
2022-09-07 19:47 ` Segher Boessenkool
2022-08-18 17:09 ` Jakub Kicinski
2022-08-19 15:17 ` Menglong Dong [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=CADxym3YCp3KyjOLWg_zj9scLjzN0SsyR99cTnp9b4i_pfxBxSQ@mail.gmail.com \
--to=menglong8.dong@gmail.com \
--cc=asml.silence@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imagedong@tencent.com \
--cc=jk@codeconstruct.com.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=luiz.von.dentz@intel.com \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=pabeni@redhat.com \
--cc=vasily.averin@linux.dev \
/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).