Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/recordhost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ QByteArray perfBuildOptions(const QString& perfPath)

bool canTrace(const QString& path)
{
const QFileInfo info(QLatin1String("/sys/kernel/debug/tracing/") + path);
const QFileInfo info(QLatin1String("/sys/kernel/tracing/") + path);
Comment thread
milianw marked this conversation as resolved.
if (!info.isDir() || !info.isReadable()) {
return false;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ bool privsAlreadyElevated()
struct stat buf;
return stat(path, &buf) == 0 && ((buf.st_mode & 07777) & required) == required;
};
static const auto paths = {"/sys/kernel/debug", "/sys/kernel/debug/tracing"};
static const auto paths = {"/sys/kernel/", "/sys/kernel/tracing"};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Checking /sys/kernel is probably redundant here right?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think so, yes - the old code was needed back then (Linux 3.x I think), because there tracing was mounted into debug, and thus needed to be checked separately

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

that said, I wouldn't mind if we could rework this code:

check first if sys/kernel/tracing is usable, if so return early. otherwise keep backwards compat and check the two old locations?

isElevated = std::all_of(paths.begin(), paths.end(), checkPerms);

return isElevated;
Expand Down
6 changes: 4 additions & 2 deletions src/recordpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@
<item row="2" column="0">
<widget class="QLabel" name="offCpuLabel">
<property name="toolTip">
<string>Record scheduler switch events. This enables off-CPU profiling to measure sleep times etc. This requires elevated privileges.</string>
<string>Record scheduler switch events. This enables off-CPU profiling to measure sleep times etc.
This requires elevated privileges or both /sys/kernel/tracing to be readable and /proc/sys/kernel/perf_event_paranoid == -1.</string>
Comment thread
milianw marked this conversation as resolved.
</property>
<property name="text">
<string>Off-CPU Profilin&amp;g:</string>
Expand All @@ -278,7 +279,8 @@
<item row="2" column="1">
<widget class="QCheckBox" name="offCpuCheckBox">
<property name="toolTip">
<string>Record scheduler switch events. This enables off-CPU profiling to measure sleep times etc. This requires elevated privileges.</string>
<string>Record scheduler switch events. This enables off-CPU profiling to measure sleep times etc.
This requires elevated privileges or both /sys/kernel/tracing to be readable and /proc/sys/kernel/perf_event_paranoid == -1.</string>
</property>
<property name="text">
<string/>
Expand Down