tools/cpudist: Fix concurrency issue caused by idle threads & Exclude CPU idle time by default #3924
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.
Like #2804, #3740, pid as key not be suitable for multiple idle threads (pid = 0), which may lead to incorrect delta time. Combines cpu and pid as unique key to avoid this issue.
Currently, cpudist includes CPU idle time by default. When idle threads (pid = 0) mixed with other threads (pid != 0), the output of cpudist is not clear enough, CPU time distribution of idle threads are usually very large on a not busy system (hundreds of milliseconds, even > 1s).
For example:
As #2166, exclude CPU idle time by default, simply check whether pid == 0. Add option -I to include CPU idle time (same as before).
Also, runqlat excludes idle threads directly (#1741).
After excluding CPU idle time by default, for example, the output looks simple and clear:
@yonghong-song @brendangregg Please take a look this patch, thanks!