[llvm] [bolt][tests] Skip tests that use perf when perf counters are unavailable (PR #107892)
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 11:48:47 PDT 2024
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/107892
>From a4256ad48b28e42521b780d6b4ce4c0225ff9901 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sat, 7 Sep 2024 15:04:51 +0000
Subject: [PATCH 1/2] [bolt][tests] Skip tests that use perf when perf counters
are unavailable
On the GitHub test runners, perf always the below error, so we need to
skip the perf tests on these platforms (and other platforms with the
same behavior):
```
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>)
```
---
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..9f20f37c6a1d7d 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"], capture_output=True).returncode == 0:
+ config.available_features.add("perf")
>From 9ad4c4164d9a38e03622faeef45927b64f1540c8 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Mon, 9 Sep 2024 11:48:24 -0700
Subject: [PATCH 2/2] fix check
---
bolt/test/perf2bolt/lit.local.cfg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bolt/test/perf2bolt/lit.local.cfg b/bolt/test/perf2bolt/lit.local.cfg
index 9f20f37c6a1d7d..1ac0e494226e2d 100644
--- a/bolt/test/perf2bolt/lit.local.cfg
+++ b/bolt/test/perf2bolt/lit.local.cfg
@@ -1,5 +1,5 @@
import shutil
import subprocess
-if shutil.which("perf") is not None and subprocess.run(["perf", "record", "-e", "cycles:u", "-o", "/dev/null", "--", "perf"], capture_output=True).returncode == 0:
+if shutil.which("perf") is not None and subprocess.run(["perf", "record", "-e", "cycles:u", "-o", "/dev/null", "--", "perf", "--version"], capture_output=False).returncode == 0:
config.available_features.add("perf")
More information about the llvm-commits
mailing list