Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1632888

[PATCH 01/14] sched/topology: Refactor function build_overlap_sched_groups()

Path csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject [PATCH 01/14] sched/topology: Refactor function build_overlap_sched_groups()
Date Fri, 28 Apr 2017 15:40:02 +0200
Message-ID <tBehQ-7VW-35@gated-at.bofh.it> (permalink)
References <tBehP-7VW-5@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Dc/HmWe1ZCRmJGeA48IM2N1UQmn+dkeKGe2mLrZLoPA=; b=BbrI0thxfXudMMDhJdzpNsAMYl +kJ0hLoUPX0HDsJnKDuMgnDfBeY8DSkCkSzWB+KtfXUdcfpfXUaI4JVuKHkfnReipj8h6brDKInUK SC66LQ8xfM/GT54I6aid1G+4glshHxnnl57OEfZSS9JNuRFNes24COZcQUtO1xtnUouFHlIduWOvg 0tNg97pSGdRXHrDa+rB2ICvrFeMRz9JUwb1zmt2fNWlmqCuRwyQiNRqlKcLB2gULEtV7XS9cADpAX KQKjvVPHxYBf6iku9cpgUMRvc+tnnMJgzrhMLr/L+fCKxordnTawKG40uYWX/aWOJnP3ZsuSyXc3A zoG9vmTg==;
User-Agent quilt/0.63-1
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Disposition inline; filename=lauro_ramos_venancio-sched_topology-refactor_function_build_overlap_sched_groups.patch
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 102
Organization linux.* mail to news gateway
X-Original-Cc lwang@redhat.com, riel@redhat.com, efault@gmx.de, tglx@linutronix.de, linux-kernel@vger.kernel.org, peterz@infradead.org
X-Original-Date Fri, 28 Apr 2017 15:19:59 +0200
X-Original-Message-ID <20170428132502.401345699@infradead.org>
X-Original-References <20170428131958.893188882@infradead.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1632888

Show key headers only | View raw


Create functions build_group_from_child_sched_domain() and
init_overlap_sched_group(). No functional change.

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Lauro Ramos Venancio <lvenanci@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1492091769-19879-2-git-send-email-lvenanci@redhat.com
---
 kernel/sched/topology.c | 62 ++++++++++++++++++++++++++++++++++---------------
 1 file changed, 43 insertions(+), 19 deletions(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 1b0b4fb..d786d45 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -513,6 +513,47 @@ int group_balance_cpu(struct sched_group *sg)
 	return cpumask_first_and(sched_group_cpus(sg), sched_group_mask(sg));
 }
 
+static struct sched_group *
+build_group_from_child_sched_domain(struct sched_domain *sd, int cpu)
+{
+	struct sched_group *sg;
+	struct cpumask *sg_span;
+
+	sg = kzalloc_node(sizeof(struct sched_group) + cpumask_size(),
+			GFP_KERNEL, cpu_to_node(cpu));
+
+	if (!sg)
+		return NULL;
+
+	sg_span = sched_group_cpus(sg);
+	if (sd->child)
+		cpumask_copy(sg_span, sched_domain_span(sd->child));
+	else
+		cpumask_copy(sg_span, sched_domain_span(sd));
+
+	return sg;
+}
+
+static void init_overlap_sched_group(struct sched_domain *sd,
+				     struct sched_group *sg, int cpu)
+{
+	struct sd_data *sdd = sd->private;
+	struct cpumask *sg_span;
+
+	sg->sgc = *per_cpu_ptr(sdd->sgc, cpu);
+	if (atomic_inc_return(&sg->sgc->ref) == 1)
+		build_group_mask(sd, sg);
+
+	/*
+	 * Initialize sgc->capacity such that even if we mess up the
+	 * domains and no possible iteration will get us here, we won't
+	 * die on a /0 trap.
+	 */
+	sg_span = sched_group_cpus(sg);
+	sg->sgc->capacity = SCHED_CAPACITY_SCALE * cpumask_weight(sg_span);
+	sg->sgc->min_capacity = SCHED_CAPACITY_SCALE;
+}
+
 static int
 build_overlap_sched_groups(struct sched_domain *sd, int cpu)
 {
@@ -537,31 +578,14 @@ int group_balance_cpu(struct sched_group *sg)
 		if (!cpumask_test_cpu(i, sched_domain_span(sibling)))
 			continue;
 
-		sg = kzalloc_node(sizeof(struct sched_group) + cpumask_size(),
-				GFP_KERNEL, cpu_to_node(cpu));
-
+		sg = build_group_from_child_sched_domain(sibling, cpu);
 		if (!sg)
 			goto fail;
 
 		sg_span = sched_group_cpus(sg);
-		if (sibling->child)
-			cpumask_copy(sg_span, sched_domain_span(sibling->child));
-		else
-			cpumask_set_cpu(i, sg_span);
-
 		cpumask_or(covered, covered, sg_span);
 
-		sg->sgc = *per_cpu_ptr(sdd->sgc, i);
-		if (atomic_inc_return(&sg->sgc->ref) == 1)
-			build_group_mask(sd, sg);
-
-		/*
-		 * Initialize sgc->capacity such that even if we mess up the
-		 * domains and no possible iteration will get us here, we won't
-		 * die on a /0 trap.
-		 */
-		sg->sgc->capacity = SCHED_CAPACITY_SCALE * cpumask_weight(sg_span);
-		sg->sgc->min_capacity = SCHED_CAPACITY_SCALE;
+		init_overlap_sched_group(sd, sg, i);
 
 		/*
 		 * Make sure the first group of this domain contains the
-- 
1.8.3.1

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 01/14] sched/topology: Refactor function build_overlap_sched_groups() Peter Zijlstra <peterz@infradead.org> - 2017-04-28 15:40 +0200

csiph-web