From: Yafang Shao <laoar.shao@gmail.com>
To: mingo@redhat.com, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH] sched: cgroup: export nr_running for each cpu cgroup
Date: Wed, 27 Dec 2017 20:37:01 +0800 [thread overview]
Message-ID: <1514378221-11020-1-git-send-email-laoar.shao@gmail.com> (raw)
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
expensive.
Hence export the nr_running.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
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;
}
--
1.8.3.1
reply other threads:[~2017-12-27 12:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1514378221-11020-1-git-send-email-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®