Re: [PATCH v2 bpf-next 09/11] libbpf: Add perf event names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jun 11, 2023 at 6:43 AM Jiri Olsa <olsajiri@xxxxxxxxx> wrote:
>
> On Thu, Jun 08, 2023 at 10:35:21AM +0000, Yafang Shao wrote:
> > Add libbpf API to get generic perf event name.
> >
> > Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx>
> > ---
> >  tools/lib/bpf/libbpf.c   | 107 +++++++++++++++++++++++++++++++++++++++++++++++
> >  tools/lib/bpf/libbpf.h   |  56 +++++++++++++++++++++++++
> >  tools/lib/bpf/libbpf.map |   6 +++
> >  3 files changed, 169 insertions(+)
> >
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 47632606..27d396f 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -119,6 +119,64 @@
> >       [BPF_STRUCT_OPS]                = "struct_ops",
> >  };
> >
> > +static const char * const perf_type_name[] = {
> > +     [PERF_TYPE_HARDWARE]            = "hardware",
> > +     [PERF_TYPE_SOFTWARE]            = "software",
> > +     [PERF_TYPE_TRACEPOINT]          = "tracepoint",
> > +     [PERF_TYPE_HW_CACHE]            = "hw_cache",
> > +     [PERF_TYPE_RAW]                 = "raw",
> > +     [PERF_TYPE_BREAKPOINT]          = "breakpoint",
> > +};
> > +
> > +static const char * const perf_hw_name[] = {
> > +     [PERF_COUNT_HW_CPU_CYCLES]              = "cpu_cycles",
>
> could you use '-' instead of '_' because that's what we do in perf
>
> actually would be great if you could use same names like in
>   tool/perf/util/parse-events.c  'event_symbols_*' arrays
>   tool/perf/util/evsel.c         'evsel__hw_cache' array
>
> so perf and bpftool would use same names and we have a chance
> to use same code for that in future

Good point. Will copy them :)

-- 
Regards
Yafang





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux