From: Robert Foley <robert.foley@linaro.org>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, Richard Henderson <rth@twiddle.net>,
alex.bennee@linaro.org, robert.foley@linaro.org,
peter.puhov@linaro.org
Subject: [PATCH v2 5/7] accel/tcg: Change BQL critical section in cpu_handle_interrupt
Date: Wed, 19 Aug 2020 14:28:54 -0400 [thread overview]
Message-ID: <20200819182856.4893-6-robert.foley@linaro.org> (raw)
In-Reply-To: <20200819182856.4893-1-robert.foley@linaro.org>
We are changing the critical section from being around
the majority of the cpu_handle_interrupt to instead
be around just the call to ->cpu_exec_interrupt.
This is in preparation for pushing down the BQL into the
per arch implementation.
We should mention that we discussed these changes as well as
some open questions here:
https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg01189.html
With the main open question being:
BQL is clearly needed to protect the critical section around the call to
->cpu_exec_interrupt. What else is the BQL protecting in cpu_handle_interrupt
that we need to consider? Are we missing anything here?
Signed-off-by: Robert Foley <robert.foley@linaro.org>
---
accel/tcg/cpu-exec.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index e661635f06..499a8bdc5e 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -556,7 +556,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
if (unlikely(cpu_interrupt_request(cpu))) {
int interrupt_request;
- qemu_mutex_lock_iothread();
interrupt_request = cpu_interrupt_request(cpu);
if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {
/* Mask out external interrupts for this step. */
@@ -565,7 +564,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
if (interrupt_request & CPU_INTERRUPT_DEBUG) {
cpu_reset_interrupt(cpu, CPU_INTERRUPT_DEBUG);
cpu->exception_index = EXCP_DEBUG;
- qemu_mutex_unlock_iothread();
return true;
}
if (replay_mode == REPLAY_MODE_PLAY && !replay_has_interrupt()) {
@@ -575,13 +573,13 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
cpu_reset_interrupt(cpu, CPU_INTERRUPT_HALT);
cpu_halted_set(cpu, 1);
cpu->exception_index = EXCP_HLT;
- qemu_mutex_unlock_iothread();
return true;
}
#if defined(TARGET_I386)
else if (interrupt_request & CPU_INTERRUPT_INIT) {
X86CPU *x86_cpu = X86_CPU(cpu);
CPUArchState *env = &x86_cpu->env;
+ qemu_mutex_lock_iothread();
replay_interrupt();
cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0);
do_cpu_init(x86_cpu);
@@ -593,7 +591,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
else if (interrupt_request & CPU_INTERRUPT_RESET) {
replay_interrupt();
cpu_reset(cpu);
- qemu_mutex_unlock_iothread();
return true;
}
#endif
@@ -602,6 +599,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
True when it is, and we should restart on a new TB,
and via longjmp via cpu_loop_exit. */
else {
+ qemu_mutex_lock_iothread();
if (cc->cpu_exec_interrupt(cpu, interrupt_request)) {
replay_interrupt();
/*
@@ -616,6 +614,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
/* The target hook may have updated the 'cpu->interrupt_request';
* reload the 'interrupt_request' value */
interrupt_request = cpu_interrupt_request(cpu);
+ qemu_mutex_unlock_iothread();
}
if (interrupt_request & CPU_INTERRUPT_EXITTB) {
cpu_reset_interrupt(cpu, CPU_INTERRUPT_EXITTB);
@@ -625,7 +624,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
}
/* If we exit via cpu_loop_exit/longjmp it is reset in cpu_exec */
- qemu_mutex_unlock_iothread();
}
/* Finally, check if we need to exit to the main loop. */
--
2.17.1
next prev parent reply other threads:[~2020-08-19 18:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 18:28 [PATCH v2 0/7] accel/tcg: remove implied BQL from cpu_handle_interrupt/exception path Robert Foley
2020-08-19 18:28 ` [PATCH v2 1/7] target: rename all *_do_interupt functions to _do_interrupt_locked Robert Foley
2020-08-31 21:14 ` Richard Henderson
2020-08-19 18:28 ` [PATCH v2 2/7] target/arm: add ARMCPUClass->do_interrupt_locked Robert Foley
2020-08-31 21:18 ` Richard Henderson
2020-08-31 22:02 ` Richard Henderson
2020-08-31 23:44 ` Philippe Mathieu-Daudé
2020-08-19 18:28 ` [PATCH v2 3/7] target/cris: add CRISCPUClass->do_interrupt_locked Robert Foley
2020-08-31 21:19 ` Richard Henderson
2020-08-19 18:28 ` [PATCH v2 4/7] target: Push BQL on ->do_interrupt down into per-arch implementation Robert Foley
2020-08-31 21:37 ` Richard Henderson
2020-08-19 18:28 ` Robert Foley [this message]
2020-08-31 21:44 ` [PATCH v2 5/7] accel/tcg: Change BQL critical section in cpu_handle_interrupt Richard Henderson
2020-08-19 18:28 ` [PATCH v2 6/7] target: rename all *_cpu_exec_interrupt functions to *_cpu_exec_interrupt_locked Robert Foley
2020-08-31 21:46 ` Richard Henderson
2020-08-19 18:28 ` [PATCH v2 7/7] target: Push BQL on ->cpu_exec_interrupt down into per-arch implementation Robert Foley
2020-08-31 22:11 ` Richard Henderson
2020-08-21 10:55 ` [PATCH v2 0/7] accel/tcg: remove implied BQL from cpu_handle_interrupt/exception path Cornelia Huck
2020-08-27 12:38 ` Robert Foley
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=20200819182856.4893-6-robert.foley@linaro.org \
--to=robert.foley@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.puhov@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).