From patchwork Mon Jul 9 09:27:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 9894 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 7B87223E1B for ; Mon, 9 Jul 2012 09:27:48 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 34C17A180D2 for ; Mon, 9 Jul 2012 09:27:48 +0000 (UTC) Received: by ghbz12 with SMTP id z12so10552974ghb.11 for ; Mon, 09 Jul 2012 02:27:47 -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=THkZG1KB2EyLs+nrE9OIwgmZd6OqmsPK7HL9okw75Og=; b=GdjlDBcIwPbMgQBPCebEz3ME3i2uIr8240itNAXBMOvwB4O7qRtYdSSA+YO5ilSh6g FBHaoEdptEj/wGFKjCFWpO/YzPVmJZEaOkICr/xANOxRhK1xcOmLKrZg+TnEpGYX/Flg 3ChJqgquuj0OJgn29D/oYlgl5Trm5z0tBlSrGQximC0vYXqj8kHf9BDwHGIvrkb4Xjwb iJaxPLgz7B0Owsx9OFKfFVgTJmrcQCh0vQ12zS0ESV5vm7zKC0ZHToh8SPdw6peg3Yiq Mn9sM2kDeDK4u1moQHnZrK74qq6iFk51ltvRYDowMurzsWtjxYtVqvNdgM4Xf0ijQALA SxJA== Received: by 10.50.203.39 with SMTP id kn7mr7676540igc.53.1341826067516; Mon, 09 Jul 2012 02:27:47 -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 v20csp33295ibb; Mon, 9 Jul 2012 02:27:46 -0700 (PDT) Received: by 10.180.81.165 with SMTP id b5mr27851148wiy.17.1341826066366; Mon, 09 Jul 2012 02:27:46 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx.google.com with ESMTPS id i13si37098697wed.33.2012.07.09.02.27.45 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 02:27:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=209.85.212.172; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) smtp.mail=vincent.guittot@linaro.org Received: by wibhm11 with SMTP id hm11so2210673wib.13 for ; Mon, 09 Jul 2012 02:27:45 -0700 (PDT) Received: by 10.180.80.134 with SMTP id r6mr27985693wix.1.1341826065613; Mon, 09 Jul 2012 02:27:45 -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 j6sm33557246wiy.4.2012.07.09.02.27.43 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 02:27:44 -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 v4 2/5] ARM: topology: factorize the update of sibling masks Date: Mon, 9 Jul 2012 11:27:03 +0200 Message-Id: <1341826026-6504-3-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341826026-6504-1-git-send-email-vincent.guittot@linaro.org> References: <1341826026-6504-1-git-send-email-vincent.guittot@linaro.org> X-Gm-Message-State: ALoCoQnRwHUZ4iJuB96RVb7reNdRsvKde4O58RLqDg+RRXnJwDfmQGPGzo2+aspJwH8VyIrPDmS+ This factorization has also been proposed in another patch 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 Reviewed-by: Namhyung Kim --- 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,