Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1960800rda; Tue, 24 Oct 2023 08:17:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8mrAL0sGxf0xSBNbqBntznjK8xVp4PaF1WkIW/+U3pMlmhnR+orlunNU8gb4/gH+9QiMA X-Received: by 2002:a17:902:fa47:b0:1c0:afda:7707 with SMTP id lb7-20020a170902fa4700b001c0afda7707mr12897745plb.34.1698160676315; Tue, 24 Oct 2023 08:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698160676; cv=none; d=google.com; s=arc-20160816; b=QlRZ0Kd3m04/8gRVh5JcUT+zdehPDT/SSN7pdXHWefu6th+DbcyZucMAQX3bE0AwL1 LUuh/C1ti6uhTiZGIHYmP1l4GO188qNKfz0ES+ueQ5ccEYxnBrJ7loHnPxUhqw/509nQ tiudz/3cb6HSD+kY5tuFALuHjCXAuoKgMaJwsMavtaiLWZDGLl4zI8XcAcwd60w4eoUP zj1JP81P5K2qrZpdiKfu2nLc5fYkuQIwbK9Oi7XYAzJCBdl10VsOad0fMsMlIxRAKsMZ NZlUq8aWpTUICtiB3HhHg+5mv8RlW4jrmMMOaSz2Whwzlz40coPYyV+oAA/Dv5r7VjXz Qmug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:sender:message-id:content-transfer-encoding :content-disposition:mime-version:subject:cc:to:from:references :in-reply-to:dkim-signature; bh=rpX32JELJVRxbBajbNmSR45zpZhhmbYGw/k55Nv6FvI=; fh=kqnmhUI72/OhTNFxW/Mp3EHegNo526ZgwLbrfgiAZBg=; b=HyjCzwmMyciS8f2evHImAm4UrlHzTMTkf+T/DFaAAEJHits8niYXVrVreCB3DAvuWN KIss7bEw7oV6cjeeI05IuON89XOR0JwX5lEKULGw+Ve59UVznq/yINmCx+gZjPaWxen6 U+JgSb4KRDHpquyciS0P2IVXRMZfKDWJV1GuvIuBeBJiyo+VdNkULn07ez6WIciAzb2U HewDcHija9EJ849xJuO6UYrOpS8b2Ao7BC60cb/38kik1S+4We3UjOqKK7bzPEhrHKHs X5IM8ohxcjH6VmQjMJjteIE8wsfk3+OYtfQIKLHEzt2mfV6aE64B8cLPuTK23iNB7tXo F+yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=OcG714uU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id c4-20020a170902aa4400b001c9af74feaesi8442374plr.215.2023.10.24.08.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 08:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=OcG714uU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3C61280AEB02; Tue, 24 Oct 2023 08:17:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343793AbjJXPR1 (ORCPT + 99 others); Tue, 24 Oct 2023 11:17:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343645AbjJXPRJ (ORCPT ); Tue, 24 Oct 2023 11:17:09 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B34DA1987; Tue, 24 Oct 2023 08:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rpX32JELJVRxbBajbNmSR45zpZhhmbYGw/k55Nv6FvI=; b=OcG714uUqwrZhegBX5wQQ0eRZX mZUreD2oXOfdv58j1eBrER0DefsWk5764QnZgFsI722cxEePKW7jkBCM62asx2pXYkyBbFLoeQdcv HU7WpXuh5BgCkmzLW9oG9918CV5/RqoRE8Y7OK1eGEvXAK9eQzrkAZnv+CSbxNAZ/k03enXtA46lE PppwrqqFP4bW1TPrA4jyamGrzPHOv4VFTfSDBsKxN3liZkF1YbT0EdrcqH1x5RrN+S6/YBZU/ddmX YeR5z03WpEjgjvnRKCyrvoGv6/iyIvTf3XeK7GNTywbwqm4ntZOaauwEkPtIrFcYp2ezvoACcBkWf yESvnrFA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:35410 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qvJ94-0004MU-2I; Tue, 24 Oct 2023 16:16:38 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qvJ96-00AqPM-5D; Tue, 24 Oct 2023 16:16:40 +0100 In-Reply-To: References: From: Russell King (Oracle) To: linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kvmarm@lists.linux.dev, x86@kernel.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse , Greg Kroah-Hartman , "Rafael J. Wysocki" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren Subject: [PATCH 06/39] drivers: base: Use present CPUs in GENERIC_CPU_DEVICES MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Tue, 24 Oct 2023 16:16:40 +0100 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 24 Oct 2023 08:17:51 -0700 (PDT) From: James Morse Three of the five ACPI architectures create sysfs entries using register_cpu() for present CPUs, whereas arm64, riscv and all GENERIC_CPU_DEVICES do this for possible CPUs. Registering a CPU is what causes them to show up in sysfs. It makes very little sense to register all possible CPUs. Registering a CPU is what triggers the udev notifications allowing user-space to react to newly added CPUs. To allow all five ACPI architectures to use GENERIC_CPU_DEVICES, change it to use for_each_present_cpu(). Making the ACPI architectures use GENERIC_CPU_DEVICES is a pre-requisite step to centralise their cpu_register() logic, before moving it into the ACPI processor driver. When ACPI is disabled this work would be done by cpu_dev_register_generic(). Of the ACPI architectures that register possible CPUs, arm64 and riscv do not support making possible CPUs present as they use the weak 'always fails' version of arch_register_cpu(). Only two of the eight architectures that use GENERIC_CPU_DEVICES have a distinction between present and possible CPUs. 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() * processor_probe() sets possible for all CPUs and present for all CPUs except the boot cpu, which will have been done by init/main.c::start_kernel(). um appears to be a subarchitecture of x86. The remaining architecture using GENERIC_CPU_DEVICES are: * openrisc and hexagon: 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 and hexagon systems that use the max_cpus command line argument would not see the other CPUs present in sysfs. This should not be a problem as these CPUs can't bre brought online as _cpu_up() checks cpu_present(). After this change, only CPUs which are present appear in sysfs. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Signed-off-by: Russell King (Oracle) --- 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 9ea22e165acd..34b48f660b6b 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -533,7 +533,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"); } -- 2.30.2