Received: from eggs.gnu.org ([2001:4830:134:3::10]:53043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZflp-0005oQ-PO for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:50:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZflo-00035z-FX for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:50:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57988) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZflo-00035k-8X for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:50:40 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id E9C708A344 for ; Wed, 9 Sep 2015 13:50:39 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-83.ams2.redhat.com [10.36.112.83]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89DoEi0030571 for ; Wed, 9 Sep 2015 09:50:39 -0400 From: Paolo Bonzini Date: Wed, 9 Sep 2015 15:49:45 +0200 Message-Id: <1441806613-13775-16-git-send-email-pbonzini@redhat.com> In-Reply-To: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> References: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 15/43] use qemu_cpu_kick instead of cpu_exit or qemu_cpu_kick_thread List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 Signed-off-by: Paolo Bonzini --- 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 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 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