From patchwork Mon Feb 8 16:14:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8251791 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5B321BEEE5 for ; Mon, 8 Feb 2016 16:17:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE7CE203B7 for ; Mon, 8 Feb 2016 16:17:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07A3120148 for ; Mon, 8 Feb 2016 16:17:51 +0000 (UTC) Received: from localhost ([::1]:46208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSoVa-0000yz-AZ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 08 Feb 2016 11:17:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSoT5-0005sI-7x for qemu-devel@nongnu.org; Mon, 08 Feb 2016 11:15:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSoT4-0002Nf-7l for qemu-devel@nongnu.org; Mon, 08 Feb 2016 11:15:15 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:36117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSoT4-0002NU-0l for qemu-devel@nongnu.org; Mon, 08 Feb 2016 11:15:14 -0500 Received: by mail-wm0-x241.google.com with SMTP id 128so16170856wmz.3 for ; Mon, 08 Feb 2016 08:15:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=OmAs3c27HDz88x0TbKWH7T3ONDQ2ipTwV18jQXfyJ9M=; b=QLxz+xp+Cr1AxHKsTPDqi1gDIX0onlqx+GGveWJwSqj8w0E6rLnUvYnbEYm5zsNHmL OAtavm0le7I/pV77QP9ujk3mIzD91ktJygMO5c+Cm6mUI5zlIpJYx2uh/9rO4MY3AMSp NS3AEV/MB/EZtlpvRqnPmia11DbnTQaFgUiR16/QS3he7SeXvoa2xT9fC22kgiO+DH5w KMXMBwT9K2c783Wh8tpyR6k6BwL6scqHjWcz7Fn6x6S5yRMUIyauchMUj5MhLxOAq7Wx uh6mZSUWsnwOMmPMBzAMX6zClE//neBxl9d/Se35MmBwrf9Oo0qLVMqJ0tFWdZGMQli3 8uTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=OmAs3c27HDz88x0TbKWH7T3ONDQ2ipTwV18jQXfyJ9M=; b=i24h7cOAG/FcwSxgm+skmIz2Rm6hYJvjyAL11OckB2SWYIeYv3xY2+iCTEIUMcbAet 92cWNbvJTlKY60no0Me2UJ+VPTDbTTeR49rOQP/5Slu8Z+wyb5bskOnLPVyWclaNJzsV 6aAyhwhoQQsSoylltig5Jysl8bnKkecNXSkkWwMseRHe99rGeXhFIwQi3uTWTPlzzRUI Sc4WSNFH8ZwdB2Ihf7JXrAvkf0s1rusNgMRUOpAmUQI2NVEFelLBC+DhDnaehhq6fHkh KQ3FSNKGVCU2S6TEhZNSBz2143ctET5Tk6sJ3rhiVuvzy+uAKHx1F977OVxUebrjYpeR 7BUQ== X-Gm-Message-State: AG10YOQy/kzvZrL5K92dSWpAK5el5mUmxJBGyYZjojXJojuCFiNoAQPG7Ke8EuMm/pkU6A== X-Received: by 10.194.23.232 with SMTP id p8mr33369971wjf.80.1454948113575; Mon, 08 Feb 2016 08:15:13 -0800 (PST) Received: from donizetti.lan (94-39-141-130.adsl-ull.clienti.tiscali.it. [94.39.141.130]) by smtp.gmail.com with ESMTPSA id v2sm13305429wmd.24.2016.02.08.08.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 08:15:12 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 8 Feb 2016 17:14:54 +0100 Message-Id: <1454948107-11844-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454948107-11844-1-git-send-email-pbonzini@redhat.com> References: <1454948107-11844-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Cc: stefanha@redhat.com Subject: [Qemu-devel] [PATCH 03/16] aio: introduce aio_poll_internal 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move the implemntation of aio_poll to aio_poll_internal, and introduce a wrapper for public use. For now it just asserts that aio_poll is being used correctly---either from the thread that manages the context, or with the QEMU global mutex held. The next patch, however, will completely separate the two cases. Signed-off-by: Paolo Bonzini --- aio-posix.c | 2 +- aio-win32.c | 2 +- async.c | 8 ++++++++ include/block/aio.h | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/aio-posix.c b/aio-posix.c index fa7f8ab..4dc075c 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -401,7 +401,7 @@ static void add_pollfd(AioHandler *node) npfd++; } -bool aio_poll(AioContext *ctx, bool blocking) +bool aio_poll_internal(AioContext *ctx, bool blocking) { AioHandler *node; int i, ret; diff --git a/aio-win32.c b/aio-win32.c index 6aaa32a..86ad822 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -281,7 +281,7 @@ bool aio_dispatch(AioContext *ctx) return progress; } -bool aio_poll(AioContext *ctx, bool blocking) +bool aio_poll_internal(AioContext *ctx, bool blocking) { AioHandler *node; HANDLE events[MAXIMUM_WAIT_OBJECTS + 1]; diff --git a/async.c b/async.c index d083564..01c4891 100644 --- a/async.c +++ b/async.c @@ -300,6 +300,14 @@ void aio_notify_accept(AioContext *ctx) } } +bool aio_poll(AioContext *ctx, bool blocking) +{ + assert(qemu_mutex_iothread_locked() || + aio_context_in_iothread(ctx)); + + return aio_poll_internal(ctx, blocking); +} + static void aio_timerlist_notify(void *opaque) { aio_notify(opaque); diff --git a/include/block/aio.h b/include/block/aio.h index 9434665..986be97 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -287,6 +287,12 @@ bool aio_pending(AioContext *ctx); */ bool aio_dispatch(AioContext *ctx); +/* Same as aio_poll, but only meant for use in the I/O thread. + * + * This is used internally in the implementation of aio_poll. + */ +bool aio_poll_internal(AioContext *ctx, bool blocking); + /* Progress in completing AIO work to occur. This can issue new pending * aio as a result of executing I/O completion or bh callbacks. *