[llvm-branch-commits] [llvm] release/19.x: [bolt][tests] Skip tests that use perf when perf counters are unavailable (#107892) (PR #109072)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 17 17:33:16 PDT 2024
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/109072
Backport 773353b20a49bfa0dab608d415c1b4734d037fce
Requested by: @tstellar
>From 556f371381ba68d0c84a0f55c6535013e8950cd4 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Tue, 17 Sep 2024 17:07:35 -0700
Subject: [PATCH] [bolt][tests] Skip tests that use perf when perf counters are
unavailable (#107892)
On the GitHub Action runners, perf always fails with the error below ,
so we need to skip the perf tests on platforms like this that have
limited access to the perf counters.
```
Access to performance monitoring and observability operations is limited.
Consider adjusting /proc/sys/kernel/perf_event_paranoid setting to open
access to performance monitoring and observability operations for processes
without CAP_PERFMON, CAP_SYS_PTRACE or CAP_SYS_ADMIN Linux capability.
More information can be found at 'Perf events and tool security' document:
https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html
perf_event_paranoid setting is 4:
-1: Allow use of (almost) all events by all users
Ignore mlock limit after perf_event_mlock_kb without CAP_IPC_LOCK
>= 0: Disallow raw and ftrace function tracepoint access
>= 1: Disallow CPU event access
>= 2: Disallow kernel profiling
To make the adjusted perf_event_paranoid setting permanent preserve it
in /etc/sysctl.conf (e.g. kernel.perf_event_paranoid = <setting>)
```
(cherry picked from commit 773353b20a49bfa0dab608d415c1b4734d037fce)
---
bolt/test/perf2bolt/lit.local.cfg | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/bolt/test/perf2bolt/lit.local.cfg b/bolt/test/perf2bolt/lit.local.cfg
index 4ee9ad08cc78a0..0fecf913aa98b8 100644
--- a/bolt/test/perf2bolt/lit.local.cfg
+++ b/bolt/test/perf2bolt/lit.local.cfg
@@ -1,4 +1,5 @@
import shutil
+import subprocess
-if shutil.which("perf") is not None:
- config.available_features.add("perf")
\ No newline at end of file
+if shutil.which("perf") is not None and subprocess.run(["perf", "record", "-e", "cycles:u", "-o", "/dev/null", "--", "perf", "--version"], capture_output=True).returncode == 0:
+ config.available_features.add("perf")
More information about the llvm-branch-commits
mailing list