Received: by 10.213.65.68 with SMTP id h4csp894461imn; Wed, 14 Mar 2018 03:30:27 -0700 (PDT) X-Google-Smtp-Source: AG47ELu8X0GNrCNwwtxQgil9NhW3cXYUaayzgMsWCfVtRJV+U/bZiYQLieSbWbCWGeOYw+p/XILF X-Received: by 10.99.121.5 with SMTP id u5mr3261212pgc.444.1521023426933; Wed, 14 Mar 2018 03:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521023426; cv=none; d=google.com; s=arc-20160816; b=Ze+v6NcxCKQYNEwlX/7Z9UepSpJVDTCku5lAAzlq1sNrOyurQL2ZQfK4FC0qDgvpHi OPJI7LMdbgZtSpLF/Ua6xeG8nJH751iwF6pDhnZq8hcf675RCUjTlFf9PqMdEVONaDUR VpMfq6p+STyPDAptPHbPqhV1IZTicqEkijKM7Dg7ziKvNS4kLUZ6UhpswUFb9/+k47BW ktAcZ7ac/O4hHLbY5JivRmNqMqv0BxDCjq94yzU61kx0fg7xEs0SCYgVAJYX41Btq87Y Nadm8AIyb9ViUm1go8nUXDCuq49uYKCJgsckJYeU+UnoOPdoLjipj3/Lit+zXDcelOqs OFFA== 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:arc-authentication-results; bh=Ivo0vXtYGeKZy4IyRMqr7NsRrRpP5Y8w5H00B7Xsg+s=; b=1EKNDzmUh1BFFAfOhFcSkXjzqqTRrZUsK8iaCdBb6ctSXykvIWPCym6ICtVeKpUXF8 Ivpv3D8qxgRgrsQtOkbIGqX7B8Pca8JtFJYtOR8tPtS+V+5zY8PM43Ob3r4VPRV88ci2 uA3zPClAOqr2oN2pQ4DplTBm/S24ij2HrE9zZ52WvfQFvzpzGy/rmuHITVq3yc5nXUG9 RHtTqFwayOptWfEA/bi3x6y5/8xcf8J+hvpxhF4wudyHesCrsPrcSG2L4zbpNfC+jIfo runuQ/YfRssKrI+QjpiUGH0xZmNiIFPSml5icHW3F9Rf0Eg/Sgqpq8UQtYrUTOvh+ECy +XJw== 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 h1si1831438pfn.266.2018.03.14.03.30.11; Wed, 14 Mar 2018 03:30:26 -0700 (PDT) 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 S1751467AbeCNK3E (ORCPT + 99 others); Wed, 14 Mar 2018 06:29:04 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:54535 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751228AbeCNK3D (ORCPT ); Wed, 14 Mar 2018 06:29:03 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="37818244" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 14 Mar 2018 18:29:00 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 73457486A78A; Wed, 14 Mar 2018 18:28:57 +0800 (CST) Received: from localhost.localdomain (10.167.226.106) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 14 Mar 2018 18:28:56 +0800 From: Dou Liyang To: , CC: , , , , , , Dou Liyang Subject: [RFC PATCH] ACPI / processor: Get accurate possible CPU count Date: Wed, 14 Mar 2018 18:28:47 +0800 Message-ID: <20180314102847.30459-1-douly.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.14.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 73457486A78A.AFFB6 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rafael J told me in order for the ACPI-based physical CPU hotplug to work, there have to be objects in the ACPI namespace corresponding to all of the processors in question. If they are not present, there is no way to signal insertion and eject the processors safely. But, Kernel calculates the possible CPU count from the number of Local APIC entries in ACPI MADT. It doesn't consider with the ACPI namespace and reports unrealistically high numbers. Depth-first search the namespace tree, check and collect the correct CPUs and update the possible map Signed-off-by: Dou Liyang --- drivers/acpi/acpi_processor.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 449d86d39965..ca4fa95e0515 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -671,6 +671,23 @@ static acpi_status __init acpi_processor_ids_walk(acpi_handle handle, } +static void __init acpi_update_possible_map(void) +{ + unsigned int cpu, nr = 0; + + if (nr_cpu_ids <= nr_unique_ids) + return; + + for_each_possible_cpu(cpu) { + if (nr >= nr_unique_ids) + set_cpu_possible(cpu, false); + nr++; + } + + nr_cpu_ids = nr_unique_ids; + pr_info("Allowing %d possible CPUs\n", nr_cpu_ids); +} + static void __init acpi_processor_check_duplicates(void) { /* check the correctness for all processors in ACPI namespace */ @@ -680,6 +697,9 @@ static void __init acpi_processor_check_duplicates(void) NULL, NULL, NULL); acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_ids_walk, NULL, NULL); + + /* make possible CPU count more realistic */ + acpi_update_possible_map(); } bool acpi_duplicate_processor_id(int proc_id) -- 2.14.3