summaryrefslogtreecommitdiff
path: root/tools/perf/tests
AgeCommit message (Collapse)Author
10 daysperf tests mmap-basic: Fix user rdpmc detection logicJames Clark
RISC-V and Arm control userspace counter access through /proc/sys/kernel/perf_user_access. Add that as a fallback to set_user_read() so the test can exercise both enabled and disabled states on those platforms. Document disabled, enabled and legacy states in user_read_state and fail on values outside the known 0-2 range. Preserve and restore any value in this range, rather than just 0 or 1. Skip when the control files exist but can't be written to (USER_READ_ERR_PERM). We can't rely on always being able to write to them when an exclude_kernel=0 event can be opened because opening events might succeed for non-root users when perf_event_paranoid=-1. This test isn't run on unsupported platforms since the previous commit, so we can simplify the following things: * Test that cap_user_rdpmc is always equal to the requested state rather than checking it only when disabled. As long as we stop setting the cap in the attr unconditionally on Arm, this is ok. * Remove the USER_READ_UNKNOWN/rdpmc_supported fallback in the checks. Now the expected state is always the one requested. USER_READ_UNKNOWN only controls whether to skip restoration of the state on unsupported platforms, so call it USER_READ_ERR_NO_FILE. Signed-off-by: James Clark <james.clark@linaro.org> 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: Ian Rogers <irogers@google.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: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <pjw@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Assisted-by: Codex:GPT-6.1-Sol [Re-write: [Re-write to fix bugs in set_user_read() and simplify tests] Signed-off-by: Qiao Zhao <qzhao@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
10 daysperf tests mmap-basic: Only test userspace reading on supported platformsJames Clark
mmap_user_read_instr() and mmap_user_read_instr_disabled() are the same test for platforms that libperf doesn't support userspace counter reading for. Only run the 'enabled' test for platforms that do support it in order to simplify it in the next commit and not run the same test twice. The test can then assert stronger guarantees and have fewer edge cases to handle as we know it only runs in places where 'rdmpc_supported' will be true. "unsupported" hasn't been a relevant skip reason since commit 588d22b40480 ("perf test: Expand user space event reading (rdpmc) tests") added the UNKNOWN fallback for unsupported platforms. Remove it and leave only "permissions". Signed-off-by: James Clark <james.clark@linaro.org> 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: Ian Rogers <irogers@google.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: Michael Petlan <mpetlan@redhat.com> 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: Qiao Zhao <qzhao@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
10 daysperf debug: Avoid calling eprintf() in pr_debugN() when verbose < nIan Rogers
pr_debugN() unconditionally evaluated its arguments and called eprintf() -> veprintf() before checking if verbose >= n. In hot paths such as dso__load_sym_internal(), two pr_debug4() calls per symbol accounted for ~15% of total CPU time in 'perf top' even at the default verbose == 0. Guard eprintf() in pr_debugN() with unlikely(verbose >= (n)) and define pr_debug() in terms of pr_debugN(1, ...). In test__parsing_callback() (tools/perf/tests/pmu-events.c), move the test_generic_metric(mexp, 0) call out of the pr_debug() argument list so the metric evaluation continues to run during 'perf test' when verbose == 0. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alessio Podda <aleph.pi.gh@gmail.com> Cc: Alireza Haghdoost <haghdoost@uber.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Michael Liang <mliang@purestorage.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Shimin Guo <shimin.guo@skydio.com> Cc: Tanushree Shah <tshah@linux.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-22perf test: Add test for events re-armed with PERF_EVENT_IOC_REFRESHFrancesco Nigro
Open a sampling event with sample_period 1, re-arm it with PERF_EVENT_IOC_REFRESH from its overflow signal handler, as self-profilers such as async-profiler do, and check that each of 1000 events delivers a signal. One case uses a software event (page faults), the other the syscalls:sys_enter_getppid tracepoint. The signal is a real-time one, so overflows cannot be coalesced, and the page fault buffer is marked MADV_NOHUGEPAGE so that each touched page faults once. The tracepoint case fails since commit 18dbcbfabfffc4a5 ("perf: Fix the POLL_HUP delivery breakage") only the first overflow is delivered. The re-arming ioctl succeeds, but the event count stays at 1. It passes on the parent commit. The software case passes on both. The test was written with an AI coding assistant (Claude) from a standalone reproducer; I reviewed it and ran it in QEMU on current mainline, on that commit and on its parent. Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Francesco Nigro <nigro.fra@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-19perf test: Avoid stack trace noise in verbose=1 failure snippetsIan Rogers
When a test fails with a signal or times out, child_test_sig_handler() appends '---- unexpected signal (<sig>) ----' followed by a multi-line stack trace (' #0 ...' through '_start'). In verbose=1 mode, print_test_failure_snippet() selects up to failure_snippet_lines (10) lines: - Pass 1 selects lines matching failure keywords plus their immediate next line (' #0 ... in child_test_sig_handler'). - Pass 2 fills the remaining quota by scanning backwards from the end of the output buffer, which consumes the remaining lines on outermost stack frames ('handle_internal_command', 'run_argv', 'main', '__libc_start_main', '_start') and hides the trailing test output showing where the test had run to. Improve print_test_failure_snippet() by: - Skipping blank lines and stack trace lines (' #<digit>...') when selecting context in Pass 1 and when scanning backwards from the end in Pass 2, with a Pass 3 fallback from the top of the buffer if quota still remains. - Prioritizing the non-blank line immediately preceding '---- unexpected signal' so there is no '...' gap before the signal message. - Only printing '...' between selected lines when at least one non-blank line was omitted between them. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test: Take turns using the perf mlock budget in the mmaping testsArnaldo Carvalho de Melo
The mmap size used when none is asked for is derived from kernel.perf_event_mlock_kb itself (see perf_event_mlock_kb_in_pages()), that after rounding down to a power of two number of pages ends up being about all of a single CPU's share of that per user budget, so with 'perf test' starting all the selected tests at once, any further mapping done while another test still has its ring buffers mapped fails with: Permission error mapping pages. Consider increasing /proc/sys/kernel/perf_event_mlock_kb, or try again with a smaller value of -m/--mmap_pages. that then shows up as a failure or, worse, as an "unsupp" skip in tests like the attr ones, i.e. as a false pass. Instead of making those tests exclusive, which would serialize them against every other test, keep them running in parallel with the tests that don't map ring buffers and have them take turns using the budget, via a robust, process-shared mutex (see mutex_init_pshared_robust()) in a MAP_SHARED|MAP_ANONYMOUS area that is inherited by the forked test processes: a test killed by a signal doesn't leave the budget locked, the kernel marks the mutex owner-died and the next locker takes it over; a signal that is caught rather than kills ends up the same way, with the longjmp out of child_test_sig_handler() leaving it held until the child exits and the kernel hands it over. Perf's struct mutex is used, so the lock discipline is checked in clang builds via -Wthread-safety; as the thread safety analysis can't verify conditionally held locks, the tests that map ring buffers run through a helper taking the mutex unconditionally around the test function call. Robust mutexes aren't always available, at build time or, as glibc and musl can do when get_robust_list(2)/set_robust_list(2) aren't usable, at run time: in that case the budget is not shared and the tests run as before, failing or skipping on starvation instead of hanging on a lock left behind by a test killed by a signal. Taking turns is unnecessary when nothing can exhaust the budget: once it is spent, whatever maps on top of it is charged against RLIMIT_MEMLOCK and the mapping is refused with EPERM when that runs out too, but only for the processes the kernel is paranoid about and that have no CAP_IPC_LOCK to lift the check, see perf_mmap_calc_limits(). Root, then, has no turns to take: it never has a mapping refused, so the turnstile only buys it the wall clock cost measured below, for a budget nothing is contending for. The area is shared by the tests of one 'perf test' invocation only: a second invocation running at the same time maps its own, so the two don't take turns with each other. The sysctl is left alone. Growing it, to leave room for whatever else the user has running, would need the original value shared between the invocations, so that the last one out puts it back, and it only helps a user who can write the sysctl but lacks CAP_IPC_LOCK, the one capability that lifts the limit. Raising the soft RLIMIT_MEMLOCK to the hard one when a mapping is refused is left for a follow-up: it would buy back the wall clock above without taking turns, where the hard limit allows the raise. None of this is done when just one of the selected tests maps ring buffers, as there is nothing to share the budget with in that case. Taking turns isn't free: a test that hangs while holding the budget now holds with it every other test mapping ring buffers, where before it would fail, or skip, by itself. And there is a cost even when nothing goes wrong, this being the whole suite on a Ryzen 9 9950X3D, kernel 7.2.7, 32 CPUs, with the default 516 KiB budget, before and after taking turns: budget not shared: 42 s wall clock, 72 tests Ok, 28 failed tests take turns: 133 s wall clock, 101 tests Ok, 10 failed Both are non-root runs of the whole series applied, the shell test markings included, and none of the ten failures is about the budget: eight of them pass as root, where it can't be exhausted, and the two that fail there too, the addr2line inline unwinding one, with no branch stack sampling to ask this machine for, and the BPF metadata collection one, whose output isn't what the test expects, are not budget related either. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf tests: Mark the shell tests not mapping perf ring buffersArnaldo Carvalho de Melo
Shell tests run perf, that maps ring buffers, so they take a turn using the per user budget in kernel.perf_event_mlock_kb by default; the ones that don't map them, like the ones running just 'perf stat', say " (no_mlock)" in their description line and thus keep running in parallel with the ones taking turns. The 'perf sched stats' tests are among them, they synthesize the samples from /proc/schedstat without mapping a ring buffer, and the tests already marked " (exclusive)" don't need it, exclusive implies every other requisite and keeps them running alone. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf tests: Mark the C tests mapping perf ring buffersArnaldo Carvalho de Melo
The C tests that run 'perf record' in the test process itself map ring buffers and so need room in the per user budget set in kernel.perf_event_mlock_kb: mark them with the new 'needs_mlock' suite flag, read by the turnstile added later in the series, so that they take turns using that budget while the tests that don't map them keep running in parallel. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf tests: Introduce a 'needs_mlock' suite flagArnaldo Carvalho de Melo
Each perf instance maps one ring buffer per CPU, all charged to the same per user budget set in kernel.perf_event_mlock_kb, so suites that map them need to be told apart from the ones that don't, to later have them take turns using that budget while the other tests keep running in parallel. Add the flag to 'struct test_suite' and a DEFINE_SUITE_NEEDS_MLOCK() variant for the suites using the DEFINE_SUITE() form. Shell tests run perf, that maps ring buffers, so they are taken to need room in that budget by default; the requisites, a comma separated list in the parens ending their description line, name what a test needs and take a "no_" prefix to waive it, e.g.: # perf stat tests (no_mlock) "mlock" is room in that budget, so stating it only spells the default out, "no_mlock" waives it, and "exclusive" is the catch-all that keeps a test from running alongside any other, so it runs alone, in sequence, and implies every other requisite, which is why it can't be waived either. More requisites are to come, each stating what a test needs, till the catch-all isn't needed anymore. 'perf test requisites' lists what each test needs, reusing the listing routine and taking the same test name fragments and numbers as 'list'. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: State, spelled out in a line, why a test is skippedArnaldo Carvalho de Melo
Per skip the default output shows a self contained one liner: unsupp 'test-record-branch-filter-any' exit 255, expected 1, no attrs recorded to verify skipped [kernel newer than 6.12] 'test-record-group-sampling' skipped [arch = !aarch64, machine = aarch64] 'test-record-graph-default' The extra notes explaining the reason, with a copy pasteable command to observe the failure, come in the very same stream when the verbosity is bumped, at -vvv, nothing is written to a separate place for later consultation, it is just the logging ladder: detail: '/root/bin/perf record -o /dev/null --no-bpf-event -j any kill' exited with 255, the expectations want the workload's 1 exit, so there are no attrs recorded to verify; this is normally a capability problem, run '/root/bin/perf record -o /dev/null --no-bpf-event -j any kill' to see why Note that 'perf test -v/-vv/-vvv attribute' appends a single -v to the shell test entry (shell_test__run()), so to see the notes one runs the python module directly, f.i.: python3 tests/shell/lib/attr.py -vvv -d tests/shell/attr -p ./perf The skip functions now return the reason fragment when they want to skip and None when the test can go on. The command suggested to observe the failure writes to /dev/null, so it doesn't leave a perf.data in the directory it is run from. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Ignore the group read_format bit the PMU count can removeArnaldo Carvalho de Melo
read_format's PERF_FORMAT_GROUP bit asks for the group members to be read along with the leader, which aside from this bit is verified with the fd/group_fd based group checking in Test.compare(), and with more than one core PMU a group whose members are pinned to one of them, say 'default_core', leaves the clones for the other core PMUs without any members: $ perf stat -e '{cycles,default_core/legacy-hardware-config=3/}:S' ... the A53 leader keeps its cohort, both A73 cycles clones are alone, read_format 20 instead of 28 so that bit isn't there: whether it is there is a consequence of how the evlist got expanded to more than one core PMU, not of the groupness the expectations say about, which is verified structurally, so take it out on both sides. That leaves the A73 leader clones, now with: expected read_format=28|31, got 20 matching the base event expectations again. With a single core PMU there is nothing to expand, so there is nothing to explain away: count the core PMUs when the script starts, from what perf makes of 'cycles', see parse_events_multi_pmu_add(), and take the bit out only when there is more than one, leaving the machines with a single core PMU verifying what the expectations say about it. That count is 2 on the Amlogic A311D, where its A53 and A73 PMUs both answer for 'cycles', and 1 on a machine with a single core PMU. Where there is no binding to ask, as when attr.py runs without setup_python.sh, the count isn't available and the bit is taken out as well. core_pmu_count() takes the count from the same probe core_pmu_available() uses, so the binding is asked once, and only when a comparison needs the answer, not at import time. The sample id bits hide_sample_id() takes out when the expectations ask for none are another consequence of having more than one core PMU, so the same single core PMU gate covers them; equating the two id bits, needed when the evlist has more than one event even with a single core PMU, keeps applying. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Leave out the events of the other core PMUsArnaldo Carvalho de Melo
On a hybrid machine the default stat metrics are opened on each core PMU, and the events of the other one have their own encodings: on an i7-14700K cpu_atom (type 10) opens UOPS_RETIRED.ALL, config 194, which the expectations, written for cpu_core (type 4), don't name: expected type=4, got 10 expected config=209|391, got 194 The test already masks the core PMU type out of 'config' for the legacy events, but raw events keep their type and encoding, so leave out the events of the core PMUs no expectation names, like the dummy tracking event. Core PMUs are found as perf finds them: 'cpu' or 'cpum_cf', or a PMU with a 'cpus' file in sysfs. Nothing is left out unless an expectation names a core PMU, so single core PMU machines and the tests with only legacy expectations are not affected. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Ignore the dummy tracking event and the terms it carriesArnaldo Carvalho de Melo
With more than one core PMU the requested events can't cover all the CPUs, each cluster has its own PMU, so perf opens the software dummy event to carry the tracking terms (mmap, comm, task, mmap_data), leaving the requested events without them: expected mmap=1, got 0 expected comm=1, got 0 expected task=1, got 0 That dummy event is not part of what the expectations are about, so leave it out of the comparison, unless the expectations ask for one, like system-wide-dummy and test-record-dummy-C0 do. And when perf used it to carry the tracking terms, those terms can't be matched on the requested events, leave them out of the match as well. The terms are left out only where the dropped dummy actually carried them, from the sample_type it was opened with, a dummy that didn't is no reason to stop verifying them. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Accept either sample id bit perf asks forArnaldo Carvalho de Melo
evlist__config() asks for a way to tell the samples apart, PERF_SAMPLE_IDENTIFIER where available, PERF_SAMPLE_ID otherwise: bool sample_id = opts->sample_id; ... if (opts->full_auxtrace || opts->sample_identifier) { ... use_sample_identifier = perf_can_sample_identifier(); sample_id = true; } else if (evlist__nr_entries(evlist) > 1) { ... use_sample_identifier = perf_can_sample_identifier(); sample_id = true; } so the id is asked for whenever the evlist has more than one event, and also when asked to outright, with --sample-identifier or by an auxtrace session, or by record__config() for a pipe run, through opts->sample_id, none of which depends on the sample types: 'perf record --sample-identifier -e cycles' and the arm SPE expectations in this very directory ask for it with a single event. Which one it asks for depends on the composition of the evlist: with more than one core PMU a request for 'cycles' becomes one event per core PMU, the extra dummy tracking events then make the sample types differ and perf goes for IDENTIFIER, while the expectations were written on machines with a single core PMU, where perf asks for ID: expected sample_type=263, got 65799 # 263 | (1 << 16) expected sample_type=343, got 65815 # (343 & ~(1 << 6)) | (1 << 16), group-sampling Both bits mean the same thing here, how the samples get associated with the event that produced them, so when the expectation asks for one of them, ask for "an id of some sort" on both sides, and when the expectation doesn't ask for any, take the bits out of what got recorded: whether they are there and which one it is are consequences of what was asked for and of how the request got expanded, none of that is what these expectations are about. Since Test.compare() looks at both directions, expectations matching the recorded events and recorded events matching the expectations, keep track of which side is the one perf recorded to take the bits out of the right side. The masking is only for the comparison: the warnings keep showing the values as they are, nothing to un-mask by hand to see what is being complained about. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Introduce mask_bits(), generalizing hide_core_pmu_type()Arnaldo Carvalho de Melo
What hide_core_pmu_type() does is take a set of bits out of each of the '|'-separated alternatives in a value, wildcards included, keeping the rest of the expression: extract that as mask_bits() and implement hide_core_pmu_type() in terms of it, a prep for using the same thing to ignore, when comparing expectations, the sample id bit perf ends up asking for and the read_format group bit that a PMU count can remove. No change in behaviour. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Ignore the core PMU type perf puts in 'config'Arnaldo Carvalho de Melo
Since commit 55bcf6ef314a ("perf: Extend PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE") in v5.13, and arm_pmu opted in with commit 5c816728651a ("arm_pmu: Add PERF_PMU_CAP_EXTENDED_HW_TYPE capability") in v6.6, the kernel can be told which core PMU a legacy type event is meant for, with its type in the top 32 bits of 'config', see perf_pmus__supports_extended_type(), which __parse_events_add_numeric() does for HARDWARE and HW_CACHE events, but only when there is more than one core PMU, i.e. on heterogeneous machines, where asking for one event ends up being one event per core PMU: $ perf stat -e cycles -a -- sleep 1 20,520,998 armv8_cortex_a53/cycles/ 13,029,350 armv8_cortex_a73/cycles/ and what lands in PERF_TEST_ATTR is the extended encoding: type=0 config=38654705664 # core PMU type 9, PERF_COUNT_HW_CPU_CYCLES so the expectations written for the single core PMU case fail with: expected config=0|1, got 38654705664 expected config=0, got 38654705664 # 'perf stat -d' L1-dcache events which is what now happens on an Amlogic A311D (2 Cortex-A53 + 4 Cortex-A73), a machine that just got the CPU PMU nodes it was missing. Take those bits out when comparing the 'config' of legacy type events, keeping what these expectations mean on machines with a single core PMU: which of the PMUs is counting is not what we're asking here. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Relax group checking for ungrouped expectationsArnaldo Carvalho de Melo
When matching the recorded events back against the expectations, attr.py requires every event opened in a group to match an expectation that declares the same group. The perf stat default metrics open the events of each metric in groups, but the test expectations only verify the event attributes, so test-stat-default fails with: FAILED '.../test-stat-default' - group failure Only enforce the group of a recorded event when the expectation it matches declares one. Expectations that ask for a group are still verified in both directions. Fixes: c7adeb0974f18da4 ("perf jevents: Add set of common metrics based on default ones") Fixes: 2dfc0cab3da4a205 ("perf stat: Add detail -d,-dd,-ddd metrics") Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Fix default stat metrics expectationsArnaldo Carvalho de Melo
Since commit c7adeb0974f1 ("perf jevents: Add set of common metrics based on default ones") and commit 2dfc0cab3da4 ("perf stat: Add detail -d,-dd,-ddd metrics") the perf stat default metrics open their events in groups, so group leaders and members have read_format=15 and members are enabled without enable_on_exec, while standalone events keep read_format=3 and are disabled until exec. Also, since commit b1c5efbfd92e ("perf parse-events: Remove hard coded legacy hardware and cache parsing") bare hardware events resolve to the core PMU sysfs/JSON events (type 4), so add the raw encodings the Intel and AMD core PMUs use for instructions, branch-misses, cpu-cycles and stalled-cycles-frontend/backend to test-stat-default and test-stat-detailed-1/2/3. Add base-stat-group, that accepts both the standalone and the group variants of read_format, disabled and enable_on_exec, and point the four default/detailed expectations at it. test-stat-basic, test-stat-C0 and test-stat-no-inherit keep base-stat, whose events aren't opened in a group: for those, a change that groups or enables them differently is still something to catch. test-stat-group1 does open its events in a group, but pins read_format, disabled and enable_on_exec itself, the very terms base-stat-group loosens, so it doesn't need it either. Fixes: b1c5efbfd92eb84d ("perf parse-events: Remove hard coded legacy hardware and cache parsing") Fixes: c7adeb0974f18da4 ("perf jevents: Add set of common metrics based on default ones") Fixes: 2dfc0cab3da4a205 ("perf stat: Add detail -d,-dd,-ddd metrics") Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Fix legacy event encodings in group testsArnaldo Carvalho de Melo
Since commit b1c5efbfd92e ("perf parse-events: Remove hard coded legacy hardware and cache parsing"), event names are resolved with sysfs/JSON priority over the legacy encodings, so bare cache-misses and instructions now become the core PMU sysfs/JSON events (on x86 type 4, configs 0x412e and 0xc0) rather than the legacy PERF_TYPE_HARDWARE/config=3 and config=1 events the tests expect, e.g.: expected config=3, got 0 expected disabled=0, got 1 expected mmap=0, got 1 expected comm=0, got 1 expected freq=0, got 1 expected enable_on_exec=0, got 1 expected task=0, got 1 FAILED '.../test-record-group-sampling1' - match failure The shown diff is against the cycles group leader, as no result event matches the expected cache-misses member anymore. Request the legacy encodings explicitly with the legacy-hardware-config term, added in commit 0012e0fa221bf9cc ("perf jevents: Add legacy-hardware and legacy-cache json"), keeping the original attribute expectations unchanged, in: test-record-group1 test-record-group2 test-record-group3 test-record-group-sampling test-record-group-sampling1 test-record-group-sampling2 test-stat-group1 This went unnoticed until tests/attr.sh stopped ignoring attr.py's return value. Fixes: b1c5efbfd92eb84d ("perf parse-events: Remove hard coded legacy hardware and cache parsing") Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Allow tests to require a core PMUArnaldo Carvalho de Melo
On machines without a usable core PMU, like an aarch64 box with no DT node for the ARM PMU, the expectations that pin the legacy hardware encoding can't be checked: without a core PMU at all 'cycles' doesn't even resolve, and with one that can't be opened 'perf record' takes the software fallback and records attributes they can never match: expected type=0, got 1 expected config=0, got 1 FAILED '.../attr/test-record-group-sampling1' - match failure And since attr.py stops at the first failure, every expectation that would come after that one ends up not being run at all. Add a 'requires' limitation, modelled after the existing 'arch', 'auxv' and 'kernel_since/until' ones, with 'core-pmu' as its first value, that is checked by asking perf itself to open 'cycles' via its python binding: a parse failure or an ENOENT means there is no PMU that can count it, hence nothing to check and the test gets skipped, while any other error means we can't tell, so the test keeps running as it does today, where there is no binding to ask either. When there is no core PMU, asking the binding fails and prints a parse error, once for every test that asks, so the answer is kept: it is asked once per run. A value other than 'core-pmu' is warned about, not silently ignored, so a typo can't turn the skip into a no-op. An old distro python package may have a 'perf' module without parse_events(), i.e. there is nothing to ask with, so that AttributeError gets the same treatment as the ImportError: let the expectations speak. The expectations that have a strict 'type=0', plus the group tests, where the fallback drops a member and leaves nothing to compare the group leader attributes with, now state that they require a core PMU. They are marked here, before the commit that has the group tests ask for the legacy encodings, so the requisite comes with that dependency. Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-17perf test attr: Fix record dwarf sample_type expectationArnaldo Carvalho de Melo
Since commit bdd051e24914 ("perf record: Split --data-mmap option"), record_opts__parse_callchain() sets record_data_mmap instead of record->sample_address for the DWARF unwind mode, so -d/--data and its implied PERF_SAMPLE_DATA_SRC are not enabled implicitly anymore. As a result, --call-graph dwarf no longer sets PERF_SAMPLE_ADDR and PERF_SAMPLE_DATA_SRC, making the test fail: expected sample_type=45359, got 12583 where 45359 (0xb12f) is: IP|TID|TIME|ADDR|CALLCHAIN|PERIOD|REGS_USER|STACK_USER|DATA_SRC and 12583 (0x3127) is: IP|TID|TIME|CALLCHAIN|PERIOD|REGS_USER|STACK_USER i.e. the values differ exactly by PERF_SAMPLE_ADDR (0x8) and PERF_SAMPLE_DATA_SRC (0x8000). The mmap_data=1 expectation is still correct as DWARF now enables record_data_mmap. This went unnoticed until tests/attr.sh stopped ignoring attr.py's return value. Fixes: bdd051e249141c79 ("perf record: Split --data-mmap option") Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-15perf test: Fix dso data testsNamhyung Kim
Now dso__binary_type() requires that the target file is a valid ELF file containing ".text" section. But the test only checks cached read/write operation on a file. Let's set the binary type to bypass the ELF check to read/write the file properly. Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-13perf test: Update PE file test for other locationsNamhyung Kim
The test__pe_file_parsing() expects the test is in the tools/perf directory, but it could be root or a separate build directory. Let's update the logic to try other paths like in the shell_tests__dir_fd(). Also add some debug messages to inform users why it's skipped. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-13perf symbol: Fix symbol loading from libbfdNamhyung Kim
The dso__load() should return a positive number (number of symbols loaded) when it succeded to load symbols. But dso__load_bfd_symbols() only returns 0 and it's hard to check if it actually loaded symbols or not. Let's return the value of dso__has_symbol() and check it in dso__load() so that it can return 1 for success. Closes: https://lore.kernel.org/r/sashiko-outbox-162540@kernel.org Fixes: eac9a4342e5447ca ("perf symbols: Try reading the symbol table with libbfd") Reported-by: Sashiko <sashiko-bot@kernel.org> Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Remi Bernon <rbernon@codeweavers.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-13perf test attr: Source setup_python.sh instead of calling pythonArnaldo Carvalho de Melo
The "Perf attribute expectations test" (perf test 82) fails on machines that don't ship a bare 'python' binary, i.e. distributions that provide only python3 unless python-is-python3 or an equivalent is installed. Namhyung Kim hit this and posted the fix applied here in <asWLmvF-3YtoKJ7j@google.com>: /home/namhyung/project/linux/tools/perf/tests/shell/attr.sh: line 20: python: command not found ---- end(-1) ---- 82: Perf attribute expectations test : FAILED! attr.sh is the only shell test that still invokes python directly; do what the others do: source lib/setup_python.sh, which prefers python3, falls back to python and skips the test when no interpreter is found, then run $PYTHON. Fixes: 8519e4f44c2af722 ("perf test: Add a shell wrapper for "Setup struct perf_event_attr"") Reported-by: Namhyung Kim <namhyung@kernel.org> Suggested-by: Namhyung Kim <namhyung@kernel.org> Reviewed-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/linux-perf-users/asWLmvF-3YtoKJ7j@google.com/ Assisted-by: LLM Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-07perf test: Add false_sharing workload exhibiting cross-CPU false sharingArnaldo Carvalho de Melo
Add a 'perf test -w false_sharing' workload that hammers one shared struct from several CPUs, shaped as a TCP connection: a read-mostly identity (five-tuple) shares a cacheline with per-packet rx counters (the false-sharing line), a second line has packet-path private tx and congestion control counters, and a third the connection config. The packet path runs in the main thread and up to four lookup threads sum the five-tuple and pull the config, reading one volatile shared instance directly so the accesses are PC-relative and resolvable by the data type profiler. Data type profiling of the workload with cacheline info: $ perf mem record -- perf test -r5 -w false_sharing [ perf record: Woken up 19 times to write data ] [ perf record: Captured and wrote 5.612 MB perf.data (72454 samples) ] $ perf report -s type,typecln -H --group --stdio # Total Lost Samples: 0 # # Samples: 72K of events 'cpu/mem-loads,ldlat=30/P, cpu/mem-stores/P' # Event count (approx.): 1261814616 # # Overhead Data Type / Data Type Cacheline # ................... ............................... # 88.99% 35.88% struct net_conn 56.43% 17.50% struct net_conn: cache-line 0 32.55% 0.00% struct net_conn: cache-line 2 0.01% 18.38% struct net_conn: cache-line 1 10.08% 63.03% (unknown) 10.08% 63.03% (unknown): cache-line 0 0.82% 0.13% int 0.82% 0.13% int: cache-line 0 0.01% 0.02% struct folio 0.01% 0.02% struct folio: cache-line 0 0.01% 0.03% Elf64_Addr 0.01% 0.03% Elf64_Addr: cache-line 0 0.01% 0.03% struct sched_entity 0.01% 0.03% struct sched_entity: cache-line 1 0.00% 0.00% struct sched_entity: cache-line 4 0.00% 0.00% struct sched_entity: cache-line 2 0.00% 0.00% struct sched_entity: cache-line 3 0.00% 0.00% struct sched_entity: cache-line 0 0.01% 0.00% struct task_group 0.01% 0.00% struct task_group: cache-line 4 0.00% 0.00% struct task_group: cache-line 5 0.00% 0.00% struct css_rstat_cpu 0.00% 0.00% struct css_rstat_cpu: cache-line 0 $ perf report -s type,typecln,typeoff -H --group --stdio # Total Lost Samples: 0 # # Samples: 72K of events 'cpu/mem-loads,ldlat=30/P, cpu/mem-stores/P' # Event count (approx.): 1261814616 # # Overhead Data Type / Data Type Cacheline / Data Type Offset # ...................... .................................................. # 88.99% 35.88% struct net_conn 56.43% 17.50% struct net_conn: cache-line 0 9.81% 0.00% struct net_conn +0xa (dport) 9.54% 0.00% struct net_conn +0x8 (sport) 9.53% 0.00% struct net_conn +0xc (state) 9.48% 0.00% struct net_conn +0xd (protocol) 9.27% 0.00% struct net_conn +0x4 (daddr) 8.79% 0.00% struct net_conn +0 (saddr) 0.00% 12.08% struct net_conn +0x10 (bytes_rx) 0.00% 1.71% struct net_conn +0x18 (packets_rx) 0.00% 2.80% struct net_conn +0x20 (rx_queue) 0.00% 0.91% struct net_conn +0x3c (last_ack) 32.55% 0.00% struct net_conn: cache-line 2 5.70% 0.00% struct net_conn +0x83 (rcv_wscale) 5.46% 0.00% struct net_conn +0x84 (keepalive_int) 5.43% 0.00% struct net_conn +0x82 (snd_wscale) 5.39% 0.00% struct net_conn +0x80 (mss) 5.34% 0.00% struct net_conn +0x88 (mark) 5.23% 0.00% struct net_conn +0x8c (priority) 0.01% 18.38% struct net_conn: cache-line 1 0.01% 0.05% struct net_conn +0x5c (retrans) 0.00% 4.83% struct net_conn +0x40 (bytes_tx) 0.00% 10.63% struct net_conn +0x48 (packets_tx) 0.00% 1.54% struct net_conn +0x58 (rtt_us) 0.00% 1.07% struct net_conn +0x50 (cwnd) 0.00% 0.25% struct net_conn +0x54 (ssthresh) 10.08% 63.03% (unknown) 10.08% 63.03% (unknown): cache-line 0 10.08% 63.03% (unknown) 0.82% 0.13% int 0.82% 0.13% int: cache-line 0 0.82% 0.13% int +0 (no field) 0.01% 0.02% struct folio 0.01% 0.02% struct folio: cache-line 0 0.01% 0.00% struct folio +0 (flags.f) 0.00% 0.01% struct folio +0x34 (_refcount.counter) 0.00% 0.00% struct folio +0x18 (mapping) Assisted-by: LLM Reviewed-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-07perf test attr: Fix wrong size expectation for eventsMichael Petlan
Although config4 and tee sample_simd_* fields has been added into 'struct perf_event_attr', the size expectation for the struct hasn't been adjusted. This hasn't been noticed, since the testcase's return value has been ignored after rewriting the testcase to python until previous commit. Fix that. Fixes: eb89aef367e47010 ("perf headers: Sync perf_event.h/perf_regs.h with the kernel headers") Fixes: 80cdf208117a36de ("tools headers UAPI: Sync linux/perf_event.h with the kernel sources") Signed-off-by: Michael Petlan <mpetlan@redhat.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> [ Updated it to take into account 80cdf208117a36de (sample_simd_* fields) 144 -> 176 ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-07perf test attr: Propagate the return value from the test to the wrapperMichael Petlan
Currently it does not matter what the python script actually returns, the test always passes, as the $err variable is always 0. Fix that. Fixes: 8519e4f44c2af722 ("perf test: Add a shell wrapper for "Setup struct perf_event_attr"") Signed-off-by: Michael Petlan <mpetlan@redhat.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-03perf test: Add a test for perf timechart --tuiAlice Rogers
Test launching ttimechart through 'perf timechart --tui', the error when there are no scheduler events, the --dump output with the -P, -T and -p options, and drive the textual app headless exercising the views and key bindings. Committer testing: root@x2:/home/acme/git/perf-tools-next# perf test "perf timechart --tui (ttimechart.py) test" 167: perf timechart --tui (ttimechart.py) test : Ok === Test Summary === Passed main tests : 1 Passed subtests : 0 Skipped tests : 0 Failed tests : 0 root@x2:/home/acme/git/perf-tools-next# perf test -vv "perf timechart --tui (ttimechart.py) test" 167: perf timechart --tui (ttimechart.py) test: ---- start ---- test child forked, pid 2833475 perf timechart --tui plumbing test perf timechart --tui plumbing test [Success] ttimechart no events test ttimechart no events test [Success] ttimechart dump test ttimechart dump test [Success] ttimechart headless UI test ttimechart headless UI test [Success] ---- end(0) ---- 167: perf timechart --tui (ttimechart.py) test : Ok === Test Summary === Passed main tests : 1 Passed subtests : 0 Skipped tests : 0 Failed tests : 0 root@x2:/home/acme/git/perf-tools-next# Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Alice Rogers <alice.mei.rogers@gmail.com> Co-developed-by: Ian Rogers <irogers@google.com> Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-03perf test: Add a test for the treport scriptAlice Rogers
Test launching treport through 'perf script', the error for a file that isn't a perf.data file, drive the textual app headless checking the profile matches one built without the UI and exercising the key bindings, and that quitting while loading stops the background load. Committer testing: root@x2:/home/acme/git/perf-tools-next# perf test "perf script treport test" 166: perf script treport test : Ok === Test Summary === Passed main tests : 1 Passed subtests : 0 Skipped tests : 0 Failed tests : 0 root@x2:/home/acme/git/perf-tools-next# perf test -vv "perf script treport test" 166: perf script treport test: ---- start ---- test child forked, pid 2829708 treport plumbing test treport plumbing test [Success] treport bad file test treport bad file test [Success] treport headless UI test treport headless UI test [Success] treport cancel test treport cancel test [Success] ---- end(0) ---- 166: perf script treport test : Ok === Test Summary === Passed main tests : 1 Passed subtests : 0 Skipped tests : 0 Failed tests : 0 root@x2:/home/acme/git/perf-tools-next# Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Alice Rogers <alice.mei.rogers@gmail.com> Co-developed-by: Ian Rogers <irogers@google.com> Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-03perf test: Add a test for the ilist scriptIan Rogers
Test launching ilist through perf script and perf list --tui, and drive the textual app headless: check the tree of PMUs and metrics, search for and select the software task-clock event checking its counters are shown, check a failed search shows an error and select a metric. Failing to open counters, for example for want of permissions, is tolerated as an error dialog is shown. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf build: Run shellcheck, mypy, and remaining pylint checks in parallelIan Rogers
Following the approach used for pylint on standalone scripts and tests, move the shellcheck and mypy checks in tools/perf/Build and tools/perf/tests/Build, as well as the mypy and pylint checks in tools/perf/util/Build and tools/perf/pmu-events/Build, into dedicated phony targets invoked as top-level sub-makes from Makefile.perf. Also add 'perf' to pylint's --ignored-modules (leaving perf module type-checking to mypy via perf.pyi), since astroid's ImportlibFinder only resolves .pyi stubs for package directories (__init__.pyi) rather than single-file stubs like perf.pyi and does not introspect C extensions by default. This removes the need for pylint to wait on building $(LANG_BINDINGS). This avoids blocking jevents code generation, archive creation (libperf-util.a, libperf-test.a, libpmu-events.a), and final linking of the perf binary and Python extension on linter execution. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test: Update attr.py to use argparseIan Rogers
optparse is deprecated since Python 3.2 and triggers a pylint deprecated-module warning on newer versions of pylint. Replace optparse.OptionParser in tools/perf/tests/shell/lib/attr.py with argparse.ArgumentParser. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test uprobe_from_different_cu: Scope probe name to PIDIan Rogers
'perf probe' names the event after the function and binary, so concurrent runs, as with 'perf test -r3', all add probe_testfile:foo and all but one fail with 'event "foo" already exists'. Name the event foo_$$. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test: Remove exclusive tag from 'perf trace' testsNamhyung Kim
Now it's safe to run multiple 'perf trace' commands at the same time. Let's make them non-exclusive so that they can run in parallel. $ sudo perf test 'perf trace' 113: Check open filename arg using perf trace + vfs_getname : Skip 114: perf trace enum augmentation tests : Ok 115: perf trace BTF general tests : Ok 116: perf trace exit race : Ok 117: perf trace record and replay : Ok 118: perf trace summary : Ok [ irogers: Keep trace+probe_vfs_getname.sh exclusive, as without BPF every 'perf trace' opens its probe:vfs_getname* probe. ] Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20250814071754.193265-6-namhyung@kernel.org Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test trace_btf_general: Drop --max-events=1 and make non-exclusiveIan Rogers
With --max-events=1 an unrelated event can end perf trace before the command's syscall is seen. Trace the whole command and grep for the expected line, as trace_btf_enum.sh does, and remove the exclusive tag. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test trace_summary: Improve error diagnosticsIan Rogers
On a mismatch print the command, the match count, the matching lines and the end of the output. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test record+probe_libc_inet_pton: Scope event to PID and make non-exclusiveIan Rogers
Scope the uprobe name to the pid, retry adding and deleting it as concurrent uprobe_events writes can fail with EBUSY, and delete it from an exit trap. Create the temporary files with mktemp rather than reserving names with mktemp -u. Remove the exclusive tag. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test probe_vfs_getname: Scope probe name to PID and make non-exclusiveIan Rogers
The fixed vfs_getname probe name collides between parallel tests, and the cleanup deletes every probe:vfs_getname* probe. Name the probe getname_flags_$$, match it exactly, and remove it from an exit trap. Not starting with vfs_getname also stops perf trace, which opens every probe:vfs_getname* event, from pinning it. Remove the exclusive tag from probe_vfs_getname.sh and record+script_probe_vfs_getname.sh. trace+probe_vfs_getname.sh needs perf trace to find its probe, so it uses vfs_getname_$$ and stays exclusive. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-10-01perf test common: Only disable probes in clear_all_probesIan Rogers
Writing 0 to events/enable disables every tracepoint, breaking perf sessions running in parallel. Disable just the kprobes and uprobes, an enabled one would make clearing kprobe_events or uprobe_events fail with EBUSY. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-30perf sched stats: Reject mismatched or incomplete snapshotsTianyi Chen
The before and after records are paired by list position. If a CPU or domain disappears, counters can be subtracted from a different record or left as absolute values. An extra record can also advance the cursor past the list. Identify the second snapshot by its timestamp or CPU ordering, and require matching CPU/domain IDs and versions before subtracting. Check that every record has a counterpart before printing, and propagate errors from either input of diff. Add a shell test with synthetic snapshots, including equal timestamps, CPU filtering, and missing or reordered CPU/domain records. Fixes: 5a357ae6ad63fd10 ("perf sched stats: Add support for report subcommand") Reviewed-by: Swapnil Sapkal <swapnil.sapkal@amd.com> Assisted-by: LLM Signed-off-by: Tianyi Chen <hi@tychen.cc> Tested-by: Swapnil Sapkal <swapnil.sapkal@amd.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-30perf build: Build the Python extension before pylint consumersLeo Yan
Pylint checks for tests and standalone Python scripts can run before the perf Python extension is available. On a clean parallel build, an import error can stop make before the extension is built. Run the script and test pylint checks in separate sub-makes after the language bindings are built. Keep their rules in the respective Build files so the perf and perf-test C sub-makes can compile concurrently with util and the Python extension. An isolated make perf does not need to build the extension just for these checks. Fixes: 8a54784e708b51c1 ("perf build: Add pylint build tests") Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com> Reviewed-by: Ian Rogers <irogers@google.com> Assisted-by: Codex:gpt-6 Signed-off-by: Leo Yan <leo.yan@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-30perf test demangle: Fail when demangling failsMichal Pluta
The Rust and Java demangle tests only log a NULL result from dso__demangle_sym() and carry on, so a symbol that fails to demangle doesn't fail the test. Set TEST_FAIL. Fixes: 07f2b1287c970e07 ("perf test demangle-java: Don't segv if demangling fails") Fixes: bdf05ccd18414274 ("perf test demangle-rust: Add Rust demangling test") Reviewed-by: Ian Rogers <irogers@google.com> Assisted-by: LLM Signed-off-by: Michal Pluta <michalpl2003@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-29perf symbols: Don't let a module's last symbol overlap the next moduleAlireza Haghdoost
symbols__fixup_end() extends a zero-size symbol that is the last one in the kernel or in a module to the end of the next page. On x86 the next module can start in that page, so the stretched symbol overlaps it, and a lookup can return the wrong symbol. For example: ffffffffc0c4aa50 t dca_sysfs_exit [dca] ffffffffc0c4b000 t __nft_trace_packet [nf_tables] ffffffffc0c4b0b0 t nft_do_chain [nf_tables] dca_sysfs_exit gets end 0xffffffffc0c4c000, and samples in nft_do_chain are reported as dca_sysfs_exit. This patch clamps the end to the next symbol's start. The ARM case this code was added for, where the next module is far away, is unchanged. Add a "Kallsyms symbol ends" test case to the Symbols suite that covers the kernel/module boundary, adjacent modules and a distant module. Fixes: 8799ebce84d672aa ("perf symbol: Update symbols__fixup_end()") Fixes: bacefe0c7b77b752 ("perf tools: Fixup module symbol end address properly") Signed-off-by: Alireza Haghdoost <haghdoost@uber.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-29perf python event_analyzing_sample: Default to in-memory SQLite databaseIan Rogers
When -d/--db is not specified, event_analyzing_sample.py created a temporary file in /tmp via tempfile.mkstemp() and deleted it in trace_end(). As noted during review, creating the database in a shared /tmp directory does not reserve SQLite's auxiliary sidecar filenames (-journal or -wal), and a temporary on-disk file is unnecessary when the caller did not ask to persist the database. Default to sqlite3.connect(":memory:") when db_path is not provided, removing the temporary file creation and cleanup logic, and test both the default in-memory mode and explicit -d file mode in test_event_analyzing_sample_python.sh. Fixes: eeb70645a8097437 ("perf python: Port event_analyzing_sample to perf module") Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-29perf test: Reduce overhead and contention in Python shell testsIan Rogers
When all Python shell tests run concurrently during 'perf test' under heavy load: 1. Unfiltered 'perf list' initializes all hardware PMUs and metrics in each test process; use 'perf list tracepoint' when checking for tracepoint events. 2. Running 'perf record' without '-B -N --no-bpf-event' synthesizes BPF events across the system and caches build-ids into ~/.debug; add '-B -N --no-bpf-event' to all Python shell test recordings. 3. Drop '-a' in test_check_perf_trace_python.sh, test_rw_by_file_python.sh, test_rw_by_pid_python.sh, test_rwtop_python.sh, and test_syscall_counts_by_pid_python.sh where only a single child workload ('dd' or 'sleep') is tested, avoiding system-wide /proc synthesis and ringbuffer contention. 4. Add '-W 1' to 'ping -c 1' in test_net_dropmonitor_python.sh and test_netdev_times_python.sh, and narrow 'compaction:*' to 'compaction:mm_compaction_begin,compaction:mm_compaction_end' in test_compaction_times_python.sh. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-29perf test: Deflake failed-syscalls Python shell tests under loadIan Rogers
When running 'perf test' in parallel under heavy system load, a one-shot 'perf record -e ... -- ls /does_not_exist' without '-B -N --no-bpf-event' can exit in under 300 microseconds before 'ls's PERF_RECORD_COMM and ENOENT sys_exit events are captured, while also contending on ~/.debug build-id caching and BPF event synthesis. Pass '-B -N --no-bpf-event' to 'perf record', sleep 0.05s in a subshell after 'ls' so its events are flushed before the parent subshell exits, and wrap the record and check steps in a bounded retry loop (up to 5 attempts). Fixes: b76c43d09b06da1b ("perf python: Port failed-syscalls-by-pid to perf module") Fixes: 4e3fe6987cbad8ab ("perf python: Port failed-syscalls from Perl to perf module") Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-29perf test: Deflake Intel PT Python shell tests under loadIan Rogers
In test_intel_pt_events_python.sh, test_export_to_sqlite_python.sh, and test_export_to_postgresql_python.sh, 'sh -c "uname; true"' uses the shell builtin 'true' and exits within microseconds of 'uname', sending SIGCHLD to 'perf record' before the Intel PT AUX buffer is always flushed under heavy parallel load (~5-10% drop rate). Sleep 0.05s in the subshell after 'uname' ('sh -c "uname; sleep 0.05"') so 'uname' completely exits and flushes its AUX trace before 'sh' exits, and wrap the record and verification step in a bounded retry loop (up to 5 attempts). Also pass '-B -N --no-bpf-event' to 'perf record -g' in test_export_to_sqlite_python.sh and test_export_to_postgresql_python.sh to avoid build-id cache and BPF synthesis overhead. Fixes: d4ce72e9e238fd70 ("perf python: Port intel-pt-events and libxed to perf module") Fixes: 62d350135e676a11 ("perf python: Port export-to-sqlite to perf module") Fixes: b1f968c9656a8a87 ("perf python: Port export-to-postgresql to perf module") Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-29perf python stat-cpi: Fix live mode signal races and test flakinessIan Rogers
In test_stat_cpi_python.sh, 'perf test -w noploop &' defaults to a 1-second duration and can exit under heavy parallel load before 'perf stat -p' and 'perf script stat-cpi' finish starting up. In addition, the fixed 'sleep 0.5' before sending SIGINT can fire before Python finishes importing the perf module, opening the live evlist, and flushing the first interval. In stat-cpi.py, register SIGINT and SIGTERM handlers before calling _open_live_evlist() and pass flush=True when printing live output so redirected stdout is flushed immediately after each interval. In test_stat_cpi_python.sh, run 'perf test -w noploop 60 &' so the target workload stays alive until killed, and poll the output file for 'cpi' (up to 5 seconds) before sending SIGINT. Fixes: 4425182d426b ("perf python: Port stat-cpi to perf module") Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-29perf python sctop: Fix offline interval printing and test flakinessIan Rogers
In sctop.py: - If an earlier interval elapsed and printed an empty table before the target comm ('sleep') executed any syscalls, analyzer.printed became True and the final partial interval containing the target comm's syscalls was never flushed at EOF. Flush print_current_totals() in finally when analyzer.syscalls is non-empty as well as when nothing has been printed yet. - Initialize analyzer.e_machine after creating perf.session rather than when session is still None. In test_sctop_python.sh: - Use a private temporary directory via 'mktemp -d'. - Drop '-a' and pass '-B -N --no-bpf-event' to 'perf record', and sleep briefly in the subshell ('sh -c "sleep 0.1; sleep 0.05"') with a bounded retry loop so 'sleep's PERF_RECORD_COMM and sys_enter events are reliably captured under heavy load. Fixes: b83f0bacf5e4f936 ("perf python: Port sctop to perf module") Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>