BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Quentin Monnet <quentin@isovalent.com>,
	bpf@vger.kernel.org, ast@kernel.org
Cc: andrii@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
	 kernel-team@fb.com, yonghong.song@linux.dev,
	alan.maguire@oracle.com
Subject: Re: [RFC v2 2/3] bpftool: add attribute preserve_static_offset for context types
Date: Tue, 12 Dec 2023 17:58:21 +0200	[thread overview]
Message-ID: <90dd9462984be5cfce9db23eda53df44f39a8687.camel@gmail.com> (raw)
In-Reply-To: <baee9fb4-7559-4ba2-a254-7388bb6caa63@isovalent.com>

On Tue, 2023-12-12 at 11:39 +0000, Quentin Monnet wrote:
[...]
> Hi, and thanks for this!
> 
> Apologies for missing the discussion on v1. Reading through the previous
> thread I see that they were votes in favour of the hard-coded approach,
> but I would ask folks to please reconsider.
> 
> I'm not keen on taking this list in bpftool, it doesn't seem to be the
> right place for that. I understand there's no plan to add new mirror
> context structs, but if we change policy for whatever reason, we're sure
> to miss the update in this list and that's a bug in bpftool. If bpftool
> ever gets ported to Windows and Windows needs support for new structs,
> that's more juggling to do to support multiple platforms. And if any
> tool other than bpftool needs to generate vmlinux.h headers in the
> future, it's back to square one - although by then there might be extra
> pushback for changing the BTF, if bpftool already does the work.
> 
> Like Alan, I rather share your own inclination towards the more generic
> declaration tags approach, if you don't mind the additional work.

Understood, thank you for feedback.
The second option is to:

1. Define __bpf_ctx macro in linux headers as follows:

    #if __has_attribute(preserve_static_offset) && defined(__bpf__)
    #define __bpf_ctx __attribute__((preserve_static_offset)) \
                      __attribute__((btf_decl_tag(preserve_static_offset)))
    #else
    #define __bpf_ctx
    #endif

2a. Update libbpf to emit __attribute__((preserve_static_offset)) when
    corresponding decl tag is present in the BTF.

2b. Update bpftool to emit __attribute__((preserve_static_offset)) for
    types with corresponding decl tag. (Like in this patch but check
    for decl tag instead of name).

I think that 2b is better, because emitting
BPF_NO_PRESERVE_STATIC_OFFSET from the same place where
BPF_NO_PRESERVE_ACCESS_INDEX makes more sense,
libbpf does not emit any macro definitions at the moment.

wdyt?



  reply	other threads:[~2023-12-12 15:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12  2:31 [RFC v2 0/2] use preserve_static_offset in bpf uapi headers Eduard Zingerman
2023-12-12  2:31 ` [RFC v2 1/3] bpf: Mark virtual BPF context structures as preserve_static_offset Eduard Zingerman
2023-12-12  2:31 ` [RFC v2 2/3] bpftool: add attribute preserve_static_offset for context types Eduard Zingerman
2023-12-12 11:39   ` Quentin Monnet
2023-12-12 15:58     ` Eduard Zingerman [this message]
2023-12-12 16:07       ` Quentin Monnet
2023-12-13  4:53         ` Yonghong Song
2023-12-12  2:31 ` [RFC v2 3/3] selftests/bpf: verify bpftool emits preserve_static_offset Eduard Zingerman

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=90dd9462984be5cfce9db23eda53df44f39a8687.camel@gmail.com \
    --to=eddyz87@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=kernel-team@fb.com \
    --cc=martin.lau@linux.dev \
    --cc=quentin@isovalent.com \
    --cc=yonghong.song@linux.dev \
    /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