Skip to content
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

tools/cpudist: Fix concurrency issue caused by idle threads & Exclude CPU idle time by default #3924

Merged
merged 2 commits into from
Mar 28, 2022

Conversation

xingfeng2510
Copy link
Contributor

@xingfeng2510 xingfeng2510 commented Mar 27, 2022

  1. Fix concurrency issue caused by idle threads

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.

  1. Exclude CPU idle time by default

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:

# ./cpudist.py -Tm 1

14:45:36
     msecs               : count     distribution
         0 -> 1          : 676      |****************************************|
         2 -> 3          : 18       |*                                       |
         4 -> 7          : 119      |*******                                 |
         8 -> 15         : 74       |****                                    |
        16 -> 31         : 52       |***                                     |
        32 -> 63         : 175      |**********                              |
        64 -> 127        : 34       |**                                      |
       128 -> 255        : 9        |                                        |
       256 -> 511        : 10       |                                        |
       512 -> 1023       : 11       |                                        |
      1024 -> 2047       : 3        |                                        |
      2048 -> 4095       : 36       |**                                      |

14:45:37
     msecs               : count     distribution
         0 -> 1          : 739      |****************************************|
         2 -> 3          : 12       |                                        |
         4 -> 7          : 115      |******                                  |
         8 -> 15         : 76       |****                                    |
        16 -> 31         : 46       |**                                      |
        32 -> 63         : 191      |**********                              |
        64 -> 127        : 39       |**                                      |
       128 -> 255        : 2        |                                        |
       256 -> 511        : 7        |                                        |
       512 -> 1023       : 18       |                                        |

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:

# ./cpudist.py -Tm 1

14:48:02
     msecs               : count     distribution
         0 -> 1          : 519      |****************************************|
         2 -> 3          : 1        |                                        |
         4 -> 7          : 0        |                                        |
         8 -> 15         : 2        |                                        |

14:48:03
     msecs               : count     distribution
         0 -> 1          : 540      |****************************************|
         2 -> 3          : 1        |                                        |
         4 -> 7          : 0        |                                        |
         8 -> 15         : 2        |                                        |

@yonghong-song @brendangregg Please take a look this patch, thanks!

@yonghong-song
Copy link
Collaborator

Agree that by default we should exclude idle task as the tool's main purpose is to cpu usage distribution for non-idle useful tasks.

@yonghong-song yonghong-song merged commit c1a767b into iovisor:master Mar 28, 2022
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.

2 participants