Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp527351rdf; Fri, 3 Nov 2023 07:37:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqWXjom9zN2r4LhJBRzank/5X0YOU3UKEUjD5gYzfnxA5Kz8AI7zjyrnIlXq0aRQVuPtPx X-Received: by 2002:a17:902:d401:b0:1cc:2f90:6291 with SMTP id b1-20020a170902d40100b001cc2f906291mr16470117ple.54.1699022259355; Fri, 03 Nov 2023 07:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022259; cv=none; d=google.com; s=arc-20160816; b=MKFCIVMDNLN84Y8V/HbZwGpLqcH6uSN0CDGTCUAs14TgZ1bprCc/tbhWsmH/NEaSMi eE7a7ivVeW6oVJoIr31OtCDk6WxRWv3n2z+o+5EJ4/rbFYllKeKJo2w4AP3cIkjMhALd YckWtPZ1oqa9B1Igc9BcyW8kMIvd/f2U6BB9R+TDciWuZNf8hAHJe53gEKwoMKeEsRkm HKgkEsqDbEvPdimCoYt2XTeVEBiAuv8eVuZYCGGY281rtl72/+4TJYNJLcRLbt+B7377 k+8Sauw0sgTrt/bcUs9CmYVAe+JI9M2WD1kN5YGY92jalAVSu6naRRApKuFJbc/0KOUm hCNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=72hxmQCBkLT/0leJQbNO6c+d3oMFYZOQGMSD17s25rI=; fh=AHiz6qxGRxI8j9KpOhS1UhEv+WKoL5AoTt9sKVqaG04=; b=KoR5hFl59GHreTIJ39Hfxc+UO0Aowohn8Z6Y8Y97AyXWR7zqmEg5cGQW0drfkmXFCU WZ6qJHOOaIjqxOG9vT8F8g8qWmLJewMnInx+RiYW5QOSroSc36Sa10oCkZ0633GReD7b rR3bug/OD/uJ2LET5qMLjMZ9gx6NcAaEvRuktCeSdx9z4xiI1fq1YAfvgpfsawxqzW4W stT1293mBTSdkGyzz9FHW2wRxRqPCC9Kl7zCWGWwuW86f3gBAqWSDYeGHfIJZ/82TDNs sZRIjQZR1HTeInOcuu+P0MXPlMTEZbqL+4SqNaonN1fq4kjJB0HyMJULU88+o3XACg1B hDmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=q8smHBP7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o15-20020a17090323cf00b001c3a06b4fd7si1554375plh.561.2023.11.03.07.37.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:37:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=q8smHBP7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 3CCD48315559; Fri, 3 Nov 2023 07:37:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377844AbjKCOhe (ORCPT + 99 others); Fri, 3 Nov 2023 10:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbjKCOhd (ORCPT ); Fri, 3 Nov 2023 10:37:33 -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 2E798CA; Fri, 3 Nov 2023 07:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding: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=72hxmQCBkLT/0leJQbNO6c+d3oMFYZOQGMSD17s25rI=; b=q8smHBP7DkeRlLmtBpuVNpbR3l Xsq9Jg+jETRWE9W6AuGqCDDiqxwTUQfqg0tFog/sx8M46baq9d88THW80uQlFB4fqAYCq/DzxQVtR g+/2VpoltDLb+HANTiWd7cpJg0mw85W6TI5UDDVSr2mh9gorJBllB4eQsCGu1APZJcTsAOhGxLMOF rSERDI7IL5O8ysT9mss7VBj65MH8WJWsPtnKokF1trUFWaDHPGx5/Vd1P9pA1ypJccnB9lslaWTOy kAjrpoOnuaYuqlvim1kLdN33vhWIuNl3wQW0SUOYQZtw8JeMgy8G8ndUDUjLI2wchB2QT/eSQVcIQ Y4XdND7w==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:54582) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qyvIX-0005cb-1Y; Fri, 03 Nov 2023 14:37:21 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qyvIY-0008Tw-8D; Fri, 03 Nov 2023 14:37:22 +0000 Date: Fri, 3 Nov 2023 14:37:22 +0000 From: "Russell King (Oracle)" To: Gavin Shan Cc: James Morse , 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, Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com Subject: Re: [RFC PATCH v2 22/35] ACPI: Check _STA present bit before making CPUs not present Message-ID: References: <20230913163823.7880-1-james.morse@arm.com> <20230913163823.7880-23-james.morse@arm.com> <518859b1-64a9-d723-963c-56c7f6fc2da1@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <518859b1-64a9-d723-963c-56c7f6fc2da1@redhat.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:37:37 -0700 (PDT) On Tue, Sep 19, 2023 at 10:45:39AM +1000, Gavin Shan wrote: > On 9/14/23 02:38, James Morse wrote: > > When called acpi_processor_post_eject() unconditionally make a CPU > > not-present and unregisters it. > > > > To add support for AML events where the CPU has become disabled, but > > remains present, the _STA method should be checked before calling > > acpi_processor_remove(). > > > > Rename acpi_processor_post_eject() acpi_processor_remove_possible(), and > > check the _STA before calling. > > > > Adding the function prototype for arch_unregister_cpu() allows the > > preprocessor guards to be removed. > > > > After this change CPUs will remain registered and visible to > > user-space as offline if buggy firmware triggers an eject-request, > > but doesn't clear the corresponding _STA bits after _EJ0 has been > > called. > > > > Signed-off-by: James Morse > > --- > > drivers/acpi/acpi_processor.c | 31 +++++++++++++++++++++++++------ > > include/linux/cpu.h | 1 + > > 2 files changed, 26 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > > index 00dcc23d49a8..2cafea1edc24 100644 > > --- a/drivers/acpi/acpi_processor.c > > +++ b/drivers/acpi/acpi_processor.c > > @@ -457,13 +457,12 @@ static int acpi_processor_add(struct acpi_device *device, > > return result; > > } > > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > > /* Removal */ > > -static void acpi_processor_post_eject(struct acpi_device *device) > > +static void acpi_processor_make_not_present(struct acpi_device *device) > > { > > struct acpi_processor *pr; > > - if (!device || !acpi_driver_data(device)) > > + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) > > return; > > In order to use IS_ENABLED(), And the rest of this statement is where? > > pr = acpi_driver_data(device); > > @@ -501,7 +500,29 @@ static void acpi_processor_post_eject(struct acpi_device *device) > > free_cpumask_var(pr->throttling.shared_cpu_map); > > kfree(pr); > > } > > -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ > > + > > +static void acpi_processor_post_eject(struct acpi_device *device) > > +{ > > + struct acpi_processor *pr; > > + unsigned long long sta; > > + acpi_status status; > > + > > + if (!device) > > + return; > > + > > + pr = acpi_driver_data(device); > > + if (!pr || pr->id >= nr_cpu_ids || invalid_phys_cpuid(pr->phys_id)) > > + return; > > + > > Do we really need to validate the logic and hardware CPU IDs here? I think > the ACPI processor device can't be added successfully if one of them is > invalid. > > > + status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); > > + if (ACPI_FAILURE(status)) > > + return; > > + > > + if (cpu_present(pr->id) && !(sta & ACPI_STA_DEVICE_PRESENT)) { > > + acpi_processor_make_not_present(device); > > + return; > > + } > > +} > > #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC > > bool __init processor_physically_present(acpi_handle handle) > > @@ -626,9 +647,7 @@ static const struct acpi_device_id processor_device_ids[] = { > > static struct acpi_scan_handler processor_handler = { > > .ids = processor_device_ids, > > .attach = acpi_processor_add, > > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > > .post_eject = acpi_processor_post_eject, > > -#endif > > .hotplug = { > > .enabled = true, > > }, > > diff --git a/include/linux/cpu.h b/include/linux/cpu.h > > index a71691d7c2ca..e117c06e0c6b 100644 > > --- a/include/linux/cpu.h > > +++ b/include/linux/cpu.h > > @@ -81,6 +81,7 @@ struct device *cpu_device_create(struct device *parent, void *drvdata, > > const struct attribute_group **groups, > > const char *fmt, ...); > > extern int arch_register_cpu(int cpu); > > +extern void arch_unregister_cpu(int cpu); > > arch_unregister_cpu() is protected by CONFIG_HOTPLUG_CPU in the individual architectures, > for example arch/ia64/kernel/topology.c Yes, I agree, there _may_ be a reference to arch_unregister_cpu() if the compiler doesn't optimise the "if(0) return". As things stand in my "head" tree (which I'll be posting once 6.7-rc1 is out) at the point that this patch exists in the series, there are no architectures which provide arch_unregister_cpu(), and the only implementation of it is the __weak one in drivers/base/cpu.c That implementation is also ifdef'd with CONFIG_HOTPLUG_CPU and also CONFIG_GENERIC_CPU_DEVICES. Meanwhile, acpi_processor.c is always built with ACPI, and while we have IS_ENABLED() clauses with James' patches for both of these symbols, if the compiler doesn't optimise the code away, we will end up with a reference and a link-time error. That being said, the 0-day bot has not reported anything as yet (and it builds my tree.) So, is this a problem that needs to be solved or not? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!