From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05324C282C3 for ; Thu, 24 Jan 2019 19:37:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C914121908 for ; Thu, 24 Jan 2019 19:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548358625; bh=84ibl89TfWUICXy5tXkKaovz/FRoNl/EdU433hzWurA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jaYKzfGNadGJMUItdTn0xwzv71+x58VFhE/dOLox+sDUF0+rI4usMPtLJoJaqe6ek NTStq++wHp+3aK0ZN6xRYtWNTyEd3jFMemK8Vt8yvTvc1N16uJOx4OymBv3JaPPc/9 PjEeD43aNyZ8hPrTI/g2OCGJRk4WHVKJll6Fy8FY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730103AbfAXThE (ORCPT ); Thu, 24 Jan 2019 14:37:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:36974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732575AbfAXThA (ORCPT ); Thu, 24 Jan 2019 14:37:00 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 869F7218FC; Thu, 24 Jan 2019 19:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548358620; bh=84ibl89TfWUICXy5tXkKaovz/FRoNl/EdU433hzWurA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GE38K9GRwvvc/eFqQ29g+3BYYmzvLpEMdxs0hnZlkSz7Rzxb87rP7o1cuYIizFKlZ lDLlcAU6Rl8EYWZ1xnm+yvaVX4Sfsomqz+DW08dTtbRUL8+pP17lsyXr6JpdFvN1bz P/Y3P/+qOrehM1/kBaHn6BQVifZfRH8/uzUHQvT8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Wang , Thomas Gleixner , guijianfeng@huawei.com, wencongyang2@huawei.com, douliyang1@huawei.com, qiaonuohan@huawei.com, Sasha Levin Subject: [PATCH 4.19 073/106] x86/topology: Use total_cpus for max logical packages calculation Date: Thu, 24 Jan 2019 20:20:30 +0100 Message-Id: <20190124190210.942797169@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124190206.342411005@linuxfoundation.org> References: <20190124190206.342411005@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit aa02ef099cff042c2a9109782ec2bf1bffc955d4 ] 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 Signed-off-by: Sasha Levin --- 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 f02ecaf97904..6489067b78a4 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1346,7 +1346,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.19.1