-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run gprofiler without root/sudo #936
Conversation
…exit. Added run_in_ns_wrapper to only run in namespace when root is detected. Updated pgrep_maps to provide parameter that ignores permission errors when not root.
…er_tmp directory. Added pids_to_process to discover_appropriate_perf_event(), so it will not error out on perf record -a while not root. Changed TEMPORARY_STORAGE_PATH to the resources directory.
I prefer that the rootless mode will be opt-in, and not a default in case of non-root user (which allows misconfigurations to continue misusing the profiler).
I left some comments on the PR about this topic.
Not sure I got you here.
Yeah, it's fine - as I commented on granulate-utils, proc_events are expected to fail in rootless. |
… is_root function (now in granulate-utils). Added mkdir_owned_root_wrapper. Moved TEMPORARY_STORAGE_PATH back to /tmp. pgrep_maps root check now inside function
I added a commit that should address all of your comments, but let me know if there is anything I should change. In particular with the new --rootless option and in mkdir_owned_root_wrapper. |
…g os.mkdir. Also some linting.
Hi!
|
I updated the granulate-utils reference to dd8aa29 in the latest commit |
Added a commit to address the test_not_root checklist failure. |
Description
This PR adds support for running gprofiler without root/sudo as discussed in issue 905. There are several assumptions and components that I will mention here.
This PR requires a change in the granulate-utils repo that defines the run_in_ns_wrapper function found in PR 265 on that repo intel/granulate-utils#265.
Assumptions when running without root:
Components:
Potential issues:
Related Issue
#905
Motivation and Context
Users of this gprofiler have requested this feature as some cloud instances do not have root access, but still want to profile user owned processes.
How Has This Been Tested?
I ran stress-ng and targeted gprofiler to the stress-ng pids without sudo. It successfully produced flamegraphs
Sample command line: ./build/x86_64/gprofiler --pids 1421864 -o results/ -d 15 --log-file ./gprofiler.log --pid-file ./gprofiler.pid
I have tested this on x86 using scripts/build_x86_64_executable.sh script. Centos 9 Stream w/ kernel 6.6
Also tested using sudo targeting specific pid(s) and system-wide, and it still works.
Was not able to run tests/test.sh as it required apt-get/debian environment.
Screenshots
Checklist:
The code is linted.
I have not updated the README.md doc here. Might need some guidance.