From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 06/18] kvm: Refactor qemu_kvm_eat_signals Date: Mon, 10 Jan 2011 11:15:55 +0100 Message-ID: <4D2ADC5B.1050308@redhat.com> References: <8630ac717d7c3fefaf091b70feaf17e63c411c26.1294648329.git.jan.kiszka@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: qemu-devel@nongnu.org To: kvm@vger.kernel.org Return-path: Received: from lo.gmane.org ([80.91.229.12]:38200 "EHLO lo.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753414Ab1AJKPm (ORCPT ); Mon, 10 Jan 2011 05:15:42 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PcEmn-0004sd-HP for kvm@vger.kernel.org; Mon, 10 Jan 2011 11:15:37 +0100 Received: from 93-34-149-100.ip50.fastwebnet.it ([93.34.149.100]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Jan 2011 11:15:37 +0100 Received: from pbonzini by 93-34-149-100.ip50.fastwebnet.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Jan 2011 11:15:37 +0100 In-Reply-To: <8630ac717d7c3fefaf091b70feaf17e63c411c26.1294648329.git.jan.kiszka@web.de> Sender: kvm-owner@vger.kernel.org List-ID: On 01/10/2011 09:31 AM, Jan Kiszka wrote: > From: Jan Kiszka > > We do not use the timeout, so drop its logic. As we always poll our > signals, we do not need to drop the global lock. Removing those calls > allows some further simplifications. Also fix the error processing of > sigpending at this chance. > > Signed-off-by: Jan Kiszka > --- > cpus.c | 23 +++++++---------------- > 1 files changed, 7 insertions(+), 16 deletions(-) > > diff --git a/cpus.c b/cpus.c > index bf0fb85..6da0f8f 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -617,31 +617,22 @@ static void sigbus_handler(int n, struct qemu_signalfd_siginfo *siginfo, > } > } > > -static void qemu_kvm_eat_signal(CPUState *env, int timeout) > +static void qemu_kvm_eat_signals(CPUState *env) > { > - struct timespec ts; > - int r, e; > + struct timespec ts = { 0, 0 }; > siginfo_t siginfo; > sigset_t waitset; > sigset_t chkset; > - > - ts.tv_sec = timeout / 1000; > - ts.tv_nsec = (timeout % 1000) * 1000000; > + int r; > > sigemptyset(&waitset); > sigaddset(&waitset, SIG_IPI); > sigaddset(&waitset, SIGBUS); > > do { > - qemu_mutex_unlock(&qemu_global_mutex); > - > r = sigtimedwait(&waitset,&siginfo,&ts); > - e = errno; > - > - qemu_mutex_lock(&qemu_global_mutex); > - > - if (r == -1&& !(e == EAGAIN || e == EINTR)) { > - fprintf(stderr, "sigtimedwait: %s\n", strerror(e)); > + if (r == -1&& !(errno == EAGAIN || errno == EINTR)) { > + perror("sigtimedwait"); > exit(1); > } > > @@ -657,7 +648,7 @@ static void qemu_kvm_eat_signal(CPUState *env, int timeout) > > r = sigpending(&chkset); > if (r == -1) { > - fprintf(stderr, "sigpending: %s\n", strerror(e)); > + perror("sigpending"); > exit(1); > } > } while (sigismember(&chkset, SIG_IPI) || sigismember(&chkset, SIGBUS)); > @@ -668,7 +659,7 @@ static void qemu_kvm_wait_io_event(CPUState *env) > while (!cpu_has_work(env)) > qemu_cond_timedwait(env->halt_cond,&qemu_global_mutex, 1000); > > - qemu_kvm_eat_signal(env, 0); > + qemu_kvm_eat_signals(env); > qemu_wait_io_event_common(env); > } > Reviewed-by: Paolo Bonzini Paolo From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48767 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcEmj-0006vc-5D for qemu-devel@nongnu.org; Mon, 10 Jan 2011 05:15:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PcEmh-0000W7-Dn for qemu-devel@nongnu.org; Mon, 10 Jan 2011 05:15:33 -0500 Received: from mail-yw0-f45.google.com ([209.85.213.45]:48678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PcEmh-0000W2-7v for qemu-devel@nongnu.org; Mon, 10 Jan 2011 05:15:31 -0500 Received: by ywl5 with SMTP id 5so8907574ywl.4 for ; Mon, 10 Jan 2011 02:15:30 -0800 (PST) Sender: Paolo Bonzini Message-ID: <4D2ADC5B.1050308@redhat.com> Date: Mon, 10 Jan 2011 11:15:55 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <8630ac717d7c3fefaf091b70feaf17e63c411c26.1294648329.git.jan.kiszka@web.de> In-Reply-To: <8630ac717d7c3fefaf091b70feaf17e63c411c26.1294648329.git.jan.kiszka@web.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 06/18] kvm: Refactor qemu_kvm_eat_signals List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Marcelo Tosatti , Avi Kivity , kvm@vger.kernel.org, qemu-devel@nongnu.org On 01/10/2011 09:31 AM, Jan Kiszka wrote: > From: Jan Kiszka > > We do not use the timeout, so drop its logic. As we always poll our > signals, we do not need to drop the global lock. Removing those calls > allows some further simplifications. Also fix the error processing of > sigpending at this chance. > > Signed-off-by: Jan Kiszka > --- > cpus.c | 23 +++++++---------------- > 1 files changed, 7 insertions(+), 16 deletions(-) > > diff --git a/cpus.c b/cpus.c > index bf0fb85..6da0f8f 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -617,31 +617,22 @@ static void sigbus_handler(int n, struct qemu_signalfd_siginfo *siginfo, > } > } > > -static void qemu_kvm_eat_signal(CPUState *env, int timeout) > +static void qemu_kvm_eat_signals(CPUState *env) > { > - struct timespec ts; > - int r, e; > + struct timespec ts = { 0, 0 }; > siginfo_t siginfo; > sigset_t waitset; > sigset_t chkset; > - > - ts.tv_sec = timeout / 1000; > - ts.tv_nsec = (timeout % 1000) * 1000000; > + int r; > > sigemptyset(&waitset); > sigaddset(&waitset, SIG_IPI); > sigaddset(&waitset, SIGBUS); > > do { > - qemu_mutex_unlock(&qemu_global_mutex); > - > r = sigtimedwait(&waitset,&siginfo,&ts); > - e = errno; > - > - qemu_mutex_lock(&qemu_global_mutex); > - > - if (r == -1&& !(e == EAGAIN || e == EINTR)) { > - fprintf(stderr, "sigtimedwait: %s\n", strerror(e)); > + if (r == -1&& !(errno == EAGAIN || errno == EINTR)) { > + perror("sigtimedwait"); > exit(1); > } > > @@ -657,7 +648,7 @@ static void qemu_kvm_eat_signal(CPUState *env, int timeout) > > r = sigpending(&chkset); > if (r == -1) { > - fprintf(stderr, "sigpending: %s\n", strerror(e)); > + perror("sigpending"); > exit(1); > } > } while (sigismember(&chkset, SIG_IPI) || sigismember(&chkset, SIGBUS)); > @@ -668,7 +659,7 @@ static void qemu_kvm_wait_io_event(CPUState *env) > while (!cpu_has_work(env)) > qemu_cond_timedwait(env->halt_cond,&qemu_global_mutex, 1000); > > - qemu_kvm_eat_signal(env, 0); > + qemu_kvm_eat_signals(env); > qemu_wait_io_event_common(env); > } > Reviewed-by: Paolo Bonzini Paolo