[lkml]   [2017]   [Dec]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] sched: cgroup: export nr_running for each cpu cgroup
Export the nr_running for each cpu cgroup could help us monitor the
container conveniently.
The total threads of cpu cgroup could be got from the tasks file, and it
could also be got from pids subsystem.
But we still donot know how many processes are running in a container,
only if we traversal the status of all processes, that's a little
Hence export the nr_running.

Signed-off-by: Yafang Shao <>
kernel/sched/core.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 644fa2e..926575a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6648,10 +6648,17 @@ 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;
+ unsigned int nr_running = 0;
+ int cpu;
+ for_each_online_cpu(cpu)
+ if (tg->cfs_rq[cpu])
+ nr_running += tg->cfs_rq[cpu]->h_nr_running;

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);
+ seq_printf(sf, "nr_running %u\n", nr_running);

return 0;
 \ /
  Last update: 2017-12-27 13:38    [W:0.025 / U:7.660 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site