From: Roman Kagan <rkagan@virtuozzo.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [RFC PATCH 2/2] cpus-common: assert BQL nesting within cpu-exclusive sections
Date: Thu, 23 May 2019 10:54:49 +0000 [thread overview]
Message-ID: <20190523105440.27045-3-rkagan@virtuozzo.com> (raw)
In-Reply-To: <20190523105440.27045-1-rkagan@virtuozzo.com>
Assert that the cpu-exclusive sections are never entered/left with the
BQL taken.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
---
cpus-common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/cpus-common.c b/cpus-common.c
index 023cfebfa3..9aa75fe1ba 100644
--- a/cpus-common.c
+++ b/cpus-common.c
@@ -174,6 +174,7 @@ void start_exclusive(void)
CPUState *other_cpu;
int running_cpus;
+ assert(!qemu_mutex_iothread_locked());
qemu_mutex_lock(&qemu_cpu_list_lock);
exclusive_idle();
@@ -205,6 +206,7 @@ void start_exclusive(void)
/* Finish an exclusive operation. */
void end_exclusive(void)
{
+ assert(!qemu_mutex_iothread_locked());
qemu_mutex_lock(&qemu_cpu_list_lock);
atomic_set(&pending_cpus, 0);
qemu_cond_broadcast(&exclusive_resume);
@@ -214,6 +216,7 @@ void end_exclusive(void)
/* Wait for exclusive ops to finish, and begin cpu execution. */
void cpu_exec_start(CPUState *cpu)
{
+ assert(!qemu_mutex_iothread_locked());
atomic_set(&cpu->running, true);
/* Write cpu->running before reading pending_cpus. */
@@ -255,6 +258,7 @@ void cpu_exec_start(CPUState *cpu)
/* Mark cpu as not executing, and release pending exclusive ops. */
void cpu_exec_end(CPUState *cpu)
{
+ assert(!qemu_mutex_iothread_locked());
atomic_set(&cpu->running, false);
/* Write cpu->running before reading pending_cpus. */
--
2.21.0
next prev parent reply other threads:[~2019-05-23 11:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 10:54 [Qemu-devel] [RFC PATCH 0/2] establish nesting rule of BQL vs cpu-exclusive Roman Kagan
2019-05-23 10:54 ` [Qemu-devel] [RFC PATCH 1/2] cpus-common: nuke finish_safe_work Roman Kagan
2019-06-24 10:58 ` Alex Bennée
2019-06-24 11:50 ` Roman Kagan
2019-06-24 12:43 ` Alex Bennée
2019-05-23 10:54 ` Roman Kagan [this message]
2019-05-23 11:31 ` [Qemu-devel] [RFC PATCH 0/2] establish nesting rule of BQL vs cpu-exclusive Alex Bennée
2019-05-27 11:05 ` Roman Kagan
2019-06-06 13:22 ` Roman Kagan
2019-06-21 12:49 ` Roman Kagan
2019-08-05 12:47 ` Roman Kagan
2019-08-05 15:56 ` Paolo Bonzini
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=20190523105440.27045-3-rkagan@virtuozzo.com \
--to=rkagan@virtuozzo.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).