Verify counter config in /sys/kernel
In this step, you will explore how performance counter configurations are exposed in the Linux kernel's /sys
filesystem. The /sys
filesystem provides an interface to kernel data structures, allowing you to inspect and sometimes modify kernel parameters.
Performance counter settings, such as whether unprivileged users can access raw performance counter events, are often controlled through files in /sys/kernel/perf_event
.
Let's navigate to the relevant directory and inspect a configuration file.
First, use the cd
command to change your current directory to /sys/kernel/perf_event
. Remember, your default directory is ~/project
, so you need to use the absolute path.
Type the following command and press Enter:
cd /sys/kernel/perf_event
Now you are in the /sys/kernel/perf_event
directory. You can use the ls
command to see the files within this directory:
ls
You should see a list of files, which might include:
kptr_restrict perf_event_paranoid sysfs_deprecated
The file we are interested in is perf_event_paranoid
. This file controls the level of access unprivileged users have to performance events. A lower value means less paranoia (more access), and a higher value means more paranoia (less access).
Let's view the content of this file using the cat
command:
cat perf_event_paranoid
The output will be a single number, typically between -1 and 2.
<number>
Here's what the different values generally mean:
-1
: Allow all users to use all perf
features.
0
: Allow all users to use perf
for per-process and per-CPU measurements.
1
: Allow only privileged users (like root) to use perf
for per-process and per-CPU measurements.
2
: Allow only privileged users to use perf
for per-process measurements.
The default value is often 2 for security reasons, preventing unprivileged users from potentially using performance counters to gain information about other processes.
Understanding this file helps you see how the system is configured regarding performance monitoring access.
Click Continue to move on.