Linus Torvalds
2f0a750453
Merge tag 'x86_cleanups_for_v6.18_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
...
Pull x86 cleanups from Borislav Petkov:
- Simplify inline asm flag output operands now that the minimum
compiler version supports the =@ccCOND syntax
- Remove a bunch of AS_* Kconfig symbols which detect assembler support
for various instruction mnemonics now that the minimum assembler
version supports them all
- The usual cleanups all over the place
* tag 'x86_cleanups_for_v6.18_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/asm: Remove code depending on __GCC_ASM_FLAG_OUTPUTS__
x86/sgx: Use ENCLS mnemonic in <kernel/cpu/sgx/encls.h>
x86/mtrr: Remove license boilerplate text with bad FSF address
x86/asm: Use RDPKRU and WRPKRU mnemonics in <asm/special_insns.h>
x86/idle: Use MONITORX and MWAITX mnemonics in <asm/mwait.h>
x86/entry/fred: Push __KERNEL_CS directly
x86/kconfig: Remove CONFIG_AS_AVX512
crypto: x86 - Remove CONFIG_AS_VPCLMULQDQ
crypto: X86 - Remove CONFIG_AS_VAES
crypto: x86 - Remove CONFIG_AS_GFNI
x86/kconfig: Drop unused and needless config X86_64_SMP
2025-10-11 10:51:14 -07:00
Linus Torvalds
ec714e371f
Merge tag 'perf-tools-for-v6.18-1-2025-10-08' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
...
Pull perf tools updates from Arnaldo Carvalho de Melo:
- Extended 'perf annotate' with DWARF type information
(--code-with-type) integration in the TUI, including a 'T'
hotkey to toggle it
- Enhanced 'perf bench mem' with new mmap() workloads and control
over page/chunk sizes
- Fix 'perf stat' error handling to correctly display unsupported
events
- Improved support for Clang cross-compilation
- Refactored LLVM and Capstone disasm for modularity
- Introduced the :X modifier to exclude an event from automatic
regrouping
- Adjusted KVM sampling defaults to use the "cycles" event to prevent
failures
- Added comprehensive support for decoding PowerPC Dispatch Trace Log
(DTL)
- Updated Arm SPE tracing logic for better analysis of memory and snoop
details
- Synchronized Intel PMU events and metrics with TMA 5.1 across
multiple processor generations
- Converted dependencies like libperl and libtracefs to be opt-in
- Handle more Rust symbols in kallsyms ('N', debugging)
- Improve the python binding to allow for python based tools to use
more of the libraries, add a 'ilist' utility to test those new
bindings
- Various 'perf test' fixes
- Kan Liang no longer a perf tools reviewer
* tag 'perf-tools-for-v6.18-1-2025-10-08' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: (192 commits)
perf tools: Fix arm64 libjvmti build by generating unistd_64.h
perf tests: Don't retest sections in "Object code reading"
perf docs: Document building with Clang
perf build: Support build with clang
perf test coresight: Dismiss clang warning for unroll loop thread
perf test coresight: Dismiss clang warning for thread loop
perf test coresight: Dismiss clang warning for memcpy thread
perf build: Disable thread safety analysis for perl header
perf build: Correct CROSS_ARCH for clang
perf python: split Clang options when invoking Popen
tools build: Align warning options with perf
perf disasm: Remove unused evsel from 'struct annotate_args'
perf srcline: Fallback between addr2line implementations
perf disasm: Make ins__scnprintf() and ins__is_nop() static
perf dso: Clean up read_symbol() error handling
perf dso: Support BPF programs in dso__read_symbol()
perf dso: Move read_symbol() from llvm/capstone to dso
perf llvm: Reduce LLVM initialization
perf check: Add libLLVM feature
perf parse-events: Fix parsing of >30kb event strings
...
2025-10-08 19:24:24 -07:00
Vincent Minet
f3b601f900
perf tools: Fix arm64 libjvmti build by generating unistd_64.h
...
Since commit 22f72088ff ("tools headers: Update the syscall table with
the kernel sources") the arm64 syscall header is generated at build
time. Later, commit bfb713ea53 ("perf tools: Fix arm64 build by
generating unistd_64.h") added a dependency to libperf to guarantee that
this header was created before building libperf or perf itself.
However, libjvmti also requires this header but does not depend on
libperf, leading to build failures such as:
In file included from /usr/include/sys/syscall.h:24,
from /usr/include/syscall.h:1,
from jvmti/jvmti_agent.c:36:
tools/arch/arm64/include/uapi/asm/unistd.h:2:10: fatal error: asm/unistd_64.h: No such file or directory
2 | #include <asm/unistd_64.h>
Fix this by ensuring that libperf is built before libjvmti, so that
unistd_64.h is always available.
Fixes: 22f72088ff ("tools headers: Update the syscall table with the kernel sources")
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Vincent Minet <v.minet@criteo.com >
Link: https://lore.kernel.org/r/20250922053702.2688374-1-v.minet@criteo.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 17:16:52 -03:00
James Clark
5205c3d002
perf tests: Don't retest sections in "Object code reading"
...
We already only test each kcore map once, but on slow systems
(particularly with network filesystems) even the non-kcore maps are
slow.
The test can test the same objdump output over and over which only wastes
time. Generalize the skipping mechanism to track all DSOs and addresses
so that each section is only tested once.
On a fully loaded ARM Juno (simulating a parallel 'perf test' run) with
a network filesystem, the original runtime is:
real 1m51.126s
user 0m19.445s
sys 1m15.431s
And the new runtime is:
real 0m48.873s
user 0m8.031s
sys 0m32.353s
Committer testing:
# perf test "code read"
22: Object code reading : Ok
#
Reviewed-by: Ian Rogers <irogers@google.com >
Signed-off-by: James Clark <james.clark@linaro.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Leo Yan <leo.yan@arm.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:59:11 -03:00
Leo Yan
0a75ba3e84
perf docs: Document building with Clang
...
Add example commands for building perf with Clang.
Since recent Android NDK releases use Clang as the default compiler, a
separate Android specific document is no longer needed; point to the
general build documentation instead.
Signed-off-by: Leo Yan <leo.yan@arm.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20251006-perf_build_android_ndk-v3-9-4305590795b2@arm.com
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Arnaldo Carvalho de Melo <acme@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: linux-riscv@lists.infradead.org
Cc: llvm@lists.linux.dev
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:49:25 -03:00
Leo Yan
4772e66cb4
perf build: Support build with clang
...
Add support for building perf with clang. For cross compilation, the
Makefile dynamically selects target flag for corresponding arch.
This patch has been verified on x86_64 machine with Ubuntu distro, it
can build successfully for native target, and for cross building Arm64
and s390.
Example: native build on x86_64 / Ubuntu machine:
$ HOSTCC=clang CC=clang CXX=clang++ make -C tools/perf
Example: cross building s390 target on x86_64 / Ubuntu machine:
# Install x390x cross toolchain and headers
$ sudo apt-get install gcc-s390x-linux-gnu g++-s390x-linux-gnu \
libc6-dev-s390x-cross linux-libc-dev-s390x-cross
# Build with clang
$ HOSTCC=clang CC=clang CXX=clang++ \
ARCH=s390 CROSS_COMPILE=s390x-linux-gnu- \
make -C tools/perf NO_LIBELF=1 NO_LIBTRACEEVENT=1 NO_LIBPYTHON=1
Signed-off-by: Leo Yan <leo.yan@arm.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20251006-perf_build_android_ndk-v3-8-4305590795b2@arm.com
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Arnaldo Carvalho de Melo <acme@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: linux-riscv@lists.infradead.org
Cc: llvm@lists.linux.dev
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:49:25 -03:00
Leo Yan
9ec46fc938
perf test coresight: Dismiss clang warning for unroll loop thread
...
clang-18.1.3 on Ubuntu 24.04.2 reports warning:
unroll_loop_thread.c:35:25: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
35 | : /* in */ [in] "r" (in)
| ^
unroll_loop_thread.c:39:1: warning: non-void function does not return a value [-Wreturn-type]
39 | }
| ^
Use the modifier "w" for 32-bit register access and return NULL at the
end of thread function.
Signed-off-by: Leo Yan <leo.yan@arm.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20251006-perf_build_android_ndk-v3-7-4305590795b2@arm.com
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Arnaldo Carvalho de Melo <acme@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: linux-riscv@lists.infradead.org
Cc: llvm@lists.linux.dev
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:49:25 -03:00
Leo Yan
244a1ac76a
perf test coresight: Dismiss clang warning for thread loop
...
clang-18.1.3 on Ubuntu 24.04.2 reports warning:
thread_loop.c:41:23: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
41 | : /* in */ [i] "r" (i), [len] "r" (len)
| ^
thread_loop.c:37:8: note: use constraint modifier "w"
37 | "add %[i], %[i], #1\n"
| ^~~~
| %w[i]
thread_loop.c:41:23: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
41 | : /* in */ [i] "r" (i), [len] "r" (len)
| ^
thread_loop.c:37:14: note: use constraint modifier "w"
37 | "add %[i], %[i], #1\n"
| ^~~~
| %w[i]
thread_loop.c:41:23: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
41 | : /* in */ [i] "r" (i), [len] "r" (len)
| ^
thread_loop.c:38:8: note: use constraint modifier "w"
38 | "cmp %[i], %[len]\n"
| ^~~~
| %w[i]
thread_loop.c:41:38: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
41 | : /* in */ [i] "r" (i), [len] "r" (len)
| ^
thread_loop.c:38:14: note: use constraint modifier "w"
38 | "cmp %[i], %[len]\n"
| ^~~~~~
| %w[len]
Use the modifier "w" for 32-bit register access.
Signed-off-by: Leo Yan <leo.yan@arm.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20251006-perf_build_android_ndk-v3-6-4305590795b2@arm.com
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Arnaldo Carvalho de Melo <acme@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: linux-riscv@lists.infradead.org
Cc: llvm@lists.linux.dev
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:49:25 -03:00
Leo Yan
50b7e7082a
perf test coresight: Dismiss clang warning for memcpy thread
...
clang-18.1.3 on Ubuntu 24.04.2 reports warning:
memcpy_thread.c:30:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
30 | }
| ^
Dismiss the warning with returning NULL from the thread function.
Signed-off-by: Leo Yan <leo.yan@arm.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20251006-perf_build_android_ndk-v3-5-4305590795b2@arm.com
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Arnaldo Carvalho de Melo <acme@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: linux-riscv@lists.infradead.org
Cc: llvm@lists.linux.dev
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:49:25 -03:00
Leo Yan
e7e86d7697
perf build: Disable thread safety analysis for perl header
...
When build with perl5, it reports error:
In file included from /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:7933:
/usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/inline.h:298:5: error:
mutex 'PL_env_mutex.lock' is not held on every path through
here [-Werror,-Wthread-safety-analysis]
298 | ENV_UNLOCK;
| ^
/usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:7091:31: note:
expanded from macro 'ENV_UNLOCK'
7091 | # define ENV_UNLOCK PERL_REENTRANT_UNLOCK("env"...
| ^
/usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:6465:7: note:
expanded from macro 'PERL_REENTRANT_UNLOCK'
6465 | } STMT_END
| ^
/usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:865:28: note:
expanded from macro 'STMT_END'
865 | # define STMT_END while (0)
| ^
The error is caused by perl header but not perf code, disable thread
safety analysis if including the header.
Though GCC does not support the thread safety analysis option, this
negative warning flag is silently ignored by it.
Signed-off-by: Leo Yan <leo.yan@arm.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20251006-perf_build_android_ndk-v3-4-4305590795b2@arm.com
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Arnaldo Carvalho de Melo <acme@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: linux-riscv@lists.infradead.org
Cc: llvm@lists.linux.dev
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:49:25 -03:00
Leo Yan
ed33e5e43c
perf build: Correct CROSS_ARCH for clang
...
Clang's -dumpmachine outputs "aarch64-unknown-linux-gnu", which does not
match the MultiArch convention. This prevents the build system from
detecting installed packages.
Fix by stripping the trailing '-' from CROSS_COMPILE when setting
CROSS_ARCH.
Signed-off-by: Leo Yan <leo.yan@arm.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20251006-perf_build_android_ndk-v3-3-4305590795b2@arm.com
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Arnaldo Carvalho de Melo <acme@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: linux-riscv@lists.infradead.org
Cc: llvm@lists.linux.dev
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:49:25 -03:00
Leo Yan
c6a43bc3e8
perf python: split Clang options when invoking Popen
...
When passing a list to subprocess.Popen, each element maps to one argv
token. Current code bundles multiple Clang flags into a single element,
something like:
cmd = ['clang',
'--target=x86_64-linux-gnu -fintegrated-as -Wno-cast-function-type-mismatch',
'test-hello.c']
So Clang only sees one long, invalid option instead of separate flags,
as a result, the script cannot capture any log via PIPE.
Fix this by using shlex.split() to separate the string so each option
becomes its own argv element. The fixed list will be:
cmd = ['clang',
'--target=x86_64-linux-gnu',
'-fintegrated-as',
'-Wno-cast-function-type-mismatch',
'test-hello.c']
Fixes: 09e6f9f983 ("perf python: Fix splitting CC into compiler and options")
Signed-off-by: Leo Yan <leo.yan@arm.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20251006-perf_build_android_ndk-v3-2-4305590795b2@arm.com
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Arnaldo Carvalho de Melo <acme@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: linux-riscv@lists.infradead.org
Cc: llvm@lists.linux.dev
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:49:24 -03:00
Ian Rogers
e3b08a0664
perf disasm: Remove unused evsel from 'struct annotate_args'
...
Set in symbol__annotate() but never used.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:47:51 -03:00
Ian Rogers
257046a367
perf srcline: Fallback between addr2line implementations
...
Factor the addr2line function implementation into separate source files
(addr2line.[ch]) and rename the addr2line function cmd__addr2line. In
srcline replace the ifdef-ed addr2line implementations with one that
first tries the llvm__addr2line implementation, then the deprecated
libbfd__addr2line function and on failure uses cmd__addr2line.
If HAVE_LIBLLVM_SUPPORT is enabled the llvm__addr2line will execute
against the libLLVM.so it is linked against.
If HAVE_LIBLLVM_DYNAMIC is enabled then libperf-llvm.so (that links
against libLLVM.so) will be dlopened. If the dlopen succeeds then the
behavior should match HAVE_LIBLLVM_SUPPORT. On failure cmd__addr2line is
used. The dlopen is only tried once.
If HAVE_LIBLLVM_DYNAMIC isn't enabled then llvm__addr2line immediately
fails and cmd__addr2line is used.
Clean up the dso__free_a2l logic, which is only needed in the non-LLVM
version and moved to addr2line.c.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:47:49 -03:00
Ian Rogers
fa770f1a9d
perf disasm: Make ins__scnprintf() and ins__is_nop() static
...
Reduce the scope of ins__scnprintf() and ins__is_nop() that aren't used
outside of disasm.c.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:35:29 -03:00
Ian Rogers
bca753204e
perf dso: Clean up read_symbol() error handling
...
Ensure errno is set and return to caller for error handling.
Unusually for perf the value isn't negated as expected by
symbol__strerror_disassemble().
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:35:28 -03:00
Ian Rogers
aa04707f50
perf dso: Support BPF programs in dso__read_symbol()
...
Set the buffer to the code in the BPF linear info. This enables BPF
JIT code disassembly by LLVM and capstone.
Move the common but minimal disassmble_bpf_image call to
disassemble_objdump so that it is only called after falling back to the
objdump option.
Similarly move the disassmble_bpf function to disassemble_objdump and
rename to disassmble_bpf_libbfd to make it clearer that this support
relies on libbfd.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:35:28 -03:00
Ian Rogers
9518e10c2b
perf dso: Move read_symbol() from llvm/capstone to dso
...
Move the read_symbol function to dso.h, make the return type const and
add a mutable out_buf out parameter.
In future changes this will allow a code pointer to be returned without
necessary allocating memory.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:35:25 -03:00
Ian Rogers
0e52f3f9f1
perf llvm: Reduce LLVM initialization
...
Move the 3 LLVM initialization routines to be called in a single
init_llvm function that has its own bool to avoid repeated
initialization.
Reduce the scope of triplet and avoid copying strings for x86.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
[ Move init_llvm() under HAVE_LIBLLVM_SUPPORT to fix the build ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:27:07 -03:00
Ian Rogers
e444c2d4a2
perf check: Add libLLVM feature
...
Advertise when perf is built with the HAVE_LIBLLVM_SUPPORT option.
Committer testing:
$ perf -vv | grep LLVM
libLLVM: [ on ] # HAVE_LIBLLVM_SUPPORT
$
And the form to use in scripts, notably the tools/perf/tests/shell/
'perf test' ones:
$ perf check feature libllvm
libLLVM: [ on ] # HAVE_LIBLLVM_SUPPORT
$ perf check -q feature libllvm && echo LLVM is present
LLVM is present
$ perf check -q feature liballvm && echo ALLVM is present
$
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 15:24:13 -03:00
Ian Rogers
a22d167ed8
perf parse-events: Fix parsing of >30kb event strings
...
Metrics may generate many particularly uncore event references. The
resulting event string may then be >32kb. The parse events lex is
using "%option reject" which stores backtracking state in a buffer
sized at roughtly 30kb. If the event string is larger than this then a
buffer overflow and typically a crash happens.
The need for "%option reject" was for BPF events which were removed in
commit 3d6dfae889 ("perf parse-events: Remove BPF event
support"). As "%option reject" is both a memory and performance cost
let's remove it and fix the parsing case for event strings being over
~30kb.
Whilst cleaning up "%option reject" make the header files accurately
reflect functions used in the code and tidy up not requiring yywrap.
Measuring on the "PMU JSON event tests" a modest reduction of 0.41%
user time and 0.27% max resident size was observed. More importantly
this change fixes parsing large metrics and event strings.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 19:06:19 -03:00
Thomas Falcon
56be0fe5f6
perf record: Add auto counter reload parse and regression tests
...
Include event parsing and regression tests for auto counter reload
and ratio-to-prev event term.
Reviewed-by: Ian Rogers <irogers@google.com >
Signed-off-by: Thomas Falcon <thomas.falcon@intel.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 16:49:51 -03:00
Thomas Falcon
6b9c0261b3
perf record: Add ratio-to-prev term
...
Provide ratio-to-prev term which allows the user to
set the event sample period of two events corresponding
to a desired ratio.
If using on an Intel x86 platform with Auto Counter Reload support, also
set corresponding event's config2 attribute with a bitmask which
counters to reset and which counters to sample if the desired ratio is
met or exceeded.
On other platforms, only the sample period is affected by the
ratio-to-prev term.
Reviewed-by: Ian Rogers <irogers@google.com >
Signed-off-by: Thomas Falcon <thomas.falcon@intel.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 16:49:51 -03:00
Ian Rogers
2bd597170f
perf bpf-event: Use libbpf version rather than feature check
...
The feature check guarded the -DHAVE_LIBBPF_STRINGS_SUPPORT is
unnecessary as it is sufficient and easier to use the
LIBBPF_CURRENT_VERSION_GEQ macro.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Blake Jones <blakejones@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 16:49:51 -03:00
Ian Rogers
a90777bb03
perf build: Move libopcode disasm tests to BUILD_NONDISTRO
...
The disasm feature tests feature-disassembler-four-args and
feature-disassembler-init-styled link against libopcodes part of
binutils which is license incompatible (GPLv3) with perf. Moving these
tests out of the common config will help improve build time.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 16:49:51 -03:00
Ian Rogers
c5b76ab525
tools build: Remove feature-libslang-include-subdir
...
Added in commit cbefd24f0a ("tools build: Add test to check if
slang.h is in /usr/include/slang/") this feature was to fix build
support on now unsupported versions of RHEL 5 and 6. As 6 years has
passed let's remove the workaround.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 16:49:51 -03:00
Zecheng Li
a5099d8143
perf annotate: Rename TSR_KIND_POINTER to TSR_KIND_PERCPU_POINTER
...
TSR_KIND_POINTER only represents percpu pointers currently. Rename it to
TSR_KIND_PERCPU_POINTER so we can use the TSR_KIND_POINTER to represent
pointer to a type.
Reviewed-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Zecheng Li <zecheng@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Xu Liu <xliuprof@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 16:49:51 -03:00
Ian Rogers
2cc7aa995c
perf stat: Refactor retry/skip/fatal error handling
...
For the sake of Intel topdown events commit 9eac5612da ("perf
stat: Don't skip failing group events") changed 'perf stat' error
handling making it so that more errors were fatal and didn't report
"<not supported>" events. The change outside of topdown events was
unintentional.
The notion of "fatal" error handling was introduced in commit
e0e6a6ca3a ("perf stat: Factor out open error handling") and
refined in commits like commit cb5ef60067 ("perf stat: Error out
unsupported group leader immediately") to be an approach for avoiding
later assertion failures in the code base.
This change fixes those issues and removes the notion of a fatal error
on an event. If all events fail to open then a fatal error occurs with
the previous fatal error message. This seems to best match the notion of
supported events and allowing some errors not to stop 'perf stat', while
allowing the truly fatal no event case to terminate the tool early.
The evsel->errored flag is only used in the stat code but always just
meaning !evsel->supported although there is a comment about it being
sticky. Force all evsels to be supported in evsel__init and then clear
this when evsel__open fails. When an event is tried the supported is
set to true again. This simplifies the notion of whether an evsel is
broken.
In the get_group_fd code, fail to get a group fd when the evsel isn't
supported. If the leader isn't supported then it is also expected that
there is no group_fd as the leader will have been skipped. Therefore
change the BUG_ON test to be on supported rather than skippable. This
corrects the assertion errors that were the reason for the previous
fatal error handling.
Fixes: 9eac5612da ("perf stat: Don't skip failing group events")
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Chun-Tse Shao <ctshao@google.com >
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Link: https://lore.kernel.org/r/20251002220727.1889799-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 16:49:51 -03:00
Ian Rogers
6026ab657a
perf stat: Move create_perf_stat_counter() to builtin-stat.c
...
The function create_perf_stat_counter is only used in builtin-stat.c
and contains logic about retrying events specific to
builtin-stat.c.
Move the code to builtin-stat.c to tidy this up.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Chun-Tse Shao <ctshao@google.com >
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 16:49:51 -03:00
Ian Rogers
062d02a96d
perf namespaces: Avoid get_current_dir_name dependency
...
get_current_dir_name is a GNU extension not supported on, for example,
Android. There is only one use of it so let's just switch to getcwd to
avoid build and other complexity.
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-03 15:28:04 -03:00
Ian Rogers
2836ed1748
perf capstone: Remove open_capstone_handle
...
open_capstone_handle is similar to capstone_init and used only by
symbol__disassemble_capstone. symbol__disassemble_capstone_powerpc
already uses capstone_init, transition symbol__disassemble_capstone
and eliminate open_capstone_handle.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:40:54 -03:00
Ian Rogers
95931d9a59
perf libbfd: Move libbfd functionality to its own file
...
Move symbolization and srcline libbfd dependencies to a separate
libbfd.c. This mirrors moving llvm and capstone code. While this code
is deprecated as it is part of BUILD_NONDISTRO license incompatible
code, moving the code to its own file minimizes disruption in the main
files.
disasm_bpf.c is moved to libbfd.c also except for
symbol__disassemble_bpf_image which is currently more of a placeholder
function rather than something that provides disassembly support.
demangle-cxx.cpp code isn't migrated as it is very limited.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:39:44 -03:00
Ian Rogers
d9007afca0
perf llvm: Move llvm functionality into its own file
...
LLVM disassembly support was in disasm.c and addr2line support in
srcline.c. Move support out of these files into llvm.[ch] and remove
LLVM includes from those files. As disassembly routines can fail, make
failure the only option without HAVE_LIBLLVM_SUPPORT. For simplicity's
sake, duplicate the read_symbol utility function.
The intent with moving LLVM support into a single file is that dynamic
support, using dlopen for libllvm, can be added in later patches. This
can potentially always succeed or fail, so relying on ifdefs isn't
sufficient. Using dlopen is a useful option to minimize the perf tools
dependencies and potentially size.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:38:23 -03:00
Ian Rogers
bbb99668b5
perf capstone: Move capstone functionality into its own file
...
Capstone disassembly support was split between disasm.c and
print_insn.c. Move support out of these files into capstone.[ch] and
remove include capstone/capstone.h from those files. As disassembly
routines can fail, make failure the only option without
HAVE_LIBCAPSTONE_SUPPORT. For simplicity's sake, duplicate the
read_symbol utility function.
The intent with moving capstone support into a single file is that
dynamic support, using dlopen for libcapstone, can be added in later
patches. This can potentially always succeed or fail, so relying on
ifdefs isn't sufficient. Using dlopen is a useful option to minimize
the perf tools dependencies and potentially size.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:36:59 -03:00
Ian Rogers
c0b8a55a11
perf map: Constify objdump offset/address conversion APIs
...
Make the map argument const as the conversion act won't modify the map
and this allows other callers to use a const struct map.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:36:13 -03:00
Dapeng Mi
cbeb3d4784
perf tools kvm: Use "cycles" to sample guest for "kvm top" on Intel
...
As same reason with previous patch, use "cyles" instead of "cycles:P"
event by default to sample guest for "perf kvm top" command on Intel
platforms.
Fixes: cf8e55fe50 ("KVM: x86/pmu: Expose CPUIDs feature bits PDCM, DS, DTES64")
Reported-by: Kevin Tian <kevin.tian@intel.com >
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Like Xu <likexu@tencent.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:31:55 -03:00
Dapeng Mi
c1afca106e
perf tools kvm: Use "cycles" to sample guest for "kvm record" on Intel
...
After KVM supports PEBS for guest on Intel platforms
(https://lore.kernel.org/all/20220411101946.20262-1-likexu@tencent.com/ ),
host loses the capability to sample guest with PEBS since all PEBS related
MSRs are switched to guest value after vm-entry, like IA32_DS_AREA MSR is
switched to guest GVA at vm-entry. This would lead to "perf kvm record"
fails to sample guest on Intel platforms since "cycles:P" event is used to
sample guest by default as below case shows.
sudo perf kvm record -a
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.787 MB perf.data.guest ]
So to ensure guest record can be sampled successfully, use "cycles"
instead of "cycles:P" to sample guest record by default on Intel
platforms. With this patch, the guest record can be sampled
successfully.
sudo perf kvm record -a
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.783 MB perf.data.guest (23 samples) ]
Fixes: cf8e55fe50 ("KVM: x86/pmu: Expose CPUIDs feature bits PDCM, DS, DTES64")
Reported-by: Kevin Tian <kevin.tian@intel.com >
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Like Xu <likexu@tencent.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:31:39 -03:00
Dapeng Mi
0f53264d71
perf tools: Add helper x86__is_intel_cpu()
...
Add helper x86__is_intel_cpu() to indicate if it's a x86 intel platform.
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:31:14 -03:00
Dapeng Mi
45ff39f6e7
perf tools kvm: Fix the potential out of range memory access issue
...
kvm_add_default_arch_event() helper may add 2 extra options but it
directly modifies the original argv[] array. This may cause out of range
memory access. Fix this issue.
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:31:00 -03:00
Dapeng Mi
6f58cf1045
perf tools kwork: Add missed memory allocation check and free
...
Same with previous builtin-kvm code, perf_kwork__record() doesn't check
the memory allocation and explicitly free the allocated memory. Just fix
it.
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:30:30 -03:00
Dapeng Mi
9262fa242b
perf tools kvm: Add missed memory allocation check and free
...
Current code allocates rec_argv[] array, but doesn't check if the
allocation is successful and explicitly free the rec_argv[] array.
Add them back.
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:30:21 -03:00
Ian Rogers
f0015d8149
tools include: Add headers to make tools builds more hermetic
...
tools/lib/bpf/netlink.c depends on rtnetlink.h and genetlink.h (via
nlattr.h) which then depends on if_addr.h.
tools/bpf/bpftool/link.c depends on netfilter_arp.h which then depends
on netfilter.h.
Update check-headers.sh to keep these in sync.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: André Almeida <andrealmeid@igalia.com >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Darren Hart <dvhart@infradead.org >
Cc: David S. Miller <davem@davemloft.net >
Cc: Davidlohr Bueso <dave@stgolabs.net >
Cc: Ido Schimmel <idosch@nvidia.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Jamal Hadi Salim <jhs@mojatatu.com >
Cc: Jason Xing <kerneljasonxing@gmail.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Jonas Gottlieb <jonas.gottlieb@stackit.cloud >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Maurice Lambert <mauricelambert434@gmail.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Paolo Abeni <pabeni@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Petr Machata <petrm@nvidia.com >
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yury Norov <yury.norov@gmail.com >
Cc: Yuyang Huang <yuyanghuang@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:13:19 -03:00
Ian Rogers
57a64919f2
tools include: Replace tools linux/gfp_types.h with kernel version
...
Previously the header gfp_types.h in tools points to the gfp_types.h
in include/linux. This is a problem for tools like perf, since the
tools header is supposed to be independent of the kernel
headers.
Therefore this patch copies the kernel header to the tools header and
adds a header check.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: André Almeida <andrealmeid@igalia.com >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Darren Hart <dvhart@infradead.org >
Cc: David S. Miller <davem@davemloft.net >
Cc: Davidlohr Bueso <dave@stgolabs.net >
Cc: Ido Schimmel <idosch@nvidia.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Jamal Hadi Salim <jhs@mojatatu.com >
Cc: Jason Xing <kerneljasonxing@gmail.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Jonas Gottlieb <jonas.gottlieb@stackit.cloud >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Maurice Lambert <mauricelambert434@gmail.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Paolo Abeni <pabeni@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Petr Machata <petrm@nvidia.com >
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yury Norov <yury.norov@gmail.com >
Cc: Yuyang Huang <yuyanghuang@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:11:03 -03:00
Ian Rogers
83fde0ee8f
perf bench futex: Add missing stdbool.h
...
futex.h uses bool but lacks stdbool.h which causes build failures in
some build systems. Add the missing #include.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: André Almeida <andrealmeid@igalia.com >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Darren Hart <dvhart@infradead.org >
Cc: David S. Miller <davem@davemloft.net >
Cc: Davidlohr Bueso <dave@stgolabs.net >
Cc: Ido Schimmel <idosch@nvidia.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Jamal Hadi Salim <jhs@mojatatu.com >
Cc: Jason Xing <kerneljasonxing@gmail.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Jonas Gottlieb <jonas.gottlieb@stackit.cloud >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Maurice Lambert <mauricelambert434@gmail.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Paolo Abeni <pabeni@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Petr Machata <petrm@nvidia.com >
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yury Norov <yury.norov@gmail.com >
Cc: Yuyang Huang <yuyanghuang@google.com >
Link: https://lore.kernel.org/r/20250905224708.2469021-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:08:44 -03:00
Ian Rogers
a272195f1c
perf test: Stat std output don't fail metric only
...
When running on a hypervisor the expected IPC metric may be missing as
the events may fail to be read. Don't expect metric output for this
test to avoid it failing.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Veronika Molnarova <vmolnaro@redhat.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:05:41 -03:00
Ian Rogers
de1111f91a
perf symbol-minimal: Be more defensive when reading build IDs
...
The note_data at ptr is read as a nhdr but this may yield
out-of-bounds reads if there isn't nhdrs worth of data.
Be more defensive before doing the reads.
This is motivated by address sanitizer capturing out of bounds reads
running "perf top".
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 15:01:26 -03:00
Sam James
4fc844347e
perf bpf: Use __builtin_preserve_field_info for GCC compatibility
...
When exploring building bpf_skel with GCC's BPF support, there was a
build failure because of bpf_core_field_exists vs the mem_hops bitfield:
```
In file included from util/bpf_skel/sample_filter.bpf.c:6:
util/bpf_skel/sample_filter.bpf.c: In function 'perf_get_sample':
tools/perf/libbpf/include/bpf/bpf_core_read.h:169:42: error: cannot take address of bit-field 'mem_hops'
169 | #define ___bpf_field_ref1(field) (&(field))
| ^
tools/perf/libbpf/include/bpf/bpf_helpers.h:222:29: note: in expansion of macro '___bpf_field_ref1'
222 | #define ___bpf_concat(a, b) a ## b
| ^
tools/perf/libbpf/include/bpf/bpf_helpers.h:225:29: note: in expansion of macro '___bpf_concat'
225 | #define ___bpf_apply(fn, n) ___bpf_concat(fn, n)
| ^~~~~~~~~~~~~
tools/perf/libbpf/include/bpf/bpf_core_read.h:173:9: note: in expansion of macro '___bpf_apply'
173 | ___bpf_apply(___bpf_field_ref, ___bpf_narg(args))(args)
| ^~~~~~~~~~~~
tools/perf/libbpf/include/bpf/bpf_core_read.h:188:39: note: in expansion of macro '___bpf_field_ref'
188 | __builtin_preserve_field_info(___bpf_field_ref(field), BPF_FIELD_EXISTS)
| ^~~~~~~~~~~~~~~~
util/bpf_skel/sample_filter.bpf.c:167:29: note: in expansion of macro 'bpf_core_field_exists'
167 | if (bpf_core_field_exists(data->mem_hops))
| ^~~~~~~~~~~~~~~~~~~~~
cc1: error: argument is not a field access
```
___bpf_field_ref1 was adapted for GCC in 12bbcf8e84
but the trick added for compatibility in 3a8b8fc317
isn't compatible with that as an address is used as an argument.
Workaround this by calling __builtin_preserve_field_info directly as the
bpf_core_field_exists macro does, but without the ___bpf_field_ref use.
Co-developed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com >
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com >
Signed-off-by: Sam James <sam@gentoo.org >
Acked-by: Yonghong Song <yonghong.song@linux.dev >
Tested-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://gcc.gnu.org/PR121420
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 14:57:07 -03:00
Ian Rogers
b19a0f6100
perf build: Remove libtracefs configuration
...
libtracefs isn't used by perf but not having it installed causes build
warnings.
Given the library isn't used, there is no need for the configuration or
warnings so remove.
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20250929170600.59000-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-02 09:42:59 -03:00
Ian Rogers
d18020cf1e
perf test: Remove C python_use test
...
Removed in favor of the shell script version.
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-01 16:59:11 -03:00
Ian Rogers
33706fb0aa
perf test: Add an 'import perf' test shell script
...
The 'import perf' test needs to set up a path to the python module as
well as to know the python command to invoke.
These are hard coded at build time to be build a directory and the
python used in the build, which is less than desirable.
Avoid the hard coded values by reusing the existing shell script python
setup and determine a potential built python module via the path of the
perf executable.
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-01 16:59:06 -03:00