From patchwork Fri Dec 6 16:36:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 298091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D59082C00A0 for ; Sat, 7 Dec 2013 03:52:18 +1100 (EST) Received: from localhost ([::1]:60115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoydU-0000yV-Bq for incoming@patchwork.ozlabs.org; Fri, 06 Dec 2013 11:52:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoyQS-0000nc-GF for qemu-devel@nongnu.org; Fri, 06 Dec 2013 11:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoyQN-0003zE-1l for qemu-devel@nongnu.org; Fri, 06 Dec 2013 11:38:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37003) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoyQM-0003z0-Nd for qemu-devel@nongnu.org; Fri, 06 Dec 2013 11:38:42 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB6GcfXq023149 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 6 Dec 2013 11:38:41 -0500 Received: from localhost (ovpn-112-22.ams2.redhat.com [10.36.112.22]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB6Gce60017819; Fri, 6 Dec 2013 11:38:40 -0500 From: Stefan Hajnoczi To: Date: Fri, 6 Dec 2013 17:36:46 +0100 Message-Id: <1386347807-27359-48-git-send-email-stefanha@redhat.com> In-Reply-To: <1386347807-27359-1-git-send-email-stefanha@redhat.com> References: <1386347807-27359-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , Anthony Liguori Subject: [Qemu-devel] [PULL 47/48] aio: make aio_poll(ctx, true) block with no fds X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list 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 This patch drops a special case where aio_poll(ctx, true) returns false instead of blocking if no file descriptors are waiting on I/O. Now it is possible to block in aio_poll() to wait for aio_notify(). This change eliminates busy waiting. bdrv_drain_all() used to rely on busy waiting to completed throttled I/O requests but this is no longer required so we can simplify aio_poll(). Note that aio_poll() still returns false when aio_notify() was used. In other words, stopping a blocking aio_poll() wait is not considered making progress. Adjust test-aio /aio/bh/callback-delete/one which assumed aio_poll(ctx, true) would immediately return false instead of blocking. Reviewed-by: Alex Bligh Signed-off-by: Stefan Hajnoczi --- aio-posix.c | 5 ----- aio-win32.c | 5 ----- tests/test-aio.c | 1 - 3 files changed, 11 deletions(-) diff --git a/aio-posix.c b/aio-posix.c index bd06f33..f921d4f 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -217,11 +217,6 @@ bool aio_poll(AioContext *ctx, bool blocking) ctx->walking_handlers--; - /* early return if we only have the aio_notify() fd */ - if (ctx->pollfds->len == 1) { - return progress; - } - /* wait until next event */ ret = qemu_poll_ns((GPollFD *)ctx->pollfds->data, ctx->pollfds->len, diff --git a/aio-win32.c b/aio-win32.c index f9cfbb7..23f4e5b 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -161,11 +161,6 @@ bool aio_poll(AioContext *ctx, bool blocking) ctx->walking_handlers--; - /* early return if we only have the aio_notify() fd */ - if (count == 1) { - return progress; - } - /* wait until next event */ while (count > 0) { int ret; diff --git a/tests/test-aio.c b/tests/test-aio.c index c4fe0fc..592721e 100644 --- a/tests/test-aio.c +++ b/tests/test-aio.c @@ -195,7 +195,6 @@ static void test_bh_delete_from_cb(void) g_assert(data1.bh == NULL); g_assert(!aio_poll(ctx, false)); - g_assert(!aio_poll(ctx, true)); } static void test_bh_delete_from_cb_many(void)