aboutsummaryrefslogtreecommitdiff
path: root/cpus.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-08-18 06:52:09 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2015-09-09 15:34:54 +0200
commit9102dedaa1ee1e89ce4a81283c403ff4928e9ef9 (patch)
treed98546ef77e276c3afea8397fd76c1e0d46d1922 /cpus.c
parentaed807c8e2bf009b2c6a35490d4fd4383887221d (diff)
downloadqemu-9102dedaa1ee1e89ce4a81283c403ff4928e9ef9.zip
qemu-9102dedaa1ee1e89ce4a81283c403ff4928e9ef9.tar.gz
qemu-9102dedaa1ee1e89ce4a81283c403ff4928e9ef9.tar.bz2
use qemu_cpu_kick instead of cpu_exit or qemu_cpu_kick_thread
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. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'cpus.c')
-rw-r--r--cpus.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/cpus.c b/cpus.c
index dd2fc29..e407910 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1090,6 +1090,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));
@@ -1127,21 +1133,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