[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6e7ef94cb4e2d7fbc82676b2af1a165cac620aae.camel@gmail.com>
Date: Mon, 27 Oct 2025 12:06:30 -0700
From: Eduard Zingerman <eddyz87@...il.com>
To: Donglin Peng <dolinux.peng@...il.com>, ast@...nel.org, Andrii Nakryiko
<andrii.nakryiko@...il.com>
Cc: linux-kernel@...r.kernel.org, bpf@...r.kernel.org, Alan Maguire
<alan.maguire@...cle.com>, Song Liu <song@...nel.org>, pengdonglin
<pengdonglin@...omi.com>
Subject: Re: [RFC PATCH v3 1/3] btf: implement BTF type sorting for
accelerated lookups
On Mon, 2025-10-27 at 21:54 +0800, Donglin Peng wrote:
[...]
Question to Andrii, I think.
It looks a bit asymmetrical, that there is btf_check_sorted() in
libbpf, but library does not provide comparison or sorting function.
Wdyt?
> +static void btf_check_sorted(struct btf *btf, int start_id)
> +{
> + const struct btf_type *t;
> + int i, n, nr_sorted_types;
> +
> + n = btf__type_cnt(btf);
> + if (btf->nr_types < BTF_CHECK_SORT_THRESHOLD)
> + return;
> +
> + n--;
> + nr_sorted_types = 0;
> + for (i = start_id; i < n; i++) {
> + int k = i + 1;
> +
> + if (btf_compare_type_kinds_names(&i, &k, btf) > 0)
> + return;
> +
> + t = btf_type_by_id(btf, k);
> + if (!str_is_empty(btf__str_by_offset(btf, t->name_off)))
> + nr_sorted_types++;
> + }
> +
> + t = btf_type_by_id(btf, start_id);
> + if (!str_is_empty(btf__str_by_offset(btf, t->name_off)))
> + nr_sorted_types++;
> +
> + if (nr_sorted_types < BTF_CHECK_SORT_THRESHOLD)
> + return;
Nit: Still think that this is not needed. It trades a couple of CPU
cycles for this check and a big comment on the top, about why
it's needed.
> +
> + btf->nr_sorted_types = nr_sorted_types;
> +}
[...]
Powered by blists - more mailing lists