Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3813914imu; Tue, 18 Dec 2018 04:44:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xb16bL4G6BSl6nGg6xmtxegAFy6aZl9qX1RiKPhv9kc+q3zvmYiM7dGfDR4ycFiaYrgnDj X-Received: by 2002:a17:902:292b:: with SMTP id g40mr16566780plb.82.1545137099416; Tue, 18 Dec 2018 04:44:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545137099; cv=none; d=google.com; s=arc-20160816; b=CaGm68YMeLhPl+P1as3zsHB2O/fltDUpoD+1tGY7ND/ukb8lDaZcRcxpWpFeI8jKQs b0EYgvvSXZqf19Qwd9UOhem7Qeco8n/yaflT/NGkBT9Kk0CImP9VczkMVPe3xdy5PPpf UkZggAXGtG3aAn/lx6+8wcycWN7KAFjwmmuKIfFISaZy8Cx5ZddhJSzLVHiB30MvnqSO Tq2G6pKjXqJFOp3xdxWnc6evVTGs+DqJulL8pxqjVXp/L6+8z/uisfYeO/GDgrd/793Q /fgT9ZMSj/iH490IZ336rTXDABnrcrAYXGvj5aoVmdxvdrwEtFh9OW9sF0HZ5urxm1wP GDFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=t0g86gXF4vkc5IVvsRya97qSLkh3IT7AsHk87F1dmh4=; b=oGKpmcnYa+arSzCPPcgyUNf+eSPqY0CwOO+CkLCHiph7fA+lLYQw6eBAWEv5kV1u99 Nhopy3EOZWu3F5VdpH4HyD5/BSgXtrnqM1wMrszAWgQJavpkGlytCeVb56uG3HBhhakd qnrjQbd27S6Wamjj0H+DAThxXs6IltlU9FqSqlaGuCtWtTN+ahl3wRF9NWeibKVXks5h jILAGDBxgsZ/xBWoHdngiAtq2eTgrY6/s6F3/jXdx+UIh9e2Hi2VFXkvxw54d1K8IOwg uA65KF0QdSf0kgpa+878j51j522TGZVb30y9wmtt7QrNlbrRSKaXjSOxcrrCpqqm4JtB XzjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k20si13638220pfb.215.2018.12.18.04.44.43; Tue, 18 Dec 2018 04:44:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726628AbeLRMnF (ORCPT + 99 others); Tue, 18 Dec 2018 07:43:05 -0500 Received: from terminus.zytor.com ([198.137.202.136]:50575 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726403AbeLRMnE (ORCPT ); Tue, 18 Dec 2018 07:43:04 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id wBICgqKh2834007 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 18 Dec 2018 04:42:52 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id wBICgqer2833999; Tue, 18 Dec 2018 04:42:52 -0800 Date: Tue, 18 Dec 2018 04:42:52 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Hui Wang Message-ID: Cc: qiaonuohan@huawei.com, wencongyang2@huawei.com, douliyang1@huawei.com, john.wanghui@huawei.com, guijianfeng@huawei.com, linux-kernel@vger.kernel.org, mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com Reply-To: hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, guijianfeng@huawei.com, john.wanghui@huawei.com, wencongyang2@huawei.com, douliyang1@huawei.com, qiaonuohan@huawei.com In-Reply-To: <20181107023643.22174-1-john.wanghui@huawei.com> References: <20181107023643.22174-1-john.wanghui@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] x86/topology: Use total_cpus for max logical packages calculation Git-Commit-ID: aa02ef099cff042c2a9109782ec2bf1bffc955d4 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 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: aa02ef099cff042c2a9109782ec2bf1bffc955d4 Gitweb: https://git.kernel.org/tip/aa02ef099cff042c2a9109782ec2bf1bffc955d4 Author: Hui Wang AuthorDate: Wed, 7 Nov 2018 10:36:43 +0800 Committer: Thomas Gleixner CommitDate: Tue, 18 Dec 2018 13:38:37 +0100 x86/topology: Use total_cpus for max logical packages calculation 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 starting the kdump kernel with command line option nr_cpus=16 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=, 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 Signed-off-by: Thomas Gleixner Cc: Cc: Cc: Cc: Link: https://lkml.kernel.org/r/20181107023643.22174-1-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); }