Skip to content

Add PMU_Hardware_Events suite - #729

Open
vnarapar wants to merge 2 commits into
qualcomm-linux:mainfrom
vnarapar:pmu-hardware-events
Open

vnarapar wants to merge 2 commits into
qualcomm-linux:mainfrom
vnarapar:pmu-hardware-events

Conversation

@vnarapar

Copy link
Copy Markdown
Contributor

Summary

Adds the PMU_Hardware_Events suite (PR 3 of 5 PMU validation PRs): run.sh, LAVA YAML and README under Runner/suites/Kernel/Baseport/PMU_Hardware_Events.

cycles and instructions are required; branches, branch-misses, bus-cycles and stall events are optional (SKIP when unsupported). Also checks IPC upper bound, branch-misses <= branches, stalls <= cycles, and {cycles,instructions} grouping.

Merge order

Depends on #727 - merge #727 first. This suite uses Runner/utils/lib_pmu.sh introduced there. This branch is based on #727, so until it merges the diff also shows its commit. Once #727 is merged, only this suite's commit remains. PRs 2-5 are independent of each other and can merge in any order after #727.

Validation

  • ShellCheck 0.9.0 with the CI flags (-s sh -e SC1091,SC2230,SC3043): clean.
  • sh -n syntax check: clean. Git modes: run.sh 100755, YAML and README 100644.
  • Not yet run on target hardware. SKIPs when perf or an armv8_pmuv3 PMU is absent.

else
test_result_record FAIL "Online CPUs without a PMU instance:$missing"
fi
elif [ "$device_count" -eq 1 ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When multiple PMU instances are present and any instance lacks cpus or cpumask, this path only logs a warning and records no result for the promised CPU coverage check. The suite can still finish PASS even though it did not prove every online CPU is served, record a FAIL or explicit SKIP for that multi-PMU unknown state instead of falling through.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the PMU_Discovery commit from #727 (c481c79), which this branch is based on. With several PMU instances and a missing cpus/cpumask list the suite now records FAIL. A single instance records an explicit SKIP.

OUT_DIR=$(test_create_run_directory "$PWD/results/$TESTNAME") || test_result_finish FAIL "Cannot create evidence directory"
COUNTS="$OUT_DIR/counts.txt"
: >"$COUNTS"
FIRST_CPU="$(get_online_cpus | awk 'NR==1')"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This selects only the first online CPU and all required event and group measurements run there. On heterogeneous systems, a PMU serving another CPU mask can fail cycles, instructions or grouping while this suite still passes, iterate the discovered PMUs with pmu_first_cpu_of_device or narrow the suite to single-CPU smoke coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dbfec2c. The checks now run per PMU instance, on the first online CPU served by each instance.

fi
;;
*)
test_result_record FAIL "$event perf stat failed, see $out"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perf failure details are kept only in files under results/, while the YAML publishes only the .res file after the runner. Replay a bounded excerpt with the existing log_file_with_label helper before recording the FAIL or missing-event result so direct runs and LAVA show the actual perf error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dbfec2c. Failed, unsupported-required and zero-count paths now replay the perf output with pmu_replay_output.

Add Runner/utils/lib_pmu.sh with helpers to discover armv8_pmuv3 PMU
instances from sysfs and to run bounded, optionally CPU-pinned perf stat
measurements. Add the PMU_Discovery suite that validates the perf type id,
event format, named and architected events, CPU coverage and perf hardware
event listing.

Signed-off-by: Vamsee Narapareddi <vnarapar@qti.qualcomm.com>
@vnarapar
vnarapar force-pushed the pmu-hardware-events branch from 19dcd88 to d1a9aa6 Compare November 29, 2026 10:27
# PMU instance, so heterogeneous systems are covered per PMU.
validate_pmu() {
PMU_DEV="$1"
FIRST_CPU="$(pmu_first_cpu_of_device "$PMU_DEV")"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This records per-PMU measurements using FIRST_CPU, but pmu_measure only applies taskset -c when taskset exists and otherwise runs the workload unpinned. On images without taskset, the suite can report a later PMU instance passed even though no workload was forced onto one of its CPUs, require taskset or cpu_is_schedulable "$FIRST_CPU" before per-PMU measurement and SKIP when it is unavailable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dbfec2c. With more than one PMU instance a missing taskset, or a CPU that fails cpu_is_schedulable, now records SKIP for that PMU instead of running unpinned. A single PMU may still run unpinned. README updated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the current head. Multi-PMU runs now SKIP before measurement when taskset is missing, and they call cpu_is_schedulable "$FIRST_CPU" before pinned per-PMU measurements.

Validate generic PMU hardware events with perf stat (cycles, instructions, branches, branch-misses, bus-cycles, stalls) and their cross-event consistency and grouping.

Signed-off-by: Vamsee Narapareddi <vnarapar@qti.qualcomm.com>
@vnarapar
vnarapar force-pushed the pmu-hardware-events branch from d1a9aa6 to dbfec2c Compare November 29, 2026 11:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants