查询与进程调度(CFS)相关信息

目录

查询与进程相关的调度信息

查看CFS调度信息 

 CPU相关的信息

CFS就绪队列的总运行时间 

实时队列与deadline调度的相关信息

所有进程相关的信息

查询与进程相关的调度信息

进程的nice值,优先级,调度策略,vruntime等信息。在proc目录下,以下是查询147号进程的调度信息。 

cat /proc/3675/sched
update-notifier (3675, #threads: 4) //进程名称,ID:3675  以及线程数4
-------------------------------------------------------------------
se.exec_start                                :      26628458.370080 //进程总执行时间
se.vruntime                                  :         89527.417357 //虚拟运行时间
se.sum_exec_runtime                          :           142.850903 //总运行时间
se.nr_migrations                             :                    9 //发生9次迁移,
nr_switches                                  :                  727 //727次上下文切换
nr_voluntary_switches                        :                  648 //主动调度次数
nr_involuntary_switches                      :                   79 //被抢占次数
se.load.weight                               :              1048576//进程权重
se.runnable_weight                           :              1048576//
se.avg.load_sum                              :                   58
se.avg.runnable_load_sum                     :                   58
se.avg.util_sum                              :                59392
se.avg.load_avg                              :                    0//量化负载
se.avg.runnable_load_avg                     :                    0
se.avg.util_avg                              :                    0 //进程的量化能力
se.avg.last_update_time                      :       26628458370048
se.avg.util_est.ewma                         :                    9
se.avg.util_est.enqueued                     :                    0
policy                                       :                    0//调度策略 SCHED_NORMAL
prio                                         :                  120//优先级
clock-delta                                  :                   14
mm->numa_scan_seq                            :                    0
numa_pages_migrated                          :                    0
numa_preferred_nid                           :                   -1
total_numa_faults                            :                    0
current_node=0, numa_group_id=0
numa_faults node=0 task_private=0 task_shared=0 group_private=0 group_shared=0
root@ubuntu:/home/wy/release# 

调度相关的统计 需要配置CONFIG_SCHEDSTATS

先执行 echo 1 > /proc/sys/kernel/sched_schedstats

再次查看,多出来好多statistics信息

cat /proc/3675/sched
update-notifier (3675, #threads: 4)
-------------------------------------------------------------------
se.exec_start                                :      26666000.266305
se.vruntime                                  :         48799.679246
se.sum_exec_runtime                          :           144.183408
se.nr_migrations                             :                   11

se.statistics.sum_sleep_runtime              :             0.000000
se.statistics.wait_start                     :             0.000000
se.statistics.sleep_start                    :             0.000000
se.statistics.block_start                    :             0.000000
se.statistics.sleep_max                      :             0.000000
se.statistics.block_max                      :             0.000000
se.statistics.exec_max                       :             0.000000
se.statistics.slice_max                      :             0.000000
se.statistics.wait_max                       :             0.000000
se.statistics.wait_sum                       :             0.000000
se.statistics.wait_count                     :                    0
se.statistics.iowait_sum                     :             0.000000
se.statistics.iowait_count                   :                    0
se.statistics.nr_migrations_cold             :                    0
se.statistics.nr_failed_migrations_affine    :                    0
se.statistics.nr_failed_migrations_running   :                    0
se.statistics.nr_failed_migrations_hot       :                    0
se.statistics.nr_forced_migrations           :                    0
se.statistics.nr_wakeups                     :                    0
se.statistics.nr_wakeups_sync                :                    0
se.statistics.nr_wakeups_migrate             :                    0
se.statistics.nr_wakeups_local               :                    0
se.statistics.nr_wakeups_remote              :                    0
se.statistics.nr_wakeups_affine              :                    0
se.statistics.nr_wakeups_affine_attempts     :                    0
se.statistics.nr_wakeups_passive             :                    0
se.statistics.nr_wakeups_idle                :                    0
avg_atom                                     :             0.194579
avg_per_cpu                                  :            13.107582
nr_switches                                  :                  741
nr_voluntary_switches                        :                  662
nr_involuntary_switches                      :                   79
se.load.weight                               :              1048576
se.runnable_weight                           :              1048576
se.avg.load_sum                              :                   98
se.avg.runnable_load_sum                     :                   98
se.avg.util_sum                              :               100391
se.avg.load_avg                              :                    0
se.avg.runnable_load_avg                     :                    0
se.avg.util_avg                              :                    0
se.avg.last_update_time                      :       26666000266240
se.avg.util_est.ewma                         :                    8
se.avg.util_est.enqueued                     :                    1
policy                                       :                    0
prio                                         :                  120
clock-delta                                  :                   15
mm->numa_scan_seq                            :                    0
numa_pages_migrated                          :                    0
numa_preferred_nid                           :                   -1
total_numa_faults                            :                    0
current_node=0, numa_group_id=0
numa_faults node=0 task_private=0 task_shared=0 group_private=0 group_shared=0

查看CFS调度信息 

Sched Debug Version: v0.11, 5.4.0-26-generic #30-Ubuntu
ktime                                   : 2270227.937775
sched_clk                               : 2270675.741916
cpu_clk                                 : 2270509.286495
jiffies                                 : 4295459310
sched_clock_stable()                    : 1

sysctl_sched
  .sysctl_sched_latency                    : 18.000000
  .sysctl_sched_min_granularity            : 2.250000
  .sysctl_sched_wakeup_granularity         : 3.000000
  .sysctl_sched_child_runs_first           : 0
  .sysctl_sched_features                   : 2059067
  .sysctl_sched_tunable_scaling            : 1 (logarithmic)

  • 和调度相关的sysctl_sched的值
  • 调度周期sysctl_sched_latency为 18ms.
  • 调度最小粒度为2.25ms
  • 唤醒最小粒度 3ms
  • fork调用完成之后,禁止子进程先运行

 CPU相关的信息

cpu#0, 2904.003 MHz
  .nr_running                    : 1
  .nr_switches                   : 360530
  .nr_load_updates               : 0
  .nr_uninterruptible            : 3
  .next_balance                  : 4295.459320
  .curr->pid                     : 11123
  .clock                         : 2270510.005225
  .clock_task                    : 2270510.005225
  .avg_idle                      : 1000000
  .max_idle_balance_cost         : 500000
  • nr_running 有1个进程在就绪队列里
  • nr_switches 就绪队列发生进程切换的次数
  • nr_load_updates 就绪队列里的cpu_load[]平滑负载更新的次数。
  • next_balance 下一次做负载均衡的时间。
  • curr->pid,正在运行的PID
  • clock和clock_task:当前系统采样的时刻。

CFS就绪队列的总运行时间 

cfs_rq[0]:/system.slice/containerd.service
  .exec_clock                    : 0.000000
  .MIN_vruntime                  : 0.000001
  .min_vruntime                  : 820.991457
  .max_vruntime                  : 0.000001
  .spread                        : 0.000000
  .spread0                       : -127322.729964
  .nr_spread_over                : 0
  .nr_running                    : 0
  .load                          : 0
  .runnable_weight               : 0
  .load_avg                      : 0
  .runnable_load_avg             : 0
  .util_avg                      : 0
  .util_est_enqueued             : 0
  .removed.load_avg              : 0
  .removed.util_avg              : 0
  .removed.runnable_sum          : 0
  .tg_load_avg_contrib           : 0
  .tg_load_avg                   : 0
  .throttled                     : 0
  .throttle_count                : 0
  .se->exec_start                : 2270382.435692
  .se->vruntime                  : 57637.719433
  .se->sum_exec_runtime          : 1692.348700
  .se->load.weight               : 1048576
  .se->runnable_weight           : 2
  .se->avg.load_avg              : 0
  • exec_clock :CFS就绪队列的总运行时间;
  • min_vruntime:表示CFS就绪队列的红黑树中最左边节点的 vruntime;
  • max_vrunrime:CFS就绪队列的红黑树中最右边节点的vruntime;
  • nr_running :CFS就绪队列中的进程数
  • load:CFS就绪队列的总权重
  • runnable_weight:CFS就绪队列中可运行状态的进程总权重
  • load_avg:调度队列中的量化负载,这是CFS就绪队列中所有进程的量化负载之和
  • runnable_load_avg:CFS就绪队列里所有可运行状态下的进程总量化负载
  • util_avg:CFS就绪队列当前的量化计算能力

实时队列与deadline调度的相关信息

rt_rq[0]:/system.slice/cups-browsed.service
  .rt_nr_running                 : 0
  .rt_nr_migratory               : 0
  .rt_throttled                  : 0
  .rt_time                       : 0.000000
  .rt_runtime                    : 0.000000


dl_rq[0]:
  .dl_nr_running                 : 0
  .dl_nr_migratory               : 0
  .dl_bw->bw                     : 996147
  .dl_bw->total_bw               : 0

所有进程相关的信息

runnable tasks:
 S           task   PID         tree-key  switches  prio     wait-time             sum-exec        sum-sleep
-----------------------------------------------------------------------------------------------------------
 S       kthreadd     2    127693.921719       338   120         0.000000        61.877558         0.000000 0 0 /
 I         rcu_gp     3        14.125023         2   100         0.000000         0.003748         0.000000 0 0 /
 I     rcu_par_gp     4        16.125400         2   100         0.000000         0.002300         0.000000 0 0 /
 I   kworker/0:0H     6      3901.743231         7   100         0.000000         0.123376         0.000000 0 0 /
 I   mm_percpu_wq     9        21.695937         2   100         0.000000         0.003137         0.000000 0 0 /
 S    ksoftirqd/0    10    127884.405645      1528   120         0.000000        55.672180         0.000000 0 0 /
 S    migration/0    12         0.000000       744     0         0.000000        28.640041         0.000000 0 0 /
 S  idle_inject/0    13         0.000000         3    49         0.000000         0.005038         0.000000 0 0 /
 S        cpuhp/0    14      9840.872379        10   120         0.000000         0.317368         0.000000 0 0 /
 I       kthrotld   154      2441.635038         2   100         0.000000         0.033174         0.000000 0 0 /
 S  irq/26-pciehp   157         0.000000         3    49         0.000000         0.215568         0.000000 0 0 /
 S  irq/30-pciehp   161         0.000000         3    49         0.000000         0.140429         0.000000 0 0 /
 S  irq/34-pciehp   165         0.000000         3    49         0.000000         0.190453         0.000000 0 0 /
 S  irq/38-pciehp   169         0.000000         3    49         0.000000         0.139489         0.000000 0 0 /
 S  irq/42-pciehp   173         0.000000         3    49         0.000000         0.139024         0.000000 0 0 /
 S  irq/46-pciehp   177         0.000000         3    49         0.000000         0.177426         0.000000 0 0 /
 S  irq/50-pciehp   181         0.000000         3    49         0.000000         0.086663         0.000000 0 0 /
 S  irq/54-pciehp   185         0.000000         3    49         0.000000         0.122572         0.000000 0 0 /
 I     scsi_tmf_1   192      2450.674661         2   100         0.000000         0.040843         0.000000 0 0 /
 Ivfio-irqfd-clea   194      2450.675783         2   100         0.000000         0.078805         0.000000 0 0 /
 Icharger_manager   227      2589.239305         2   100         0.000000         0.035306         0.000000 0 0 /
 I          mpt/0   297      3102.875515         2   100         0.000000         0.134915         0.000000 0 0 /
 Ikworker/u256:28   365    128003.470404      5326   120         0.000000       333.547859         0.000000 0 0 /
 I   kworker/0:1H   377    127827.693809      1669   100         0.000000       242.858239         0.000000 0 0 /
 Svmware-vmblock-   492         1.857542         5   120         0.000000         0.497505         0.000000 0 0 /system.slice/run-vmblock\x2dfuse.mount
 S          loop6   494      7943.387963        84   100         0.000000        21.071145         0.000000 0 0 /
 S          loop8   497     22417.738300        78   100         0.000000        16.332343         0.000000 0 0 /

你可能感兴趣的:(linux内核分析,linux,调度信息)