[PATCH v2 0/8] Refactor cpuid and metric table lookup code

Ian Rogers posted 8 patches 2 weeks, 2 days ago
tools/perf/arch/arm64/util/arm-spe.c     | 14 +---
tools/perf/arch/arm64/util/header.c      | 73 ++++++++++-----------
tools/perf/arch/arm64/util/pmu.c         | 20 ------
tools/perf/arch/loongarch/util/header.c  |  4 +-
tools/perf/arch/powerpc/util/header.c    |  4 +-
tools/perf/arch/riscv/util/header.c      |  4 +-
tools/perf/arch/s390/util/header.c       |  6 +-
tools/perf/arch/x86/util/auxtrace.c      |  3 +-
tools/perf/arch/x86/util/header.c        |  5 +-
tools/perf/bench/numa.c                  | 53 +++++++++++++++
tools/perf/builtin-kvm.c                 |  4 +-
tools/perf/pmu-events/empty-pmu-events.c | 39 ++++++-----
tools/perf/pmu-events/jevents.py         | 39 ++++++-----
tools/perf/pmu-events/pmu-events.h       |  2 +-
tools/perf/tests/expr.c                  |  5 +-
tools/perf/util/env.c                    |  4 +-
tools/perf/util/expr.c                   |  6 +-
tools/perf/util/header.c                 | 82 ++++++++----------------
tools/perf/util/header.h                 | 23 +++----
tools/perf/util/pmu.c                    | 25 --------
tools/perf/util/pmu.h                    |  2 -
tools/perf/util/probe-event.c            |  1 +
22 files changed, 189 insertions(+), 229 deletions(-)
[PATCH v2 0/8] Refactor cpuid and metric table lookup code
Posted by Ian Rogers 2 weeks, 2 days ago
Xu Yang <xu.yang_2@nxp.com> reported issues with the system metric
lookup:
https://lore.kernel.org/linux-perf-users/20241106085441.3945502-1-xu.yang_2@nxp.com/
These patches remove a lot of the logic relating CPUIDs to PMUs so
that the PMU isn't part of the question when finding a metric table.
For time reasons, it doesn't go as far as allowing system metrics
without a metric table as a metric table is needed for metrics to
refer to other metrics, and the refactoring of that resolution is a
hassle.

Ian Rogers (7):
  perf header: Move is_cpu_online to numa bench
  perf header: Refactor get_cpuid to take a CPU for ARM
  perf arm64 header: Use cpu argument in get_cpuid
  perf header: Avoid transitive PMU includes
  perf header: Pass a perf_cpu rather than a PMU to get_cpuid_str
  perf jevents: Add map_for_cpu
  perf pmu: Move pmu_metrics_table__find and remove ARM override

Xu Yang (1):
  perf jevents: fix breakage when do perf stat on system metric

 tools/perf/arch/arm64/util/arm-spe.c     | 14 +---
 tools/perf/arch/arm64/util/header.c      | 73 ++++++++++-----------
 tools/perf/arch/arm64/util/pmu.c         | 20 ------
 tools/perf/arch/loongarch/util/header.c  |  4 +-
 tools/perf/arch/powerpc/util/header.c    |  4 +-
 tools/perf/arch/riscv/util/header.c      |  4 +-
 tools/perf/arch/s390/util/header.c       |  6 +-
 tools/perf/arch/x86/util/auxtrace.c      |  3 +-
 tools/perf/arch/x86/util/header.c        |  5 +-
 tools/perf/bench/numa.c                  | 53 +++++++++++++++
 tools/perf/builtin-kvm.c                 |  4 +-
 tools/perf/pmu-events/empty-pmu-events.c | 39 ++++++-----
 tools/perf/pmu-events/jevents.py         | 39 ++++++-----
 tools/perf/pmu-events/pmu-events.h       |  2 +-
 tools/perf/tests/expr.c                  |  5 +-
 tools/perf/util/env.c                    |  4 +-
 tools/perf/util/expr.c                   |  6 +-
 tools/perf/util/header.c                 | 82 ++++++++----------------
 tools/perf/util/header.h                 | 23 +++----
 tools/perf/util/pmu.c                    | 25 --------
 tools/perf/util/pmu.h                    |  2 -
 tools/perf/util/probe-event.c            |  1 +
 22 files changed, 189 insertions(+), 229 deletions(-)

-- 
2.47.0.199.ga7371fff76-goog
Re: [PATCH v2 0/8] Refactor cpuid and metric table lookup code
Posted by Xu Yang 2 weeks, 1 day ago
On Thu, Nov 07, 2024 at 08:20:27AM -0800, Ian Rogers wrote:
> Xu Yang <xu.yang_2@nxp.com> reported issues with the system metric
> lookup:
> https://lore.kernel.org/linux-perf-users/20241106085441.3945502-1-xu.yang_2@nxp.com/
> These patches remove a lot of the logic relating CPUIDs to PMUs so
> that the PMU isn't part of the question when finding a metric table.
> For time reasons, it doesn't go as far as allowing system metrics
> without a metric table as a metric table is needed for metrics to
> refer to other metrics, and the refactoring of that resolution is a
> hassle.

For this patchset:
Tested-by: Xu Yang <xu.yang_2@nxp.com>

Thanks,
Xu Yang

> 
> Ian Rogers (7):
>   perf header: Move is_cpu_online to numa bench
>   perf header: Refactor get_cpuid to take a CPU for ARM
>   perf arm64 header: Use cpu argument in get_cpuid
>   perf header: Avoid transitive PMU includes
>   perf header: Pass a perf_cpu rather than a PMU to get_cpuid_str
>   perf jevents: Add map_for_cpu
>   perf pmu: Move pmu_metrics_table__find and remove ARM override
> 
> Xu Yang (1):
>   perf jevents: fix breakage when do perf stat on system metric
> 
>  tools/perf/arch/arm64/util/arm-spe.c     | 14 +---
>  tools/perf/arch/arm64/util/header.c      | 73 ++++++++++-----------
>  tools/perf/arch/arm64/util/pmu.c         | 20 ------
>  tools/perf/arch/loongarch/util/header.c  |  4 +-
>  tools/perf/arch/powerpc/util/header.c    |  4 +-
>  tools/perf/arch/riscv/util/header.c      |  4 +-
>  tools/perf/arch/s390/util/header.c       |  6 +-
>  tools/perf/arch/x86/util/auxtrace.c      |  3 +-
>  tools/perf/arch/x86/util/header.c        |  5 +-
>  tools/perf/bench/numa.c                  | 53 +++++++++++++++
>  tools/perf/builtin-kvm.c                 |  4 +-
>  tools/perf/pmu-events/empty-pmu-events.c | 39 ++++++-----
>  tools/perf/pmu-events/jevents.py         | 39 ++++++-----
>  tools/perf/pmu-events/pmu-events.h       |  2 +-
>  tools/perf/tests/expr.c                  |  5 +-
>  tools/perf/util/env.c                    |  4 +-
>  tools/perf/util/expr.c                   |  6 +-
>  tools/perf/util/header.c                 | 82 ++++++++----------------
>  tools/perf/util/header.h                 | 23 +++----
>  tools/perf/util/pmu.c                    | 25 --------
>  tools/perf/util/pmu.h                    |  2 -
>  tools/perf/util/probe-event.c            |  1 +
>  22 files changed, 189 insertions(+), 229 deletions(-)
> 
> -- 
> 2.47.0.199.ga7371fff76-goog
>
Re: [PATCH v2 0/8] Refactor cpuid and metric table lookup code
Posted by Ian Rogers 1 week, 2 days ago
On Thu, Nov 7, 2024 at 6:57 PM Xu Yang <xu.yang_2@nxp.com> wrote:
>
> On Thu, Nov 07, 2024 at 08:20:27AM -0800, Ian Rogers wrote:
> > Xu Yang <xu.yang_2@nxp.com> reported issues with the system metric
> > lookup:
> > https://lore.kernel.org/linux-perf-users/20241106085441.3945502-1-xu.yang_2@nxp.com/
> > These patches remove a lot of the logic relating CPUIDs to PMUs so
> > that the PMU isn't part of the question when finding a metric table.
> > For time reasons, it doesn't go as far as allowing system metrics
> > without a metric table as a metric table is needed for metrics to
> > refer to other metrics, and the refactoring of that resolution is a
> > hassle.
>
> For this patchset:
> Tested-by: Xu Yang <xu.yang_2@nxp.com>

Ping. Would be nice for this to land given the ARM fix and general cleanup.

Thanks,
Ian
Re: [PATCH v2 0/8] Refactor cpuid and metric table lookup code
Posted by James Clark 1 week, 1 day ago

On 07/11/2024 4:20 pm, Ian Rogers wrote:
> Xu Yang <xu.yang_2@nxp.com> reported issues with the system metric
> lookup:
> https://lore.kernel.org/linux-perf-users/20241106085441.3945502-1-xu.yang_2@nxp.com/
> These patches remove a lot of the logic relating CPUIDs to PMUs so
> that the PMU isn't part of the question when finding a metric table.
> For time reasons, it doesn't go as far as allowing system metrics
> without a metric table as a metric table is needed for metrics to
> refer to other metrics, and the refactoring of that resolution is a
> hassle.
> 
> Ian Rogers (7):
>    perf header: Move is_cpu_online to numa bench
>    perf header: Refactor get_cpuid to take a CPU for ARM
>    perf arm64 header: Use cpu argument in get_cpuid
>    perf header: Avoid transitive PMU includes
>    perf header: Pass a perf_cpu rather than a PMU to get_cpuid_str
>    perf jevents: Add map_for_cpu
>    perf pmu: Move pmu_metrics_table__find and remove ARM override
> 
> Xu Yang (1):
>    perf jevents: fix breakage when do perf stat on system metric
> 
>   tools/perf/arch/arm64/util/arm-spe.c     | 14 +---
>   tools/perf/arch/arm64/util/header.c      | 73 ++++++++++-----------
>   tools/perf/arch/arm64/util/pmu.c         | 20 ------
>   tools/perf/arch/loongarch/util/header.c  |  4 +-
>   tools/perf/arch/powerpc/util/header.c    |  4 +-
>   tools/perf/arch/riscv/util/header.c      |  4 +-
>   tools/perf/arch/s390/util/header.c       |  6 +-
>   tools/perf/arch/x86/util/auxtrace.c      |  3 +-
>   tools/perf/arch/x86/util/header.c        |  5 +-
>   tools/perf/bench/numa.c                  | 53 +++++++++++++++
>   tools/perf/builtin-kvm.c                 |  4 +-
>   tools/perf/pmu-events/empty-pmu-events.c | 39 ++++++-----
>   tools/perf/pmu-events/jevents.py         | 39 ++++++-----
>   tools/perf/pmu-events/pmu-events.h       |  2 +-
>   tools/perf/tests/expr.c                  |  5 +-
>   tools/perf/util/env.c                    |  4 +-
>   tools/perf/util/expr.c                   |  6 +-
>   tools/perf/util/header.c                 | 82 ++++++++----------------
>   tools/perf/util/header.h                 | 23 +++----
>   tools/perf/util/pmu.c                    | 25 --------
>   tools/perf/util/pmu.h                    |  2 -
>   tools/perf/util/probe-event.c            |  1 +
>   22 files changed, 189 insertions(+), 229 deletions(-)
> 

Reviewed-by: James Clark <james.clark@linaro.org>
Re: [PATCH v2 0/8] Refactor cpuid and metric table lookup code
Posted by Arnaldo Carvalho de Melo 1 week, 1 day ago
On Fri, Nov 15, 2024 at 03:35:55PM +0000, James Clark wrote:
> 
> 
> On 07/11/2024 4:20 pm, Ian Rogers wrote:
> > Xu Yang <xu.yang_2@nxp.com> reported issues with the system metric
> > lookup:
> > https://lore.kernel.org/linux-perf-users/20241106085441.3945502-1-xu.yang_2@nxp.com/
> > These patches remove a lot of the logic relating CPUIDs to PMUs so
> > that the PMU isn't part of the question when finding a metric table.
> > For time reasons, it doesn't go as far as allowing system metrics
> > without a metric table as a metric table is needed for metrics to
> > refer to other metrics, and the refactoring of that resolution is a
> > hassle.
> > 
> > Ian Rogers (7):
> >    perf header: Move is_cpu_online to numa bench
> >    perf header: Refactor get_cpuid to take a CPU for ARM
> >    perf arm64 header: Use cpu argument in get_cpuid
> >    perf header: Avoid transitive PMU includes
> >    perf header: Pass a perf_cpu rather than a PMU to get_cpuid_str
> >    perf jevents: Add map_for_cpu
> >    perf pmu: Move pmu_metrics_table__find and remove ARM override
> > 
> > Xu Yang (1):
> >    perf jevents: fix breakage when do perf stat on system metric
> > 
> >   tools/perf/arch/arm64/util/arm-spe.c     | 14 +---
> >   tools/perf/arch/arm64/util/header.c      | 73 ++++++++++-----------
> >   tools/perf/arch/arm64/util/pmu.c         | 20 ------
> >   tools/perf/arch/loongarch/util/header.c  |  4 +-
> >   tools/perf/arch/powerpc/util/header.c    |  4 +-
> >   tools/perf/arch/riscv/util/header.c      |  4 +-
> >   tools/perf/arch/s390/util/header.c       |  6 +-
> >   tools/perf/arch/x86/util/auxtrace.c      |  3 +-
> >   tools/perf/arch/x86/util/header.c        |  5 +-
> >   tools/perf/bench/numa.c                  | 53 +++++++++++++++
> >   tools/perf/builtin-kvm.c                 |  4 +-
> >   tools/perf/pmu-events/empty-pmu-events.c | 39 ++++++-----
> >   tools/perf/pmu-events/jevents.py         | 39 ++++++-----
> >   tools/perf/pmu-events/pmu-events.h       |  2 +-
> >   tools/perf/tests/expr.c                  |  5 +-
> >   tools/perf/util/env.c                    |  4 +-
> >   tools/perf/util/expr.c                   |  6 +-
> >   tools/perf/util/header.c                 | 82 ++++++++----------------
> >   tools/perf/util/header.h                 | 23 +++----
> >   tools/perf/util/pmu.c                    | 25 --------
> >   tools/perf/util/pmu.h                    |  2 -
> >   tools/perf/util/probe-event.c            |  1 +
> >   22 files changed, 189 insertions(+), 229 deletions(-)
> > 
> 
> Reviewed-by: James Clark <james.clark@linaro.org>

Thanks for reviewing James, I'm doing a round of tests to push what I
have in tmp.perf-tools-next to perf-tools-next so that it gets test
merged on linux-next and later today I'll escape from the holiday and
take a last look on this series, apply and test.

- Arnaldo
Re: [PATCH v2 0/8] Refactor cpuid and metric table lookup code
Posted by Arnaldo Carvalho de Melo 1 week ago
On Fri, Nov 15, 2024 at 12:43:05PM -0300, Arnaldo Carvalho de Melo wrote:
> On Fri, Nov 15, 2024 at 03:35:55PM +0000, James Clark wrote:
> > 
> > 
> > On 07/11/2024 4:20 pm, Ian Rogers wrote:
> > > Xu Yang <xu.yang_2@nxp.com> reported issues with the system metric
> > > lookup:
> > > https://lore.kernel.org/linux-perf-users/20241106085441.3945502-1-xu.yang_2@nxp.com/
> > > These patches remove a lot of the logic relating CPUIDs to PMUs so
> > > that the PMU isn't part of the question when finding a metric table.
> > > For time reasons, it doesn't go as far as allowing system metrics
> > > without a metric table as a metric table is needed for metrics to
> > > refer to other metrics, and the refactoring of that resolution is a
> > > hassle.
> > > 
> > > Ian Rogers (7):
> > >    perf header: Move is_cpu_online to numa bench
> > >    perf header: Refactor get_cpuid to take a CPU for ARM
> > >    perf arm64 header: Use cpu argument in get_cpuid
> > >    perf header: Avoid transitive PMU includes
> > >    perf header: Pass a perf_cpu rather than a PMU to get_cpuid_str
> > >    perf jevents: Add map_for_cpu
> > >    perf pmu: Move pmu_metrics_table__find and remove ARM override
> > > 
> > > Xu Yang (1):
> > >    perf jevents: fix breakage when do perf stat on system metric
> > > 
> > >   tools/perf/arch/arm64/util/arm-spe.c     | 14 +---
> > >   tools/perf/arch/arm64/util/header.c      | 73 ++++++++++-----------
> > >   tools/perf/arch/arm64/util/pmu.c         | 20 ------
> > >   tools/perf/arch/loongarch/util/header.c  |  4 +-
> > >   tools/perf/arch/powerpc/util/header.c    |  4 +-
> > >   tools/perf/arch/riscv/util/header.c      |  4 +-
> > >   tools/perf/arch/s390/util/header.c       |  6 +-
> > >   tools/perf/arch/x86/util/auxtrace.c      |  3 +-
> > >   tools/perf/arch/x86/util/header.c        |  5 +-
> > >   tools/perf/bench/numa.c                  | 53 +++++++++++++++
> > >   tools/perf/builtin-kvm.c                 |  4 +-
> > >   tools/perf/pmu-events/empty-pmu-events.c | 39 ++++++-----
> > >   tools/perf/pmu-events/jevents.py         | 39 ++++++-----
> > >   tools/perf/pmu-events/pmu-events.h       |  2 +-
> > >   tools/perf/tests/expr.c                  |  5 +-
> > >   tools/perf/util/env.c                    |  4 +-
> > >   tools/perf/util/expr.c                   |  6 +-
> > >   tools/perf/util/header.c                 | 82 ++++++++----------------
> > >   tools/perf/util/header.h                 | 23 +++----
> > >   tools/perf/util/pmu.c                    | 25 --------
> > >   tools/perf/util/pmu.h                    |  2 -
> > >   tools/perf/util/probe-event.c            |  1 +
> > >   22 files changed, 189 insertions(+), 229 deletions(-)
> > > 
> > 
> > Reviewed-by: James Clark <james.clark@linaro.org>
> 
> Thanks for reviewing James, I'm doing a round of tests to push what I
> have in tmp.perf-tools-next to perf-tools-next so that it gets test
> merged on linux-next and later today I'll escape from the holiday and
> take a last look on this series, apply and test.

Applied locally, pushing to tmp.perf-tools-next as I'm still testing the
hwmon case, building it on an 32-bit ARM machine:

processor	: 3
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 38.40
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

Hardware	: BCM2835
Revision	: a020d3
Serial		: 00000000783939e0
Model		: Raspberry Pi 3 Model B Plus Rev 1.3

- Arnaldo