From: Eduard Zingerman <eddyz87@gmail.com>
To: Ihor Solodrai <ihor.solodrai@linux.dev>,
dwarves@vger.kernel.org, bpf@vger.kernel.org
Cc: acme@kernel.org, alan.maguire@oracle.com, ast@kernel.org,
andrii@kernel.org, mykolal@fb.com, kernel-team@meta.com
Subject: Re: [PATCH v2 dwarves 2/4] btf_encoder: emit type tags for bpf_arena pointers
Date: Tue, 18 Feb 2025 20:36:11 -0800 [thread overview]
Message-ID: <8d222fd0f26fdce0193047074e660abab19ffc32.camel@gmail.com> (raw)
In-Reply-To: <20250212201552.1431219-3-ihor.solodrai@linux.dev>
On Wed, 2025-02-12 at 12:15 -0800, Ihor Solodrai wrote:
[...]
> diff --git a/btf_encoder.c b/btf_encoder.c
> index 965e8f0..3cec106 100644
> --- a/btf_encoder.c
> +++ b/btf_encoder.c
[...]
> +static int btf__tag_bpf_arena_ptr(struct btf *btf, int ptr_id)
> +{
> + const struct btf_type *ptr;
> + int tagged_type_id;
> +
> + ptr = btf__type_by_id(btf, ptr_id);
> + if (!btf_is_ptr(ptr))
> + return -EINVAL;
> +
> + tagged_type_id = btf__add_type_attr(btf, BPF_ARENA_ATTR, ptr->type);
> + if (tagged_type_id < 0)
> + return tagged_type_id;
> +
> + return btf__add_ptr(btf, tagged_type_id);
> +}
I might be confused, but this is a bit strange.
The type constructed here is: ptr -> type_tag -> t.
However, address_space is an attribute of a pointer, not a pointed type.
I think that correct sequence should be: type_tag -> ptr -> t.
This would make libbpf emit C declaration as follows:
void * __attribute__((address_space(1))) ptr;
Instead of current:
void __attribute__((address_space(1))) * ptr;
clang generates identical IR for both declarations:
@ptr = dso_local global ptr addrspace(1) null, align 8
Thus, imo, this function should be simplified as below:
static int btf__tag_bpf_arena_ptr(struct btf *btf, int ptr_id)
{
const struct btf_type *ptr;
ptr = btf__type_by_id(btf, ptr_id);
if (!btf_is_ptr(ptr))
return -EINVAL;
return btf__add_type_attr(btf, BPF_ARENA_ATTR, ptr_id);
}
[...]
next prev parent reply other threads:[~2025-02-19 4:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-12 20:15 [PATCH v2 dwarves 0/4] btf_encoder: emit type tags for bpf_arena pointers Ihor Solodrai
2025-02-12 20:15 ` [PATCH v2 dwarves 1/4] btf_encoder: refactor btf_encoder__tag_kfuncs() Ihor Solodrai
2025-02-19 3:25 ` Eduard Zingerman
2025-02-12 20:15 ` [PATCH v2 dwarves 2/4] btf_encoder: emit type tags for bpf_arena pointers Ihor Solodrai
2025-02-19 4:36 ` Eduard Zingerman [this message]
2025-02-19 5:45 ` Eduard Zingerman
2025-02-19 18:03 ` Ihor Solodrai
2025-02-12 20:15 ` [PATCH v2 dwarves 3/4] pahole: introduce --btf_feature=attributes Ihor Solodrai
2025-02-19 5:30 ` Eduard Zingerman
2025-02-12 20:15 ` [PATCH v2 dwarves 4/4] man-pages: describe attributes and remove reproducible_build Ihor Solodrai
2025-02-13 13:16 ` [PATCH v2 dwarves 0/4] btf_encoder: emit type tags for bpf_arena pointers Jiri Olsa
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=8d222fd0f26fdce0193047074e660abab19ffc32.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.com \
--cc=mykolal@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