Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2591828imu; Tue, 6 Nov 2018 18:07:37 -0800 (PST) X-Google-Smtp-Source: AJdET5c4sxlVfyzy9sNmRzY7e/8pHBkBQmQpvLLUreLF9NfvywMfAh63hMcTO23Z2a6O7BfyhLep X-Received: by 2002:a17:902:a614:: with SMTP id u20-v6mr28813664plq.77.1541556457131; Tue, 06 Nov 2018 18:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541556457; cv=none; d=google.com; s=arc-20160816; b=A/T1G2SvEv1DUAKA0+TH3A7h8CvWaKb7HAfD+9Z2XkJsstz9XSpAdU0DvlJwisBX+F 9j44vMsU2CyndUGft1YFOeoOqbMq9K7FyaeI8LBypEbPgAPGguXSgoumqzN73rhgYSFJ dv2n1mhGFB8PSFoFbLIhash2DcaRyBxT9HTaDJDu4FIVL3fFqEB00hG323IMupKv8hnh rRjNn1qB7rZ5lsHpHvqOuN3fiSxWCTgxxo/gkt45at9LiK9ZDCaJo+0tT3sdtGEr2tlV YrMl+a9A9UjKM3vMoJGny3H4cTph453KWLRabyF2gBXF026EFG8Vf4wXg3rZd8HKkkI7 nLKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=PrVL8tLiLd/nAKeeFTCB5iijc0G/KudCh3N4XW5atqA=; b=iZgfenAdpPslR7vTNtAvk96P22JrIJJE9FS2+6y2Ce+oiKAzH3gZTymL7VoEZ7JTP0 bq6sSGp2UqrdMPVRQcqRogGXQ2lFF4O9T5xkbdLtxXKwyZ4uGgvUW+vsy+DE6B8l1UDm sAkL/95ZOd5XytIHQ5wTFLocqvO5HvI25H1mbuVdmDVsqn34PEBkwyscejj8PjJ7iInL 0LO9371xcmp5if9z/dVpNPQ/Rr9mPsn6Hjye6tCNirkLG7947t9qyfqQcEaeIcMKGftA fKQfnjqP96li1WxKruUASg1d4ePbQa1xoZjh7Xg8aVPOe5uv7D5Bt9GscNnlfqd9Zn2t SNUA== 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 s13-v6si46385553pgp.382.2018.11.06.18.07.20; Tue, 06 Nov 2018 18:07:37 -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 S2389133AbeKGLa7 (ORCPT + 99 others); Wed, 7 Nov 2018 06:30:59 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:14185 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388747AbeKGLa7 (ORCPT ); Wed, 7 Nov 2018 06:30:59 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0D91150BAE96D for ; Wed, 7 Nov 2018 10:02:43 +0800 (CST) Received: from huawei.com (10.175.104.244) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Wed, 7 Nov 2018 10:02:33 +0800 From: Hui Wang To: , CC: , , , Subject: [PATCH] x86/topology: use total_cpus for max logical packages calculation Date: Wed, 7 Nov 2018 10:36:43 +0800 Message-ID: <20181107023643.22174-1-john.wanghui@huawei.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.104.244] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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=, 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 --- 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