找出 Linux 中一个进程休眠了多长时间?

发布于 2024-10-19 16:27:31 字数 1459 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

当爱已成负担 2024-10-26 16:27:31

/proc/pid/sched 文件包含大量调度数据:

$ cat sched
bash (2192, #threads: 1)
---------------------------------------------------------
se.exec_start                      :     294360163.632873
se.vruntime                        :         17694.720927
se.sum_exec_runtime                :          2643.766318
se.statistics.wait_start           :             0.000000
se.statistics.sleep_start          :     294360163.632873
se.statistics.block_start          :             0.000000
se.statistics.sleep_max            :      34689385.720961
se.statistics.block_max            :         11337.665116
se.statistics.exec_max             :             7.657145
se.statistics.slice_max            :             0.550257
se.statistics.wait_max             :             7.464190
se.statistics.wait_sum             :            37.981183
se.statistics.wait_count           :                13774
se.statistics.iowait_sum           :          1556.105204
se.statistics.iowait_count         :                  278
sched_info.bkl_count               :                    0
se.nr_migrations                   :                 2816
se.statistics.nr_migrations_cold   :                    0
se.statistics.nr_failed_migrations_affine:                    0
se.statistics.nr_failed_migrations_running:                  335
se.statistics.nr_failed_migrations_hot:                   14
se.statistics.nr_forced_migrations :                    0
se.statistics.nr_wakeups           :                13471
se.statistics.nr_wakeups_sync      :                 3293
se.statistics.nr_wakeups_migrate   :                 2532
se.statistics.nr_wakeups_local     :                  655
se.statistics.nr_wakeups_remote    :                12816
se.statistics.nr_wakeups_affine    :                   78
se.statistics.nr_wakeups_affine_attempts:                 9452
se.statistics.nr_wakeups_passive   :                    0
se.statistics.nr_wakeups_idle      :                    0
avg_atom                           :             0.196329
avg_per_cpu                        :             0.938837
nr_switches                        :                13466
nr_voluntary_switches              :                13447
nr_involuntary_switches            :                   19
se.load.weight                     :                 1024
policy                             :                    0
prio                               :                  120
clock-delta                        :                   95

我建议通读 /proc/*/sched 文件,查找 se.statistics .nr_wakeupsse.statistics.wait_count 行一小时内不会发生变化。我不知道哪一个会给你“更好”的结果,但尝试两者:),看看哪一个给你像你期望的答案。

The /proc/pid/sched file contains a metric ton of scheduling data:

$ cat sched
bash (2192, #threads: 1)
---------------------------------------------------------
se.exec_start                      :     294360163.632873
se.vruntime                        :         17694.720927
se.sum_exec_runtime                :          2643.766318
se.statistics.wait_start           :             0.000000
se.statistics.sleep_start          :     294360163.632873
se.statistics.block_start          :             0.000000
se.statistics.sleep_max            :      34689385.720961
se.statistics.block_max            :         11337.665116
se.statistics.exec_max             :             7.657145
se.statistics.slice_max            :             0.550257
se.statistics.wait_max             :             7.464190
se.statistics.wait_sum             :            37.981183
se.statistics.wait_count           :                13774
se.statistics.iowait_sum           :          1556.105204
se.statistics.iowait_count         :                  278
sched_info.bkl_count               :                    0
se.nr_migrations                   :                 2816
se.statistics.nr_migrations_cold   :                    0
se.statistics.nr_failed_migrations_affine:                    0
se.statistics.nr_failed_migrations_running:                  335
se.statistics.nr_failed_migrations_hot:                   14
se.statistics.nr_forced_migrations :                    0
se.statistics.nr_wakeups           :                13471
se.statistics.nr_wakeups_sync      :                 3293
se.statistics.nr_wakeups_migrate   :                 2532
se.statistics.nr_wakeups_local     :                  655
se.statistics.nr_wakeups_remote    :                12816
se.statistics.nr_wakeups_affine    :                   78
se.statistics.nr_wakeups_affine_attempts:                 9452
se.statistics.nr_wakeups_passive   :                    0
se.statistics.nr_wakeups_idle      :                    0
avg_atom                           :             0.196329
avg_per_cpu                        :             0.938837
nr_switches                        :                13466
nr_voluntary_switches              :                13447
nr_involuntary_switches            :                   19
se.load.weight                     :                 1024
policy                             :                    0
prio                               :                  120
clock-delta                        :                   95

I suggest reading through the /proc/*/sched files looking for se.statistics.nr_wakeups or se.statistics.wait_count lines that don't change for an hour. I don't know off-hand which one would give you 'better' results, but try both :) and see which one gives you answers like you expect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文