From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753842AbcCSJf6 (ORCPT ); Sat, 19 Mar 2016 05:35:58 -0400 Received: from [198.137.202.10] ([198.137.202.10]:58140 "EHLO terminus.zytor.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752244AbcCSJfv (ORCPT ); Sat, 19 Mar 2016 05:35:51 -0400 Date: Sat, 19 Mar 2016 02:31:29 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: bp@alien8.de, hpa@zytor.com, umgwanakikbuti@gmail.com, mingo@kernel.org, tglx@linutronix.de, aherrmann@suse.com, jencce.kernel@gmail.com, linux-kernel@vger.kernel.org Reply-To: tglx@linutronix.de, aherrmann@suse.com, bp@alien8.de, hpa@zytor.com, mingo@kernel.org, umgwanakikbuti@gmail.com, linux-kernel@vger.kernel.org, jencce.kernel@gmail.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/topology: Use total_cpus not nr_cpu_ids for logical packages Git-Commit-ID: 3e8db2246b434c6b18a6a9f09904038bddcf76c7 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 3e8db2246b434c6b18a6a9f09904038bddcf76c7 Gitweb: http://git.kernel.org/tip/3e8db2246b434c6b18a6a9f09904038bddcf76c7 Author: Thomas Gleixner AuthorDate: Fri, 18 Mar 2016 17:20:30 +0100 Committer: Thomas Gleixner CommitDate: Sat, 19 Mar 2016 10:26:40 +0100 x86/topology: Use total_cpus not nr_cpu_ids for logical packages nr_cpu_ids can be limited on the command line via nr_cpus=. That can break the logical package management because it results in a smaller number of packages, but the cpus to online are occupying the full package space as the hyper threads are enumerated after the physical cores typically. total_cpus is the real possible cpu space not limited by nr_cpus command line and gives us the proper number of packages. Reported-by: Mike Galbraith Fixes: 1f12e32f4cd5 ("x86/topology: Create logical package id") Signed-off-by: Thomas Gleixner Cc: Xiong Zhou Cc: Ingo Molnar Cc: Borislav Petkov Cc: Andreas Herrmann Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1603181254330.3978@nanos --- arch/x86/kernel/smpboot.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 81e6a43..b2c99f8 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -325,9 +325,14 @@ static void __init smp_init_package_map(void) * By not including this we'll sometimes over-estimate the number of * logical packages by the amount of !present siblings, but this is * still better than MAX_LOCAL_APIC. + * + * We use total_cpus not nr_cpu_ids because nr_cpu_ids can be limited + * on the command line leading to a similar issue as the HT disable + * problem because the hyperthreads are usually enumerated after the + * primary cores. */ ncpus = boot_cpu_data.x86_max_cores; - __max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus); + __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus); /* * Possibly larger than what we need as the number of apic ids per