public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tg: add cpu's wait_count of a task group
@ 2021-01-15 14:30 wu860403-Re5JQEeQqe8AvxtiuMwx3w
       [not found] ` <20210115143005.7071-1-wu860403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: wu860403-Re5JQEeQqe8AvxtiuMwx3w @ 2021-01-15 14:30 UTC (permalink / raw)
  To: tj-DgEjT+Ai2ygdnm+yROfE0A, cgroups-u79uwXL29TY76Z2rM5mHXA,
	398776277-9uewiaClKEY
  Cc: Liming Wu

From: Liming Wu <wu860403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

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/QT0dZR+AlfA@public.gmane.org>
---
 kernel/sched/core.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index e7e453492..e7ff47436 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-19 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-15 14:30 [PATCH] tg: add cpu's wait_count of a task group wu860403-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <20210115143005.7071-1-wu860403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-01-15 20:19   ` Tejun Heo
     [not found]     ` <YAH4w5T3/oCTGJny-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2021-01-18  3:07       ` liming wu
     [not found]         ` <CAPnMXWWmfzWh9J_G4OPT=eCFySaD2NAFE0_OiWFQKL-1R0uOkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-01-19 15:32           ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox