Skip to contentSkip to conversation

cpu-throttle: reset throttle_thread_scheduled when throttle_percentage is 0

PATCH New [email protected] 1 participant 1 message May 7, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpu-throttle: reset throttle_thread_scheduled when throttle_percentage is 0

From: yilingjin <[email protected]>

The throttle_thread_scheduled flag is set to 1 in cpu_throttle_timer_tick() when throttle_percentage isn't 0, and will reset back to 0 after sleeping in cpu_throttle_thread(). Given that throttle_timer may tick with a slight delay, the throttle_percentage may reset to 0 before schedule cpu_throttle_thread(). This results on cpu_throttle_thread() to return immediately without reset throttle_thread_scheduled flag back to 0, so there is no longer any chances for vCPU thread to sleep in cpu_throttle_thread().

---
 softmmu/cpu-throttle.c | 1 +
 1 file changed, 1 insertion(+)
softmmu/cpu-throttle.c +1 -0
index d9bb30a223..7c2fd26072 100644
@@ -44,6 +44,7 @@ static void cpu_throttle_thread(CPUState *cpu, run_on_cpu_data opaque)
     int64_t sleeptime_ns, endtime_ns;
 
     if (!cpu_throttle_get_percentage()) {
+        qatomic_set(&cpu->throttle_thread_scheduled, 0);
         return;
     }
 
Signature · 1 line
2.27.0