From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 04/22] Leave inner main_loop faster on pending requests Date: Mon, 31 Jan 2011 15:17:56 +0200 Message-ID: <4D46B684.1050507@redhat.com> References: <34720dd344455d0abee575d399caedebcc099e5a.1296133797.git.jan.kiszka@siemens.com> <4D46865A.2090405@redhat.com> <4D469B86.7030400@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:9129 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754562Ab1AaNSC (ORCPT ); Mon, 31 Jan 2011 08:18:02 -0500 In-Reply-To: <4D469B86.7030400@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: On 01/31/2011 01:22 PM, Jan Kiszka wrote: > On 2011-01-31 10:52, Avi Kivity wrote: > > On 01/27/2011 03:09 PM, Jan Kiszka wrote: > >> If there is any pending request that requires us to leave the inner loop > >> if main_loop, makes sure we do this as soon as possible by enforcing > >> non-blocking IO processing. > >> > >> At this change, move variable definitions out of the inner loop to > >> improve readability. > >> > >> Signed-off-by: Jan Kiszka > >> --- > >> vl.c | 11 +++++++---- > >> 1 files changed, 7 insertions(+), 4 deletions(-) > >> > >> diff --git a/vl.c b/vl.c > >> index 5fad700..2ebc55b 100644 > >> --- a/vl.c > >> +++ b/vl.c > >> @@ -1384,18 +1384,21 @@ qemu_irq qemu_system_powerdown; > >> > >> static void main_loop(void) > >> { > >> + bool nonblocking = false; > >> +#ifdef CONFIG_PROFILER > >> + int64_t ti; > >> +#endif > >> int r; > >> > >> qemu_main_loop_start(); > >> > >> for (;;) { > >> do { > >> - bool nonblocking = false; > >> -#ifdef CONFIG_PROFILER > >> - int64_t ti; > >> -#endif > >> #ifndef CONFIG_IOTHREAD > >> nonblocking = cpu_exec_all(); > >> + if (!vm_can_run()) { > >> + nonblocking = true; > >> + } > > > > Doesn't this cause vmstop to spin? We'll never execute > > main_loop_wait(false) if I read the code correctly? > > > > The code path is not changed, we just poll instead of wait in > main_loop_wait. Where do we wait then? > Also, I didn't get your error scenario yet. Even if we left the loop > here, what magic would main_loop_wait do to vmstop processing? The stop > request is handled outside the loop, that's why we should leave ASAP. I'm just missing the alternate place where we sleep. If there's no such place, we spin. -- error compiling committee.c: too many arguments to function From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39821 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pjtdp-0001Pw-Pu for qemu-devel@nongnu.org; Mon, 31 Jan 2011 08:18:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pjtdo-0004wm-G9 for qemu-devel@nongnu.org; Mon, 31 Jan 2011 08:18:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pjtdo-0004wf-80 for qemu-devel@nongnu.org; Mon, 31 Jan 2011 08:18:00 -0500 Message-ID: <4D46B684.1050507@redhat.com> Date: Mon, 31 Jan 2011 15:17:56 +0200 From: Avi Kivity MIME-Version: 1.0 References: <34720dd344455d0abee575d399caedebcc099e5a.1296133797.git.jan.kiszka@siemens.com> <4D46865A.2090405@redhat.com> <4D469B86.7030400@siemens.com> In-Reply-To: <4D469B86.7030400@siemens.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 04/22] Leave inner main_loop faster on pending requests List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Marcelo Tosatti , "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" On 01/31/2011 01:22 PM, Jan Kiszka wrote: > On 2011-01-31 10:52, Avi Kivity wrote: > > On 01/27/2011 03:09 PM, Jan Kiszka wrote: > >> If there is any pending request that requires us to leave the inner loop > >> if main_loop, makes sure we do this as soon as possible by enforcing > >> non-blocking IO processing. > >> > >> At this change, move variable definitions out of the inner loop to > >> improve readability. > >> > >> Signed-off-by: Jan Kiszka > >> --- > >> vl.c | 11 +++++++---- > >> 1 files changed, 7 insertions(+), 4 deletions(-) > >> > >> diff --git a/vl.c b/vl.c > >> index 5fad700..2ebc55b 100644 > >> --- a/vl.c > >> +++ b/vl.c > >> @@ -1384,18 +1384,21 @@ qemu_irq qemu_system_powerdown; > >> > >> static void main_loop(void) > >> { > >> + bool nonblocking = false; > >> +#ifdef CONFIG_PROFILER > >> + int64_t ti; > >> +#endif > >> int r; > >> > >> qemu_main_loop_start(); > >> > >> for (;;) { > >> do { > >> - bool nonblocking = false; > >> -#ifdef CONFIG_PROFILER > >> - int64_t ti; > >> -#endif > >> #ifndef CONFIG_IOTHREAD > >> nonblocking = cpu_exec_all(); > >> + if (!vm_can_run()) { > >> + nonblocking = true; > >> + } > > > > Doesn't this cause vmstop to spin? We'll never execute > > main_loop_wait(false) if I read the code correctly? > > > > The code path is not changed, we just poll instead of wait in > main_loop_wait. Where do we wait then? > Also, I didn't get your error scenario yet. Even if we left the loop > here, what magic would main_loop_wait do to vmstop processing? The stop > request is handled outside the loop, that's why we should leave ASAP. I'm just missing the alternate place where we sleep. If there's no such place, we spin. -- error compiling committee.c: too many arguments to function