public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Usama Arif <usama.arif@bytedance.com>,
	bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii.nakryiko@gmail.com, fam.zheng@bytedance.com,
	cong.wang@bytedance.com, song@kernel.org
Subject: Re: [RFC bpf-next 0/3] bpf: Introduce module helper functions
Date: Sat, 22 Jan 2022 09:34:07 +0530	[thread overview]
Message-ID: <20220122040407.p5qbax5qtuywvyf3@thp> (raw)
In-Reply-To: <20220121224813.6necsmszanxg5p5e@ast-mbp.dhcp.thefacebook.com>

On Sat, Jan 22, 2022 at 04:18:13AM IST, Alexei Starovoitov wrote:
> On Fri, Jan 21, 2022 at 07:39:53PM +0000, Usama Arif wrote:
> > This patchset is a working prototype that adds support for calling helper
> > functions in eBPF applications that have been defined in a kernel module.
> >
> > It would require further work including code refractoring (not included in
> > the patchset) to rename functions, data structures and variables that are
> > used for kfunc as well to be appropriately renamed for module helper usage.
> > If the idea of module helper functions and the approach used in this patchset
> > is acceptable to the bpf community, I can send a follow up patchset with the
> > code refractoring included to make it ready for review.
> >
> > Module helpers are useful as:
> > - They support more argument and return types when compared to module
> > kfunc.
>
> What exactly is missing?
>

I looked at the set. I think the only difference between existing support and
this series is that you are using bpf_func_proto for argument checks, right? Is
there anything else it is adding?

We discussed whether to use bpf_func_proto for kfunc in [0], the conclusion was
that BTF has enough info that we don't have to use it. The only thing missing
is making the verifier assume type of argument from kernel BTF rather than
passed in argument register.

e.g. same argument can currently work with PTR_TO_BTF_ID and PTR_TO_MEM. On
Alexei's suggestion, we disabled the bad cases by limiting PTR_TO_MEM support
to struct with scalars. For current usecase that works fine.

I think once BTF tags are supported, we will be able to tag the function
argument as __arg_mem or __arg_btf_id and make the verifier more strict.
Same can be done for the return value (instead of ret_null_set as it is now).

  [0]: https://lore.kernel.org/bpf/20211105204908.4cqxk2nbkas6bduw@ast-mbp.dhcp.thefacebook.com/

> > - This adds a way to have helper functions that would be too specialized
> > for a specific usecase to merge upstream, but are functions that can have
> > a constant API and can be maintained in-kernel modules.
>
> Could you give an example of something that would be "too specialized" that
> it's worth maintaining in a module, but not worth maintaining in the kernel?
>
> Also see:
> https://www.kernel.org/doc/html/latest/bpf/bpf_design_QA.html#q-new-functionality-via-kernel-modules
>
> Why do you think we made that rule years ago?

  reply	other threads:[~2022-01-22  4:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21 19:39 [RFC bpf-next 0/3] bpf: Introduce module helper functions Usama Arif
2022-01-21 19:39 ` [RFC bpf-next 1/3] bpf: btf: Introduce infrastructure for module helpers Usama Arif
2022-01-22  3:23   ` Kumar Kartikeya Dwivedi
2022-01-21 19:39 ` [RFC bpf-next 2/3] bpf: add support for module helpers in verifier Usama Arif
2022-01-22  3:31   ` Kumar Kartikeya Dwivedi
2022-01-22  3:56     ` Kumar Kartikeya Dwivedi
2022-01-24 16:23       ` Usama Arif
2022-01-21 19:39 ` [RFC bpf-next 3/3] selftests/bpf: add test for module helper Usama Arif
2022-01-21 22:48 ` [RFC bpf-next 0/3] bpf: Introduce module helper functions Alexei Starovoitov
2022-01-22  4:04   ` Kumar Kartikeya Dwivedi [this message]
2022-01-24 16:33     ` [External] " Usama Arif

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=20220122040407.p5qbax5qtuywvyf3@thp \
    --to=memxor@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=cong.wang@bytedance.com \
    --cc=daniel@iogearbox.net \
    --cc=fam.zheng@bytedance.com \
    --cc=song@kernel.org \
    --cc=usama.arif@bytedance.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