From patchwork Tue Feb 9 11:45:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8260521 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 4E71BBEEE5 for ; Tue, 9 Feb 2016 11:49:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C4F12025A for ; Tue, 9 Feb 2016 11:49:36 +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 E55D620114 for ; Tue, 9 Feb 2016 11:49:35 +0000 (UTC) Received: from localhost ([::1]:54675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT6nX-00033l-Ak for patchwork-qemu-devel@patchwork.kernel.org; Tue, 09 Feb 2016 06:49:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT6kO-000668-Q1 for qemu-devel@nongnu.org; Tue, 09 Feb 2016 06:46:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aT6kN-0005Eg-0i for qemu-devel@nongnu.org; Tue, 09 Feb 2016 06:46:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT6kM-0005Ec-Rl for qemu-devel@nongnu.org; Tue, 09 Feb 2016 06:46:18 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 673ECC0C234B for ; Tue, 9 Feb 2016 11:46:18 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-47.ams2.redhat.com [10.36.112.47]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u19BkELj002965; Tue, 9 Feb 2016 06:46:17 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 9 Feb 2016 12:45:59 +0100 Message-Id: <1455018374-4706-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1455018374-4706-1-git-send-email-pbonzini@redhat.com> References: <1455018374-4706-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: stefanha@redhat.com Subject: [Qemu-devel] [PATCH 01/16] aio: introduce aio_context_in_iothread 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable 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 This will be used by the synchronous I/O helpers, to choose between aio_poll or QemuEvent. Signed-off-by: Paolo Bonzini --- include/block/aio.h | 7 +++++++ iothread.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/include/block/aio.h b/include/block/aio.h index e086e3b..9434665 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -435,6 +435,13 @@ static inline bool aio_node_check(AioContext *ctx, bool is_external) } /** + * @ctx: the aio context + * + * Return whether we are running in the I/O thread that manages @ctx. + */ +bool aio_context_in_iothread(AioContext *ctx); + +/** * aio_context_setup: * @ctx: the aio context * diff --git a/iothread.c b/iothread.c index f183d38..8d40bb0 100644 --- a/iothread.c +++ b/iothread.c @@ -20,6 +20,7 @@ #include "qmp-commands.h" #include "qemu/error-report.h" #include "qemu/rcu.h" +#include "qemu/main-loop.h" typedef ObjectClass IOThreadClass; @@ -28,6 +29,13 @@ typedef ObjectClass IOThreadClass; #define IOTHREAD_CLASS(klass) \ OBJECT_CLASS_CHECK(IOThreadClass, klass, TYPE_IOTHREAD) +static __thread IOThread *my_iothread; + +bool aio_context_in_iothread(AioContext *ctx) +{ + return ctx == (my_iothread ? my_iothread->ctx : qemu_get_aio_context()); +} + static void *iothread_run(void *opaque) { IOThread *iothread = opaque; @@ -35,6 +43,7 @@ static void *iothread_run(void *opaque) rcu_register_thread(); + my_iothread = iothread; qemu_mutex_lock(&iothread->init_done_lock); iothread->thread_id = qemu_get_thread_id(); qemu_cond_signal(&iothread->init_done_cond);