From patchwork Fri Feb 3 13:50:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 13127632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DEFDC05027 for ; Fri, 3 Feb 2023 14:02:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UKCOZkNWimtb7AonBHeNbvlSB1D/dSRSPUEteyrIp2Q=; b=reFqv+qQT33TEF jjXqBrAufsESKS0IQm/8uIBTjGgmlx+bicCCn7H85OjtHrCmRWyUmn21zA91JiNJFWiumSK6/9fIj mTW25nJy37Nc6o3FG7qa3dy4ijSYvUd1ivvmRPhaoBKD/BHbYZTPwxwBUZiWWQ0lOplQEBKodYOAo RiefP9Xy/87K3vgscwiVbFLCvbgi+8WgXCJNAZEY1sXQmrXLHZ0BptLVfii/H8ppN1pjs98fZNDFT K50Xde7+/kAhdBopCu/xcFKKb7Ju545x76ICGlRf9Atn1sKngTyI0kokeh7Fx50LPCwOuQCZCHcBm /WpgV3tHMM+Ahjp1IBZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNwce-002D5s-IV; Fri, 03 Feb 2023 14:01:00 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNwU5-002A1w-Ag for linux-arm-kernel@lists.infradead.org; Fri, 03 Feb 2023 13:52:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 575A815A1; Fri, 3 Feb 2023 05:52:47 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.177]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 885F23F71E; Fri, 3 Feb 2023 05:52:01 -0800 (PST) From: James Morse To: linux-pm@vger.kernel.org, loongarch@lists.linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Mark Rutland , Sudeep Holla , Borislav Petkov , H Peter Anvin , Dave Hansen , Ingo Molnar , Will Deacon , Catalin Marinas , Huacai Chen , James Morse , Suzuki K Poulose , Oliver Upton , Len Brown , Rafael Wysocki , WANG Xuerui , Salil Mehta , Russell King , Jean-Philippe Brucker Subject: [RFC PATCH 03/32] drivers: base: Use present CPUs in GENERIC_CPU_DEVICES Date: Fri, 3 Feb 2023 13:50:14 +0000 Message-Id: <20230203135043.409192-4-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230203135043.409192-1-james.morse@arm.com> References: <20230203135043.409192-1-james.morse@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230203_055209_523326_ED478548 X-CRM114-Status: GOOD ( 14.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The four ACPI architectures only create sysfs entries using register_cpu() for present CPUs, whereas GENERIC_CPU_DEVICES does this for possible CPUs. Only two of the eight architectures that use GENERIC_CPU_DEVICES have a distinction between present and possible CPUs. To allow all four ACPI architectures to use GENERIC_CPU_DEVICES, change it to use for_each_present_cpu(). The following architectures use GENERIC_CPU_DEVICES but are not SMP, so possible == present: * m68k * microblaze * nios2 The following architectures use GENERIC_CPU_DEVICES and consider possible == present: * csky: setup_smp() * hexagon: compare smp_start_cpus() and smp_prepare_cpus() * parisc: smp_prepare_boot_cpu() marks the boot cpu as present, processor_probe() sets possible for all CPUs and present for all CPUs except the boot cpu. um appears to be a subarchitecture of x86. The remaining architecture using GENERIC_CPU_DEVICES is openrisc, where smp_init_cpus() makes all CPUs < NR_CPUS possible, whereas smp_prepare_cpus() only makes CPUs < setup_max_cpus present. After this change, openrisc systems that boot with max_cpus=1 would not see other CPUs present in sysfs. This should not be a problem as these CPUs can't be brought online as _cpu_up() checks cpu_present(). Signed-off-by: James Morse --- drivers/base/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 4c98849577d4..cf6407c34ede 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -500,7 +500,7 @@ static void __init cpu_dev_register_generic(void) #ifdef CONFIG_GENERIC_CPU_DEVICES int i; - for_each_possible_cpu(i) { + for_each_present_cpu(i) { if (register_cpu(&per_cpu(cpu_devices, i), i)) panic("Failed to register CPU device"); }