From patchwork Mon Jul 20 23:10:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 36424 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6KNAVKg021882 for ; Mon, 20 Jul 2009 23:10:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754317AbZGTXKa (ORCPT ); Mon, 20 Jul 2009 19:10:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754332AbZGTXK3 (ORCPT ); Mon, 20 Jul 2009 19:10:29 -0400 Received: from mx2.redhat.com ([66.187.237.31]:53385 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754284AbZGTXKU (ORCPT ); Mon, 20 Jul 2009 19:10:20 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6KNAK9l029415 for ; Mon, 20 Jul 2009 19:10:20 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6KNAJdi002983; Mon, 20 Jul 2009 19:10:20 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6KNAGkl028980; Mon, 20 Jul 2009 19:10:19 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH 8/9] kvm_send_ipi Date: Mon, 20 Jul 2009 19:10:15 -0400 Message-Id: <1248131416-11272-9-git-send-email-glommer@redhat.com> In-Reply-To: <1248131416-11272-8-git-send-email-glommer@redhat.com> References: <1248131416-11272-1-git-send-email-glommer@redhat.com> <1248131416-11272-2-git-send-email-glommer@redhat.com> <1248131416-11272-3-git-send-email-glommer@redhat.com> <1248131416-11272-4-git-send-email-glommer@redhat.com> <1248131416-11272-5-git-send-email-glommer@redhat.com> <1248131416-11272-6-git-send-email-glommer@redhat.com> <1248131416-11272-7-git-send-email-glommer@redhat.com> <1248131416-11272-8-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Provide a wrapper to pthread kill. It is more elegant because we only need to pass a CPUState pointer, meaning "signall this cpu" Signed-off-by: Glauber Costa --- qemu-kvm.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 6d556b8..c89146d 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -66,6 +66,11 @@ static CPUState *kvm_debug_cpu_requested; static uint64_t phys_ram_size; +static inline void kvm_send_ipi(CPUState *env) +{ + pthread_kill(env->kvm_cpu_state.thread, SIG_IPI); +} + /* The list of ioperm_data */ static LIST_HEAD(, ioperm_data) ioperm_head; @@ -1712,7 +1717,7 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data) wi.next = NULL; wi.done = false; - pthread_kill(env->kvm_cpu_state.thread, SIG_IPI); + kvm_send_ipi(env); while (!wi.done) qemu_cond_wait(&qemu_work_cond); } @@ -1744,7 +1749,7 @@ void kvm_update_interrupt_request(CPUState *env) if (signal) { env->kvm_cpu_state.signalled = 1; if (env->kvm_cpu_state.thread) - pthread_kill(env->kvm_cpu_state.thread, SIG_IPI); + kvm_send_ipi(env); } } } @@ -1892,7 +1897,7 @@ static void pause_all_threads(void) while (penv) { if (penv != cpu_single_env) { penv->stop = 1; - pthread_kill(penv->kvm_cpu_state.thread, SIG_IPI); + kvm_send_ipi(penv); } else { penv->stop = 0; penv->stopped = 1; @@ -1914,7 +1919,7 @@ static void resume_all_threads(void) while (penv) { penv->stop = 0; penv->stopped = 0; - pthread_kill(penv->kvm_cpu_state.thread, SIG_IPI); + kvm_send_ipi(penv); penv = (CPUState *)penv->next_cpu; } }