Message ID | 20230913163823.7880-25-james.morse@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1214081vqx; Wed, 13 Sep 2023 09:41:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ3X6Max+jxeqHjEBQtJ2/6o6ozZjmJ6mp1OLl3mDkJ1k99W820uvoh2n6dTXhhXE1jy8K X-Received: by 2002:a05:6a00:1819:b0:68f:d554:a299 with SMTP id y25-20020a056a00181900b0068fd554a299mr3785026pfa.10.1694623303284; Wed, 13 Sep 2023 09:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623303; cv=none; d=google.com; s=arc-20160816; b=npf/JJur6OmHN6j9CxQbHRhwrl9N6vTS/CGQVN+zyOQ/T1mdEc3qY3nfMp8YmDGYIU 1tfn7TJRoYOKNmxRN1r9Vnsmc/KaKA5sCkR0HGHt4ki4utRpG8QwGZTr9VD+Em9vv1EU eozFQC0rF8YDvG8G3bXxccJUgrX6cvNntGpvYQXp7SxKC9BpspitPfIbiMnwj/4hruz6 oZLl8lL1QTnKv/Xhj+hnSK4KUcx+Di5etf0RV9vSCJZkGauCq+yQrSQOeXLLivhmAI22 2IkRwMyOBDdEkK2lXzt3CiLQP9NjQGZFK5gMNoUdI1fNma6kMIjDy1IAjJELDZ431ips d8Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5XUwq6cWSioemH6X3uwmt5P5O1VCxxq8pzs8XEfSEik=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=uVOa5fhHytjXgGHjTt9VsLzr+qCGI85IprzneqEdRPxcan+YNTmu4chhdJn084S2kB TyNOBl9Bedg09q+yoP0ui4UVxI2EluhWWktlM7tyLdsmGNiR+9EYDITzbv6M49a+fkfv C5OfIhwacDfqsOZGk3kHE3VY91gnASWztyONvBi66l21c8d/uSgh/vytakAKahRdSn5q EXY5xlB3y6D8KkW7hB18fyfZNaoIkcwNrNit3YMZ03M4NLUFZ98ZGfAL+7/cjpBzmd7t eOC79H74R6Zqu7MvAKU8i6za1Ti7D0VZ6B+2ifbjuSuc/f1pwXadeTrlfbkoIkQB6+9r o2wA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id cg19-20020a056a00291300b0068e35157c22si10359474pfb.119.2023.09.13.09.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:41:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3DBAC81ECCED; Wed, 13 Sep 2023 09:41:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231230AbjIMQl0 (ORCPT <rfc822;pwkd43@gmail.com> + 35 others); Wed, 13 Sep 2023 12:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbjIMQka (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Sep 2023 12:40:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78EA226B3; Wed, 13 Sep 2023 09:39:41 -0700 (PDT) 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 586F01007; Wed, 13 Sep 2023 09:40:18 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5DDC13F5A1; Wed, 13 Sep 2023 09:39:39 -0700 (PDT) From: James Morse <james.morse@arm.com> 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 Cc: x86@kernel.org, Salil Mehta <salil.mehta@huawei.com>, Russell King <linux@armlinux.org.uk>, Jean-Philippe Brucker <jean-philippe@linaro.org>, jianyong.wu@arm.com, justin.he@arm.com Subject: [RFC PATCH v2 24/35] drivers: base: Implement weak arch_unregister_cpu() Date: Wed, 13 Sep 2023 16:38:12 +0000 Message-Id: <20230913163823.7880-25-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230913163823.7880-1-james.morse@arm.com> References: <20230913163823.7880-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:41:38 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=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 agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941324841205683 X-GMAIL-MSGID: 1776941324841205683 |
Series |
ACPI/arm64: add support for virtual cpuhotplug
|
|
Commit Message
James Morse
Sept. 13, 2023, 4:38 p.m. UTC
Add arch_unregister_cpu() to allow the ACPI machinery to call
unregister_cpu(). This is enough for arm64, riscv and loongarch, but
needs to be overridden by x86 and ia64 who need to do more work.
CC: Jean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: James Morse <james.morse@arm.com>
---
Changes since v1:
* Added CONFIG_HOTPLUG_CPU ifdeffery around unregister_cpu
---
arch/ia64/include/asm/cpu.h | 4 ----
arch/loongarch/include/asm/cpu.h | 6 ------
arch/x86/include/asm/cpu.h | 1 -
drivers/base/cpu.c | 9 ++++++++-
4 files changed, 8 insertions(+), 12 deletions(-)
Comments
On Wed, 13 Sep 2023 16:38:12 +0000 James Morse <james.morse@arm.com> wrote: > Add arch_unregister_cpu() to allow the ACPI machinery to call > unregister_cpu(). This is enough for arm64, riscv and loongarch, but > needs to be overridden by x86 and ia64 who need to do more work. > > CC: Jean-Philippe Brucker <jean-philippe@linaro.org> > Signed-off-by: James Morse <james.morse@arm.com> Ah. Was thinking this should happen in an earlier patch. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > Changes since v1: > * Added CONFIG_HOTPLUG_CPU ifdeffery around unregister_cpu > --- > arch/ia64/include/asm/cpu.h | 4 ---- > arch/loongarch/include/asm/cpu.h | 6 ------ > arch/x86/include/asm/cpu.h | 1 - > drivers/base/cpu.c | 9 ++++++++- > 4 files changed, 8 insertions(+), 12 deletions(-) > > diff --git a/arch/ia64/include/asm/cpu.h b/arch/ia64/include/asm/cpu.h > index a3e690e685e5..642d71675ddb 100644 > --- a/arch/ia64/include/asm/cpu.h > +++ b/arch/ia64/include/asm/cpu.h > @@ -15,8 +15,4 @@ DECLARE_PER_CPU(struct ia64_cpu, cpu_devices); > > DECLARE_PER_CPU(int, cpu_state); > > -#ifdef CONFIG_HOTPLUG_CPU > -extern void arch_unregister_cpu(int); > -#endif > - > #endif /* _ASM_IA64_CPU_H_ */ > diff --git a/arch/loongarch/include/asm/cpu.h b/arch/loongarch/include/asm/cpu.h > index b8568e637420..48b9f7168bcc 100644 > --- a/arch/loongarch/include/asm/cpu.h > +++ b/arch/loongarch/include/asm/cpu.h > @@ -128,10 +128,4 @@ enum cpu_type_enum { > #define LOONGARCH_CPU_HYPERVISOR BIT_ULL(CPU_FEATURE_HYPERVISOR) > #define LOONGARCH_CPU_PTW BIT_ULL(CPU_FEATURE_PTW) > > -#if !defined(__ASSEMBLY__) > -#ifdef CONFIG_HOTPLUG_CPU > -void arch_unregister_cpu(int cpu); > -#endif > -#endif /* ! __ASSEMBLY__ */ > - > #endif /* _ASM_CPU_H */ > diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h > index f349c94510e8..91867a6a9f8e 100644 > --- a/arch/x86/include/asm/cpu.h > +++ b/arch/x86/include/asm/cpu.h > @@ -24,7 +24,6 @@ static inline void prefill_possible_map(void) {} > #endif /* CONFIG_SMP */ > > #ifdef CONFIG_HOTPLUG_CPU > -extern void arch_unregister_cpu(int); > extern void soft_restart_cpu(void); > #endif > > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c > index 677f963e02ce..c709747c4a18 100644 > --- a/drivers/base/cpu.c > +++ b/drivers/base/cpu.c > @@ -531,7 +531,14 @@ int __weak arch_register_cpu(int cpu) > { > return register_cpu(&per_cpu(cpu_devices, cpu), cpu); > } > -#endif > + > +#ifdef CONFIG_HOTPLUG_CPU > +void __weak arch_unregister_cpu(int num) > +{ > + unregister_cpu(&per_cpu(cpu_devices, num)); > +} > +#endif /* CONFIG_HOTPLUG_CPU */ > +#endif /* CONFIG_GENERIC_CPU_DEVICES */ > > static void __init cpu_dev_register_generic(void) > {
On 9/14/23 02:38, James Morse wrote: > Add arch_unregister_cpu() to allow the ACPI machinery to call > unregister_cpu(). This is enough for arm64, riscv and loongarch, but > needs to be overridden by x86 and ia64 who need to do more work. > > CC: Jean-Philippe Brucker <jean-philippe@linaro.org> > Signed-off-by: James Morse <james.morse@arm.com> > --- > Changes since v1: > * Added CONFIG_HOTPLUG_CPU ifdeffery around unregister_cpu > --- > arch/ia64/include/asm/cpu.h | 4 ---- > arch/loongarch/include/asm/cpu.h | 6 ------ > arch/x86/include/asm/cpu.h | 1 - > drivers/base/cpu.c | 9 ++++++++- > 4 files changed, 8 insertions(+), 12 deletions(-) > I agree with Jonathan this patch needs to come early. Maybe move this before the following one: [RFC PATCH v2 19/35] ACPI: Move acpi_bus_trim_one() before acpi_scan_hot_remove() > diff --git a/arch/ia64/include/asm/cpu.h b/arch/ia64/include/asm/cpu.h > index a3e690e685e5..642d71675ddb 100644 > --- a/arch/ia64/include/asm/cpu.h > +++ b/arch/ia64/include/asm/cpu.h > @@ -15,8 +15,4 @@ DECLARE_PER_CPU(struct ia64_cpu, cpu_devices); > > DECLARE_PER_CPU(int, cpu_state); > > -#ifdef CONFIG_HOTPLUG_CPU > -extern void arch_unregister_cpu(int); > -#endif > - > #endif /* _ASM_IA64_CPU_H_ */ > diff --git a/arch/loongarch/include/asm/cpu.h b/arch/loongarch/include/asm/cpu.h > index b8568e637420..48b9f7168bcc 100644 > --- a/arch/loongarch/include/asm/cpu.h > +++ b/arch/loongarch/include/asm/cpu.h > @@ -128,10 +128,4 @@ enum cpu_type_enum { > #define LOONGARCH_CPU_HYPERVISOR BIT_ULL(CPU_FEATURE_HYPERVISOR) > #define LOONGARCH_CPU_PTW BIT_ULL(CPU_FEATURE_PTW) > > -#if !defined(__ASSEMBLY__) > -#ifdef CONFIG_HOTPLUG_CPU > -void arch_unregister_cpu(int cpu); > -#endif > -#endif /* ! __ASSEMBLY__ */ > - > #endif /* _ASM_CPU_H */ > diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h > index f349c94510e8..91867a6a9f8e 100644 > --- a/arch/x86/include/asm/cpu.h > +++ b/arch/x86/include/asm/cpu.h > @@ -24,7 +24,6 @@ static inline void prefill_possible_map(void) {} > #endif /* CONFIG_SMP */ > > #ifdef CONFIG_HOTPLUG_CPU > -extern void arch_unregister_cpu(int); > extern void soft_restart_cpu(void); > #endif > > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c > index 677f963e02ce..c709747c4a18 100644 > --- a/drivers/base/cpu.c > +++ b/drivers/base/cpu.c > @@ -531,7 +531,14 @@ int __weak arch_register_cpu(int cpu) > { > return register_cpu(&per_cpu(cpu_devices, cpu), cpu); > } > -#endif > + > +#ifdef CONFIG_HOTPLUG_CPU > +void __weak arch_unregister_cpu(int num) > +{ > + unregister_cpu(&per_cpu(cpu_devices, num)); > +} > +#endif /* CONFIG_HOTPLUG_CPU */ > +#endif /* CONFIG_GENERIC_CPU_DEVICES */ > It seems conflicting with its declaration in include/linux/cpu.h. Besides, the function is still needed by drivers/acpi/acpi_processor.c::acpi_processor_make_not_present() even both CONFIG_HOTPLUG_CPU and CONFIG_GENERIC_CPU_DEVICES are disabled? > static void __init cpu_dev_register_generic(void) > { Thanks, Gavin
On Tue, Sep 19, 2023 at 10:59:23AM +1000, Gavin Shan wrote: > On 9/14/23 02:38, James Morse wrote: > > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c > > index 677f963e02ce..c709747c4a18 100644 > > --- a/drivers/base/cpu.c > > +++ b/drivers/base/cpu.c > > @@ -531,7 +531,14 @@ int __weak arch_register_cpu(int cpu) > > { > > return register_cpu(&per_cpu(cpu_devices, cpu), cpu); > > } > > -#endif > > + > > +#ifdef CONFIG_HOTPLUG_CPU > > +void __weak arch_unregister_cpu(int num) > > +{ > > + unregister_cpu(&per_cpu(cpu_devices, num)); > > +} > > +#endif /* CONFIG_HOTPLUG_CPU */ > > +#endif /* CONFIG_GENERIC_CPU_DEVICES */ > > It seems conflicting with its declaration in include/linux/cpu.h. How so? The declaration is: extern void arch_unregister_cpu(int cpu); So: void __weak arch_unregister_cpu(int num) is compatible. > Besides, the function is still needed by > drivers/acpi/acpi_processor.c::acpi_processor_make_not_present() > even both CONFIG_HOTPLUG_CPU and CONFIG_GENERIC_CPU_DEVICES are disabled? Yes, I agree - it needs to be present when ACPI is built, so I'm thinking the right solution is to move it out from under at least CONFIG_HOTPLUG_CPU. It can't be moved out from under CONFIG_GENERIC_CPU_DEVICES because then we end up referencing the per-cpu variable cpu_devices which only exists when CONFIG_GENERIC_CPU_DEVICES is enabled. Is that a problem though, because in the case of !CONFIG_GENERIC_CPU_DEVICES, aren't architectures required to provide both arch_.*register_cpu() functions? Thanks.
On Mon, Oct 23, 2023 at 09:44:50AM +0100, Russell King (Oracle) wrote: > On Tue, Sep 19, 2023 at 10:59:23AM +1000, Gavin Shan wrote: > > On 9/14/23 02:38, James Morse wrote: > > > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c > > > index 677f963e02ce..c709747c4a18 100644 > > > --- a/drivers/base/cpu.c > > > +++ b/drivers/base/cpu.c > > > @@ -531,7 +531,14 @@ int __weak arch_register_cpu(int cpu) > > > { > > > return register_cpu(&per_cpu(cpu_devices, cpu), cpu); > > > } > > > -#endif > > > + > > > +#ifdef CONFIG_HOTPLUG_CPU > > > +void __weak arch_unregister_cpu(int num) > > > +{ > > > + unregister_cpu(&per_cpu(cpu_devices, num)); > > > +} > > > +#endif /* CONFIG_HOTPLUG_CPU */ > > > +#endif /* CONFIG_GENERIC_CPU_DEVICES */ > > > > It seems conflicting with its declaration in include/linux/cpu.h. > > How so? The declaration is: > > extern void arch_unregister_cpu(int cpu); > > So: > > void __weak arch_unregister_cpu(int num) > > is compatible. > > > Besides, the function is still needed by > > drivers/acpi/acpi_processor.c::acpi_processor_make_not_present() > > even both CONFIG_HOTPLUG_CPU and CONFIG_GENERIC_CPU_DEVICES are disabled? > > Yes, I agree - it needs to be present when ACPI is built, so I'm > thinking the right solution is to move it out from under at least > CONFIG_HOTPLUG_CPU. > > It can't be moved out from under CONFIG_GENERIC_CPU_DEVICES because > then we end up referencing the per-cpu variable cpu_devices which only > exists when CONFIG_GENERIC_CPU_DEVICES is enabled. Is that a problem > though, because in the case of !CONFIG_GENERIC_CPU_DEVICES, aren't > architectures required to provide both arch_.*register_cpu() functions? I'm also wondering why this patch isn't part of: "drivers: base: Allow parts of GENERIC_CPU_DEVICES to be overridden" because it seems to be doing something very similar. The commit I refer to introduces a weak version of arch_register_cpu(), and it seems it would also be appropriate to introduce a weak version of its unregister paired function at the same time. Any existing definitions of non-weak arch_unregister_cpu() would override it so it shouldn't cause any issues. Thanks.
diff --git a/arch/ia64/include/asm/cpu.h b/arch/ia64/include/asm/cpu.h index a3e690e685e5..642d71675ddb 100644 --- a/arch/ia64/include/asm/cpu.h +++ b/arch/ia64/include/asm/cpu.h @@ -15,8 +15,4 @@ DECLARE_PER_CPU(struct ia64_cpu, cpu_devices); DECLARE_PER_CPU(int, cpu_state); -#ifdef CONFIG_HOTPLUG_CPU -extern void arch_unregister_cpu(int); -#endif - #endif /* _ASM_IA64_CPU_H_ */ diff --git a/arch/loongarch/include/asm/cpu.h b/arch/loongarch/include/asm/cpu.h index b8568e637420..48b9f7168bcc 100644 --- a/arch/loongarch/include/asm/cpu.h +++ b/arch/loongarch/include/asm/cpu.h @@ -128,10 +128,4 @@ enum cpu_type_enum { #define LOONGARCH_CPU_HYPERVISOR BIT_ULL(CPU_FEATURE_HYPERVISOR) #define LOONGARCH_CPU_PTW BIT_ULL(CPU_FEATURE_PTW) -#if !defined(__ASSEMBLY__) -#ifdef CONFIG_HOTPLUG_CPU -void arch_unregister_cpu(int cpu); -#endif -#endif /* ! __ASSEMBLY__ */ - #endif /* _ASM_CPU_H */ diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index f349c94510e8..91867a6a9f8e 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -24,7 +24,6 @@ static inline void prefill_possible_map(void) {} #endif /* CONFIG_SMP */ #ifdef CONFIG_HOTPLUG_CPU -extern void arch_unregister_cpu(int); extern void soft_restart_cpu(void); #endif diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 677f963e02ce..c709747c4a18 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -531,7 +531,14 @@ int __weak arch_register_cpu(int cpu) { return register_cpu(&per_cpu(cpu_devices, cpu), cpu); } -#endif + +#ifdef CONFIG_HOTPLUG_CPU +void __weak arch_unregister_cpu(int num) +{ + unregister_cpu(&per_cpu(cpu_devices, num)); +} +#endif /* CONFIG_HOTPLUG_CPU */ +#endif /* CONFIG_GENERIC_CPU_DEVICES */ static void __init cpu_dev_register_generic(void) {