From patchwork Tue Jun 19 08:28:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 9445 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 892D623E4F for ; Tue, 19 Jun 2012 08:30:11 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 43D3AA186DA for ; Tue, 19 Jun 2012 08:30:11 +0000 (UTC) Received: by ggnf1 with SMTP id f1so4787113ggn.11 for ; Tue, 19 Jun 2012 01:30:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=6QO57J4r2NgpGbxS793QtE/RlvhlBJt/aeTztaiWEJQ=; b=UUQPglLo/5X2koH6c2Crw0ebKrHK2aIO/FBhKXH5h0LRczyyLWv8byDves5kG0Z8TD m+Txkvk+WghzKoUCrzxMMe4HEcC9qEv/M0ylZCZs9hlGIc7lx+fl4uyFK7u4J+Nbntqx ABWZPUClCXXi9CdreokAhGijAq2A2rSd+eUFYCUtHO8ONuMbrAQ7nUDkqJyG45U71yfw Obu/UVwDkXkqhiJ1zGUfMRFfZmLIgJxyHcq+jszMNuoPogPDyhLLUoXYpshmaQ5OHaLG UCExMQVYfRJkiY69RRa94P+rLzQ+bS5JottBkvYeozTvOKg4NNHSKyYGTxdBlhcs168s IKFA== Received: by 10.50.46.232 with SMTP id y8mr301761igm.57.1340094610217; Tue, 19 Jun 2012 01:30:10 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp112577ibb; Tue, 19 Jun 2012 01:30:09 -0700 (PDT) Received: by 10.180.97.165 with SMTP id eb5mr1721498wib.0.1340094608839; Tue, 19 Jun 2012 01:30:08 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id c9si25782090wie.18.2012.06.19.01.30.08 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Jun 2012 01:30:08 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) smtp.mail=vincent.guittot@linaro.org Received: by mail-wg0-f50.google.com with SMTP id ds11so5984686wgb.31 for ; Tue, 19 Jun 2012 01:30:08 -0700 (PDT) Received: by 10.180.80.97 with SMTP id q1mr1277801wix.13.1340094607589; Tue, 19 Jun 2012 01:30:07 -0700 (PDT) Received: from localhost.localdomain (LPuteaux-156-14-44-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPS id d3sm56434001wiz.9.2012.06.19.01.30.05 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Jun 2012 01:30:06 -0700 (PDT) From: Vincent Guittot To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org, devicetree-discuss@lists.ozlabs.org Cc: linux@arm.linux.org.uk, a.p.zijlstra@chello.nl, grant.likely@secretlab.ca, rob.herring@calxeda.com, Vincent Guittot , Lorenzo Pieralisi Subject: [PATCH v2 2/5] ARM: topology: factorize the update of sibling masks Date: Tue, 19 Jun 2012 10:28:53 +0200 Message-Id: <1340094536-20873-3-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1340094536-20873-1-git-send-email-vincent.guittot@linaro.org> References: <1340094536-20873-1-git-send-email-vincent.guittot@linaro.org> X-Gm-Message-State: ALoCoQmVYxaPxXDrSqP2/Cmz3MLg7huo994h54875I6zqSVNgxWiDdjshcjCo2KanqAtTVdSH13U This factorization has also been proposed in another patchset that has not been merged yet: http://lists.infradead.org/pipermail/linux-arm-kernel/2012-January/080873.html So, this patch could be dropped depending of the state of the other one. Signed-off-by: Lorenzo Pieralisi Signed-off-by: Vincent Guittot --- arch/arm/kernel/topology.c | 47 ++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 37e2e57..92c2fb3 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -82,6 +82,31 @@ const struct cpumask *cpu_coregroup_mask(int cpu) return &cpu_topology[cpu].core_sibling; } +void update_siblings_masks(unsigned int cpuid) +{ + struct cputopo_arm *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; + int cpu; + /* update core and thread sibling masks */ + for_each_possible_cpu(cpu) { + cpu_topo = &cpu_topology[cpu]; + + if (cpuid_topo->socket_id == cpu_topo->socket_id) { + cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); + if (cpu != cpuid) + cpumask_set_cpu(cpu, &cpuid_topo->core_sibling); + + if (cpuid_topo->core_id == cpu_topo->core_id) { + cpumask_set_cpu(cpuid, + &cpu_topo->thread_sibling); + if (cpu != cpuid) + cpumask_set_cpu(cpu, + &cpuid_topo->thread_sibling); + } + } + } + smp_wmb(); +} + /* * store_cpu_topology is called at boot when only one cpu is running * and with the mutex cpu_hotplug.lock locked, when several cpus have booted, @@ -91,7 +116,6 @@ void store_cpu_topology(unsigned int cpuid) { struct cputopo_arm *cpuid_topo = &cpu_topology[cpuid]; unsigned int mpidr; - unsigned int cpu; /* If the cpu topology has been already set, just return */ if (cpuid_topo->core_id != -1) @@ -133,26 +157,7 @@ void store_cpu_topology(unsigned int cpuid) cpuid_topo->socket_id = -1; } - /* update core and thread sibling masks */ - for_each_possible_cpu(cpu) { - struct cputopo_arm *cpu_topo = &cpu_topology[cpu]; - - if (cpuid_topo->socket_id == cpu_topo->socket_id) { - cpumask_set_cpu(cpuid, &cpu_topo->core_sibling); - if (cpu != cpuid) - cpumask_set_cpu(cpu, - &cpuid_topo->core_sibling); - - if (cpuid_topo->core_id == cpu_topo->core_id) { - cpumask_set_cpu(cpuid, - &cpu_topo->thread_sibling); - if (cpu != cpuid) - cpumask_set_cpu(cpu, - &cpuid_topo->thread_sibling); - } - } - } - smp_wmb(); + update_siblings_masks(cpuid); printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n", cpuid, cpu_topology[cpuid].thread_id,