From patchwork Wed May 22 06:02:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 245548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 149CC2C0522 for ; Wed, 22 May 2013 16:28:43 +1000 (EST) Received: from localhost ([::1]:49110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf2XR-0004mE-6S for incoming@patchwork.ozlabs.org; Wed, 22 May 2013 02:28:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf2X2-0004hv-Du for qemu-devel@nongnu.org; Wed, 22 May 2013 02:28:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uf2Go-0004YG-0u for qemu-devel@nongnu.org; Wed, 22 May 2013 02:12:01 -0400 Received: from indium.canonical.com ([91.189.90.7]:45762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf2Gn-0004YB-Py for qemu-devel@nongnu.org; Wed, 22 May 2013 02:11:29 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Uf2Gm-0007l3-9B for ; Wed, 22 May 2013 06:11:28 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 4640D2E856F for ; Wed, 22 May 2013 06:11:25 +0000 (UTC) MIME-Version: 1.0 Date: Wed, 22 May 2013 06:02:08 -0000 From: Evan Green To: qemu-devel@nongnu.org X-Launchpad-Bug: product=qemu; status=New; importance=Undecided; assignee=None; X-Launchpad-Bug-Information-Type: Public X-Launchpad-Bug-Private: no X-Launchpad-Bug-Security-Vulnerability: no X-Launchpad-Bug-Commenters: evan-g jakub X-Launchpad-Bug-Reporter: Evan Green (evan-g) X-Launchpad-Bug-Modifier: Evan Green (evan-g) References: <20130519164858.7560.43164.malonedeb@wampee.canonical.com> Message-Id: <20130522060208.605.21539.malone@soybean.canonical.com> X-Launchpad-Message-Rationale: Subscriber (QEMU) @qemu-devel-ml Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16626"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 55e373698dec0333535520530016ca5874aceaca X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 91.189.90.7 Subject: [Qemu-devel] [Bug 1181796] Re: Qemu locks up when incoming serial fills up X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Reply-To: Bug 1181796 <1181796@bugs.launchpad.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The following patch gets things moving again for me. It only reports that the poll was satisfied if there was data that could be written to the destination. While it successfully opens up a window where the I/O thread is unlocked (previously there was no such window, hence the hang), it's far from ideal. Someone with more familiarity than me could consider an approach where descriptors that have responded to the poll but are unable to be acted on are temporarily disabled or removed from the list. This would allow the main thread to quiet back down, rather than aggressively spinning locking and unlocking the global mutex, which puts a drag on the VCPU threads that need to acquire the same lock and do real work. The line numbers here might not line up, but you get the idea. --- qemu-char.c.orig2 2013-05-19 22:27:16 -0700 +++ qemu-char.c 2013-05-19 23:49:38 -0700 @@ -1650,6 +1650,7 @@ static int win_chr_poll(void *opaque) { + int available; CharDriverState *chr = opaque; WinCharState *s = chr->opaque; COMSTAT status; @@ -1658,9 +1659,9 @@ ClearCommError(s->hcom, &comerr, &status); if (status.cbInQue > 0) { s->len = status.cbInQue; - win_chr_read_poll(chr); + available = win_chr_read_poll(chr); win_chr_read(chr); - return 1; + return available != 0; } return 0; } @@ -1692,6 +1693,7 @@ static int win_chr_pipe_poll(void *opaque) { + int available; CharDriverState *chr = opaque; WinCharState *s = chr->opaque; DWORD size; @@ -1699,9 +1701,9 @@ PeekNamedPipe(s->hcom, NULL, 0, NULL, &size, NULL); if (size > 0) { s->len = size; - win_chr_read_poll(chr); + available = win_chr_read_poll(chr); win_chr_read(chr); - return 1; + return available != 0; } return 0; }