News from the source  


Content
Weekly Edition
Archives
Search
Kernel
Security
Events calendar
Unread comments

LWN FAQ
Write for us


 




|  
|  


Log in /  Subscribe /  Register  




perf Cross platform KVM support



From:  Ian Rogers <irogers-AT-google.com>
To:  Peter Zijlstra <peterz-AT-infradead.org>, Ingo Molnar <mingo-AT-redhat.com>, Arnaldo Carvalho de Melo <acme-AT-kernel.org>, Namhyung Kim <namhyung-AT-kernel.org>, Alexander Shishkin <alexander.shishkin-AT-linux.intel.com>, Jiri Olsa <jolsa-AT-kernel.org>, Ian Rogers <irogers-AT-google.com>, Adrian Hunter <adrian.hunter-AT-intel.com>, James Clark <james.clark-AT-linaro.org>, John Garry <john.g.garry-AT-oracle.com>, Will Deacon <will-AT-kernel.org>, Mike Leach <mike.leach-AT-linaro.org>, Leo Yan <leo.yan-AT-linux.dev>, Paul Walmsley <pjw-AT-kernel.org>, Palmer Dabbelt <palmer-AT-dabbelt.com>, Albert Ou <aou-AT-eecs.berkeley.edu>, Alexandre Ghiti <alex-AT-ghiti.fr>, Shimin Guo <shimin.guo-AT-skydio.com>, Yunseong Kim <ysk-AT-kzalloc.com>, Athira Rajeev <atrajeev-AT-linux.ibm.com>, Quan Zhou <zhouquan-AT-iscas.ac.cn>, Andrew Jones <ajones-AT-ventanamicro.com>, Anup Patel <anup-AT-brainfault.org>, Dapeng Mi <dapeng1.mi-AT-linux.intel.com>, Thomas Falcon <thomas.falcon-AT-intel.com>, Blake Jones <blakejones-AT-google.com>, Swapnil Sapkal <swapnil.sapkal-AT-amd.com>, Kan Liang <kan.liang-AT-linux.intel.com>, Howard Chu <howardchu95-AT-gmail.com>, Anubhav Shelat <ashelat-AT-redhat.com>, Aditya Bodkhe <aditya.b1-AT-linux.ibm.com>, Chun-Tse Shao <ctshao-AT-google.com>, Andi Kleen <ak-AT-linux.intel.com>, Dmitry Vyukov <dvyukov-AT-google.com>, linux-kernel-AT-vger.kernel.org, linux-perf-users-AT-vger.kernel.org, linux-arm-kernel-AT-lists.infradead.org, linux-riscv-AT-lists.infradead.org
Subject:  [PATCH v2 0/6] perf Cross platform KVM support
Date:  Sat, 31 Jan 2026 12:02:18 -0800
Message-ID:  <20260131200224.1296136-1-irogers@google.com>
Archive-link:  Article
The existing perf kvm code is using the arch directory, which means a
data file can only be processed on the same machine type that it was
recorded. Switch to using the ELF machine of the session at runtime to
set up the KVM support, making it cross-architectural. So that the ELF
machine number is available early in initialization add it to the perf
data file header.

v2: Wire up the perf data header to have the e_machine and allow early
    initialization of the KVM operations based upon it.
v1: https://lore.kernel.org/lkml/20260128074106.788156-1-irog...

Ian Rogers (6):
  perf test kvm: Add stat live testing
  perf kvm stat: Remove use of the arch directory
  perf kvm: Wire up e_machine
  perf session: Add e_flags to the e_machine helper
  perf header: Add e_machine/e_flags to the header
  perf thread: Don't require machine to compute the e_machine

 tools/perf/Makefile.config                    |   4 -
 tools/perf/arch/arm64/Makefile                |   1 -
 tools/perf/arch/arm64/util/Build              |   1 -
 tools/perf/arch/loongarch/Makefile            |   1 -
 tools/perf/arch/loongarch/util/Build          |   1 -
 tools/perf/arch/powerpc/Makefile              |   1 -
 tools/perf/arch/powerpc/util/Build            |   1 -
 tools/perf/arch/riscv/Makefile                |   1 -
 tools/perf/arch/riscv/util/Build              |   2 -
 tools/perf/arch/s390/Makefile                 |   1 -
 tools/perf/arch/s390/util/Build               |   1 -
 tools/perf/arch/x86/Makefile                  |   1 -
 tools/perf/arch/x86/util/Build                |   1 -
 tools/perf/builtin-kvm.c                      |  73 +++---
 tools/perf/builtin-report.c                   |   4 +-
 tools/perf/builtin-script.c                   |   6 +-
 tools/perf/tests/shell/kvm.sh                 |  30 ++-
 tools/perf/util/Build                         |   3 +-
 tools/perf/util/env.h                         |   3 +
 tools/perf/util/evsel.c                       |   6 +-
 tools/perf/util/evsel.h                       |   1 +
 tools/perf/util/header.c                      |  33 +++
 tools/perf/util/header.h                      |   1 +
 tools/perf/util/kvm-stat-arch/Build           |   6 +
 .../kvm-stat-arch}/arm64_exception_types.h    |   0
 .../kvm-stat-arch}/book3s_hcalls.h            |   0
 .../kvm-stat-arch}/book3s_hv_exits.h          |   0
 .../kvm-stat-arch/kvm-stat-arm64.c}           |  43 ++--
 .../kvm-stat-arch/kvm-stat-loongarch.c}       |  48 ++--
 .../kvm-stat-arch/kvm-stat-powerpc.c}         |  61 ++---
 .../kvm-stat-arch/kvm-stat-riscv.c}           |  42 ++--
 .../kvm-stat-arch/kvm-stat-s390.c}            |  38 ++--
 .../kvm-stat-arch/kvm-stat-x86.c}             |  44 ++--
 .../kvm-stat-arch}/riscv_trap_types.h         |   2 +-
 tools/perf/util/kvm-stat.c                    | 215 +++++++++++++++++-
 tools/perf/util/kvm-stat.h                    |  70 ++++--
 .../scripting-engines/trace-event-python.c    |   8 +-
 tools/perf/util/session.c                     |  62 ++++-
 tools/perf/util/session.h                     |   2 +-
 tools/perf/util/thread.c                      |   5 +
 40 files changed, 606 insertions(+), 217 deletions(-)
 create mode 100644 tools/perf/util/kvm-stat-arch/Build
 rename tools/perf/{arch/arm64/util => util/kvm-stat-arch}/arm64_exception_types.h (100%)
 rename tools/perf/{arch/powerpc/util => util/kvm-stat-arch}/book3s_hcalls.h (100%)
 rename tools/perf/{arch/powerpc/util => util/kvm-stat-arch}/book3s_hv_exits.h (100%)
 rename tools/perf/{arch/arm64/util/kvm-stat.c => util/kvm-stat-arch/kvm-stat-arm64.c} (62%)
 rename tools/perf/{arch/loongarch/util/kvm-stat.c => util/kvm-stat-arch/kvm-stat-loongarch.c} (77%)
 rename tools/perf/{arch/powerpc/util/kvm-stat.c => util/kvm-stat-arch/kvm-stat-powerpc.c} (78%)
 rename tools/perf/{arch/riscv/util/kvm-stat.c => util/kvm-stat-arch/kvm-stat-riscv.c} (57%)
 rename tools/perf/{arch/s390/util/kvm-stat.c => util/kvm-stat-arch/kvm-stat-s390.c} (77%)
 rename tools/perf/{arch/x86/util/kvm-stat.c => util/kvm-stat-arch/kvm-stat-x86.c} (88%)
 rename tools/perf/{arch/riscv/util => util/kvm-stat-arch}/riscv_trap_types.h (96%)

-- 
2.53.0.rc1.225.gd81095ad13-goog




 




Copyright © 2026, Eklektix, Inc.
  Comments and public postings are copyrighted by their creators.
 Linux is a registered trademark of Linus Torvalds