tg: add cpu's wait_count of a task group
PATCH 1/1 tg: add cpu's wait_count of a task group
From: Liming Wu <[email protected]>
Now we can rely on PSI to reflect whether there is contention in the task group, but it cannot reflect the details of the contention. Through this metric, we can get details of task group contention
from the dimension of scheduling.
delta(wait_sum)/delta(wait_count)
Also unified the cpu.stat output of cgroup v1 and v2
Signed-off-by Liming Wu <19092205-t/fWbKJQg0/[email protected]>
--- kernel/sched/core.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)
kernel/sched/core.c +28 -5
@@ -8139,19 +8139,29 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v) {struct task_group *tg =css_tg (seq_css (sf));struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; +u64 throttled_usec; -seq_printf (sf,"nr_periods %d\n" , cfs_b->nr_periods); -seq_printf (sf,"nr_throttled %d\n" , cfs_b->nr_throttled); -seq_printf (sf,"throttled_time %llu\n" , cfs_b->throttled_time); + throttled_usec = cfs_b->throttled_time; +do_div (throttled_usec,NSEC_PER_USEC ); + +seq_printf (sf,"nr_periods %d\n" +"nr_throttled %d\n" +"throttled_usec %llu\n" , + cfs_b->nr_periods, cfs_b->nr_throttled, + throttled_usec);if (schedstat_enabled () && tg != &root_task_group) {u64 ws =0 ; +u64 wc =0 ;int i; -for_each_possible_cpu (i) +for_each_possible_cpu (i) { ws +=schedstat_val (tg->se[i]->statistics.wait_sum); + wc +=schedstat_val (tg->se[i]->statistics.wait_count); + } -seq_printf (sf,"wait_sum %llu\n" , ws); +seq_printf (sf,"wait_sum %llu\n" +"wait_count %llu\n" , ws, wc); }return 0 ;
@@ -8255,6 +8265,19 @@ static int cpu_extra_stat_show(struct seq_file *sf,"throttled_usec %llu\n" , cfs_b->nr_periods, cfs_b->nr_throttled, throttled_usec); +if (schedstat_enabled () && tg != &root_task_group) { +u64 ws =0 ; +u64 wc =0 ; +int i; + +for_each_possible_cpu (i) { + ws +=schedstat_val (tg->se[i]->statistics.wait_sum); + wc +=schedstat_val (tg->se[i]->statistics.wait_count); + } + +seq_printf (sf,"wait_sum %llu\n" +"wait_count %llu\n" , ws, wc); + } }#endif return 0 ;
Signature · 1 line
2.20.1
A message that is not in the archive (sent off-list or not yet received): 20210115143005.7071-1-wu860403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Hello,
Quoted 1 line · On Fri, Jan 15, 2021 at 10:30:05PM +0800…
kernel/sched/core.c +0
-1-seq_printf (sf,"throttled_time %llu\n" , cfs_b->throttled_time);
...
kernel/sched/core.c static int cpu_cfs_stat_show(struct seq_file *sf, void *v) · line 8151
Quoted 5 lines
kernel/sched/core.c +5
-0+seq_printf (sf,"nr_periods %d\n" +"nr_throttled %d\n" +"throttled_usec %llu\n" , + cfs_b->nr_periods, cfs_b->nr_throttled, + throttled_usec);
This is interface breaking change. I don't think we can do this at this point.
Quoted 7 lines
kernel/sched/core.c +3
-0@@ -8255,6 +8265,19 @@ static int cpu_extra_stat_show(struct seq_file *sf,"throttled_usec %llu\n" , cfs_b->nr_periods, cfs_b->nr_throttled, throttled_usec); +if (schedstat_enabled () && tg != &root_task_group) { +u64 ws =0 ; +u64 wc =0 ;
kernel/sched/core.c static int cpu_extra_stat_show(struct seq_file *sf, · line 8280
Quoted 10 lines
kernel/sched/core.c +10
-0+int i; + +for_each_possible_cpu (i) { + ws +=schedstat_val (tg->se[i]->statistics.wait_sum); + wc +=schedstat_val (tg->se[i]->statistics.wait_count); + } + +seq_printf (sf,"wait_sum %llu\n" +"wait_count %llu\n" , ws, wc); + }
What does sum/count tell?
Thanks.
Signature · 1 line
tejun
A message that is not in the archive (sent off-list or not yet received): YAH4w5T3/[email protected]
Hello tejun:
Quoted 6 lines · Tejun Heo
Hello,
Quoted 1 line · On Fri, Jan 15, 2021 at 10:30:05PM +0800…
-
seq_printf(sf, "throttled_time %llu\n", cfs_b->throttled_time);...
Quoted 8 lines
kernel/sched/core.c static int cpu_cfs_stat_show(struct seq_file *sf, void *v) · line 8151
Quoted 5 lines
kernel/sched/core.c +5
-0+seq_printf (sf,"nr_periods %d\n" +"nr_throttled %d\n" +"throttled_usec %llu\n" , + cfs_b->nr_periods, cfs_b->nr_throttled, + throttled_usec);This is interface breaking change. I don't think we can do this at this point.
Thanks for your reply, agree with it.
Quoted 11 lines
Quoted 11 lines
kernel/sched/core.c +7
-0@@ -8255,6 +8265,19 @@ static int cpu_extra_stat_show(struct seq_file *sf,"throttled_usec %llu\n" , cfs_b->nr_periods, cfs_b->nr_throttled, throttled_usec); +if (schedstat_enabled () && tg != &root_task_group) { +u64 ws =0 ; +u64 wc =0 ; +int i; + +for_each_possible_cpu (i) { + ws +=schedstat_val (tg->se[i]->statistics.wait_sum);
Quoted 8 lines
kernel/sched/core.c static int cpu_extra_stat_show(struct seq_file *sf, · line 8280
Quoted 6 lines
kernel/sched/core.c +6
-0+ wc +=schedstat_val (tg->se[i]->statistics.wait_count); + } + +seq_printf (sf,"wait_sum %llu\n" +"wait_count %llu\n" , ws, wc); + }What does sum/count tell?
It can tell the task group average latency of every context switch wait_sum is equivalent to sched_info->run_delay (the second parameter of /proc/$pid/schedstat)wait_count is equivalent to sched_info->pcount(the third parameter of /proc/$pid/schedstat)
Thanks
Liming
A message that is not in the archive (sent off-list or not yet received): CAPnMXWWmfzWh9J_G4OPT=eCFySaD2NAFE0_OiWFQKL-1R0uOkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Hello,
Quoted 15 lines · liming wu
Quoted 7 lines
Quoted 7 lines
kernel/sched/core.c +7
-0+if (schedstat_enabled () && tg != &root_task_group) { +u64 ws =0 ; +u64 wc =0 ; +int i; + +for_each_possible_cpu (i) { + ws +=schedstat_val (tg->se[i]->statistics.wait_sum);Quoted 8 lines
kernel/sched/core.c static int cpu_extra_stat_show(struct seq_file *sf, · line 8280
Quoted 6 lines
kernel/sched/core.c +6
-0+ wc +=schedstat_val (tg->se[i]->statistics.wait_count); + } + +seq_printf (sf,"wait_sum %llu\n" +"wait_count %llu\n" , ws, wc); + }What does sum/count tell?
Quoted 5 lines
It can tell the task group average latency of every context switch
wait_sumis equivalent tosched_info->run_delay(the second parameter of/proc/$pid/schedstat)wait_countis equivalent tosched_info->pcount(the third parameter of /proc/$pid/schedstat)
Sounds good to me but can you please:
* Rename wait_sum to wait_usec and make sure the duration is in usecs.
* Rename wait_count to nr_waits.
* This should go through the scheduler tree. When you post the updated version, please cc the scheduler folks from MAINAINERS.
Thanks.
Signature · 1 line
tejun