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]
Message-Id: <1320182360-20043-13-git-send-email-glommer@parallels.com>
Date:	Tue,  1 Nov 2011 19:19:18 -0200
From:	Glauber Costa <glommer@...allels.com>
To:	linux-kernel@...r.kernel.org
Cc:	paul@...lmenage.org, lizf@...fujitsu.com, daniel.lezcano@...e.fr,
	a.p.zijlstra@...llo.nl, jbottomley@...allels.com, pjt@...gle.com,
	fweisbec@...il.com, Glauber Costa <glommer@...allels.com>
Subject: [PATCH v2 12/14] Keep number of running processes per-cgroup

This relies on the fact that the scheduler classes keep the number
of running processes internally in their entities.

Signed-off-by: Glauber Costa <glommer@...allels.com>
---
 kernel/sched.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 6ef6e1b..d93cfd4 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9763,6 +9763,7 @@ int cpu_cgroup_proc_stat(struct cgroup *cgrp, struct cftype *cft,
 	struct timespec boottime;
 	unsigned long tg_iowait = 0;
 	u64 tg_nr_switches = 0;
+	unsigned long tg_nr_running = 0;
 #ifdef CONFIG_CGROUP_SCHED
 	struct task_group *tg;
 	struct task_group *sib;
@@ -9822,6 +9823,18 @@ int cpu_cgroup_proc_stat(struct cgroup *cgrp, struct cftype *cft,
 		}
 #endif
 		kstat_unlock();
+#ifdef CONFIG_CGROUP_SCHED
+		/* root task group has autogrouping, so this doesn't hold */
+		if  (tg != &root_task_group) {
+#ifdef CONFIG_FAIR_GROUP_SCHED
+			tg_nr_running += cpu_rq(i)->cfs.nr_running;
+#endif
+#ifdef CONFIG_RT_GROUP_SCHED
+			tg_nr_running += cpu_rq(i)->rt.rt_nr_running;
+#endif
+		} else
+#endif
+			tg_nr_running += cpu_rq(i)->nr_running;
 
 		for (j = 0; j < NR_SOFTIRQS; j++) {
 			unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
@@ -9911,7 +9924,7 @@ int cpu_cgroup_proc_stat(struct cgroup *cgrp, struct cftype *cft,
 		tg_nr_switches,
 		(unsigned long)jif,
 		total_forks,
-		nr_running(),
+		tg_nr_running,
 		tg_iowait),
 
 	seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
-- 
1.7.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ