2024-05-28 10:16:10

by John Garry

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] perf jevents: Autogenerate empty-pmu-events.c

On 25/05/2024 02:30, Ian Rogers wrote:
> empty-pmu-events.c exists so that builds may occur without python
> being installed on a system. > Manually updating empty-pmu-events.c to
> be in sync with jevents.py is a pain, let's use jevents.py to generate
> empty-pmu-events.c.
>
> 1) change jevents.py so that an arch and model of none cause
> generation of a pmu-events.c without any json. Add a SPDX and
> autogenerated warning to the start of the file.
>
> 2) change Build so that if a generated pmu-events.c for arch none and
> model none doesn't match empty-pmu-events.c the build fails with a
> cat of the differences. Update Makefile.perf to clean up the files
> used for this.
>
> 3) update empty-pmu-events.c to match the output of jevents.py with
> arch and mode of none.
>
> Signed-off-by: Ian Rogers <[email protected]>


Reviewed-by: John Garry <[email protected]>

> ---
> tools/perf/Makefile.perf | 2 +
> tools/perf/pmu-events/Build | 12 +-
> tools/perf/pmu-events/empty-pmu-events.c | 894 ++++++++++++++---------
> tools/perf/pmu-events/jevents.py | 6 +-
> 4 files changed, 562 insertions(+), 352 deletions(-)
>
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.per

..

> - },
> +struct pmu_table_entry {
> + const struct compact_pmu_event *entries;
> + uint32_t num_entries;
> + struct compact_pmu_event pmu_name;
> +};
> +
> +static const char *const big_c_string =
> +/* offset=0 */ "default_core\000"
> +/* offset=13 */ "bp_l1_btb_correct\000branch\000L1 BTB Correction\000event=0x8a\000\00000\000\000"
> +/* offset=72 */ "bp_l2_btb_correct\000branch\000L2 BTB Correction\000event=0x8b\000\00000\000\000"

Please remind me: how to figure out this number when adding a new entry?

> +/* offset=131 */ "l3_cache_rd\000cache\000L3 cache access, read\000event=0x40\000\00000\000Attributable Level 3 cache access, read\000"


2024-05-28 15:16:45

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] perf jevents: Autogenerate empty-pmu-events.c

On Tue, May 28, 2024 at 3:01 AM John Garry <[email protected]> wrote:
>
> On 25/05/2024 02:30, Ian Rogers wrote:
> > empty-pmu-events.c exists so that builds may occur without python
> > being installed on a system. > Manually updating empty-pmu-events.c to
> > be in sync with jevents.py is a pain, let's use jevents.py to generate
> > empty-pmu-events.c.
> >
> > 1) change jevents.py so that an arch and model of none cause
> > generation of a pmu-events.c without any json. Add a SPDX and
> > autogenerated warning to the start of the file.
> >
> > 2) change Build so that if a generated pmu-events.c for arch none and
> > model none doesn't match empty-pmu-events.c the build fails with a
> > cat of the differences. Update Makefile.perf to clean up the files
> > used for this.
> >
> > 3) update empty-pmu-events.c to match the output of jevents.py with
> > arch and mode of none.
> >
> > Signed-off-by: Ian Rogers <[email protected]>
>
>
> Reviewed-by: John Garry <[email protected]>

Thanks!

> > ---
> > tools/perf/Makefile.perf | 2 +
> > tools/perf/pmu-events/Build | 12 +-
> > tools/perf/pmu-events/empty-pmu-events.c | 894 ++++++++++++++---------
> > tools/perf/pmu-events/jevents.py | 6 +-
> > 4 files changed, 562 insertions(+), 352 deletions(-)
> >
> > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.per
>
> ...
>
> > - },
> > +struct pmu_table_entry {
> > + const struct compact_pmu_event *entries;
> > + uint32_t num_entries;
> > + struct compact_pmu_event pmu_name;
> > +};
> > +
> > +static const char *const big_c_string =
> > +/* offset=0 */ "default_core\000"
> > +/* offset=13 */ "bp_l1_btb_correct\000branch\000L1 BTB Correction\000event=0x8a\000\00000\000\000"
> > +/* offset=72 */ "bp_l2_btb_correct\000branch\000L2 BTB Correction\000event=0x8b\000\00000\000\000"
>
> Please remind me: how to figure out this number when adding a new entry?

So this shouldn't be generated by hand. The old one was, this one is
created by jevents.py as maintaining something by hand is a pain. If
you need to add entries then they are in the
`tools/perf/pmu-events/arch/test/` directory. When you build with
NO_JEVENTS=1 then this file will be used. When building normally
jevents.py will be used and used to check that the empty-pmu-events.c
isn't out-of-date - the build will break if it is. The fix is just to
copy `test-empty-pmu-events.c` to `empty-pmu-events.c`, which is
hopefully implied by the result of the diff being shown.

Thanks,
Ian

> > +/* offset=131 */ "l3_cache_rd\000cache\000L3 cache access, read\000event=0x40\000\00000\000Attributable Level 3 cache access, read\000"