From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
Networking <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 1/3] bpftool: add extra CO-RE mode to btf dump command
Date: Thu, 19 Dec 2019 14:04:03 -0800 [thread overview]
Message-ID: <20191219220402.cdmxkkz3nmwmk6rc@ast-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <CAEf4BzYKf=+WNZv5HMv=W8robWWTab1L5NURAT=N7LQNW4oeGQ@mail.gmail.com>
On Thu, Dec 19, 2019 at 01:07:38PM -0800, Andrii Nakryiko wrote:
> On Thu, Dec 19, 2019 at 9:06 AM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Wed, Dec 18, 2019 at 11:06:56PM -0800, Andrii Nakryiko wrote:
> > > + if (core_mode) {
> > > + printf("#if defined(__has_attribute) && __has_attribute(preserve_access_index)\n");
> > > + printf("#define __CLANG_BPF_CORE_SUPPORTED\n");
> > > + printf("#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)\n");
> > > + printf("#endif\n\n");
> >
> > I think it's dangerous to automatically opt-out when clang is not new enough.
> > bpf prog will compile fine, but it will be missing co-re relocations.
> > How about doing something like:
> > printf("#ifdef NEEDS_CO_RE\n");
> > printf("#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)\n");
> > printf("#endif\n\n");
> > and emit it always when 'format c'.
> > Then on the program side it will look:
> > #define NEEDS_CO_RE
> > #include "vmlinux.h"
> > If clang is too old there will be a compile time error which is a good thing.
> > Future features will have different NEEDS_ macros.
>
> Wouldn't it be cleaner to separate vanilla C types dump vs
> CO-RE-specific one? I'd prefer to have them separate and not require
> every application to specify this #define NEEDS_CO_RE macro.
> Furthermore, later we probably are going to add some additional
> auto-generated types, definitions, etc, so plain C types dump and
> CO-RE-specific one will deviate quite a bit. So it feels cleaner to
> separate them now instead of polluting `format c` with irrelevant
> noise.
Say we do this 'format core' today then tomorrow another tweak to vmlinux.h
would need 'format core2' ? I think adding new format to bpftool for every
little feature will be annoying to users. I think the output should stay as
'format c' and that format should be extensible/customizable by bpf progs via
#define NEEDS_FEATURE_X. Then these features can grow without a need to keep
adding new cmd line args. This preserve_access_index feature makes up for less
than 1% difference in generated vmlinux.h. If some feature extension would
drastically change generated .h then it would justify new 'format'. This one is
just a small tweak. Also #define NEEDS_CO_RE is probably too broad. I think
#define CLANG_NEEDS_TO_EMIT_RELO would be more precise and less ambiguous.
next prev parent reply other threads:[~2019-12-19 22:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-19 7:06 [PATCH bpf-next 0/3] Implement runqslower BCC tool with BPF CO-RE Andrii Nakryiko
2019-12-19 7:06 ` [PATCH bpf-next 1/3] bpftool: add extra CO-RE mode to btf dump command Andrii Nakryiko
2019-12-19 17:06 ` Alexei Starovoitov
2019-12-19 21:07 ` Andrii Nakryiko
2019-12-19 22:04 ` Alexei Starovoitov [this message]
2019-12-20 17:40 ` Andrii Nakryiko
2019-12-21 3:21 ` Alexei Starovoitov
2019-12-21 5:40 ` Andrii Nakryiko
2019-12-19 7:06 ` [PATCH bpf-next 2/3] libbpf/tools: add runqslower tool to libbpf Andrii Nakryiko
2019-12-19 15:41 ` Daniel Borkmann
2019-12-19 21:14 ` Andrii Nakryiko
2019-12-19 22:04 ` Alexei Starovoitov
2019-12-19 18:13 ` Yonghong Song
2019-12-19 21:16 ` Andrii Nakryiko
2019-12-19 7:06 ` [PATCH bpf-next 3/3] selftests/bpf: build runqslower from selftests 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=20191219220402.cdmxkkz3nmwmk6rc@ast-mbp.dhcp.thefacebook.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.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).