From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URjAG-00080R-Us for qemu-devel@nongnu.org; Mon, 15 Apr 2013 09:09:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URjAF-0005W0-HW for qemu-devel@nongnu.org; Mon, 15 Apr 2013 09:09:44 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:44590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URjAF-0005J6-0G for qemu-devel@nongnu.org; Mon, 15 Apr 2013 09:09:43 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Apr 2013 23:06:43 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 7FF323578050 for ; Mon, 15 Apr 2013 23:08:53 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3FD8Ewk12124614 for ; Mon, 15 Apr 2013 23:08:14 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3FD8Je1029573 for ; Mon, 15 Apr 2013 23:08:19 +1000 From: Anthony Liguori In-Reply-To: <1365311880-11800-1-git-send-email-peter.crosthwaite@xilinx.com> References: <1365311880-11800-1-git-send-email-peter.crosthwaite@xilinx.com> Date: Mon, 15 Apr 2013 08:08:07 -0500 Message-ID: <878v4kvt54.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH] mainloop.c: Keep unlocking BQL during busy-wait spin-out List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite , qemu-devel@nongnu.org Cc: pbonzini@redhat.com Peter Crosthwaite writes: > Modify Anthony's starvation detection logic to keep the BQL unlocked > until the starvation condition goes away. Otherwise the counter has to > count up to 1000 for each needed iteration until the busy-wait is > lifted. > > Reset the counter back to zero once glib_pollfds_fill returns with a > non-zero timout, (indicating a return to normality). The 1000 iteration > wait now only happens once on the transition from normal operation to > busy-wait starvation. > > Anthony's original patch fixed the serial paste bug, but this patch is > also needed to restore performance. > > Signed-off-by: Peter Crosthwaite I'm going through patches for 1.5 candidates. I believe the paste performance issue has been resolved now and this patch is no longer needed. I can't find a definitive statement on the list for that though. Peter, can you confirm? Regards, Anthony Liguori > --- > main-loop.c | 20 ++++++++++---------- > 1 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/main-loop.c b/main-loop.c > index f46aece..93d2917 100644 > --- a/main-loop.c > +++ b/main-loop.c > @@ -200,10 +200,13 @@ static int os_host_main_loop_wait(uint32_t timeout) > /* If the I/O thread is very busy or we are incorrectly busy waiting in > * the I/O thread, this can lead to starvation of the BQL such that the > * VCPU threads never run. To make sure we can detect the later case, > - * print a message to the screen. If we run into this condition, create > - * a fake timeout in order to give the VCPU threads a chance to run. > + * print a message to the screen. If we run into this condition, unlock > + * the BQL until a non-zero timout is given (indicating the starvation > + * issue has gome away). > */ > - if (spin_counter > MAX_MAIN_LOOP_SPIN) { > + if (timeout > 0) { > + spin_counter = 0; > + } else if (spin_counter > MAX_MAIN_LOOP_SPIN) { > static bool notified; > > if (!notified) { > @@ -212,21 +215,18 @@ static int os_host_main_loop_wait(uint32_t timeout) > MAX_MAIN_LOOP_SPIN); > notified = true; > } > - > - timeout = 1; > } > > - if (timeout > 0) { > - spin_counter = 0; > + if (timeout > 0 || spin_counter > MAX_MAIN_LOOP_SPIN) { > qemu_mutex_unlock_iothread(); > - } else { > - spin_counter++; > } > > ret = g_poll((GPollFD *)gpollfds->data, gpollfds->len, timeout); > > - if (timeout > 0) { > + if (timeout > 0 || spin_counter > MAX_MAIN_LOOP_SPIN) { > qemu_mutex_lock_iothread(); > + } else { > + spin_counter++; > } > > glib_pollfds_poll(); > -- > 1.7.0.4