perf kvm stat: Remove use of the arch directory
authorIan Rogers <irogers@google.com>
Tue, 3 Feb 2026 18:26:36 +0000 (10:26 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 3 Feb 2026 21:01:27 +0000 (18:01 -0300)
commitceea279f93760767c0e654341829334a1c881a08
tree6cd073f1efdea448a36457100615fa6716e12e9d
parent8c5b40678c63be6b85f1c2dc8c8b89d632faf988
perf kvm stat: Remove use of the arch directory

`perf kvm stat` supports record and report options.

By using the arch directory a report for a different machine type cannot
be supported.

Move the kvm-stat code out of the arch directory and into
util/kvm-stat-arch following the pattern of perf-regs and dwarf-regs.

Avoid duplicate symbols by renaming functions to have the architecture
name within them.

For global variables, wrap them in an architecture specific function.
Selecting the architecture to use with `perf kvm stat` is selected by
EM_HOST, ie no different than before the change.

Later the ELF machine can be determined from the session or a header
feature (ie EM_HOST at the time of the record).

The build and #define HAVE_KVM_STAT_SUPPORT is now redundant so remove
across Makefiles and in the build.

Opportunistically constify architectural structs and arrays.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrew Jones <ajones@ventanamicro.com>
Cc: Anubhav Shelat <ashelat@redhat.com>
Cc: Anup Patel <anup@brainfault.org>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Blake Jones <blakejones@google.com>
Cc: Chun-Tse Shao <ctshao@google.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quan Zhou <zhouquan@iscas.ac.cn>
Cc: Shimin Guo <shimin.guo@skydio.com>
Cc: Swapnil Sapkal <swapnil.sapkal@amd.com>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yunseong Kim <ysk@kzalloc.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
38 files changed:
tools/perf/Makefile.config
tools/perf/arch/arm64/Makefile
tools/perf/arch/arm64/util/Build
tools/perf/arch/arm64/util/arm64_exception_types.h [deleted file]
tools/perf/arch/arm64/util/kvm-stat.c [deleted file]
tools/perf/arch/loongarch/Makefile
tools/perf/arch/loongarch/util/Build
tools/perf/arch/loongarch/util/kvm-stat.c [deleted file]
tools/perf/arch/powerpc/Makefile
tools/perf/arch/powerpc/util/Build
tools/perf/arch/powerpc/util/book3s_hcalls.h [deleted file]
tools/perf/arch/powerpc/util/book3s_hv_exits.h [deleted file]
tools/perf/arch/powerpc/util/kvm-stat.c [deleted file]
tools/perf/arch/riscv/Makefile
tools/perf/arch/riscv/util/Build
tools/perf/arch/riscv/util/kvm-stat.c [deleted file]
tools/perf/arch/riscv/util/riscv_trap_types.h [deleted file]
tools/perf/arch/s390/Makefile
tools/perf/arch/s390/util/Build
tools/perf/arch/s390/util/kvm-stat.c [deleted file]
tools/perf/arch/x86/Makefile
tools/perf/arch/x86/util/Build
tools/perf/arch/x86/util/kvm-stat.c [deleted file]
tools/perf/builtin-kvm.c
tools/perf/util/Build
tools/perf/util/kvm-stat-arch/Build [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/arm64_exception_types.h [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/book3s_hcalls.h [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/book3s_hv_exits.h [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/kvm-stat-arm64.c [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/kvm-stat-loongarch.c [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/kvm-stat-s390.c [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/kvm-stat-x86.c [new file with mode: 0644]
tools/perf/util/kvm-stat-arch/riscv_trap_types.h [new file with mode: 0644]
tools/perf/util/kvm-stat.c
tools/perf/util/kvm-stat.h