From patchwork Mon Jan 20 12:39:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 23387 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C39402107B for ; Mon, 20 Jan 2014 12:41:58 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id 5sf12032594qeb.3 for ; Mon, 20 Jan 2014 04:41:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=3fQ0TyD3LPhXeOIzUvvV4ic/ha5Rcqkd/WiQBEbi/vc=; b=Rp4FRLVVxdah5LfndO6vQp+XlTxcLPfCN+p1G4FbEN2aVhH4QAFZDQc7dTfVfeP/Hk KRgyVp820Vg31Ojl6IrwsNTZCz3IIPkLsnQxejs91xEJB1S9UKVZoA/+juYac2/wHZcl vEJTE3fO7c1jy2Ya2YV6De0gxKPfqiB7FpoupUnvxouLHwXnNND8r8hi9ITm1rpUFJtM IzqyWcnVh1KG79IYxQWLm0+g5VS/U4mWYBtpeeagXKo+U+FS6HlqrhsuhhOUniVSRKkm pVWSYAJ9/H7+GxfN/ZnMe3evUgUOW9YOdVlM7M9qgMbNotwmrjKmxNfan00oC3xz0EAU klrw== X-Gm-Message-State: ALoCoQmc2vK7ZtNr+GOQV68WMzsegp70Ry3GlNVQQFbDNLPQo8g9x/ffnkyZzhNksPbizJzCOtz/ X-Received: by 10.58.39.202 with SMTP id r10mr6754718vek.12.1390221717991; Mon, 20 Jan 2014 04:41:57 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.72 with SMTP id li8ls48733qeb.32.gmail; Mon, 20 Jan 2014 04:41:57 -0800 (PST) X-Received: by 10.220.106.84 with SMTP id w20mr10493515vco.18.1390221717801; Mon, 20 Jan 2014 04:41:57 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id kn3si290505veb.130.2014.01.20.04.41.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 04:41:57 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so1670201veb.35 for ; Mon, 20 Jan 2014 04:41:57 -0800 (PST) X-Received: by 10.53.9.201 with SMTP id du9mr57233vdd.36.1390221717718; Mon, 20 Jan 2014 04:41:57 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp55925vcz; Mon, 20 Jan 2014 04:41:57 -0800 (PST) X-Received: by 10.67.22.67 with SMTP id hq3mr6502960pad.132.1390221716454; Mon, 20 Jan 2014 04:41:56 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bq5si1351022pbb.198.2014.01.20.04.41.55; Mon, 20 Jan 2014 04:41:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753871AbaATMlv (ORCPT + 26 others); Mon, 20 Jan 2014 07:41:51 -0500 Received: from service87.mimecast.com ([91.220.42.44]:51718 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752630AbaATMkH (ORCPT ); Mon, 20 Jan 2014 07:40:07 -0500 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 20 Jan 2014 12:40:05 +0000 Received: from e103711-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 20 Jan 2014 12:40:04 +0000 From: dietmar.eggemann@arm.com To: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, morten.rasmussen@arm.com, chris.redpath@arm.com Cc: linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com Subject: [RFC v2 PATCH 07/11] sched: consolidate sched_init_numa() and sched_init_conv() Date: Mon, 20 Jan 2014 12:39:44 +0000 Message-Id: <1390221588-20473-8-git-send-email-dietmar.eggemann@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1390221588-20473-1-git-send-email-dietmar.eggemann@arm.com> References: <1390221588-20473-1-git-send-email-dietmar.eggemann@arm.com> X-OriginalArrivalTime: 20 Jan 2014 12:40:04.0722 (UTC) FILETIME=[BE545520:01CF15DC] X-MC-Unique: 114012012400516901 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dietmar.eggemann@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Dietmar Eggemann Consolidate sched_init_numa() and sched_init_conv() into one function sched_init_topology(). Signed-off-by: Dietmar Eggemann --- kernel/sched/core.c | 164 +++++++++++++++++++++------------------------------ 1 file changed, 68 insertions(+), 96 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 798a4d2c9d7b..9edd1d511f3c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5410,13 +5410,72 @@ static bool find_numa_distance(int distance) return false; } -static void sched_init_numa(void) +static void sched_domains_numa_masks_set(int cpu) +{ + int i, j; + int node = cpu_to_node(cpu); + + for (i = 0; i < sched_domains_numa_levels; i++) { + for (j = 0; j < nr_node_ids; j++) { + if (node_distance(j, node) <= sched_domains_numa_distance[i]) + cpumask_set_cpu(cpu, sched_domains_numa_masks[i][j]); + } + } +} + +static void sched_domains_numa_masks_clear(int cpu) +{ + int i, j; + for (i = 0; i < sched_domains_numa_levels; i++) { + for (j = 0; j < nr_node_ids; j++) + cpumask_clear_cpu(cpu, sched_domains_numa_masks[i][j]); + } +} + +/* + * Update sched_domains_numa_masks[level][node] array when new cpus + * are onlined. + */ +static int sched_domains_numa_masks_update(struct notifier_block *nfb, + unsigned long action, + void *hcpu) +{ + int cpu = (long)hcpu; + + switch (action & ~CPU_TASKS_FROZEN) { + case CPU_ONLINE: + sched_domains_numa_masks_set(cpu); + break; + + case CPU_DEAD: + sched_domains_numa_masks_clear(cpu); + break; + + default: + return NOTIFY_DONE; + } + + return NOTIFY_OK; +} +#else +static int sched_domains_numa_masks_update(struct notifier_block *nfb, + unsigned long action, + void *hcpu) +{ + return 0; +} +#endif /* CONFIG_NUMA */ + +static void sched_init_topology(void) { - int next_distance, curr_distance = node_distance(0, 0); struct sched_domain_topology_level *tl; struct sched_domain_topology_info *ti = sched_domain_topology_info; int level = 0; - int i, j, k; + int i; + +#ifdef CONFIG_NUMA + int next_distance, curr_distance = node_distance(0, 0); + int j, k; sched_domains_numa_distance = kzalloc(sizeof(int) * nr_node_ids, GFP_KERNEL); if (!sched_domains_numa_distance) @@ -5512,6 +5571,7 @@ static void sched_init_numa(void) } } } +#endif /* CONFIG_NUMA */ /* * An extra empty struct sched_domain_topology_level element at the end @@ -5529,6 +5589,9 @@ static void sched_init_numa(void) for (i = 0; i < sched_domain_topology_info_size; i++) tl[i].info = ti[i]; + sched_domain_topology = tl; + +#ifdef CONFIG_NUMA /* * .. and append 'j' levels of NUMA goodness. */ @@ -5541,99 +5604,9 @@ static void sched_init_numa(void) }; } - sched_domain_topology = tl; - sched_domains_numa_levels = level; -} - -static void sched_init_conv(void) -{ -} - -static void sched_domains_numa_masks_set(int cpu) -{ - int i, j; - int node = cpu_to_node(cpu); - - for (i = 0; i < sched_domains_numa_levels; i++) { - for (j = 0; j < nr_node_ids; j++) { - if (node_distance(j, node) <= sched_domains_numa_distance[i]) - cpumask_set_cpu(cpu, sched_domains_numa_masks[i][j]); - } - } -} - -static void sched_domains_numa_masks_clear(int cpu) -{ - int i, j; - for (i = 0; i < sched_domains_numa_levels; i++) { - for (j = 0; j < nr_node_ids; j++) - cpumask_clear_cpu(cpu, sched_domains_numa_masks[i][j]); - } -} - -/* - * Update sched_domains_numa_masks[level][node] array when new cpus - * are onlined. - */ -static int sched_domains_numa_masks_update(struct notifier_block *nfb, - unsigned long action, - void *hcpu) -{ - int cpu = (long)hcpu; - - switch (action & ~CPU_TASKS_FROZEN) { - case CPU_ONLINE: - sched_domains_numa_masks_set(cpu); - break; - - case CPU_DEAD: - sched_domains_numa_masks_clear(cpu); - break; - - default: - return NOTIFY_DONE; - } - - return NOTIFY_OK; -} -#else -static inline void sched_init_numa(void) -{ -} - -static void sched_init_conv(void) -{ - struct sched_domain_topology_level *tl; - struct sched_domain_topology_info *ti = sched_domain_topology_info; - int i; - - /* - * An extra empty struct sched_domain_topology_level element at the end - * of the array is needed to let for_each_sd_topology() work correctly. - */ - tl = kzalloc((sched_domain_topology_info_size + 1) * - sizeof(struct sched_domain_topology_level), - GFP_KERNEL); - if (!tl) - return; - - /* - * Copy the topology info bits.. - */ - for (i = 0; i < sched_domain_topology_info_size; i++) - tl[i].info = ti[i]; - - sched_domain_topology = tl; -} - -static int sched_domains_numa_masks_update(struct notifier_block *nfb, - unsigned long action, - void *hcpu) -{ - return 0; -} #endif /* CONFIG_NUMA */ +} static struct sched_domain * sd_init(struct sched_domain_topology_level *tl, int cpu) @@ -6151,8 +6124,7 @@ void __init sched_init_smp(void) alloc_cpumask_var(&non_isolated_cpus, GFP_KERNEL); alloc_cpumask_var(&fallback_doms, GFP_KERNEL); - sched_init_conv(); - sched_init_numa(); + sched_init_topology(); /* * There's no userspace yet to cause hotplug operations; hence all the