[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230615154635.13660-6-ldufour@linux.ibm.com>
Date: Thu, 15 Jun 2023 17:46:30 +0200
From: Laurent Dufour <ldufour@...ux.ibm.com>
To: linux-kernel@...r.kernel.org
Cc: linux-arch@...r.kernel.org, x86@...nel.org,
linuxppc-dev@...ts.ozlabs.org, mpe@...erman.id.au,
npiggin@...il.com, christophe.leroy@...roup.eu, tglx@...utronix.de,
dave.hansen@...ux.intel.com, mingo@...hat.com, bp@...en8.de
Subject: [PATCH 05/10] cpu/SMT: Create topology_smt_threads_supported()
From: Michael Ellerman <mpe@...erman.id.au>
A subsequent patch will enable partial SMT states, ie. when not all SMT
threads are brought online.
To support that, add an arch helper to check how many SMT threads are
supported.
To retain existing behaviour, the x86 implementation only allows a
single thread or all threads to be online.
Signed-off-by: Michael Ellerman <mpe@...erman.id.au>
---
arch/x86/include/asm/topology.h | 2 ++
arch/x86/kernel/smpboot.c | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 87358a8fe843..232df5ffab34 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -143,6 +143,7 @@ int topology_update_die_map(unsigned int dieid, unsigned int cpu);
int topology_phys_to_logical_pkg(unsigned int pkg);
int topology_phys_to_logical_die(unsigned int die, unsigned int cpu);
bool topology_is_primary_thread(unsigned int cpu);
+bool topology_smt_threads_supported(unsigned int threads);
#else
#define topology_max_packages() (1)
static inline int
@@ -155,6 +156,7 @@ static inline int topology_phys_to_logical_die(unsigned int die,
static inline int topology_max_die_per_package(void) { return 1; }
static inline int topology_max_smt_threads(void) { return 1; }
static inline bool topology_is_primary_thread(unsigned int cpu) { return true; }
+static inline bool topology_smt_threads_supported(unsigned int threads) { return false; }
#endif
static inline void arch_fix_phys_package_id(int num, u32 slot)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 3052c171668d..d163ef55577b 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -278,6 +278,18 @@ bool topology_is_primary_thread(unsigned int cpu)
return apic_id_is_primary_thread(per_cpu(x86_cpu_to_apicid, cpu));
}
+/**
+ * topology_smt_threads_supported - Check if the given number of SMT threads
+ * is supported.
+ *
+ * @threads: The number of SMT threads.
+ */
+bool topology_smt_threads_supported(unsigned int threads)
+{
+ // Only support a single thread or all threads.
+ return threads == 1 || threads == smp_num_siblings;
+}
+
/**
* topology_phys_to_logical_pkg - Map a physical package id to a logical
*
--
2.41.0
Powered by blists - more mailing lists