Documentation/translations/zh_CN/scheduler/sched-stats.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/scheduler/sched-stats.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/scheduler/sched-stats.rst- Extension
.rst- Size
- 7639 bytes
- Lines
- 157
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
.. SPDX-License-Identifier: GPL-2.0
.. include:: ../disclaimer-zh_CN.rst
:Original: Documentation/scheduler/sched-stats.rst
:翻译:
唐艺舟 Tang Yizhou <tangyeechou@gmail.com>
==============
调度器统计数据
==============
第15版schedstats去掉了sched_yield的一些计数器:yld_exp_empty,yld_act_empty
和yld_both_empty。在其它方面和第14版完全相同。
第14版schedstats包括对sched_domains(译注:调度域)的支持,该特性进入内核
主线2.6.20,不过这一版schedstats与2.6.13-2.6.19内核的版本12的统计数据是完全
相同的(内核未发布第13版)。有些计数器按每个运行队列统计是更有意义的,其它则
按每个调度域统计是更有意义的。注意,调度域(以及它们的附属信息)仅在开启
CONFIG_SMP的机器上是相关的和可用的。
在第14版schedstat中,每个被列出的CPU至少会有一级域统计数据,且很可能有一个
以上的域。在这个实现中,域没有特别的名字,但是编号最高的域通常在机器上所有的
CPU上仲裁平衡,而domain0是最紧密聚焦的域,有时仅在一对CPU之间进行平衡。此时,
没有任何体系结构需要3层以上的域。域统计数据中的第一个字段是一个位图,表明哪些
CPU受该域的影响。
这些字段是计数器,而且只能递增。使用这些字段的程序将需要从基线观测开始,然后在
后续每一个观测中计算出计数器的变化。一个能以这种方式处理其中很多字段的perl脚本
可见
http://eaglet.pdxhosts.com/rick/linux/schedstat/
请注意,任何这样的脚本都必须是特定于版本的,改变版本的主要原因是输出格式的变化。
对于那些希望编写自己的脚本的人,可以参考这里描述的各个字段。
CPU统计数据
-----------
cpu<N> 1 2 3 4 5 6 7 8 9
第一个字段是sched_yield()的统计数据:
1) sched_yield()被调用了#次
接下来的三个是schedule()的统计数据:
2) 这个字段是一个过时的数组过期计数,在O(1)调度器中使用。为了ABI兼容性,
我们保留了它,但它总是被设置为0。
3) schedule()被调用了#次
4) 调用schedule()导致处理器变为空闲了#次
接下来的两个是try_to_wake_up()的统计数据:
5) try_to_wake_up()被调用了#次
6) 调用try_to_wake_up()导致本地CPU被唤醒了#次
接下来的三个统计数据描述了调度延迟:
7) 本处理器运行任务的总时间,单位是纳秒
8) 本处理器任务等待运行的时间,单位是纳秒
9) 本CPU运行了#个时间片
域统计数据
----------
对于每个被描述的CPU,和它相关的每一个调度域均会产生下面一行数据(注意,如果
CONFIG_SMP没有被定义,那么*没有*调度域被使用,这些行不会出现在输出中)。
domain<N> <cpumask> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
Annotation
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.