summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2025-03-25 22:32:28 +0300
committerCatalin Marinas <catalin.marinas@arm.com>2025-03-25 22:32:28 +0300
commit8ae9e2d8325698edc1335ede5401f68bcd7cc400 (patch)
tree44cec9b60ecc2b2b1290439685beb4a7eb0bdeb7 /include
parent8cc14fdcc1b8473adcf90dae63a246042ebdcc25 (diff)
parenteed4583bcf9a60f8d6dd3a3c7c94dea28134b1eb (diff)
downloadlinux-8ae9e2d8325698edc1335ede5401f68bcd7cc400.tar.xz
Merge branch 'for-next/smt-control' into for-next/core
* for-next/smt-control: : Support SMT control on arm64 arm64: Kconfig: Enable HOTPLUG_SMT arm64: topology: Support SMT control on ACPI based system arch_topology: Support SMT control for OF based system cpu/SMT: Provide a default topology_is_primary_thread()
Diffstat (limited to 'include')
-rw-r--r--include/linux/topology.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 52f5850730b3..f8bb02c5e8a4 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -240,6 +240,29 @@ static inline const struct cpumask *cpu_smt_mask(int cpu)
}
#endif
+#ifndef topology_is_primary_thread
+
+static inline bool topology_is_primary_thread(unsigned int cpu)
+{
+ /*
+ * When disabling SMT, the primary thread of the SMT will remain
+ * enabled/active. Architectures that have a special primary thread
+ * (e.g. x86) need to override this function. Otherwise the first
+ * thread in the SMT can be made the primary thread.
+ *
+ * The sibling cpumask of an offline CPU always contains the CPU
+ * itself on architectures using the implementation of
+ * CONFIG_GENERIC_ARCH_TOPOLOGY for building their topology.
+ * Other architectures not using CONFIG_GENERIC_ARCH_TOPOLOGY for
+ * building their topology have to check whether to use this default
+ * implementation or to override it.
+ */
+ return cpu == cpumask_first(topology_sibling_cpumask(cpu));
+}
+#define topology_is_primary_thread topology_is_primary_thread
+
+#endif
+
static inline const struct cpumask *cpu_cpu_mask(int cpu)
{
return cpumask_of_node(cpu_to_node(cpu));