Skip to content

Conversation

@adamtassier
Copy link

Hi,

This PR changes the file system location that is checked for tracefs. At least since linux v4.1 the default location has been /sys/kernel/tracing/ instead of /sys/kernel/debug/tracing/ (but the latter was kept for compatability).

I also changed the tooltip of the 'off-cpu profiling' checkbox to better reflect the conditions under which it can be checked as I had to go look into the source code.

This was an issue for me when setting up rootless 'off-cpu profiling' (ie not using 'elevate privileges'). Turns out the problem was that /sys/kernel/debug/tracing/ was not readable on my machine but /sys/kernel/tracing/ was (via tracing group).

…ernel/debug/tracing. The default location for tracefs has been /sys/kernel/tracing since at least linux v4.1.
…uire elevated privileges if both /sys/kernel/tracing is readable and /proc/sys/kernel/perf_event_paranoid == -1
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
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
Member

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
Member

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?

@lievenhey lievenhey requested a review from milianw April 22, 2025 10:55
Copy link
Member

@milianw milianw left a comment

Choose a reason for hiding this comment

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

ping? will you attend the review comment I gave you?

@adamtassier
Copy link
Author

@milianw see latest commit 262cd7d

I did remove the permission check on /sys/kernel/debug/ as we dont need to directly use it and stat will fail anyway if anything in the path to /sys/kernel/debug/tracing is not executable.

@adamtassier adamtassier requested a review from milianw May 8, 2025 13:29
@adamtassier adamtassier requested a review from milianw May 9, 2025 08:01
@GitMensch
Copy link
Contributor

Looks like a rebase may fix the failing checks, sounds like a good change to get in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants