lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 06 Nov 2017 17:40:49 +0300
From:   Kirill Tkhai <ktkhai@...tuozzo.com>
To:     mingo@...hat.com, peterz@...radead.org,
        linux-kernel@...r.kernel.org, ktkhai@...tuozzo.com
Subject: [PATCH 4/4] sched: Export per task_cgroup nr_running to userspace

Show task_cgroup's nr_running in cgroup's "cpu.stat" file.

This may be useful for containers to check a statistics
of a single container.

Signed-off-by: Kirill Tkhai <ktkhai@...tuozzo.com>
---
 kernel/sched/core.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1b54707f5344..96dd30e6d243 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6671,7 +6671,7 @@ static int __cfs_schedulable(struct task_group *tg, u64 period, u64 quota)
 static int cpu_stats_show(struct seq_file *sf, void *v)
 {
 	struct task_group *tg = css_tg(seq_css(sf));
-	int i, nr_iowait = 0;
+	int i, nr_running = 0, nr_iowait = 0;
 #ifdef CONFIG_CFS_BANDWIDTH
 	struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
 
@@ -6680,8 +6680,15 @@ static int cpu_stats_show(struct seq_file *sf, void *v)
 	seq_printf(sf, "throttled_time %llu\n", cfs_b->throttled_time);
 #endif
 	for_each_possible_cpu(i) {
+#ifdef CONFIG_FAIR_GROUP_SCHED
+		nr_running += tg->cfs_rq[i]->nr_running;
+#endif
+#ifdef CONFIG_RT_GROUP_SCHED
+		nr_running += tg->rt_rq[i]->rt_nr_running;
+#endif
 		nr_iowait += atomic_read(&tg->stat[i].nr_iowait);
 	}
+	seq_printf(sf, "nr_running %d\n", nr_running);
 	seq_printf(sf, "nr_iowait %d\n", nr_iowait);
 
 	return 0;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ