From patchwork Wed Jun 20 15:19:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 9508 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 EFCFA23E1B for ; Wed, 20 Jun 2012 15:20:22 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id C0887A181E2 for ; Wed, 20 Jun 2012 15:20:22 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so6361165yhp.11 for ; Wed, 20 Jun 2012 08:20:22 -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=pfIaDRRhJ7jy7R/Tqpmcuuvm8QHUKlpTqDkqTbao7rw=; b=ecjRgwFw3+xrvOq/uQuIgkjzucxyGa+/59xmhLqE+ntGpUUTsevw57escFz23kFRgO /+c6fjY/fTp7RnNu8ZrkxiqPgwTO55UKCD80ebvpdv/zcwFcHUR0pfVoi3uAfkfnmtEr 2RT1whQlYZ5Buz8Krj3wyyCn5DQLydejnNBYliHvmGzsDLnRPbK1WfMbjOciHVJgP876 grbOeR7HYG/oXR/DTPk2+Mnnzo3aAcWt05Yftv1dnWLPVcWp5lyLIxNqNGnApLQvNFQH 2Y695/V2N6EiamyGWXG4w5glW63S++LmVZbaLvhxm5zfLLP2M3JpFrKaIXXqQXFvu3Lh TCCg== Received: by 10.50.163.99 with SMTP id yh3mr4883562igb.53.1340205622324; Wed, 20 Jun 2012 08:20:22 -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 v20csp185132ibb; Wed, 20 Jun 2012 08:20:21 -0700 (PDT) Received: by 10.180.83.168 with SMTP id r8mr12811037wiy.22.1340205620873; Wed, 20 Jun 2012 08:20:20 -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 dy10si35236125wib.1.2012.06.20.08.20.20 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jun 2012 08:20:20 -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 ds11so7525078wgb.31 for ; Wed, 20 Jun 2012 08:20:20 -0700 (PDT) Received: by 10.216.213.163 with SMTP id a35mr13408278wep.131.1340205620006; Wed, 20 Jun 2012 08:20:20 -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 gb9sm39525109wib.8.2012.06.20.08.20.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jun 2012 08:20:18 -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, yong.zhang0@gmail.com, namhyung@kernel.org, jean.pihet@newoldbits.com, Vincent Guittot , Lorenzo Pieralisi Subject: [PATCH v3 2/5] ARM: topology: factorize the update of sibling masks Date: Wed, 20 Jun 2012 17:19:19 +0200 Message-Id: <1340205562-7653-3-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1340205562-7653-1-git-send-email-vincent.guittot@linaro.org> References: <1340205562-7653-1-git-send-email-vincent.guittot@linaro.org> X-Gm-Message-State: ALoCoQkDSQGaF+3zHcbsefLnsKpH7DWu25biDuhOd8z5Amq/j7JFgHe3FuhrDx1zwx5i68plggok 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 | 48 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 51f23b3..eb5fc81 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -82,6 +82,32 @@ 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) + continue; + + 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) + continue; + + 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 +117,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 +158,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,