From: John Fastabend <john.fastabend@gmail.com>
To: Yonghong Song <yhs@fb.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
John Fastabend <john.fastabend@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Jiri Olsa <jolsa@redhat.com>, Andrii Nakryiko <andriin@fb.com>,
Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Jakub Kicinski <kuba@kernel.org>,
David Miller <davem@redhat.com>,
Jesper Dangaard Brouer <hawk@kernel.org>,
KP Singh <kpsingh@chromium.org>,
Masanori Misono <m.misono760@gmail.com>
Subject: Re: [PATCH] bpf: Allow small structs to be type of function argument
Date: Fri, 19 Jun 2020 10:44:43 -0700 [thread overview]
Message-ID: <5eecf98ba643c_137b2ad09f64a5c458@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <4aec5fb8-9f9d-d01b-dd58-f15d50c5e827@fb.com>
Yonghong Song wrote:
>
>
> On 6/18/20 7:04 PM, Alexei Starovoitov wrote:
> > On Thu, Jun 18, 2020 at 5:26 PM John Fastabend <john.fastabend@gmail.com> wrote:
> >>
> >> foo(int a, __int128 b)
> >>
> >> would put a in r0 and b in r2 and r3 leaving a hole in r1. But that
> >> was some old reference manual and might no longer be the case
>
> This should not happen if clang compilation with -target bpf.
> This MAY happen if they compile with 'clang -target riscv' as the IR
> could change before coming to bpf backend.
I guess this means in order to handle __int128 and structs in
btf_ctx_access we would have to know this did not happen. Otherwise
the arg to type mappings are off because we simply do
arg = off / 8
>
> >> in reality. Perhaps just spreading hearsay, but the point is we
> >> should say something about what the BPF backend convention
> >> is and write it down. We've started to bump into these things
> >> lately.
> >
> > calling convention for int128 in bpf is _undefined_.
> > calling convention for struct by value in bpf is also _undefined_.
>
> Just to clarify a little bit. bpf backend did not do anything
> special about int128 and struct type. It is using llvm default.
> That is, int128 using two argument registers and struct passed
> by address. But I do see some other architectures having their
> own ways to handle these parameters like X86, AARCH64, AMDGPU, MIPS.
>
> int128 is not widely used. passing struct as the argument is not
> a good practice. So Agree with Alexei is not really worthwhile to
> handle them in the place of arguments.
Agree as well I'll just add a small fix to check btf_type_is_int()
size is <= u64 and that should be sufficient to skip handling the
int128 case.
>
> >
> > In many cases the compiler has to have the backend code
> > so other parts of the compiler can function.
> > I didn't bother explicitly disabling every undefined case.
> > Please don't read too much into llvm generated code.
> >
next prev parent reply other threads:[~2020-06-19 17:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-16 17:35 [PATCH] bpf: Allow small structs to be type of function argument Jiri Olsa
2020-06-17 23:20 ` John Fastabend
2020-06-18 11:48 ` Jiri Olsa
2020-06-18 22:05 ` Alexei Starovoitov
2020-06-19 8:50 ` Jiri Olsa
2020-06-18 22:06 ` John Fastabend
2020-06-18 23:59 ` Andrii Nakryiko
2020-06-19 0:25 ` John Fastabend
2020-06-19 2:04 ` Alexei Starovoitov
2020-06-19 5:39 ` Yonghong Song
2020-06-19 17:44 ` John Fastabend [this message]
2020-06-19 18:56 ` Yonghong Song
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=5eecf98ba643c_137b2ad09f64a5c458@john-XPS-13-9370.notmuch \
--to=john.fastabend@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@redhat.com \
--cc=hawk@kernel.org \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=kuba@kernel.org \
--cc=m.misono760@gmail.com \
--cc=netdev@vger.kernel.org \
--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