From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: mttcg@greensocs.com, cota@braap.org, rth@twiddle.net
Subject: [Qemu-devel] [PATCH 8/9] use qemu_cpu_kick instead of cpu_exit or qemu_cpu_kick_thread
Date: Wed, 26 Aug 2015 02:17:44 +0200 [thread overview]
Message-ID: <1440548265-4755-9-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1440548265-4755-1-git-send-email-pbonzini@redhat.com>
Use the same API to trigger interruption of a CPU, no matter if
under TCG or KVM. There is no difference: these calls come from
the CPU thread, so the qemu_cpu_kick calls will send a signal
to the running thread and it will be processed synchronously,
just like a call to cpu_exit. The only difference is in the
overhead, but neither call to cpu_exit (now qemu_cpu_kick)
is in a hot path.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
cpus.c | 17 ++++++++---------
gdbstub.c | 2 +-
hw/ppc/spapr_rtas.c | 2 +-
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/cpus.c b/cpus.c
index 783ef00..8243b2c 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1101,6 +1101,12 @@ static void qemu_cpu_kick_thread(CPUState *cpu)
#ifndef _WIN32
int err;
+ if (!tcg_enabled()) {
+ if (cpu->thread_kicked) {
+ return;
+ }
+ cpu->thread_kicked = true;
+ }
err = pthread_kill(cpu->thread->thread, SIG_IPI);
if (err) {
fprintf(stderr, "qemu:%s: %s", __func__, strerror(err));
@@ -1138,21 +1144,14 @@ static void qemu_cpu_kick_thread(CPUState *cpu)
void qemu_cpu_kick(CPUState *cpu)
{
qemu_cond_broadcast(cpu->halt_cond);
- if (!tcg_enabled() && !cpu->thread_kicked) {
- qemu_cpu_kick_thread(cpu);
- cpu->thread_kicked = true;
- }
+ qemu_cpu_kick_thread(cpu);
}
void qemu_cpu_kick_self(void)
{
#ifndef _WIN32
assert(current_cpu);
-
- if (!current_cpu->thread_kicked) {
- qemu_cpu_kick_thread(current_cpu);
- current_cpu->thread_kicked = true;
- }
+ qemu_cpu_kick_thread(current_cpu);
#else
abort();
#endif
diff --git a/gdbstub.c b/gdbstub.c
index ffe7e6e..a5a173a 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1362,7 +1362,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
is still in the running state, which can cause packets to be dropped
and state transition 'T' packets to be sent while the syscall is still
being processed. */
- cpu_exit(s->c_cpu);
+ qemu_cpu_kick(s->c_cpu);
#endif
}
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index 2986f94..9869bc9 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -214,7 +214,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,
CPUPPCState *env = &cpu->env;
cs->halted = 1;
- cpu_exit(cs);
+ qemu_cpu_kick(cs);
/*
* While stopping a CPU, the guest calls H_CPPR which
* effectively disables interrupts on XICS level.
--
2.4.3
next prev parent reply other threads:[~2015-08-26 0:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-26 0:17 [Qemu-devel] [PATCH v2 0/9] tcg: signal-free qemu_cpu_kick Paolo Bonzini
2015-08-26 0:17 ` [Qemu-devel] [PATCH 1/9] i8257: rewrite DMA_schedule to avoid hooking into the CPU loop Paolo Bonzini
2015-08-26 0:17 ` [Qemu-devel] [PATCH 2/9] i8257: remove cpu_request_exit irq Paolo Bonzini
2015-08-26 0:17 ` [Qemu-devel] [PATCH 3/9] tcg: introduce tcg_current_cpu Paolo Bonzini
2015-08-26 0:17 ` [Qemu-devel] [PATCH 4/9] remove qemu/tls.h Paolo Bonzini
2015-08-26 0:17 ` [Qemu-devel] [PATCH 5/9] tcg: assign cpu->current_tb in a simpler place Paolo Bonzini
2015-08-26 0:17 ` [Qemu-devel] [PATCH 6/9] tcg: synchronize cpu->exit_request and cpu->tcg_exit_req accesses Paolo Bonzini
2015-08-28 2:19 ` Emilio G. Cota
2015-08-28 8:50 ` Paolo Bonzini
2015-08-26 0:17 ` [Qemu-devel] [PATCH 7/9] tcg: synchronize exit_request and tcg_current_cpu accesses Paolo Bonzini
2015-08-26 0:17 ` Paolo Bonzini [this message]
2015-08-26 0:17 ` [Qemu-devel] [PATCH 9/9] tcg: signal-free qemu_cpu_kick Paolo Bonzini
2015-08-28 4:21 ` [Qemu-devel] [PATCH v2 0/9] " Richard Henderson
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=1440548265-4755-9-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=cota@braap.org \
--cc=mttcg@greensocs.com \
--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).