From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USSFM-0006gE-CS for qemu-devel@nongnu.org; Wed, 17 Apr 2013 09:18:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USSFJ-000483-Uf for qemu-devel@nongnu.org; Wed, 17 Apr 2013 09:18:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42684) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USSFJ-00047K-Gw for qemu-devel@nongnu.org; Wed, 17 Apr 2013 09:17:57 -0400 Message-ID: <516E9FB9.3070408@redhat.com> Date: Wed, 17 Apr 2013 15:12:25 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1366204073-8468-1-git-send-email-stefanha@redhat.com> <1366204073-8468-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1366204073-8468-5-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 04/17] tests: adjust test-thread-pool to new aio_poll() semantics List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , pingfank@linux.vnet.ibm.com, qemu-devel@nongnu.org Il 17/04/2013 15:07, Stefan Hajnoczi ha scritto: > aio_poll(ctx, true) will soon block when fd handlers have been set. > Previously aio_poll() would return early if all .io_flush() returned > false. This means we need to check the equivalent of the .io_flush() > condition *before* calling aio_poll(ctx, true) to avoid deadlock. > > Signed-off-by: Stefan Hajnoczi > --- > tests/test-thread-pool.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/tests/test-thread-pool.c b/tests/test-thread-pool.c > index 22915aa..f0b2ef1 100644 > --- a/tests/test-thread-pool.c > +++ b/tests/test-thread-pool.c > @@ -40,19 +40,13 @@ static void done_cb(void *opaque, int ret) > active--; > } > > -/* Wait until all aio and bh activity has finished */ > -static void qemu_aio_wait_all(void) > -{ > - while (aio_poll(ctx, true)) { > - /* Do nothing */ > - } > -} > - > static void test_submit(void) > { > WorkerTestData data = { .n = 0 }; > thread_pool_submit(pool, worker_cb, &data); > - qemu_aio_wait_all(); > + while (data.n == 0) { > + aio_poll(ctx, true); > + } > g_assert_cmpint(data.n, ==, 1); > } > > @@ -65,7 +59,9 @@ static void test_submit_aio(void) > /* The callbacks are not called until after the first wait. */ > active = 1; > g_assert_cmpint(data.ret, ==, -EINPROGRESS); > - qemu_aio_wait_all(); > + while (data.ret == -EINPROGRESS) { > + aio_poll(ctx, true); > + } > g_assert_cmpint(active, ==, 0); > g_assert_cmpint(data.n, ==, 1); > g_assert_cmpint(data.ret, ==, 0); > @@ -103,7 +99,9 @@ static void test_submit_co(void) > > /* qemu_aio_wait_all will execute the rest of the coroutine. */ > > - qemu_aio_wait_all(); > + while (data.ret == -EINPROGRESS) { > + aio_poll(ctx, true); > + } > > /* Back here after the coroutine has finished. */ > > @@ -187,7 +185,9 @@ static void test_cancel(void) > } > > /* Finish execution and execute any remaining callbacks. */ > - qemu_aio_wait_all(); > + while (active > 0) { > + aio_poll(ctx, true); > + } > g_assert_cmpint(active, ==, 0); > for (i = 0; i < 100; i++) { > if (data[i].n == 3) { > Reviewed-by: Polo Bonzini