From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032001AbdDTTwh (ORCPT ); Thu, 20 Apr 2017 15:52:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36510 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S944422AbdDTTw2 (ORCPT ); Thu, 20 Apr 2017 15:52:28 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CED0FC049D5D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvenanci@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CED0FC049D5D From: Lauro Ramos Venancio To: Peter Zijlstra Cc: lwang@redhat.com, riel@redhat.com, Mike Galbraith , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, Lauro Ramos Venancio Subject: [PATCH 2/4] sched/topology: all instances of a sched group must use the same sched_group_capacity Date: Thu, 20 Apr 2017 16:51:41 -0300 Message-Id: <1492717903-5195-3-git-send-email-lvenanci@redhat.com> In-Reply-To: <1492717903-5195-1-git-send-email-lvenanci@redhat.com> References: <1492717903-5195-1-git-send-email-lvenanci@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 20 Apr 2017 19:52:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the group balance cpu to select the same sched_group_capacity instance for all instances of a sched group. As the group mask is stored in the struct sched_group_capacity and the function group_balance_cpu() cannot be used when the group mask is not available, this patch creates a function to find the group balance cpu when the mask is not available. Signed-off-by: Lauro Ramos Venancio --- kernel/sched/topology.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index f8b53b3..55bbaf7 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -529,6 +529,27 @@ int group_balance_cpu(struct sched_group *sg) return cpumask_first_and(sched_group_cpus(sg), sched_group_mask(sg)); } +/* + * Find the group balance cpu when the group mask is not available yet. + */ +static int find_group_balance_cpu(struct sched_domain *sd, + struct sched_group *sg) +{ + const struct cpumask *sg_span = sched_group_cpus(sg); + struct sd_data *sdd = sd->private; + struct sched_domain *sibling; + int i; + + for_each_cpu(i, sg_span) { + sibling = *per_cpu_ptr(sdd->sd, i); + if (cpumask_test_cpu(i, sched_domain_span(sibling))) + return i; + } + + WARN(1, "group balance cpu not found."); + return 0; +} + static struct sched_group * build_group_from_child_sched_domain(struct sched_domain *sd, int cpu) { @@ -551,10 +572,11 @@ int group_balance_cpu(struct sched_group *sg) } static void init_overlap_sched_group(struct sched_domain *sd, - struct sched_group *sg, int cpu) + struct sched_group *sg) { struct sd_data *sdd = sd->private; struct cpumask *sg_span; + int cpu = find_group_balance_cpu(sd, sg); sg->sgc = *per_cpu_ptr(sdd->sgc, cpu); if (atomic_inc_return(&sg->sgc->ref) == 1) @@ -601,7 +623,7 @@ static void init_overlap_sched_group(struct sched_domain *sd, sg_span = sched_group_cpus(sg); cpumask_or(covered, covered, sg_span); - init_overlap_sched_group(sd, sg, i); + init_overlap_sched_group(sd, sg); if (!first) first = sg; -- 1.8.3.1