From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Network Development <netdev@vger.kernel.org>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH v9 bpf-next 3/5] bpf: Add skb dynptrs
Date: Wed, 8 Feb 2023 15:22:50 -0800 [thread overview]
Message-ID: <CAADnVQJYOR7YMEFV7c1e4p8hvrEmoa3VA2wp0oJSgmuAjSF+EA@mail.gmail.com> (raw)
In-Reply-To: <CAJnrk1bxm3_QQFK_aqiApiu5vYC+z++jRj9HF2jO6a+WWkswpQ@mail.gmail.com>
On Wed, Feb 8, 2023 at 1:47 PM Joanne Koong <joannelkoong@gmail.com> wrote:
>
> On Tue, Jan 31, 2023 at 9:54 AM Joanne Koong <joannelkoong@gmail.com> wrote:
> >
> > On Mon, Jan 30, 2023 at 9:36 PM Alexei Starovoitov
> > <alexei.starovoitov@gmail.com> wrote:
> > >
> > > On Mon, Jan 30, 2023 at 04:44:12PM -0800, Joanne Koong wrote:
> > > > On Sun, Jan 29, 2023 at 3:39 PM Alexei Starovoitov
> > > > <alexei.starovoitov@gmail.com> wrote:
> > > > >
> > > > > On Fri, Jan 27, 2023 at 11:17:01AM -0800, Joanne Koong wrote:
> [...]
> > > > > > diff --git a/net/core/filter.c b/net/core/filter.c
> > > > > > index 6da78b3d381e..ddb47126071a 100644
> > > > > > --- a/net/core/filter.c
> > > > > > +++ b/net/core/filter.c
> > > > > > @@ -1684,8 +1684,8 @@ static inline void bpf_pull_mac_rcsum(struct sk_buff *skb)
> > > > > > skb_postpull_rcsum(skb, skb_mac_header(skb), skb->mac_len);
> > > > > > }
> > > > > >
> > > > > > -BPF_CALL_5(bpf_skb_store_bytes, struct sk_buff *, skb, u32, offset,
> > > > > > - const void *, from, u32, len, u64, flags)
> > > > > > +int __bpf_skb_store_bytes(struct sk_buff *skb, u32 offset, const void *from,
> > > > > > + u32 len, u64 flags)
> > > > >
> > > > > This change is just to be able to call __bpf_skb_store_bytes() ?
> > > > > If so, it's unnecessary.
> > > > > See:
> > > > > BPF_CALL_4(sk_reuseport_load_bytes,
> > > > > const struct sk_reuseport_kern *, reuse_kern, u32, offset,
> > > > > void *, to, u32, len)
> > > > > {
> > > > > return ____bpf_skb_load_bytes(reuse_kern->skb, offset, to, len);
> > > > > }
> > > > >
> > > >
> > > > There was prior feedback [0] that using four underscores to call a
> > > > helper function is confusing and makes it ungreppable
> > >
> > > There are plenty of ungreppable funcs in the kernel.
> > > Try finding where folio_test_dirty() is defined.
> > > mm subsystem is full of such 'features'.
> > > Not friendly for casual kernel code reader, but useful.
> > >
> > > Since quadruple underscore is already used in the code base
> > > I see no reason to sacrifice bpf_skb_load_bytes performance with extra call.
> >
> > I don't have a preference either way, I'll change it to use the
> > quadruple underscore in the next version
>
> I think we still need these extra __bpf_skb_store/load_bytes()
> functions, because BPF_CALL_x static inlines the
> bpf_skb_store/load_bytes helpers in net/core/filter.c, and we need to
> call these bpf_skb_store/load_bytes helpers from another file
> (kernel/bpf/helpers.c). I think the only other alternative is moving
> the BPF_CALL_x declaration of bpf_skb_store/load bytes to
> include/linux/filter.h, but I think having the extra
> __bpf_skb_store/load_bytes() is cleaner.
bpf_skb_load_bytes() is a performance critical function.
I'm worried about the cost of the extra call.
Will compiler be smart enough to inline __bpf_skb_load_bytes()
in both cases? Probably not if they're in different .c files.
Not sure how to solve it. Make it a static inline in skbuff.h ?
next prev parent reply other threads:[~2023-02-08 23:23 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 19:16 [PATCH v9 bpf-next 0/5] Add skb + xdp dynptrs Joanne Koong
2023-01-27 19:16 ` [PATCH v9 bpf-next 1/5] bpf: Allow "sk_buff" and "xdp_buff" as valid kfunc arg types Joanne Koong
2023-01-27 19:17 ` [PATCH v9 bpf-next 2/5] bpf: Allow initializing dynptrs in kfuncs Joanne Koong
2023-01-27 19:17 ` [PATCH v9 bpf-next 3/5] bpf: Add skb dynptrs Joanne Koong
2023-01-29 23:39 ` Alexei Starovoitov
2023-01-31 0:44 ` Joanne Koong
2023-01-31 5:36 ` Alexei Starovoitov
2023-01-31 17:54 ` Joanne Koong
2023-01-31 19:50 ` Alexei Starovoitov
2023-01-31 21:29 ` Joanne Koong
2023-02-08 21:46 ` Joanne Koong
2023-02-08 23:22 ` Alexei Starovoitov [this message]
2023-01-30 22:04 ` Martin KaFai Lau
2023-01-30 22:31 ` Alexei Starovoitov
2023-01-30 23:11 ` Martin KaFai Lau
2023-01-31 1:04 ` Andrii Nakryiko
2023-01-31 1:49 ` Martin KaFai Lau
2023-01-31 4:43 ` Andrii Nakryiko
2023-01-31 5:30 ` Alexei Starovoitov
2023-01-31 22:07 ` Martin KaFai Lau
2023-01-31 23:17 ` Joanne Koong
2023-02-01 0:46 ` Alexei Starovoitov
2023-02-01 0:11 ` Andrii Nakryiko
2023-02-01 0:40 ` Alexei Starovoitov
2023-02-02 1:21 ` Andrii Nakryiko
2023-02-02 11:43 ` Alexei Starovoitov
2023-02-03 21:37 ` Andrii Nakryiko
2023-02-08 2:25 ` Alexei Starovoitov
2023-02-08 20:13 ` Joanne Koong
2023-02-09 0:39 ` Andrii Nakryiko
2023-01-31 18:30 ` Joanne Koong
2023-01-31 19:58 ` Alexei Starovoitov
2023-01-31 20:47 ` Joanne Koong
2023-01-31 21:10 ` Alexei Starovoitov
2023-01-31 21:33 ` Joanne Koong
2023-01-31 18:18 ` Joanne Koong
2023-01-31 0:48 ` Andrii Nakryiko
2023-01-31 0:55 ` Joanne Koong
2023-01-31 1:06 ` Andrii Nakryiko
2023-01-31 1:13 ` Joanne Koong
2023-01-31 1:19 ` Andrii Nakryiko
2023-01-27 19:17 ` [PATCH v9 bpf-next 4/5] bpf: Add xdp dynptrs Joanne Koong
2023-01-27 19:17 ` [PATCH v9 bpf-next 5/5] selftests/bpf: tests for using dynptrs to parse skb and xdp buffers Joanne Koong
2023-01-31 0:49 ` Andrii Nakryiko
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=CAADnVQJYOR7YMEFV7c1e4p8hvrEmoa3VA2wp0oJSgmuAjSF+EA@mail.gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=joannelkoong@gmail.com \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
/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).