From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: Hyman Huang <yong.huang@smartx.com>,
Thomas Huth <thuth@redhat.com>, Peter Xu <peterx@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Fabiano Rosas <farosas@suse.de>,
Laurent Vivier <lvivier@redhat.com>,
Juan Quintela <quintela@redhat.com>,
Leonardo Bras <leobras@redhat.com>
Subject: [PULL 1/7] system/dirtylimit: Fix a race situation
Date: Fri, 3 Nov 2023 13:04:42 +0100 [thread overview]
Message-ID: <20231103120448.58428-2-quintela@redhat.com> (raw)
In-Reply-To: <20231103120448.58428-1-quintela@redhat.com>
From: Hyman Huang <yong.huang@smartx.com>
Fix a race situation for global variable dirtylimit_state.
Also, replace usleep by g_usleep to increase platform
accessibility to the sleep function.
Signed-off-by: Hyman Huang <yong.huang@smartx.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <27c86239e21eda03d11ce5a3d07da3c229f562e3.1698847223.git.yong.huang@smartx.com>
---
system/dirtylimit.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/system/dirtylimit.c b/system/dirtylimit.c
index fa959d7743..3666c4cb7c 100644
--- a/system/dirtylimit.c
+++ b/system/dirtylimit.c
@@ -411,12 +411,20 @@ void dirtylimit_set_all(uint64_t quota,
void dirtylimit_vcpu_execute(CPUState *cpu)
{
- if (dirtylimit_in_service() &&
- dirtylimit_vcpu_get_state(cpu->cpu_index)->enabled &&
- cpu->throttle_us_per_full) {
- trace_dirtylimit_vcpu_execute(cpu->cpu_index,
- cpu->throttle_us_per_full);
- usleep(cpu->throttle_us_per_full);
+ if (cpu->throttle_us_per_full) {
+ dirtylimit_state_lock();
+
+ if (dirtylimit_in_service() &&
+ dirtylimit_vcpu_get_state(cpu->cpu_index)->enabled) {
+ dirtylimit_state_unlock();
+ trace_dirtylimit_vcpu_execute(cpu->cpu_index,
+ cpu->throttle_us_per_full);
+
+ g_usleep(cpu->throttle_us_per_full);
+ return;
+ }
+
+ dirtylimit_state_unlock();
}
}
--
2.41.0
next prev parent reply other threads:[~2023-11-03 12:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 12:04 [PULL 0/7] Migration 20231103 patches Juan Quintela
2023-11-03 12:04 ` Juan Quintela [this message]
2023-11-03 12:04 ` [PULL 2/7] system/dirtylimit: Drop the reduplicative check Juan Quintela
2023-11-03 12:04 ` [PULL 3/7] tests: Add migration dirty-limit capability test Juan Quintela
2023-11-03 12:04 ` [PULL 4/7] tests/migration: Introduce dirty-ring-size option into guestperf Juan Quintela
2023-11-03 12:04 ` [PULL 5/7] tests/migration: Introduce dirty-limit " Juan Quintela
2023-11-03 12:04 ` [PULL 6/7] docs/migration: Add the dirty limit section Juan Quintela
2023-11-03 12:04 ` [PULL 7/7] migration: Unlock mutex in error case Juan Quintela
2023-11-06 14:23 ` [PULL 0/7] Migration 20231103 patches Stefan Hajnoczi
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=20231103120448.58428-2-quintela@redhat.com \
--to=quintela@redhat.com \
--cc=farosas@suse.de \
--cc=leobras@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
--cc=yong.huang@smartx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).