Message ID | 20230524155630.794584-8-mpe@ellerman.id.au |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp31628vqr; Wed, 24 May 2023 09:27:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KE52oDzoI6AYKsopRWEmzCV1RW9TO8NIcsF/67jc1nWNxF2VWET5aBwXAUKc6L+zeLDjO X-Received: by 2002:a17:902:7448:b0:1a6:dd9a:62c5 with SMTP id e8-20020a170902744800b001a6dd9a62c5mr17447800plt.10.1684945628165; Wed, 24 May 2023 09:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684945628; cv=none; d=google.com; s=arc-20160816; b=mTs66/vpafU2oWIQ6AVQPhJSMspJIxgTGEUEvGBjl68ZZdSaL9xdVsPjyxhsQFaqv3 miHj/EpKYK6wjX5U0Dk8PWySSLBpecOZ13lOEd77oyh5Qd5SZO3d5U7qboIZ1ZZ2EKpx GaOPRtK1Y5NEnl0IVzYRmBQ8Gl4J/U9VFysRbiF04yCAbg6W/dC9IWigEZCvVjgwORYq ZdzzaHCmStDEuwqZGrTGzicdzsbLIaAyb5sGQDzRpTNOjKU8gvAhj2RpaAfooOKrS9LK +uob4VWW3l9ozys5mqGOAbqs31dBF7m8K/Oen4SteY16pwC0WURdFeUQMwcU2YXr7z+Y smug== 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 :dkim-signature; bh=p1bBAk5FodJhZ4XtodQ/RroeKg6GW9YX3VKIMJsVMLY=; b=E/CrlIJS1GHJUXRFOPZNie7LQxMmi1O9K8SoaFjW0/6kIigqYEzN+iNXiCFJcijAfl QqlqenA9KHKbpihc7j+8ZRhF8pa0ckT5AFuuv2dE7dVxbchcPh77qHPATvB3OM2aE4wt p3qdkouT4dq1JMHsdcVVJH5v3G2E2MUe5uhFtYWFH9F4FBioG9v+LOJrmXgSYXBRv0sn Y6YKTRxXHj/VS9f7OM2w138udwbl9xeOuFS+phHLMMbTSl6w7qf11EebZRnSSQlIJjU0 1TvjeLKgVsX+Bi/+0ov0EGQiwfztl3oCkm45PDFfsehgwPqYFSEZoVkDVrN4T8GBovPL s0WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=R22szaPD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a170902f68300b001ae488bbbd0si1617909plg.494.2023.05.24.09.26.56; Wed, 24 May 2023 09:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=R22szaPD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237874AbjEXQAR (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Wed, 24 May 2023 12:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237587AbjEXP7a (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 24 May 2023 11:59:30 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57A281701; Wed, 24 May 2023 08:58:43 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4QRG5p4CQBz4x4l; Thu, 25 May 2023 01:57:02 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1684943822; bh=p1bBAk5FodJhZ4XtodQ/RroeKg6GW9YX3VKIMJsVMLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R22szaPDT6DGwq17NyDcp7B49+a7ThZT8uGc7W+qKi3W0c6DMaB2h0vQ+vue6uOR+ b2XrnJAvmLo6pAX2f8xxj86lm9GKwYwfvA2/tTAOaaqjtVABSuKDdGByysUc7XZpby +g2f+yFDRIE5qlupG1yMOC5jokWBHsyU4/WGLxWQfFoejzxG6suWMWgl04/jskyc9i /CaYcsLNYzVHcnBfcW3D25cIMeOmF/w3ZV9jkBMtgOoMwTxwU/h0vlEx+juDKliXeG NqsMJuHoAQZGkTxJaPZTxvY4ahm49NrEIZ0JLiz16imgfbF+CPAZCVjYNuqqubFdlU b01tMkPDIzEhg== From: Michael Ellerman <mpe@ellerman.id.au> To: <linux-kernel@vger.kernel.org> Cc: <linuxppc-dev@lists.ozlabs.org>, <linux-arch@vger.kernel.org>, <ldufour@linux.ibm.com>, <tglx@linutronix.de>, bp@alien8.de, dave.hansen@linux.intel.com, mingo@redhat.com, x86@kernel.org Subject: [PATCH 8/9] powerpc: Add HOTPLUG_SMT support Date: Thu, 25 May 2023 01:56:29 +1000 Message-Id: <20230524155630.794584-8-mpe@ellerman.id.au> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230524155630.794584-1-mpe@ellerman.id.au> References: <20230524155630.794584-1-mpe@ellerman.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_PASS,SPF_PASS, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766793546813736125?= X-GMAIL-MSGID: =?utf-8?q?1766793546813736125?= |
Series |
[1/9] cpu/SMT: Move SMT prototypes into cpu_smt.h
|
|
Commit Message
Michael Ellerman
May 24, 2023, 3:56 p.m. UTC
Add support for HOTPLUG_SMT, which enables the generic sysfs SMT support
files in /sys/devices/system/cpu/smt, as well as the "nosmt" boot
parameter.
Implement the recently added hooks to allow partial SMT states, allow
any number of threads per core.
Tie the config symbol to HOTPLUG_CPU, which enables it on the major
platforms that support SMT. If there are other platforms that want the
SMT support that can be tweaked in future.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/topology.h | 25 +++++++++++++++++++++++++
arch/powerpc/kernel/smp.c | 3 +++
3 files changed, 29 insertions(+)
Comments
On 24/05/2023 17:56:29, Michael Ellerman wrote: > Add support for HOTPLUG_SMT, which enables the generic sysfs SMT support > files in /sys/devices/system/cpu/smt, as well as the "nosmt" boot > parameter. Hi Michael, It seems that there is now a conflict between with the PPC 'smt-enabled' boot option. Booting the patched kernel with 'smt-enabled=4', later, change to the SMT level (for instance to 6) done through /sys/devices/system/cpu/smt/control are not applied. Nothing happens. Based on my early debug, I think the reasons is that cpu_smt_num_threads=8 when entering __store_smt_control(). But I need to dig further. BTW, should the 'smt-enabled' PPC specific option remain? Cheers, Laurent. > Implement the recently added hooks to allow partial SMT states, allow > any number of threads per core. > > Tie the config symbol to HOTPLUG_CPU, which enables it on the major > platforms that support SMT. If there are other platforms that want the > SMT support that can be tweaked in future. > > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> > --- > arch/powerpc/Kconfig | 1 + > arch/powerpc/include/asm/topology.h | 25 +++++++++++++++++++++++++ > arch/powerpc/kernel/smp.c | 3 +++ > 3 files changed, 29 insertions(+) > > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > index 539d1f03ff42..5cf87ca10a9c 100644 > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -273,6 +273,7 @@ config PPC > select HAVE_SYSCALL_TRACEPOINTS > select HAVE_VIRT_CPU_ACCOUNTING > select HAVE_VIRT_CPU_ACCOUNTING_GEN > + select HOTPLUG_SMT if HOTPLUG_CPU > select HUGETLB_PAGE_SIZE_VARIABLE if PPC_BOOK3S_64 && HUGETLB_PAGE > select IOMMU_HELPER if PPC64 > select IRQ_DOMAIN > diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h > index 8a4d4f4d9749..1e9117a22d14 100644 > --- a/arch/powerpc/include/asm/topology.h > +++ b/arch/powerpc/include/asm/topology.h > @@ -143,5 +143,30 @@ static inline int cpu_to_coregroup_id(int cpu) > #endif > #endif > > +#ifdef CONFIG_HOTPLUG_SMT > +#include <linux/cpu_smt.h> > +#include <asm/cputhreads.h> > + > +static inline bool topology_smt_supported(void) > +{ > + return threads_per_core > 1; > +} > + > +static inline bool topology_smt_threads_supported(unsigned int num_threads) > +{ > + return num_threads <= threads_per_core; > +} > + > +static inline bool topology_is_primary_thread(unsigned int cpu) > +{ > + return cpu == cpu_first_thread_sibling(cpu); > +} > + > +static inline bool topology_smt_thread_allowed(unsigned int cpu) > +{ > + return cpu_thread_in_core(cpu) < cpu_smt_num_threads; > +} > +#endif > + > #endif /* __KERNEL__ */ > #endif /* _ASM_POWERPC_TOPOLOGY_H */ > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 265801a3e94c..eed20b9253b7 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -1154,6 +1154,9 @@ void __init smp_prepare_cpus(unsigned int max_cpus) > > if (smp_ops && smp_ops->probe) > smp_ops->probe(); > + > + // Initalise the generic SMT topology support > + cpu_smt_check_topology(threads_per_core); > } > > void smp_prepare_boot_cpu(void)
On 01/06/2023 15:27:30, Laurent Dufour wrote: > On 24/05/2023 17:56:29, Michael Ellerman wrote: >> Add support for HOTPLUG_SMT, which enables the generic sysfs SMT support >> files in /sys/devices/system/cpu/smt, as well as the "nosmt" boot >> parameter. > > Hi Michael, > > It seems that there is now a conflict between with the PPC 'smt-enabled' > boot option. > > Booting the patched kernel with 'smt-enabled=4', later, change to the SMT > level (for instance to 6) done through /sys/devices/system/cpu/smt/control > are not applied. Nothing happens. > Based on my early debug, I think the reasons is that cpu_smt_num_threads=8 > when entering __store_smt_control(). But I need to dig further. I dug deeper. FWIW, I think smt_enabled_at_boot should be passed to cpu_smt_check_topology() in smp_prepare_cpus(), instead of threads_per_core. But that's not enough to fix the issue because this value is also used to set cpu_smt_max_threads. To achieve that, cpu_smt_check_topology() should receive 2 parameters, the current SMT level define at boot time, and the maximum SMT level. The attached patch is fixing the issue on my ppc64 test LPAR. This patch is not addressing the x86 architecture (I didn't get the time to do it, but it should be doable) and should be spread among the patches 3 and 8 of your series. Hope this helps. Cheers, Laurent. > > BTW, should the 'smt-enabled' PPC specific option remain? > > Cheers, > Laurent. > >> Implement the recently added hooks to allow partial SMT states, allow >> any number of threads per core. >> >> Tie the config symbol to HOTPLUG_CPU, which enables it on the major >> platforms that support SMT. If there are other platforms that want the >> SMT support that can be tweaked in future. >> >> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> >> --- >> arch/powerpc/Kconfig | 1 + >> arch/powerpc/include/asm/topology.h | 25 +++++++++++++++++++++++++ >> arch/powerpc/kernel/smp.c | 3 +++ >> 3 files changed, 29 insertions(+) >> >> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig >> index 539d1f03ff42..5cf87ca10a9c 100644 >> --- a/arch/powerpc/Kconfig >> +++ b/arch/powerpc/Kconfig >> @@ -273,6 +273,7 @@ config PPC >> select HAVE_SYSCALL_TRACEPOINTS >> select HAVE_VIRT_CPU_ACCOUNTING >> select HAVE_VIRT_CPU_ACCOUNTING_GEN >> + select HOTPLUG_SMT if HOTPLUG_CPU >> select HUGETLB_PAGE_SIZE_VARIABLE if PPC_BOOK3S_64 && HUGETLB_PAGE >> select IOMMU_HELPER if PPC64 >> select IRQ_DOMAIN >> diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h >> index 8a4d4f4d9749..1e9117a22d14 100644 >> --- a/arch/powerpc/include/asm/topology.h >> +++ b/arch/powerpc/include/asm/topology.h >> @@ -143,5 +143,30 @@ static inline int cpu_to_coregroup_id(int cpu) >> #endif >> #endif >> >> +#ifdef CONFIG_HOTPLUG_SMT >> +#include <linux/cpu_smt.h> >> +#include <asm/cputhreads.h> >> + >> +static inline bool topology_smt_supported(void) >> +{ >> + return threads_per_core > 1; >> +} >> + >> +static inline bool topology_smt_threads_supported(unsigned int num_threads) >> +{ >> + return num_threads <= threads_per_core; >> +} >> + >> +static inline bool topology_is_primary_thread(unsigned int cpu) >> +{ >> + return cpu == cpu_first_thread_sibling(cpu); >> +} >> + >> +static inline bool topology_smt_thread_allowed(unsigned int cpu) >> +{ >> + return cpu_thread_in_core(cpu) < cpu_smt_num_threads; >> +} >> +#endif >> + >> #endif /* __KERNEL__ */ >> #endif /* _ASM_POWERPC_TOPOLOGY_H */ >> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c >> index 265801a3e94c..eed20b9253b7 100644 >> --- a/arch/powerpc/kernel/smp.c >> +++ b/arch/powerpc/kernel/smp.c >> @@ -1154,6 +1154,9 @@ void __init smp_prepare_cpus(unsigned int max_cpus) >> >> if (smp_ops && smp_ops->probe) >> smp_ops->probe(); >> + >> + // Initalise the generic SMT topology support >> + cpu_smt_check_topology(threads_per_core); >> } >> >> void smp_prepare_boot_cpu(void) > From 682e7d78fb98d6298926e88e5093e2172488ea6f Mon Sep 17 00:00:00 2001 From: Laurent Dufour <ldufour@linux.ibm.com> Date: Thu, 1 Jun 2023 18:02:55 +0200 Subject: [PATCH] Consider the SMT level specify at boot time This allows PPC kernel to boot with a SMT level different from 1 or threads per core value. Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com> --- arch/powerpc/kernel/smp.c | 2 +- include/linux/cpu_smt.h | 6 ++++-- kernel/cpu.c | 9 +++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index eed20b9253b7..ec8ccf3d6294 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1156,7 +1156,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) smp_ops->probe(); // Initalise the generic SMT topology support - cpu_smt_check_topology(threads_per_core); + cpu_smt_check_topology(smt_enabled_at_boot, threads_per_core); } void smp_prepare_boot_cpu(void) diff --git a/include/linux/cpu_smt.h b/include/linux/cpu_smt.h index 8d4ae26047c9..b5f13acb323f 100644 --- a/include/linux/cpu_smt.h +++ b/include/linux/cpu_smt.h @@ -14,7 +14,8 @@ enum cpuhp_smt_control { extern enum cpuhp_smt_control cpu_smt_control; extern unsigned int cpu_smt_num_threads; extern void cpu_smt_disable(bool force); -extern void cpu_smt_check_topology(unsigned int num_threads); +extern void cpu_smt_check_topology(unsigned int num_threads, + unsigned int max_threads); extern bool cpu_smt_possible(void); extern int cpuhp_smt_enable(void); extern int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval); @@ -22,7 +23,8 @@ extern int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval); # define cpu_smt_control (CPU_SMT_NOT_IMPLEMENTED) # define cpu_smt_num_threads 1 static inline void cpu_smt_disable(bool force) { } -static inline void cpu_smt_check_topology(unsigned int num_threads) { } +static inline void cpu_smt_check_topology(unsigned int num_threads, + unsigned int max_threads) { } static inline bool cpu_smt_possible(void) { return false; } static inline int cpuhp_smt_enable(void) { return 0; } static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; } diff --git a/kernel/cpu.c b/kernel/cpu.c index aca23c7b4547..268d386bd4e7 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -435,12 +435,17 @@ void __init cpu_smt_disable(bool force) * The decision whether SMT is supported can only be done after the full * CPU identification. Called from architecture code. */ -void __init cpu_smt_check_topology(unsigned int num_threads) +void __init cpu_smt_check_topology(unsigned int num_threads, + unsigned int max_threads) { if (!topology_smt_supported()) cpu_smt_control = CPU_SMT_NOT_SUPPORTED; - cpu_smt_max_threads = num_threads; + cpu_smt_max_threads = max_threads; + + WARN_ON(num_threads > max_threads); + if (num_threads > max_threads) + num_threads = max_threads; // May already be disabled by nosmt command line parameter if (cpu_smt_control != CPU_SMT_ENABLED)
On Thu, Jun 01 2023 at 18:19, Laurent Dufour wrote: > @@ -435,12 +435,17 @@ void __init cpu_smt_disable(bool force) > * The decision whether SMT is supported can only be done after the full > * CPU identification. Called from architecture code. > */ > -void __init cpu_smt_check_topology(unsigned int num_threads) > +void __init cpu_smt_check_topology(unsigned int num_threads, > + unsigned int max_threads) > { > if (!topology_smt_supported()) > cpu_smt_control = CPU_SMT_NOT_SUPPORTED; > > - cpu_smt_max_threads = num_threads; > + cpu_smt_max_threads = max_threads; > + > + WARN_ON(num_threads > max_threads); > + if (num_threads > max_threads) > + num_threads = max_threads; This does not work. The call site does: > + cpu_smt_check_topology(smt_enabled_at_boot, threads_per_core); smt_enabled_at_boot is 0 when 'smt-enabled=off', which is not what the hotplug core expects. If SMT is disabled it brings up the primary thread, which means cpu_smt_num_threads = 1. This needs more thoughts to avoid a completely inconsistent duct tape mess. Btw, the command line parser and the variable smt_enabled_at_boot being type int allow negative number of threads too... Maybe not what you want. Thanks, tglx
On 10/06/2023 23:10:02, Thomas Gleixner wrote: > On Thu, Jun 01 2023 at 18:19, Laurent Dufour wrote: >> @@ -435,12 +435,17 @@ void __init cpu_smt_disable(bool force) >> * The decision whether SMT is supported can only be done after the full >> * CPU identification. Called from architecture code. >> */ >> -void __init cpu_smt_check_topology(unsigned int num_threads) >> +void __init cpu_smt_check_topology(unsigned int num_threads, >> + unsigned int max_threads) >> { >> if (!topology_smt_supported()) >> cpu_smt_control = CPU_SMT_NOT_SUPPORTED; >> >> - cpu_smt_max_threads = num_threads; >> + cpu_smt_max_threads = max_threads; >> + >> + WARN_ON(num_threads > max_threads); >> + if (num_threads > max_threads) >> + num_threads = max_threads; > > This does not work. The call site does: > >> + cpu_smt_check_topology(smt_enabled_at_boot, threads_per_core); > > smt_enabled_at_boot is 0 when 'smt-enabled=off', which is not what the > hotplug core expects. If SMT is disabled it brings up the primary > thread, which means cpu_smt_num_threads = 1. Thanks, Thomas, Definitively, a test against smt_enabled_at_boot==0 is required here. > This needs more thoughts to avoid a completely inconsistent duct tape > mess. Despite the test against smt_enabled_at_boot, mentioned above, I can't see anything else to rework. Am I missing something? > > Btw, the command line parser and the variable smt_enabled_at_boot being > type int allow negative number of threads too... Maybe not what you want. I do agree, it should an unsigned type. Thanks, Laurent. > Thanks, > > tglx > > > >
On Mon, Jun 12 2023 at 17:20, Laurent Dufour wrote: > On 10/06/2023 23:10:02, Thomas Gleixner wrote: >> This needs more thoughts to avoid a completely inconsistent duct tape >> mess. > > Despite the test against smt_enabled_at_boot, mentioned above, I can't see > anything else to rework. Am I missing something? See my comments on the core code changes. >> Btw, the command line parser and the variable smt_enabled_at_boot being >> type int allow negative number of threads too... Maybe not what you want. > > I do agree, it should an unsigned type. I assume you'll fix that yourself. :) Thanks, tglx
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 539d1f03ff42..5cf87ca10a9c 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -273,6 +273,7 @@ config PPC select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING select HAVE_VIRT_CPU_ACCOUNTING_GEN + select HOTPLUG_SMT if HOTPLUG_CPU select HUGETLB_PAGE_SIZE_VARIABLE if PPC_BOOK3S_64 && HUGETLB_PAGE select IOMMU_HELPER if PPC64 select IRQ_DOMAIN diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h index 8a4d4f4d9749..1e9117a22d14 100644 --- a/arch/powerpc/include/asm/topology.h +++ b/arch/powerpc/include/asm/topology.h @@ -143,5 +143,30 @@ static inline int cpu_to_coregroup_id(int cpu) #endif #endif +#ifdef CONFIG_HOTPLUG_SMT +#include <linux/cpu_smt.h> +#include <asm/cputhreads.h> + +static inline bool topology_smt_supported(void) +{ + return threads_per_core > 1; +} + +static inline bool topology_smt_threads_supported(unsigned int num_threads) +{ + return num_threads <= threads_per_core; +} + +static inline bool topology_is_primary_thread(unsigned int cpu) +{ + return cpu == cpu_first_thread_sibling(cpu); +} + +static inline bool topology_smt_thread_allowed(unsigned int cpu) +{ + return cpu_thread_in_core(cpu) < cpu_smt_num_threads; +} +#endif + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_TOPOLOGY_H */ diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 265801a3e94c..eed20b9253b7 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1154,6 +1154,9 @@ void __init smp_prepare_cpus(unsigned int max_cpus) if (smp_ops && smp_ops->probe) smp_ops->probe(); + + // Initalise the generic SMT topology support + cpu_smt_check_topology(threads_per_core); } void smp_prepare_boot_cpu(void)