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: <1386936688-29113-7-git-send-email-dietmar.eggemann@arm.com>
Date:	Fri, 13 Dec 2013 12:11:26 +0000
From:	dietmar.eggemann@....com
To:	peterz@...radead.org, mingo@...hat.com, vincent.guittot@...aro.org,
	morten.rasmussen@....com, chris.redpath@....com
Cc:	linux-kernel@...r.kernel.org, dietmar.eggemann@....com
Subject: [RFC PATCH 6/8] sched: replace for_each_sd_topology with explicit for loop

From: Dietmar Eggemann <dietmar.eggemann@....com>

This patch prepares the scheduler domain level set up code to be able to
not rely on the default_topology[] any more.
The for_each_sd_topology macro is replaced with an explicit for loop
iterating over the sched_domain_topology array.  It introduces the file
global variable sched_domains_levels to hold the number of scheduler
domain levels.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@....com>
---
 kernel/sched/core.c |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 37febb067bad..897ff9222cab 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5379,9 +5379,7 @@ static struct sched_domain_topology_level default_topology[] = {
 };
 
 static struct sched_domain_topology_level *sched_domain_topology = default_topology;
-
-#define for_each_sd_topology(tl)			\
-	for (tl = sched_domain_topology; tl->init; tl++)
+static int sched_domains_levels;
 
 #ifdef CONFIG_NUMA
 
@@ -5734,7 +5732,9 @@ static void sched_alloc(void)
 	}
 #endif /* CONFIG_NUMA */
 
-	tl = kzalloc((ARRAY_SIZE(default_topology) + level) *
+	sched_domains_levels = arch_sd_levels();
+
+	tl = kzalloc((sched_domains_levels + level) *
 			sizeof(struct sched_domain_topology_level), GFP_KERNEL);
 	if (!tl)
 		return;
@@ -5761,15 +5761,16 @@ static void sched_alloc(void)
 	}
 
 	sched_domains_numa_levels = level;
+	sched_domains_levels += level;
 #endif /* CONFIG_NUMA */
 }
 
 static int __sdt_alloc(const struct cpumask *cpu_map)
 {
-	struct sched_domain_topology_level *tl;
-	int j;
+	int i, j;
 
-	for_each_sd_topology(tl) {
+	for (i = 0; i < sched_domains_levels; i++) {
+		struct sched_domain_topology_level *tl = &sched_domain_topology[i];
 		struct sd_data *sdd = &tl->data;
 
 		sdd->sd = alloc_percpu(struct sched_domain *);
@@ -5819,10 +5820,10 @@ static int __sdt_alloc(const struct cpumask *cpu_map)
 
 static void __sdt_free(const struct cpumask *cpu_map)
 {
-	struct sched_domain_topology_level *tl;
-	int j;
+	int i, j;
 
-	for_each_sd_topology(tl) {
+	for (i = 0; i < sched_domains_levels; i++) {
+		struct sched_domain_topology_level *tl = &sched_domain_topology[i];
 		struct sd_data *sdd = &tl->data;
 
 		for_each_cpu(j, cpu_map) {
@@ -5887,10 +5888,10 @@ static int build_sched_domains(const struct cpumask *cpu_map,
 
 	/* Set up domains for cpus specified by the cpu_map. */
 	for_each_cpu(i, cpu_map) {
-		struct sched_domain_topology_level *tl;
-
+		int y;
 		sd = NULL;
-		for_each_sd_topology(tl) {
+		for (y = 0; y < sched_domains_levels; y++) {
+			struct sched_domain_topology_level *tl = &sched_domain_topology[y];
 			sd = build_sched_domain(tl, cpu_map, attr, sd, i);
 			if (tl == sched_domain_topology)
 				*per_cpu_ptr(d.sd, i) = sd;
-- 
1.7.9.5


--
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