lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260123114728.1616203-1-tianyaxiong@kylinos.cn>
Date: Fri, 23 Jan 2026 19:47:28 +0800
From: Yaxiong Tian <tianyaxiong@...inos.cn>
To: tglx@...nel.org,
	mingo@...hat.com,
	bp@...en8.de,
	dave.hansen@...ux.intel.com,
	x86@...nel.org,
	hpa@...or.com,
	srinivas.pandruvada@...ux.intel.com,
	lenb@...nel.org,
	rafael@...nel.org,
	viresh.kumar@...aro.org,
	ricardo.neri-calderon@...ux.intel.com
Cc: linux-kernel@...r.kernel.org,
	linux-pm@...r.kernel.org,
	Yaxiong Tian <tianyaxiong@...inos.cn>
Subject: [PATCH 1/3] x86/sched: Add arch_disable_hybrid_capacity_scale() interface

Users can enable/disable SMT (Simultaneous Multi-Threading) via
/sys/devices/system/cpu/smt, which means hybrid_capacity() may not
remain constant on heterogeneous platforms.

Therefore, add the arch_disable_hybrid_capacity_scale() interface
to handle dynamic SMT state changes.

Signed-off-by: Yaxiong Tian <tianyaxiong@...inos.cn>
---
 arch/x86/include/asm/topology.h  |  2 ++
 arch/x86/kernel/cpu/aperfmperf.c | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 1fadf0cf520c..a0c1205513e3 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -303,6 +303,7 @@ static inline long arch_scale_freq_capacity(int cpu)
 #define arch_scale_freq_capacity arch_scale_freq_capacity
 
 bool arch_enable_hybrid_capacity_scale(void);
+void arch_disable_hybrid_capacity_scale(void);
 void arch_set_cpu_capacity(int cpu, unsigned long cap, unsigned long max_cap,
 			   unsigned long cap_freq, unsigned long base_freq);
 
@@ -313,6 +314,7 @@ extern void arch_set_max_freq_ratio(bool turbo_disabled);
 extern void freq_invariance_set_perf_ratio(u64 ratio, bool turbo_disabled);
 #else
 static inline bool arch_enable_hybrid_capacity_scale(void) { return false; }
+static inline void arch_disable_hybrid_capacity_scale(void) { return; }
 static inline void arch_set_cpu_capacity(int cpu, unsigned long cap,
 					 unsigned long max_cap,
 					 unsigned long cap_freq,
diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index 7ffc78d5ebf2..a499eccf2f5c 100644
--- a/arch/x86/kernel/cpu/aperfmperf.c
+++ b/arch/x86/kernel/cpu/aperfmperf.c
@@ -362,6 +362,7 @@ struct arch_hybrid_cpu_scale {
 };
 
 static struct arch_hybrid_cpu_scale __percpu *arch_cpu_scale;
+static DEFINE_MUTEX(arch_hybrid_mutex);
 
 /**
  * arch_enable_hybrid_capacity_scale() - Enable hybrid CPU capacity scaling
@@ -375,11 +376,19 @@ bool arch_enable_hybrid_capacity_scale(void)
 {
 	int cpu;
 
+	guard(mutex)(&arch_hybrid_mutex);
+
 	if (static_branch_unlikely(&arch_hybrid_cap_scale_key)) {
 		WARN_ONCE(1, "Hybrid CPU capacity scaling already enabled");
 		return true;
 	}
 
+	if (arch_cpu_scale) {
+		static_branch_enable(&arch_hybrid_cap_scale_key);
+		pr_info("Hybrid CPU capacity scaling enabled\n");
+		return true;
+	}
+
 	arch_cpu_scale = alloc_percpu(struct arch_hybrid_cpu_scale);
 	if (!arch_cpu_scale)
 		return false;
@@ -396,6 +405,20 @@ bool arch_enable_hybrid_capacity_scale(void)
 	return true;
 }
 
+/**
+ * arch_disable_hybrid_capacity_scale() - Disable hybrid CPU capacity scaling
+ */
+void arch_disable_hybrid_capacity_scale(void)
+{
+	guard(mutex)(&arch_hybrid_mutex);
+
+	if (static_branch_unlikely(&arch_hybrid_cap_scale_key)) {
+		static_branch_disable(&arch_hybrid_cap_scale_key);
+		pr_info("Hybrid CPU capacity scaling disable\n");
+		return;
+	}
+}
+
 /**
  * arch_set_cpu_capacity() - Set scale-invariance parameters for a CPU
  * @cpu: Target CPU.
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ