@@ -74,14 +74,12 @@ def install_sio2jail(directory=None):
74
74
75
75
def check_perf_counters_enabled ():
76
76
"""
77
- Checks if sio2jail is able to use perf counters to count instructions.
77
+ Checks if `kernel.perf_event_paranoid` is set to -1.
78
+ :return:
78
79
"""
79
- if not sio2jail_supported () or not check_sio2jail ():
80
+ if not util . is_linux () or not check_sio2jail ():
80
81
return
81
82
82
- with open ('/proc/sys/kernel/perf_event_paranoid' ) as f :
83
- perf_event_paranoid = int (f .read ())
84
-
85
83
sio2jail = get_default_sio2jail_path ()
86
84
test_file = os .path .join (os .path .dirname (os .path .realpath (__file__ )), 'perf_test.py' )
87
85
python_executable = sys .executable
@@ -96,21 +94,9 @@ def check_perf_counters_enabled():
96
94
process .terminate ()
97
95
98
96
if output != "Test string\n " :
99
- max_perf_event_paranoid = 2
100
- if perf_event_paranoid > max_perf_event_paranoid :
101
- hint = (f"You have `kernel.perf_event_paranoid` set to `{ perf_event_paranoid } `"
102
- ", which might be preventing userspace perf counters from working.\n "
103
- f"Try running: `sudo sysctl kernel.perf_event_paranoid={ max_perf_event_paranoid } `\n "
104
- "If that fixes the problem, you can set this permanently by adding "
105
- f"`kernel.perf_event_paranoid={ max_perf_event_paranoid } ` to `/etc/sysctl.conf` and rebooting.\n " )
106
- else :
107
- hint = ("Your kernel, drivers, or hardware might be too old.\n "
108
- "Check if the Intel PMU driver is loaded: `dmesg | grep -i 'perf'`\n "
109
- "You can also check if the perf tool works correctly: `perf stat -e instructions:u -- sleep 0`\n "
110
- "(if perf can't be found, it might be located in: `/usr/lib/linux-tools/*/perf`).\n " )
111
- cmdline = " " .join (process .args )
112
- util .exit_with_error (f"Failed performance counters test: `{ cmdline } `\n "
113
- + hint +
114
- "Alternatively, you can run sinol-make without instruction counting"
115
- ", by adding the `--time-tool time` flag.\n "
116
- "For more details, see https://github.com/sio2project/sio2jail#running.\n " )
97
+ util .exit_with_error ("To use the recommended tool for measuring time called `sio2jail`, please:\n "
98
+ "- execute `sudo sysctl kernel.perf_event_paranoid=-1` to make `sio2jail` work for\n "
99
+ " the current system session,\n "
100
+ "- or add `kernel.perf_event_paranoid=-1` to `/etc/sysctl.conf`\n "
101
+ " and reboot to permanently make sio2jail work.\n "
102
+ "For more details, see https://github.com/sio2project/sio2jail#running.\n " )
0 commit comments