From: Laurent Dufour <ldufour@linux.ibm.com>
To: mpe@ellerman.id.au
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org, npiggin@gmail.com,
christophe.leroy@csgroup.eu, tglx@linutronix.de,
dave.hansen@linux.intel.com, mingo@redhat.com, bp@alien8.de
Subject: Re: [PATCH v3 8/9] powerpc: Add HOTPLUG_SMT support
Date: Fri, 30 Jun 2023 17:19:12 +0200 [thread overview]
Message-ID: <b62c80ba-e4eb-b694-7e45-082bc8ef7f2c@linux.ibm.com> (raw)
In-Reply-To: <20230629143149.79073-9-ldufour@linux.ibm.com>
Hi Michael,
Le 29/06/2023 à 16:31, Laurent Dufour a écrit :
> From: Michael Ellerman <mpe@ellerman.id.au>
>
> 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>
> [ldufour: pass current SMT level to cpu_smt_set_num_threads]
> [ldufour: remove topology_smt_supported]
> [ldufour: remove topology_smt_threads_supported]
> [ldufour: select CONFIG_SMT_NUM_THREADS_DYNAMIC]
> [ldufour: update kernel-parameters.txt]
> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
> ---
> Documentation/admin-guide/kernel-parameters.txt | 4 ++--
> arch/powerpc/Kconfig | 2 ++
> arch/powerpc/include/asm/topology.h | 15 +++++++++++++++
> arch/powerpc/kernel/smp.c | 8 +++++++-
> 4 files changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 9e5bab29685f..5efb6c73a928 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -3838,10 +3838,10 @@
> nosmp [SMP] Tells an SMP kernel to act as a UP kernel,
> and disable the IO APIC. legacy for "maxcpus=0".
>
> - nosmt [KNL,S390] Disable symmetric multithreading (SMT).
> + nosmt [KNL,S390,PPC] Disable symmetric multithreading (SMT).
> Equivalent to smt=1.
>
> - [KNL,X86] Disable symmetric multithreading (SMT).
> + [KNL,X86,PPC] Disable symmetric multithreading (SMT).
> nosmt=force: Force disable SMT, cannot be undone
> via the sysfs control file.
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 8b955bc7b59f..bacabc3d7f0c 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -273,6 +273,8 @@ config PPC
> select HAVE_SYSCALL_TRACEPOINTS
> select HAVE_VIRT_CPU_ACCOUNTING
> select HAVE_VIRT_CPU_ACCOUNTING_GEN
> + select HOTPLUG_SMT if HOTPLUG_CPU
> + select SMT_NUM_THREADS_DYNAMIC
I missed that this list should be kept sorted alphabetically.
Could you fix that when applying the series, or should I send a new
version ?
Thanks,
Laurent.
> 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..f4e6f2dd04b7 100644
> --- a/arch/powerpc/include/asm/topology.h
> +++ b/arch/powerpc/include/asm/topology.h
> @@ -143,5 +143,20 @@ 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_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 406e6d0ffae3..eb539325dff8 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -1087,7 +1087,7 @@ static int __init init_big_cores(void)
>
> void __init smp_prepare_cpus(unsigned int max_cpus)
> {
> - unsigned int cpu;
> + unsigned int cpu, num_threads;
>
> DBG("smp_prepare_cpus\n");
>
> @@ -1154,6 +1154,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
>
> if (smp_ops && smp_ops->probe)
> smp_ops->probe();
> +
> + // Initalise the generic SMT topology support
> + num_threads = 1;
> + if (smt_enabled_at_boot)
> + num_threads = smt_enabled_at_boot;
> + cpu_smt_set_num_threads(num_threads, threads_per_core);
> }
>
> void smp_prepare_boot_cpu(void)
next prev parent reply other threads:[~2023-06-30 15:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-29 14:31 [PATCH v3 0/9] Introduce SMT level and add PowerPC support Laurent Dufour
2023-06-29 14:31 ` [PATCH v3 1/9] cpu/SMT: Move SMT prototypes into cpu_smt.h Laurent Dufour
2023-06-29 14:31 ` [PATCH v3 2/9] cpu/SMT: Move smt/control simple exit cases earlier Laurent Dufour
2023-06-29 14:31 ` [PATCH v3 3/9] cpu/SMT: Store the current/max number of threads Laurent Dufour
2023-07-05 3:05 ` Zhang, Rui
2023-07-05 11:58 ` Laurent Dufour
2023-06-29 14:31 ` [PATCH v3 4/9] cpu/SMT: Remove topology_smt_supported() Laurent Dufour
2023-06-29 14:31 ` [PATCH v3 5/9] cpu/SMT: Create topology_smt_thread_allowed() Laurent Dufour
2023-06-29 14:31 ` [PATCH v3 6/9] cpu/SMT: Allow enabling partial SMT states via sysfs Laurent Dufour
2023-07-05 3:14 ` Zhang, Rui
2023-07-05 11:57 ` Laurent Dufour
2023-06-29 14:31 ` [PATCH v3 7/9] powerpc/pseries: Initialise CPU hotplug callbacks earlier Laurent Dufour
2023-06-29 14:31 ` [PATCH v3 8/9] powerpc: Add HOTPLUG_SMT support Laurent Dufour
2023-06-30 15:19 ` Laurent Dufour [this message]
2023-06-29 14:31 ` [PATCH v3 9/9] powerpc/pseries: Honour current SMT state when DLPAR onlining CPUs Laurent Dufour
2023-06-30 13:32 ` [PATCH v3 0/9] Introduce SMT level and add PowerPC support Sachin Sant
2023-06-30 13:41 ` Laurent Dufour
2023-07-05 3:04 ` Zhang, Rui
2023-07-05 11:53 ` Laurent Dufour
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b62c80ba-e4eb-b694-7e45-082bc8ef7f2c@linux.ibm.com \
--to=ldufour@linux.ibm.com \
--cc=bp@alien8.de \
--cc=christophe.leroy@csgroup.eu \
--cc=dave.hansen@linux.intel.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox