[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzaXHrjoEWmEcvK62bqKuT3de__+juvGctR3=e8avRWpMQ@mail.gmail.com>
Date: Wed, 30 Oct 2024 10:35:17 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Donglin Peng <dolinux.peng@...il.com>
Cc: andrii@...nel.org, eddyz87@...il.com, ast@...nel.org, rostedt@...dmis.org,
mhiramat@...nel.org, bpf@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 1/3] libbpf: Sort btf_types in ascending order by name
On Wed, Oct 30, 2024 at 8:13 AM Donglin Peng <dolinux.peng@...il.com> wrote:
>
> On Wed, Oct 30, 2024 at 5:58 AM Andrii Nakryiko
> <andrii.nakryiko@...il.com> wrote:
> >
> > On Mon, Oct 28, 2024 at 5:22 PM Donglin Peng <dolinux.peng@...il.com> wrote:
> > >
> > > To enhance the searching performance of btf_find_by_name_kind, we
> > > can sort the btf_types in ascending order based on their names.
> > > This allows us to implement a binary search method.
> > >
> > > Co-developed-by: Eduard Zingerman <eddyz87@...il.com>
> > > Signed-off-by: Eduard Zingerman <eddyz87@...il.com>
> > > Signed-off-by: Donglin Peng <dolinux.peng@...il.com>
> > > ---
> > > v4:
> > > - Divide the patch into two parts: kernel and libbpf
> > > - Use Eduard's code to sort btf_types in the btf__dedup function
> > > - Correct some btf testcases due to modifications of the order of btf_types.
> > > ---
> > > tools/lib/bpf/btf.c | 115 +++++--
> > > tools/testing/selftests/bpf/prog_tests/btf.c | 296 +++++++++---------
> > > .../bpf/prog_tests/btf_dedup_split.c | 64 ++--
> > > 3 files changed, 268 insertions(+), 207 deletions(-)
> > >
> >
> > I don't think we should do any extra sorting by default. Maybe we need
> > some extra API to explicitly re-sort underlying types. But then again,
>
> How do you feel about adding a new feature to the '--btf_features' option,
> which could be used to control sorting?
This is pahole question, and yes, having a --btf_features makes sense to me.
>
> > why just by type name? What if type names are equal, what do we use to
> > disambiguate. None of this is considered in this patch.
>
> If there are multiple btf_types with identical names in a btf file,
> they will have different kinds. These btf_types will be grouped
Not necessarily, you can easily have types of the same kind with the
same name. But this changes nothing, I'd still define fuller search
criteria.
> together after being sorted according to their names. We can
> determine the range of the group and verify the btf_types within
> that range by their kind to obtain the appropriate btf_type.
>
> >
> > pw-bot: cr
> >
> > > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> > > index 3c131039c523..5290e9d59997 100644
> > > --- a/tools/lib/bpf/btf.c
> > > +++ b/tools/lib/bpf/btf.c
> > > @@ -1,6 +1,9 @@
> > > // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
> > > /* Copyright (c) 2018 Facebook */
> > >
[...]
Powered by blists - more mailing lists