From: Hengqi Chen <hengqi.chen@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>, Yonghong Song <yhs@fb.com>,
john fastabend <john.fastabend@gmail.com>,
Martin Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>
Subject: Re: [PATCH bpf-next 1/2] libbpf: Add btf__type_cnt() and btf__raw_data() APIs
Date: Wed, 20 Oct 2021 21:51:17 +0800 [thread overview]
Message-ID: <fc764766-e4fd-dc0a-c042-5af92373a461@gmail.com> (raw)
In-Reply-To: <CAEf4BzZyjoaRATpKHuYFFmZ1u5WnEh4nBdOOpSO+OZi7MH=cHg@mail.gmail.com>
On 2021/10/20 1:48 AM, Andrii Nakryiko wrote:
> On Sat, Oct 9, 2021 at 8:01 AM Hengqi Chen <hengqi.chen@gmail.com> wrote:
>>
>> Add btf__type_cnt() and btf__raw_data() APIs and deprecate
>> btf__get_nr_type() and btf__get_raw_data() since the old APIs
>> don't follow the libbpf naming convention for getters which
>> omit 'get' in the name.[0] btf__raw_data() is just an alias to
>
> nit: this ".[0]" looks out of place, please use it as a reference in a
> sentence, e.g.,:
>
> omit 'get' in the name (see [0]).
>
> So that it reads naturally and fits the overall commit message.
>
>
Got it. Will do.
>> the existing btf__get_raw_data(). btf__type_cnt() now returns
>> the number of all types of the BTF object including 'void'.
>>
>> [0] Closes: https://github.com/libbpf/libbpf/issues/279
>>
>> Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
>> ---
>> tools/lib/bpf/btf.c | 36 ++++++++++++++++++++++--------------
>> tools/lib/bpf/btf.h | 4 ++++
>> tools/lib/bpf/btf_dump.c | 8 ++++----
>> tools/lib/bpf/libbpf.c | 32 ++++++++++++++++----------------
>> tools/lib/bpf/libbpf.map | 2 ++
>> tools/lib/bpf/linker.c | 28 ++++++++++++++--------------
>> 6 files changed, 62 insertions(+), 48 deletions(-)
>>
>
> [...]
>
>> diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
>> index 864eb51753a1..49397a22d72b 100644
>> --- a/tools/lib/bpf/btf.h
>> +++ b/tools/lib/bpf/btf.h
>> @@ -131,7 +131,9 @@ LIBBPF_API __s32 btf__find_by_name(const struct btf *btf,
>> const char *type_name);
>> LIBBPF_API __s32 btf__find_by_name_kind(const struct btf *btf,
>> const char *type_name, __u32 kind);
>> +LIBBPF_DEPRECATED_SINCE(0, 6, "use btf__type_cnt() instead")
>
> it has to be scheduled to 0.7 to have a release with new API
> (btf__type_cnt) before we deprecate btf__get_nr_types(). It's probably
> worth mentioning in the deprecation message that btf__type_cnt()
> return is +1 from btf__get_nr_types(). Maybe something like:
>
I am a little confused about this scheduling. You mentioned that
we can deprecate old API on the development version (0.6). See [0].
> LIBBPF_DEPRECATED_SINCE(0, 7, "use btf__type_cnt() instead; note that
> btf__get_nr_types() == btf__type_cnt() - 1")
>
Will take this in v2.
>> LIBBPF_API __u32 btf__get_nr_types(const struct btf *btf);
>> +LIBBPF_API __u32 btf__type_cnt(const struct btf *btf);
>> LIBBPF_API const struct btf *btf__base_btf(const struct btf *btf);
>> LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf,
>> __u32 id);
>> @@ -144,7 +146,9 @@ LIBBPF_API int btf__resolve_type(const struct btf *btf, __u32 type_id);
>> LIBBPF_API int btf__align_of(const struct btf *btf, __u32 id);
>> LIBBPF_API int btf__fd(const struct btf *btf);
>> LIBBPF_API void btf__set_fd(struct btf *btf, int fd);
>> +LIBBPF_DEPRECATED_SINCE(0, 6, "use btf__raw_data() instead")
>
> same, 0.7+
>
>> LIBBPF_API const void *btf__get_raw_data(const struct btf *btf, __u32 *size);
>> +LIBBPF_API const void *btf__raw_data(const struct btf *btf, __u32 *size);
>> LIBBPF_API const char *btf__name_by_offset(const struct btf *btf, __u32 offset);
>> LIBBPF_API const char *btf__str_by_offset(const struct btf *btf, __u32 offset);
>> LIBBPF_API int btf__get_map_kv_tids(const struct btf *btf, const char *map_name,
>
> [...]
>
[0] https://lore.kernel.org/all/CAEf4BzZ_JB1VLAF0=7gu=2M0M735aXava=nPL8m8ewQWdS3m8g@mail.gmail.com/
next prev parent reply other threads:[~2021-10-20 13:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-09 15:00 [PATCH bpf-next 0/2] libbpf: Add btf__type_cnt() and btf__raw_data() APIs Hengqi Chen
2021-10-09 15:00 ` [PATCH bpf-next 1/2] " Hengqi Chen
2021-10-19 17:48 ` Andrii Nakryiko
2021-10-20 13:51 ` Hengqi Chen [this message]
2021-10-20 23:14 ` Andrii Nakryiko
2021-10-21 13:53 ` Hengqi Chen
2021-10-09 15:00 ` [PATCH bpf-next 2/2] tools: Switch to new btf__type_cnt/btf__raw_data APIs Hengqi Chen
2021-10-19 17:50 ` Andrii Nakryiko
2021-10-20 13:54 ` Hengqi Chen
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=fc764766-e4fd-dc0a-c042-5af92373a461@gmail.com \
--to=hengqi.chen@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=songliubraving@fb.com \
--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