Skip to contentSkip to conversation

x86/sched: Print debug messages on hybrid asym capacity changes

PATCH In review Rafael J. Wysocki 3 participants 3 messages Jul 9, 2025 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/sched: Print debug messages on hybrid asym capacity changes

From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH v1] x86/sched: Print debug messages on hybrid asym capacity changes

Make arch_set_cpu_capacity() print a debug message including the capacity and maximum frequency ratio used in scale-invariant utilization computations for a given CPU and in capacity-aware scheduling (CAS) or energy-aware scheduling (EAS).

---
 arch/x86/kernel/cpu/aperfmperf.c |    4 ++++
 1 file changed, 4 insertions(+)
arch/x86/kernel/cpu/aperfmperf.c +4 -0
@@ -416,6 +416,10 @@
 			   div_u64(cap << SCHED_CAPACITY_SHIFT, max_cap));
 		WRITE_ONCE(per_cpu_ptr(arch_cpu_scale, cpu)->freq_ratio,
 			   div_u64(cap_freq << SCHED_CAPACITY_SHIFT, base_freq));
+
+		pr_debug("CPU%d: capacity = %lu, freq_ratio = %lu\n", cpu,
+			 per_cpu_ptr(arch_cpu_scale, cpu)->capacity,
+			 per_cpu_ptr(arch_cpu_scale, cpu)->freq_ratio);
 	} else {
 		WARN_ONCE(1, "Hybrid CPU capacity scaling not enabled");
 	}
#1 lore raw
Quoted 16 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH v1] x86/sched: Print debug messages on hybrid asym capacity changes

Make arch_set_cpu_capacity() print a debug message including the capacity and maximum frequency ratio used in scale-invariant utilization computations for a given CPU and in capacity-aware scheduling (CAS) or energy-aware scheduling (EAS).

---
 arch/x86/kernel/cpu/aperfmperf.c |    4 ++++
 1 file changed, 4 insertions(+)

arch/x86/kernel/cpu/aperfmperf.c line 425

Quoted 10 lines
arch/x86/kernel/cpu/aperfmperf.c +4 -0
@@ -416,6 +416,10 @@
 			   div_u64(cap << SCHED_CAPACITY_SHIFT, max_cap));
 		WRITE_ONCE(per_cpu_ptr(arch_cpu_scale, cpu)->freq_ratio,
 			   div_u64(cap_freq << SCHED_CAPACITY_SHIFT, base_freq));
+
+		pr_debug("CPU%d: capacity = %lu, freq_ratio = %lu\n", cpu,
+			 per_cpu_ptr(arch_cpu_scale, cpu)->capacity,
+			 per_cpu_ptr(arch_cpu_scale, cpu)->freq_ratio);
 	} else {
 		WARN_ONCE(1, "Hybrid CPU capacity scaling not enabled");
 	}

There's already a printk in the calling function hybrid_set_cpu_capacity(), so now we get _2_ prints per CPU. That's a bit excessive, no?

Also, should this print be conditional on sched_debug_verbose?

#2 lore raw
Quoted 24 lines · Peter Zijlstra
Quoted 22 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH v1] x86/sched: Print debug messages on hybrid asym capacity changes

Make arch_set_cpu_capacity() print a debug message including the capacity and maximum frequency ratio used in scale-invariant utilization computations for a given CPU and in capacity-aware scheduling (CAS) or energy-aware scheduling (EAS).

---
 arch/x86/kernel/cpu/aperfmperf.c |    4 ++++
 1 file changed, 4 insertions(+)
arch/x86/kernel/cpu/aperfmperf.c +3 -0
@@ -416,6 +416,10 @@
                         div_u64(cap << SCHED_CAPACITY_SHIFT, max_cap));
              WRITE_ONCE(per_cpu_ptr(arch_cpu_scale, cpu)->freq_ratio,
                         div_u64(cap_freq << SCHED_CAPACITY_SHIFT, base_freq));
+
+             pr_debug("CPU%d: capacity = %lu, freq_ratio = %lu\n", cpu,
+                      per_cpu_ptr(arch_cpu_scale, cpu)->capacity,
Quoted 8 lines

arch/x86/kernel/cpu/aperfmperf.c line 425

Quoted 4 lines
arch/x86/kernel/cpu/aperfmperf.c +1 -0
+                      per_cpu_ptr(arch_cpu_scale, cpu)->freq_ratio);
      } else {
              WARN_ONCE(1, "Hybrid CPU capacity scaling not enabled");
      }

There's already a printk in the calling function hybrid_set_cpu_capacity(), so now we get _2_ prints per CPU. That's a bit excessive, no?

Yeah, fair enough.

Quoted 1 line

Also, should this print be conditional on sched_debug_verbose?

It might, but it is dynamic debug anyway.