public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Anton Blanchard <anton@au1.ibm.com>,
	Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
	Suresh Siddha <suresh.b.siddha@intel.com>,
	Venkatesh Pallipadi <venki@google.com>,
	Paul Turner <pjt@google.com>, Mike Galbraith <efault@gmx.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Andreas Herrmann <andreas.herrmann3@amd.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [RFC][PATCH 07/14] sched: Simplify finding the lowest sched_domain
Date: Mon, 14 Mar 2011 16:06:20 +0100	[thread overview]
Message-ID: <20110314152227.018622572@chello.nl> (raw)
In-Reply-To: 20110314150613.749843433@chello.nl

[-- Attachment #1: sched-foo6.patch --]
[-- Type: text/plain, Size: 2456 bytes --]

Instead of relying on knowing the build order and various CONFIG_
flags simply remember the bottom most sched_domain when we created the
domain hierarchy.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
---
 include/asm-generic/percpu.h |    4 ++++
 kernel/sched.c               |   23 +++++++++++++----------
 2 files changed, 17 insertions(+), 10 deletions(-)

Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -6841,11 +6841,13 @@ struct s_data {
 	cpumask_var_t		nodemask;
 	cpumask_var_t		send_covered;
 	cpumask_var_t		tmpmask;
+	struct sched_domain ** __percpu sd;
 	struct root_domain	*rd;
 };
 
 enum s_alloc {
 	sa_rootdomain,
+	sa_sd,
 	sa_tmpmask,
 	sa_send_covered,
 	sa_nodemask,
@@ -7080,6 +7082,8 @@ static void __free_domain_allocs(struct
 	switch (what) {
 	case sa_rootdomain:
 		free_rootdomain(d->rd); /* fall through */
+	case sa_sd:
+		free_percpu(d->sd); /* fall through */
 	case sa_tmpmask:
 		free_cpumask_var(d->tmpmask); /* fall through */
 	case sa_send_covered:
@@ -7100,10 +7104,15 @@ static enum s_alloc __visit_domain_alloc
 		return sa_nodemask;
 	if (!alloc_cpumask_var(&d->tmpmask, GFP_KERNEL))
 		return sa_send_covered;
+	d->sd = alloc_percpu(struct sched_domain *);
+	if (!d->sd) {
+		printk(KERN_WARNING "Cannot alloc per-cpu pointers\n");
+		return sa_tmpmask;
+	}
 	d->rd = alloc_rootdomain();
 	if (!d->rd) {
 		printk(KERN_WARNING "Cannot alloc root domain\n");
-		return sa_tmpmask;
+		return sa_sd;
 	}
 	return sa_rootdomain;
 }
@@ -7292,6 +7301,8 @@ static int __build_sched_domains(const s
 		sd = __build_mc_sched_domain(&d, cpu_map, attr, sd, i);
 		sd = __build_smt_sched_domain(&d, cpu_map, attr, sd, i);
 
+		*per_cpu_ptr(d.sd, i) = sd;
+
 		for (tmp = sd; tmp; tmp = tmp->parent) {
 			tmp->span_weight = cpumask_weight(sched_domain_span(tmp));
 			build_sched_groups(&d, tmp, cpu_map, i);
@@ -7339,15 +7350,7 @@ static int __build_sched_domains(const s
 
 	/* Attach the domains */
 	for_each_cpu(i, cpu_map) {
-#ifdef CONFIG_SCHED_SMT
-		sd = &per_cpu(cpu_domains, i).sd;
-#elif defined(CONFIG_SCHED_MC)
-		sd = &per_cpu(core_domains, i).sd;
-#elif defined(CONFIG_SCHED_BOOK)
-		sd = &per_cpu(book_domains, i).sd;
-#else
-		sd = &per_cpu(phys_domains, i).sd;
-#endif
+		sd = *per_cpu_ptr(d.sd, i);
 		cpu_attach_domain(sd, d.rd, i);
 	}
 



  parent reply	other threads:[~2011-03-14 15:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-14 15:06 [RFC][PATCH 00/14] Rewrite sched_domain/sched_group creation Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 01/14] sched: Remove obsolete arch_ prefixes Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 02/14] sched: Simplify cpu_power initialization Peter Zijlstra
2011-03-14 21:35   ` Steven Rostedt
2011-03-14 21:46     ` Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 03/14] sched: Simplify build_sched_groups Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 04/14] sched: Change NODE sched_domain group creation Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 05/14] sched: Clean up some ALLNODES code Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 06/14] Simplify group creation Peter Zijlstra
2011-03-14 15:06 ` Peter Zijlstra [this message]
2011-03-14 15:06 ` [RFC][PATCH 08/14] sched: Simplify sched_groups_power initialization Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 09/14] sched: Dynamically allocate sched_domain/sched_group data-structures Peter Zijlstra
2011-03-18  9:08   ` Bharata B Rao
2011-03-18  9:37     ` Peter Zijlstra
2011-03-19  1:23   ` Venkatesh Pallipadi
2011-03-25 21:06     ` Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 10/14] sched: Simplify the free path some Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 11/14] sched: Reduce some allocation pressure Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 12/14] sched: Simplify NODE/ALLNODES domain creation Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 13/14] sched: Remove nodemask allocation Peter Zijlstra
2011-03-14 15:06 ` [RFC][PATCH 14/14] sched: Remove some dead code Peter Zijlstra
2011-03-25 21:46 ` [RFC][PATCH 00/14] Rewrite sched_domain/sched_group creation Peter Zijlstra
2011-03-25 21:53   ` Peter Zijlstra

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=20110314152227.018622572@chello.nl \
    --to=a.p.zijlstra@chello.nl \
    --cc=andreas.herrmann3@amd.com \
    --cc=anton@au1.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=efault@gmx.de \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=pjt@google.com \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=vatsa@linux.vnet.ibm.com \
    --cc=venki@google.com \
    /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