bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf@vger.kernel.org, "Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <kafai@fb.com>,
	"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
	"Jesper Dangaard Brouer" <brouer@redhat.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 06/10] bpf: Bump MAX_BPF_STACK size to 768 bytes
Date: Wed, 15 Sep 2021 23:27:22 +0530	[thread overview]
Message-ID: <20210915175722.viwvzg4ilpumqxid@apollo.localdomain> (raw)
In-Reply-To: <20210915163353.ysltf6edghj75koq@ast-mbp.dhcp.thefacebook.com>

On Wed, Sep 15, 2021 at 10:03:53PM IST, Alexei Starovoitov wrote:
> On Wed, Sep 15, 2021 at 10:39:39AM +0530, Kumar Kartikeya Dwivedi wrote:
> > Increase the maximum stack size accessible to BPF program to 768 bytes.
> > This is done so that gen_loader can use 94 additional fds for kfunc BTFs
> > that it passes in to fd_array from the remaining space available for the
> > loader_stack struct to expand.
> >
> > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> > ---
> >  include/linux/filter.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/filter.h b/include/linux/filter.h
> > index 4a93c12543ee..b214189ece62 100644
> > --- a/include/linux/filter.h
> > +++ b/include/linux/filter.h
> > @@ -82,8 +82,8 @@ struct ctl_table_header;
> >   */
> >  #define BPF_SYM_ELF_TYPE	't'
> >
> > -/* BPF program can access up to 512 bytes of stack space. */
> > -#define MAX_BPF_STACK	512
> > +/* BPF program can access up to 768 bytes of stack space. */
> > +#define MAX_BPF_STACK	768
>
> Yikes.
> I guess you meant as RFC, right? You didn't really propose
> to increase prog stack size just for that, right?
>

Yes, and right, it's ugly :/.

> In the later patch:
> +/* MAX_BPF_STACK is 768 bytes, so (64 + 32 + 94 (MAX_KFUNC_DESCS) + 2) * 4 */
>  #define MAX_USED_MAPS 64
>  #define MAX_USED_PROGS 32
>
> @@ -31,6 +33,8 @@ struct loader_stack {
>         __u32 btf_fd;
>         __u32 map_fd[MAX_USED_MAPS];
>         __u32 prog_fd[MAX_USED_PROGS];
> +       /* Update insn->off store when reordering kfunc_btf_fd */
> +       __u32 kfunc_btf_fd[MAX_KFUNC_DESCS];
>         __u32 inner_map_fd;
> };
>
> There are few other ways to do that.
> For example:
> A: rename map_fd[] into fds[] and store both map and btf FDs in there.
> B: move map and btf FDs into data instead of stack.

Both are great suggestions, I thought about A but not B, but it will be better
(even though it requires more changes, we can do full 256 BTF fds using B).
Thanks!

--
Kartikeya

  reply	other threads:[~2021-09-15 17:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  5:09 [PATCH bpf-next v3 00/10] Support kernel module function calls from eBPF Kumar Kartikeya Dwivedi
2021-09-15  5:09 ` [PATCH bpf-next v3 01/10] bpf: Introduce BPF support for kernel module function calls Kumar Kartikeya Dwivedi
2021-09-15  5:09 ` [PATCH bpf-next v3 02/10] bpf: Be conservative while processing invalid kfunc calls Kumar Kartikeya Dwivedi
2021-09-15  5:09 ` [PATCH bpf-next v3 03/10] bpf: btf: Introduce helpers for dynamic BTF set registration Kumar Kartikeya Dwivedi
2021-09-15 16:18   ` Alexei Starovoitov
2021-09-15 18:06     ` Kumar Kartikeya Dwivedi
2021-09-16  3:04       ` Alexei Starovoitov
2021-09-15  5:09 ` [PATCH bpf-next v3 04/10] tools: Allow specifying base BTF file in resolve_btfids Kumar Kartikeya Dwivedi
2021-09-15  5:09 ` [PATCH bpf-next v3 05/10] bpf: Enable TCP congestion control kfunc from modules Kumar Kartikeya Dwivedi
2021-09-15  5:09 ` [PATCH bpf-next v3 06/10] bpf: Bump MAX_BPF_STACK size to 768 bytes Kumar Kartikeya Dwivedi
2021-09-15 16:33   ` Alexei Starovoitov
2021-09-15 17:57     ` Kumar Kartikeya Dwivedi [this message]
2021-09-16  2:56       ` Alexei Starovoitov
2021-09-15  5:09 ` [PATCH bpf-next v3 07/10] libbpf: Support kernel module function calls Kumar Kartikeya Dwivedi
2021-09-15  5:09 ` [PATCH bpf-next v3 08/10] libbpf: Resolve invalid weak kfunc calls with imm = 0, off = 0 Kumar Kartikeya Dwivedi
2021-09-15  5:09 ` [PATCH bpf-next v3 09/10] libbpf: Update gen_loader to emit BTF_KIND_FUNC relocations Kumar Kartikeya Dwivedi
2021-09-15  5:09 ` [PATCH bpf-next v3 10/10] bpf, selftests: Add basic test for module kfunc call Kumar Kartikeya Dwivedi
2021-09-15 16:04 ` [PATCH bpf-next v3 00/10] Support kernel module function calls from eBPF Andrii Nakryiko
2021-09-15 18:03   ` Kumar Kartikeya Dwivedi
2021-09-15 18:05     ` 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=20210915175722.viwvzg4ilpumqxid@apollo.localdomain \
    --to=memxor@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=toke@redhat.com \
    --cc=yhs@fb.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).