From patchwork Mon Feb 8 16:14:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8251741 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 A9090BEEE5 for ; Mon, 8 Feb 2016 16:15:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EA2E20148 for ; Mon, 8 Feb 2016 16:15:34 +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 69473203C3 for ; Mon, 8 Feb 2016 16:15:33 +0000 (UTC) Received: from localhost ([::1]:46192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSoTM-0005v0-OE for patchwork-qemu-devel@patchwork.kernel.org; Mon, 08 Feb 2016 11:15:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSoT5-0005sJ-89 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 1aSoT1-0002Mw-91 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]:34715) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSoT1-0002Mp-27 for qemu-devel@nongnu.org; Mon, 08 Feb 2016 11:15:11 -0500 Received: by mail-wm0-x241.google.com with SMTP id p63so16173764wmp.1 for ; Mon, 08 Feb 2016 08:15:11 -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=iNvd8JqYtVX1/PBS3Hq23H7YWTXLFfqyEt3CcJdIWvo=; b=AGtKcybnyRBQs11goxO8UuXQaSgl/9M/GCmyCLl3nPwbaaDMrrG3tHYdepue7nKyTx SHeUR4ke3/l06YfxvTUITSP94CYHlBPKiacohkPFEpITvTPJpasyPJR87TCXRIPY92R9 gsh6xDqQsYdPOhu9harlGTB2N7oPdgDa7yxX2EQCkzv3auGUMxhXT4U2CrUrAMzNU64b W7C5JaaBZrgZrjpwEr4m5ifnKq1gzNHldI6ndQJBWg5Ki7mnhVdb3bSbtbh7Nx9HJHlR rIUhUNOQ4aMOrYOfw6xf6FbSLw4u3+XpyGI/QcBrYIQVTB7wNxNazV12/vvwKxj0Okun CYZw== 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=iNvd8JqYtVX1/PBS3Hq23H7YWTXLFfqyEt3CcJdIWvo=; b=HHYN+Kpt3wlpuTF0WayuvEM1QS0GAn5D8v/NXkQf0LiNo6GyCcsFirRHCxA+cVudz1 +1uD9T4hfBeEEYaaPXXsSchn7HjZ4iiYnPrguzhckyliKbLDqKEIvMlNr7//akLM91AF zx1WD8n63KeZC1KF1LvD99an2Ykv2hpl66zGR3UpfpfaGKSFCVCX57/ZBY9+mS6qA27d yF5+DX5VZNFy/QhDG2OiYaVzMZSkkFotwI4rMbLYpKTOWb54TMCIy9Cv03KvPphjj8r1 X6fAxHEOY/95iY2VyWNzT+LvvrsaWc9xfJMSp6KlmKI87jLfaeoJPnmrxJ1MyuDtmdYR /Bkw== X-Gm-Message-State: AG10YOR3FmWb5gjm/iiYCvGp3JHf1sjd0STObWMBWMOQ6e7tj9S4kvyd0462zliJwtyfmA== X-Received: by 10.28.21.19 with SMTP id 19mr49360757wmv.43.1454948110544; Mon, 08 Feb 2016 08:15:10 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 08:15:09 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 8 Feb 2016 17:14:52 +0100 Message-Id: <1454948107-11844-2-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 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.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 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);