[PATCH V2] tg: add sched wait_count of a task group

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Liming Wu <wu860403@xxxxxxxxx>

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 avg latency of task group contention
 from the dimension of scheduling.
   delta(wait_usec)/delta(nr_waits)
Also change wait_sum to wait_usec.

Signed-off-by Liming Wu <wu860403@xxxxxxxxx>
---
 kernel/sched/core.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index e7e453492..45e46114e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8146,12 +8146,17 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v)
 
 	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);
+		do_div(ws, NSEC_PER_USEC);
+		seq_printf(sf, "wait_usec %llu\n"
+			   "nr_waits %llu\n", ws, wc);
 	}
 
 	return 0;
@@ -8255,6 +8260,20 @@ 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);
+			}
+
+			do_div(ws, NSEC_PER_USEC);
+			seq_printf(sf, "wait_usec %llu\n"
+				   "nr_waits %llu\n", ws, wc);
+		}
 	}
 #endif
 	return 0;
-- 
2.20.1




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux