From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTdGu-0006Jh-Lb for qemu-devel@nongnu.org; Tue, 08 Oct 2013 15:48:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTdGt-0000v6-SU for qemu-devel@nongnu.org; Tue, 08 Oct 2013 15:48:44 -0400 Received: from mail.avalus.com ([2001:41c8:10:1dd::10]:52080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTdGt-0000uw-MQ for qemu-devel@nongnu.org; Tue, 08 Oct 2013 15:48:43 -0400 Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Alex Bligh In-Reply-To: <1381259403-7386-1-git-send-email-hdegoede@redhat.com> Date: Tue, 8 Oct 2013 20:48:26 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <0863CECC-BE13-4B55-8FFF-593D942A5195@alex.org.uk> References: <1381259403-7386-1-git-send-email-hdegoede@redhat.com> Subject: Re: [Qemu-devel] [PATCH] main-loop: Don't lock starve io-threads when main_loop_tlg has pending events List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hans de Goede Cc: qemu-devel@nongnu.org, Alex Bligh On 8 Oct 2013, at 20:10, Hans de Goede wrote: > I noticed today that current qemu master would hang as soon as Xorg = starts in > the guest when using qxl + a Linux guest. This message would be = printed: > main-loop: WARNING: I/O thread spun for 1000 iterations >=20 > And from then on the guest hangs and qemu consumes 100% cpu, bisecting = pointed > out commit 7b595f35d89d73bc69c35bf3980a89c420e8a44b: > "aio / timers: Convert mainloop to use timeout" >=20 > After looking at that commit I had a hunch the problem might be = blocking > main_loop_wait calls being turned into non-blocking ones (and thus = never > releasing the io-lock), a debug printf confirmed this was happening at > the moment of the hang, so I wrote this patch which fixes the hang for = me > and seems like a good idea in general. >=20 > Signed-off-by: Hans de Goede > --- > main-loop.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > diff --git a/main-loop.c b/main-loop.c > index c3c9c28..921c939 100644 > --- a/main-loop.c > +++ b/main-loop.c > @@ -480,6 +480,11 @@ int main_loop_wait(int nonblocking) > timerlistgroup_deadline_ns( > &main_loop_tlg)); >=20 > + /* When not non-blocking always allow io-threads to acquire the = lock */ > + if (timeout !=3D 0 && timeout_ns =3D=3D 0) { > + timeout_ns =3D 1; > + } > + > ret =3D os_host_main_loop_wait(timeout_ns); > qemu_iohandler_poll(gpollfds, ret); > #ifdef CONFIG_SLIRP I /think/ you might mean "if (!blocking && timeout_ns =3D=3D 0)" as timeout can be zero on a blocking call at this stage (i.e. when there is a timer which has already expired. I'm not entirely sure I understand the problem from your description - I'll answer this in your subseqent message. --=20 Alex Bligh