Filesystem: speed up get pids #2084
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For
force_umount=safe
, we can significantly speed up get_pids() by limiting the search for significant symlinksto the process and skipping the tasks (or threads).
We are interested in
/proc/<pid>/{cwd,root,exe}
and/proc/<pid>/fd/<fd>
as well as memory mappings.All of these are per process, not per thread. We can save us a lot of time and effort by not scanning
/proc/<pid>/taks/<tid>/*
, we'd only to find identical information there.Even on a mostly idle system with just a few "heavily threaded" processes,
this can speed up the scanning by a factor of 10.
With "modern" linux kernels, we can also drop the "grep" in
maps
, we already found the symlinks inmap_files/
.