linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hui Wang <john.wanghui@huawei.com>
To: <linux-kernel@vger.kernel.org>, <tglx@linutronix.de>
Cc: <guijianfeng@huawei.com>, <wencongyang2@huawei.com>,
	<douliyang1@huawei.com>, <qiaonuohan@huawei.com>
Subject: [PATCH] x86/topology: use total_cpus for max logical packages calculation
Date: Wed, 7 Nov 2018 10:36:43 +0800	[thread overview]
Message-ID: <20181107023643.22174-1-john.wanghui@huawei.com> (raw)

nr_cpu_ids can be limited on the command line via nr_cpus=. This can break the
logical package management because it results in a smaller number of packages
while in kdump kernel.

Check below case:
There is a two sockets system, each socket has 8 cores, which has 16 logical
cpus while HT was turn on.

 0  1  2  3  4  5  6  7     |    16 17 18 19 20 21 22 23
 cores on socket 0               threads on socket 0
 8  9 10 11 12 13 14 15     |    24 25 26 27 28 29 30 31
 cores on socket 1               threads on socket 1

While start kdump kernel with option nr_cpus=16, and panic was triggered on one
of the cpus 24-31 eg. 26, then online cpu will be 1-15, 26(cpu 0 was disabled in
kdump), ncpus will be 16 and __max_logical_packages will be 1, but actually two
packages were booted on.

This issue can reproduced by set kdump option nr_cpus=<real physical core
numbers>, and then trigger panic on last socket's thread, for example:

taskset -c 26 echo c > /proc/sysrq-trigger

Use total_cpus which will not be limited by nr_cpus command line to calculate
the value of __max_logical_packages.

Signed-off-by: Hui Wang <john.wanghui@huawei.com>
---
 arch/x86/kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index a9134d1910b9..ccd1f2a8e557 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1347,7 +1347,7 @@ void __init calculate_max_logical_packages(void)
 	 * extrapolate the boot cpu's data to all packages.
 	 */
 	ncpus = cpu_data(0).booted_cores * topology_max_smt_threads();
-	__max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus);
+	__max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);
 	pr_info("Max logical packages: %u\n", __max_logical_packages);
 }
 
-- 
2.17.0


             reply	other threads:[~2018-11-07  2:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07  2:36 Hui Wang [this message]
2018-12-18 12:42 ` [tip:x86/cpu] x86/topology: Use total_cpus for max logical packages calculation tip-bot for Hui Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181107023643.22174-1-john.wanghui@huawei.com \
    --to=john.wanghui@huawei.com \
    --cc=douliyang1@huawei.com \
    --cc=guijianfeng@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qiaonuohan@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=wencongyang2@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).