All of lore.kernel.org
 help / color / mirror / Atom feed
From: jinyilingjyl@gmail.com
To: pbonzini@redhat.com
Cc: qemu-devel@nongnu.org, yilingjin <yilingjin@tencent.com>
Subject: [PATCH] cpu-throttle: reset throttle_thread_scheduled when throttle_percentage is 0
Date: Sat,  7 May 2022 17:43:40 +0800	[thread overview]
Message-ID: <20220507094340.33700-1-yilingjin@tencent.com> (raw)

From: yilingjin <yilingjin@tencent.com>

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().

Signed-off-by: yilingjin <yilingjin@tencent.com>
---
 softmmu/cpu-throttle.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/softmmu/cpu-throttle.c b/softmmu/cpu-throttle.c
index d9bb30a223..7c2fd26072 100644
--- a/softmmu/cpu-throttle.c
+++ b/softmmu/cpu-throttle.c
@@ -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;
     }
 
-- 
2.27.0



                 reply	other threads:[~2022-05-07 14:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220507094340.33700-1-yilingjin@tencent.com \
    --to=jinyilingjyl@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yilingjin@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.