Thread (14 messages) 14 messages, 3 authors, 2023-06-22

Re: [PATCH 07/10] cpu/SMT: Allow enabling partial SMT states via sysfs

From: Thomas Gleixner <hidden>
Date: 2023-06-22 09:22:41
Also in: linux-arch, lkml

On Thu, Jun 15 2023 at 17:46, Laurent Dufour wrote:
 
-	if (ctrlval != cpu_smt_control) {
+	orig_threads = cpu_smt_num_threads;
+	cpu_smt_num_threads = num_threads;
+
+	if (num_threads > orig_threads) {
+		ret = cpuhp_smt_enable();
+	} else if (num_threads < orig_threads) {
+		ret = cpuhp_smt_disable(ctrlval);
+	} else if (ctrlval != cpu_smt_control) {
 		switch (ctrlval) {
 		case CPU_SMT_ENABLED:
 			ret = cpuhp_smt_enable();
This switch() is still as pointless as in the previous version.

OFF -> ON, ON -> OFF, ON -> FORCE_OFF are covered by the num_threads
comparisons.

So the only case where (ctrlval != cpu_smt_control) is relevant is the
OFF -> FORCE_OFF transition because in that case the number of threads
is not changing.

          force_off = ctrlval != cpu_smt_control && ctrval == CPU_SMT_FORCE_DISABLED;

	  if (num_threads > orig_threads)
		  ret = cpuhp_smt_enable();
	  else if (num_threads < orig_threads || force_off)
		  ret = cpuhp_smt_disable(ctrlval);

Should just work, no?

Thanks,

        tglx

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help