linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: Yonghong Song <yhs@fb.com>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>, Martin Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>,
	john fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Quentin Monnet <quentin@isovalent.com>,
	open list <linux-kernel@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Shuah Khan <shuah@kernel.org>, Lorenz Bauer <lmb@cloudflare.com>,
	"open list:KERNEL SELFTEST FRAMEWORK" 
	<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH v2 bpf-next 0/3] bpf: support module BTF in BTF display helpers
Date: Mon, 7 Dec 2020 19:42:19 -0800	[thread overview]
Message-ID: <CAEf4BzYmDZVnHRYFJk+J90s-GKUt_Sa2HPNs6mKxyZ8Bm6TN3w@mail.gmail.com> (raw)
In-Reply-To: <alpine.LRH.2.23.451.2012060038260.1505@localhost>

On Sat, Dec 5, 2020 at 4:44 PM Alan Maguire <alan.maguire@oracle.com> wrote:
>
>
> On Sat, 5 Dec 2020, Yonghong Song wrote:
>
> >
> >
> > __builtin_btf_type_id() is really only supported in llvm12
> > and 64bit return value support is pushed to llvm12 trunk
> > a while back. The builtin is introduced in llvm11 but has a
> > corner bug, so llvm12 is recommended. So if people use the builtin,
> > you can assume 64bit return value. libbpf support is required
> > here. So in my opinion, there is no need to do feature detection.
> >
> > Andrii has a patch to support 64bit return value for
> > __builtin_btf_type_id() and I assume that one should
> > be landed before or together with your patch.
> >
> > Just for your info. The following is an example you could
> > use to determine whether __builtin_btf_type_id()
> > supports btf object id at llvm level.
> >
> > -bash-4.4$ cat t.c
> > int test(int arg) {
> >   return __builtin_btf_type_id(arg, 1);
> > }
> >
> > Compile to generate assembly code with latest llvm12 trunk:
> >   clang -target bpf -O2 -S -g -mcpu=v3 t.c
> > In the asm code, you should see one line with
> >   r0 = 1 ll
> >
> > Or you can generate obj code:
> >   clang -target bpf -O2 -c -g -mcpu=v3 t.c
> > and then you disassemble the obj file
> >   llvm-objdump -d --no-show-raw-insn --no-leading-addr t.o
> > You should see below in the output
> >   r0 = 1 ll
> >
> > Use earlier version of llvm12 trunk, the builtin has
> > 32bit return value, you will see
> >   r0 = 1
> > which is a 32bit imm to r0, while "r0 = 1 ll" is
> > 64bit imm to r0.
> >
>
> Thanks for this Yonghong!  I'm thinking the way I'll tackle it
> is to simply verify that the upper 32 bits specifying the
> veth module object id are non-zero; if they are zero, we'll skip

Let's instead of the real veth module use selftests's bpf_testmod,
which I added specifically to use for tests like these. We can define
whatever types we need in there.

> the test (I think a skip probably makes sense as not everyone will
> have llvm12). Does that seem reasonable?
>
> With the additional few minor changes on top of Andrii's patch,
> the use of __builtin_btf_type_id() worked perfectly. Thanks!
>
> Alan

      parent reply	other threads:[~2020-12-08  3:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-04 18:48 Alan Maguire
2020-12-04 18:48 ` [PATCH v2 bpf-next 1/3] bpf: eliminate btf_module_mutex as RCU synchronization can be used Alan Maguire
2020-12-04 18:48 ` [PATCH v2 bpf-next 2/3] bpf: add module support to btf display helpers Alan Maguire
2020-12-04 18:48 ` [PATCH v2 bpf-next 3/3] selftests/bpf: verify module-specific types can be shown via bpf_snprintf_btf Alan Maguire
2020-12-05 20:35 ` [PATCH v2 bpf-next 0/3] bpf: support module BTF in BTF display helpers Yonghong Song
2020-12-05 20:39   ` Yonghong Song
2020-12-06  0:43   ` Alan Maguire
2020-12-07  3:38     ` Yonghong Song
2020-12-08  3:42     ` Andrii Nakryiko [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=CAEf4BzYmDZVnHRYFJk+J90s-GKUt_Sa2HPNs6mKxyZ8Bm6TN3w@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lmb@cloudflare.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=quentin@isovalent.com \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    --subject='Re: [PATCH v2 bpf-next 0/3] bpf: support module BTF in BTF display helpers' \
    /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

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).