From patchwork Tue May 21 23:52:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aarushi Mehta X-Patchwork-Id: 1103073 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MhGUjGjl"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 457tBH3fzxz9s6w for ; Wed, 22 May 2019 10:03:03 +1000 (AEST) Received: from localhost ([127.0.0.1]:32925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEij-0002xD-GH for incoming@patchwork.ozlabs.org; Tue, 21 May 2019 20:03:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEcZ-0005oR-Qk for qemu-devel@nongnu.org; Tue, 21 May 2019 19:56:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTEYe-0001ba-AJ for qemu-devel@nongnu.org; Tue, 21 May 2019 19:52:37 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:37052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTEYe-0001az-52; Tue, 21 May 2019 19:52:36 -0400 Received: by mail-pg1-x544.google.com with SMTP id n27so311543pgm.4; Tue, 21 May 2019 16:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q+Kzz8YvgmccQoubOgUbAFtVK8kRATQnmKwd+TXQuz4=; b=MhGUjGjl8RHNjBLycf3ZmHZzYcMobB711qKUAwC1k60LCuS2IuvcIxejJ1SlxJCnGT tdrfZsGBmUlR93hdsqHytG3eJIL+mL9YnInLIJdfKddEiHeXVgFPA/B+GUqllTG5Gb7v /q1b9lQnuEwYlMjP8vfC17zN6zhegfNUve3rK0z2H6BfGVNp5e0a8WL5rcHSdEYqZnqi GgiPLd0+//Im49o9J+Vc8mSwctr5w8fe2Y3PBaAFnesXQ3R21RHP/iVylv0+OQEIkEq4 x2nqbMtiZRnH49s0XJAIDuhfVBuy2BTuX0VKYmk4PqDtL12ZbRsM2r/hrvCLSkwHWZW6 MEUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q+Kzz8YvgmccQoubOgUbAFtVK8kRATQnmKwd+TXQuz4=; b=S5IZScAuzUPBSKsXotoXEtkOjn9ivw8GmI1se/KexIAxiKB16I84gm2llWz/yofeE1 nRL8LO6FZTH6jXTCabgwYqLWPPs5pHsNau33o1vAIjsH17504OvvwsPHEWDitt3YvNyH qJk9M8l6QtoOyVxylqfjUbED36ulkQrNy6c+jBfnlxPiOt6DdB383ZijPPWiMvOTW9K4 BNDCJ3OUjlYIFP+5Xc8sEr17xnu2+OLpp32RDn/t9hj4NGSNakv7jZCS71TqVR5d3GVd 7L38vBZL+ofNj6EdQ8USFuBvzpbxUOpNh42rhOrFSzzwZP61hDShGG0y+xiwWzDMOVWR Z3aQ== X-Gm-Message-State: APjAAAVHrso52KGMg/DPim6Ewb4k4OlpH632YSsiQBO5Dn3elke0w9gC l63ixamD51RZOAI78DTv3qgInwGHHELtJw== X-Google-Smtp-Source: APXvYqxY2Zeiq0+y9ddZskZfS3muhFWgR8gZjsLgifKPMczF8maiAQmDh3CamNxioaxHP7DESdh80Q== X-Received: by 2002:a62:4ed8:: with SMTP id c207mr92654835pfb.241.1558482754777; Tue, 21 May 2019 16:52:34 -0700 (PDT) Received: from localhost.localdomain ([120.57.118.207]) by smtp.gmail.com with ESMTPSA id e5sm51571752pgh.35.2019.05.21.16.52.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 16:52:34 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 05:22:07 +0530 Message-Id: <20190521235215.31341-2-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521235215.31341-1-mehta.aaru20@gmail.com> References: <20190521235215.31341-1-mehta.aaru20@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [RFC PATCH 1/9] qapi/block-core: add option for io_uring X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saket.sinha89@gmail.com, Julia Suvorova , qemu-block@nongnu.org, Stefan Hajnoczi , Aarushi Mehta Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Aarushi Mehta --- qapi/block-core.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/qapi/block-core.json b/qapi/block-core.json index 7ccbfff9d0..116995810a 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2776,11 +2776,12 @@ # # @threads: Use qemu's thread pool # @native: Use native AIO backend (only Linux and Windows) +# @io_uring: Use linux io_uring # # Since: 2.9 ## { 'enum': 'BlockdevAioOptions', - 'data': [ 'threads', 'native' ] } + 'data': [ 'threads', 'native','io_uring' ] } ## # @BlockdevCacheOptions: From patchwork Tue May 21 23:52:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aarushi Mehta X-Patchwork-Id: 1103074 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VwWIgeZZ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 457tDD6JZnz9s3l for ; Wed, 22 May 2019 10:04:44 +1000 (AEST) Received: from localhost ([127.0.0.1]:32953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEkM-0004C1-V2 for incoming@patchwork.ozlabs.org; Tue, 21 May 2019 20:04:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEcY-0005oR-PU for qemu-devel@nongnu.org; Tue, 21 May 2019 19:56:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTEYh-0001dK-SJ for qemu-devel@nongnu.org; Tue, 21 May 2019 19:52:40 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:34646) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTEYh-0001d3-NJ; Tue, 21 May 2019 19:52:39 -0400 Received: by mail-pl1-x642.google.com with SMTP id w7so126757plz.1; Tue, 21 May 2019 16:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LRaFFcCz9V1QD7Nw7bkLXRkuVZNJbVer9JVm4TimWgA=; b=VwWIgeZZ5/MBtJzQLdxtn3PXnbPFJErvmovMXIa3p+4NLl+UoNdFQA09LLD2b15toS fzqAVo4YydOomMNzWjJ+6gY/usO4+Lq2T/Fcwy7jksdsb2h29+66DCpvHBRRKwpBrxSM 1moMbCaRWfUOzoepTqeYhWe/nGIwHGc8pKg1XKSOXUk3ZQKWmM2E+6Kv9yQ4JO0xSVpf FrU3f+ezPeWCJKK8F9AdUZGs0sElNcFrS7rShuq77xFCDnqRWI03/wyvUYEwy0HZ6yBq LowRfKszjcnq2QjbPpXCVfiiGVUdENDIRR0bnnNTOMJquD0Yf5s/8HJLH/CW7lf8bsHU yaeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LRaFFcCz9V1QD7Nw7bkLXRkuVZNJbVer9JVm4TimWgA=; b=TGOl+nfj1S0LbqqSS+nbM4bJoYjY05GUa+//5s7VdaTvj+gOjyWTFPOqEYN2mw6d6S HtiCGdR9fhIeO/5Pbe+xuDu3/r/LUxzPBc2F+OgViYIJHJ5ZSD91ZS3sNX8yMzFL+2+8 LDcfp/Ss2p94AOb0991KZnhg3yXMhk017rguVYVemqy/QHaj5QwbwZcI9xTtmZEDD6tY nNkELdZ9aub8ZILKM8Ooq1Fs7g3QfFBGpsqkyDISL2n7Kh7gyUJtADQmnvtUVC6iBM9y Axa6a91s79tZ3PR5qYSdZGeFxnYa4EgxmpVRZbOaYpDxgwcSRUXcBQTyKQeTN1ytlPhm el9Q== X-Gm-Message-State: APjAAAX0b60dRAbTLayIu0ekZyW3ksTTFIgYFNm76N9wZh/WJFARTn50 x8KElrXxZrOLJm23oY3Gyz9hmFKXeoAJKQ== X-Google-Smtp-Source: APXvYqyOyqWnuEqrtisT0T3c3nnK2ripmJWOfs4A2qm+YS8dQQPJAlD+fFXGn/sp7Z3/oX+Pr/x4OQ== X-Received: by 2002:a17:902:b094:: with SMTP id p20mr63128698plr.164.1558482758299; Tue, 21 May 2019 16:52:38 -0700 (PDT) Received: from localhost.localdomain ([120.57.118.207]) by smtp.gmail.com with ESMTPSA id e5sm51571752pgh.35.2019.05.21.16.52.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 16:52:37 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 05:22:08 +0530 Message-Id: <20190521235215.31341-3-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521235215.31341-1-mehta.aaru20@gmail.com> References: <20190521235215.31341-1-mehta.aaru20@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [RFC PATCH 2/9] block/block: add BDRV flag for io_uring X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saket.sinha89@gmail.com, Julia Suvorova , qemu-block@nongnu.org, Stefan Hajnoczi , Aarushi Mehta Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Aarushi Mehta --- include/block/block.h | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/include/block/block.h b/include/block/block.h index 5e2b98b0ee..005f42b133 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -121,6 +121,7 @@ typedef struct HDGeometry { ignoring the format layer */ #define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */ #define BDRV_O_AUTO_RDONLY 0x20000 /* degrade to read-only if opening read-write fails */ +#define BDRV_O_IO_URING 0x40000 /* use io_uring instead of the thread pool */ #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH) From patchwork Tue May 21 23:52:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aarushi Mehta X-Patchwork-Id: 1103072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EGTJ4Kyg"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 457tBG1RlJz9s3l for ; Wed, 22 May 2019 10:03:00 +1000 (AEST) Received: from localhost ([127.0.0.1]:32918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEif-0002nz-Bv for incoming@patchwork.ozlabs.org; Tue, 21 May 2019 20:02:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEcX-0005iQ-SR for qemu-devel@nongnu.org; Tue, 21 May 2019 19:56:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTEYl-0001f4-AO for qemu-devel@nongnu.org; Tue, 21 May 2019 19:52:44 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:42288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTEYl-0001en-5G; Tue, 21 May 2019 19:52:43 -0400 Received: by mail-pf1-x441.google.com with SMTP id 13so267742pfw.9; Tue, 21 May 2019 16:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u+flvTgxCSEnbGBAPAYORRxauVugPBlncOQJBlabvsk=; b=EGTJ4KygxPfOKSU16lqWxY8l83cPOLjgZ1SbYKLcfA1U7ZrOLAuqaljRWQrKCXfJOh x/hTk+H8nUPd1j9HgMRolFr/cX/2jRLEzrMpPG/1H02CQzYPeQgs4tAU/UXhL33iLxbX paq2P4RoqomyHLa7Xa0WU2PgYttubz6HXIcNo3/ArweaiMAZ+bEkAzuMbRm/ydMGc9ku Hkeqe438yyhu7ehjNCw6J9dk5vdr2n6gXwEOdlnuRENcnmbPHVZ2+tF8i2yRqLxC5odU IPTiXJhHPk7CkIBl1rNad96pPEsB1+2NJLORSuC5THHFduSQvxMgyd/NCSDptH4VW5I8 19Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u+flvTgxCSEnbGBAPAYORRxauVugPBlncOQJBlabvsk=; b=s+rhbiGca15HsH3y8GaoVmxc+653AOrzqizncw0SCKLoTZeXw9uuocQL2/sM9ImDiO cxKKmclKvVdfnV7Hj9hIUfES1KQWGXkRJCVQ55tfr/Ee9o8PnBS87+g/7Mwt0PlDYf/8 IX5w4tHCvDUYnXjuYfC8iP9TxsElGv611JSEKsEng3DIyvxe7lKLs5iVoBIVowPf1zlJ n8eJZVlFvAUUhHSTCasUoBXUpsKFLgvA2SeRSnV3D/0jeHMWd+ipfOh3fDSTyggV/8tj N0QqORKfOYgdIdz8eGHB7tcqpDZLoE/hfPxCX/aqIW0DI9OZCaO8cTm4+HeOpYf4pzbn u51g== X-Gm-Message-State: APjAAAWCo+UyzP2xeEXCwvcc1xyZuqiGhEYMK1qz8maAZOmbzORnasxt T9D+VRo/Hq1C1ptUh7FAccNanf1ATDMiFw== X-Google-Smtp-Source: APXvYqwqWyjoLHnK34cWpnbSnqkY5qobLwOip2Ucb3kTehPjM8JwAP5414Vv1BxmATUTMpZE5vSlfQ== X-Received: by 2002:a63:d343:: with SMTP id u3mr85966342pgi.285.1558482761861; Tue, 21 May 2019 16:52:41 -0700 (PDT) Received: from localhost.localdomain ([120.57.118.207]) by smtp.gmail.com with ESMTPSA id e5sm51571752pgh.35.2019.05.21.16.52.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 16:52:41 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 05:22:09 +0530 Message-Id: <20190521235215.31341-4-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521235215.31341-1-mehta.aaru20@gmail.com> References: <20190521235215.31341-1-mehta.aaru20@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [RFC PATCH 3/9] include/block: declare interfaces for io_uring X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saket.sinha89@gmail.com, Julia Suvorova , qemu-block@nongnu.org, Stefan Hajnoczi , Aarushi Mehta Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Aarushi Mehta --- include/block/aio.h | 16 +++++++++++++++- include/block/raw-aio.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/include/block/aio.h b/include/block/aio.h index 0ca25dfec6..2f9acbcd7d 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -50,6 +50,7 @@ typedef void IOHandler(void *opaque); struct Coroutine; struct ThreadPool; struct LinuxAioState; +struct LuringState; struct AioContext { GSource source; @@ -118,11 +119,19 @@ struct AioContext { struct ThreadPool *thread_pool; #ifdef CONFIG_LINUX_AIO - /* State for native Linux AIO. Uses aio_context_acquire/release for + /* + * State for native Linux AIO. Uses aio_context_acquire/release for * locking. */ struct LinuxAioState *linux_aio; #endif +#ifdef CONFIG_LINUX_IO_URING + /* + * State for native Linux AIO. Uses aio_context_acquire/release for + * locking. + */ + struct LuringState *linux_io_uring; +#endif /* TimerLists for calling timers - one per clock type. Has its own * locking. @@ -387,6 +396,11 @@ struct LinuxAioState *aio_setup_linux_aio(AioContext *ctx, Error **errp); /* Return the LinuxAioState bound to this AioContext */ struct LinuxAioState *aio_get_linux_aio(AioContext *ctx); +/* Setup the LuringState bound to this AioContext */ +struct LuringState *aio_setup_linux_io_uring(AioContext *ctx, Error **errp); + +/* Return the LuringState bound to this AioContext */ +struct LuringState *aio_get_linux_io_uring(AioContext *ctx); /** * aio_timer_new_with_attrs: * @ctx: the aio context diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h index ba223dd1f1..2e413bbee0 100644 --- a/include/block/raw-aio.h +++ b/include/block/raw-aio.h @@ -58,6 +58,21 @@ void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context); void laio_io_plug(BlockDriverState *bs, LinuxAioState *s); void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s); #endif +/* io_uring.c - Linux io_uring implementation */ +#ifdef CONFIG_LINUX_IO_URING +typedef struct LuringState LuringState; +LuringState *luring_init(Error **errp); +void luring_cleanup(LuringState *s); +int coroutine_fn luring_co_submit(BlockDriverState *bs, LuringState *s, int fd, + uint64_t offset, QEMUIOVector *qiov, int type); +BlockAIOCB *luring_submit(BlockDriverState *bs, LuringState *s, int fd, + int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, + BlockCompletionFunc *cb, void *opaque, int type); +void luring_detach_aio_context(LuringState *s, AioContext *old_context); +void luring_attach_aio_context(LuringState *s, AioContext *new_context); +void luring_io_plug(BlockDriverState *bs, LuringState *s); +void luring_io_unplug(BlockDriverState *bs, LuringState *s); +#endif #ifdef _WIN32 typedef struct QEMUWin32AIOState QEMUWin32AIOState; From patchwork Tue May 21 23:52:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aarushi Mehta X-Patchwork-Id: 1103069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jHqgYbzD"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 457t7J71dsz9sBb for ; Wed, 22 May 2019 10:00:28 +1000 (AEST) Received: from localhost ([127.0.0.1]:32837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEgE-0008Qg-To for incoming@patchwork.ozlabs.org; Tue, 21 May 2019 20:00:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEcW-0005iQ-QI for qemu-devel@nongnu.org; Tue, 21 May 2019 19:56:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTEYp-0001hC-1O for qemu-devel@nongnu.org; Tue, 21 May 2019 19:52:47 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:41192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTEYo-0001gr-S8; Tue, 21 May 2019 19:52:46 -0400 Received: by mail-pf1-x444.google.com with SMTP id q17so271533pfq.8; Tue, 21 May 2019 16:52:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6t8EyasZJmDI3dL3/CDwbkFcNJeDBde1hDDWAyb831A=; b=jHqgYbzD0MLSWwn80XgJA6ozg3JiiVqBcEWYyvc6jD/nKXFdSM0ZmmKAQtTfQ+ruY/ gRloWm2VCuN0fpdd7IRqO28eXccV0RYyNjw6DRkbAE3qpq64Svfy8CbZ0PkRyA8mE6Pd Xg36g1kdMnlSFyx0niyoZ2LvvFuJJUL9v62H1ZvrfOS59FBi2lmrzPUx+ZsoKiClwCr6 dObbxYt/1VXqu/vkJ1F59oF65a410U5Y7cV1hQ4B6uF8a/ChLFLZuh4Aa84OZF6bCVaT wy/QTq0VbP5/utrXh+HpMuApuVSyX9GRaM1++wssj38xsYcQ5Rpl+CYii8PMIllH2dcL vekA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6t8EyasZJmDI3dL3/CDwbkFcNJeDBde1hDDWAyb831A=; b=r2vsYhAneTGPCx+iqGRzghZBLY+omng7aRTHBbEWsWh+hy4ZII+8/n8MVELQH8srJG Tf1OVsI3ioFhzv/Q44UAVjJssduf0Ml0Q5AaUtk6f8v1f7w4MI/LQyI89NErgNEuS98a Qj6+c2ed/Pg+F94GnCvQqOf41yqTwRT6SUi0fgxmZpEN0lzcINi+vQMaqmORJivfUK6T DABjvwuIPVRmtWLGycKsvRO6oAimEaW2Dk6SO2kcFlwv4DhJ+ioOf7fqGUQ6nGyEANlP HnnsIt8MXJtOq29TugY/2LRirarOVU9XsyyuPUnHC35DoVOWGPehBnfvDdqe38He05ZC mbSg== X-Gm-Message-State: APjAAAXdkLjFw9EbiiNtifLm/amrUBFKfnWO1vSARIgI6E+yAOR+HUhi +fWlVr7XCGmqAN5sPqcGTeb+ZxcbeHVx8g== X-Google-Smtp-Source: APXvYqzrWBbsbCPMPl8mF11WMCnG1LHB+X9TVBJWdz50dtDDFoaii6bdMnVOKj8nr5x7IjOut+eqVQ== X-Received: by 2002:a62:6dc6:: with SMTP id i189mr91080963pfc.155.1558482765576; Tue, 21 May 2019 16:52:45 -0700 (PDT) Received: from localhost.localdomain ([120.57.118.207]) by smtp.gmail.com with ESMTPSA id e5sm51571752pgh.35.2019.05.21.16.52.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 16:52:44 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 05:22:10 +0530 Message-Id: <20190521235215.31341-5-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521235215.31341-1-mehta.aaru20@gmail.com> References: <20190521235215.31341-1-mehta.aaru20@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [RFC PATCH 4/9] stubs: add aio interface stubs for io_uring X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saket.sinha89@gmail.com, Julia Suvorova , qemu-block@nongnu.org, Stefan Hajnoczi , Aarushi Mehta Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Aarushi Mehta Reviewed-by: Stefan Hajnoczi --- stubs/Makefile.objs | 1 + stubs/io_uring.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 stubs/io_uring.c -- 2.17.1 diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 269dfa5832..86ceca5c4e 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -13,6 +13,7 @@ stub-obj-y += iothread.o stub-obj-y += iothread-lock.o stub-obj-y += is-daemonized.o stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o +stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o stub-obj-y += machine-init-done.o stub-obj-y += migr-blocker.o stub-obj-y += change-state-handler.o diff --git a/stubs/io_uring.c b/stubs/io_uring.c new file mode 100644 index 0000000000..622d1e4648 --- /dev/null +++ b/stubs/io_uring.c @@ -0,0 +1,32 @@ +/* + * Linux io_uring support. + * + * Copyright (C) 2009 IBM, Corp. + * Copyright (C) 2009 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "block/aio.h" +#include "block/raw-aio.h" + +void luring_detach_aio_context(LuringState *s, AioContext *old_context) +{ + abort(); +} + +void luring_attach_aio_context(LuringState *s, AioContext *new_context) +{ + abort(); +} + +LuringState *luring_init(Error **errp) +{ + abort(); +} + +void luring_cleanup(LuringState *s) +{ + abort(); +} From patchwork Tue May 21 23:52:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aarushi Mehta X-Patchwork-Id: 1103070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rO1UXrDK"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 457t7R1H6Mz9s6w for ; Wed, 22 May 2019 10:00:35 +1000 (AEST) Received: from localhost ([127.0.0.1]:32843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEgL-0008VZ-1o for incoming@patchwork.ozlabs.org; Tue, 21 May 2019 20:00:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEcV-0005iQ-5A for qemu-devel@nongnu.org; Tue, 21 May 2019 19:56:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTEYs-0001j3-KL for qemu-devel@nongnu.org; Tue, 21 May 2019 19:52:51 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:39077) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTEYs-0001ij-F8; Tue, 21 May 2019 19:52:50 -0400 Received: by mail-pf1-x441.google.com with SMTP id z26so276701pfg.6; Tue, 21 May 2019 16:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HFBwuOKEbqexqwPgrKzRL4NNTvNhKQclyEPlvywkxJs=; b=rO1UXrDK9jTzkhu+6kaDlqwnX3bPbTNFxaOfQuwgzABgp0BJHEfFHYN/4c0X0hnYOm 5tSpvxL50yYL9QrTI1QDwED63lwJ+5a3adDCvaLROGH5XJRVKeYHlJVNZ6CJn9JVkTLr rUOy5IetczVYw07KEp7051J+KPivqfWhLjlSj1qlPTGu1jBdxWIB8schOf54yHYGhO0M D04OmcbBalHZ6RLv3uY+dd5F20TdE+s3rztJY6lZSlvnSwblfsuiUhzoAE4Pb5hbRNJw SY7HA/sOCbqUQ6NLvJV68/VwKri0FUWbjlSJ3TQ9WXEx76Euxod/Dne8wmhT0nfx37lI cq1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HFBwuOKEbqexqwPgrKzRL4NNTvNhKQclyEPlvywkxJs=; b=hChM1VOBEEQaGG3y5Rch31jfa5K76wlh0A2SaLH2Njc3fHT/wGyMcdIl10/qbFsher zJ5O5jTD52vzfe19f9Bbn1BkfxgZfMDEO+VsPuPUD9XdIc7dpuD4YZwWteIzzLtWyme8 Okr7xTZ+w2TJJMjbLQRWjHbSEDPGO57w2rhd3Dk9FVKp1yV6XZtLSAWTT9+aTpGkHkrm 6HVhajVzXrjFw3rQcNE1LyzbMT8cyRGER4ysD1666bMx4naQqhcBVJGpipN+KQEVm1E4 +YIPQezbGiIZ1QoWyX5HR8JYKTl+00m3B1xUQb6J6JIb6gcQT2FZO5T81xBRiAhfae+t 7N+Q== X-Gm-Message-State: APjAAAXXKZev12h9anrecR4/fvZ5kRSfsdF7nH6rax3kYL+gmrSGiVXO VYbhW9oMvkiy/9VZuziSurRO/IuVMI1Qtg== X-Google-Smtp-Source: APXvYqx3Z/px+tuLCUbtnRfSLoCItyYKrqbM0NNIiB5m5HbbR1omm9nam5H+2MmEgKYnB4zdzX8RgA== X-Received: by 2002:aa7:9a99:: with SMTP id w25mr52155463pfi.249.1558482769204; Tue, 21 May 2019 16:52:49 -0700 (PDT) Received: from localhost.localdomain ([120.57.118.207]) by smtp.gmail.com with ESMTPSA id e5sm51571752pgh.35.2019.05.21.16.52.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 16:52:48 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 05:22:11 +0530 Message-Id: <20190521235215.31341-6-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521235215.31341-1-mehta.aaru20@gmail.com> References: <20190521235215.31341-1-mehta.aaru20@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [RFC PATCH 5/9] util/asyn: add aio interfaces for io_uring X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saket.sinha89@gmail.com, Julia Suvorova , qemu-block@nongnu.org, Stefan Hajnoczi , Aarushi Mehta Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Aarushi Mehta --- util/async.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) -- 2.17.1 diff --git a/util/async.c b/util/async.c index c10642a385..dd45aff8f5 100644 --- a/util/async.c +++ b/util/async.c @@ -277,6 +277,14 @@ aio_ctx_finalize(GSource *source) } #endif +#ifdef CONFIG_LINUX_IO_URING + if (ctx->linux_io_uring) { + luring_detach_aio_context(ctx->linux_io_uring, ctx); + luring_cleanup(ctx->linux_io_uring); + ctx->linux_io_uring = NULL; + } +#endif + assert(QSLIST_EMPTY(&ctx->scheduled_coroutines)); qemu_bh_delete(ctx->co_schedule_bh); @@ -341,6 +349,25 @@ LinuxAioState *aio_get_linux_aio(AioContext *ctx) } #endif +#ifdef CONFIG_LINUX_IO_URING +LuringState *aio_setup_linux_io_uring(AioContext *ctx, Error **errp) +{ + if (!ctx->linux_io_uring) { + ctx->linux_io_uring = luring_init(errp); + if (ctx->linux_io_uring) { + luring_attach_aio_context(ctx->linux_io_uring, ctx); + } + } + return ctx->linux_io_uring; +} + +LuringState *aio_get_linux_io_uring(AioContext *ctx) +{ + assert(ctx->linux_io_uring); + return ctx->linux_io_uring; +} +#endif + void aio_notify(AioContext *ctx) { /* Write e.g. bh->scheduled before reading ctx->notify_me. Pairs @@ -432,6 +459,11 @@ AioContext *aio_context_new(Error **errp) #ifdef CONFIG_LINUX_AIO ctx->linux_aio = NULL; #endif + +#ifdef CONFIG_LINUX_IO_URING + ctx->linux_io_uring = NULL; +#endif + ctx->thread_pool = NULL; qemu_rec_mutex_init(&ctx->lock); timerlistgroup_init(&ctx->tlg, aio_timerlist_notify, ctx); From patchwork Tue May 21 23:52:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aarushi Mehta X-Patchwork-Id: 1103068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CRvUvTEZ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 457t5L6pBmz9s6w for ; Wed, 22 May 2019 09:58:46 +1000 (AEST) Received: from localhost ([127.0.0.1]:32819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEea-000731-Th for incoming@patchwork.ozlabs.org; Tue, 21 May 2019 19:58:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEcT-0005iQ-6l for qemu-devel@nongnu.org; Tue, 21 May 2019 19:56:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTEYw-0001lv-LI for qemu-devel@nongnu.org; Tue, 21 May 2019 19:52:56 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:41193) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTEYw-0001lW-Dy; Tue, 21 May 2019 19:52:54 -0400 Received: by mail-pf1-x443.google.com with SMTP id q17so271697pfq.8; Tue, 21 May 2019 16:52:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rZoSYzQBqztWJbTLj3mPksJxb8vygw+5t40niBgkeQo=; b=CRvUvTEZEC11SbSl6KIwrB9oY7h2SyAZJSHkrnml2UNlijjmOzEG0FXd15TUwl6Efl CiC+db0hspoXJlQLqmSD2fwrOTr+paT6HhL0gxrM200EHAqXvqfaZky6swnN91kH5/qO 0EnL2k6hpQVgzY50TWI83PsEJgggkxmjjJwSuJ5YMyeWYVBGq8s05SZvIEMhxPCdEXgw RQCOh5RLv8PnyD+XAJ5JxYx3JghoBqK7VNfBOPfvwPigte9eVv9i3uknRiyCIO1ZYmUO bqC1i5/DF3tfYcwkvWBdWvuL25oLNcJt0ufD+KlwE4eEPASrA51qqCbaFoevWiunmVEy kCKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rZoSYzQBqztWJbTLj3mPksJxb8vygw+5t40niBgkeQo=; b=AHxv1GlRdnkX/Ja5YKYUzyi+1DacW/V+2J5k/7DAV7KlBwXN0Rq4wbcuff35eJaahd d4RXIT6tp27Fp5TYSvPCvlW4h1fw/a/4xYFGHVOFxltn38dgw97NNi5U7eWw1rBoLbL2 3FQpPfBkZwvcF54ss/sQQkCclGb3EMNsoNFWN/J812zjsBEH2fZIVaG7OCSZjs5PGDH7 3fBw2UNasvPABz/Drw2sQjQySMtoGY5MAN7WkO4VOwz1aF6f1/mSf06CZgKzbAVJeHIL Rj6vyi9Ui1IF++ChjRPFOBa+qazKrFo0yUwKvgj326HJXfN4srSGcdx6Xm0xqqbwXdRX uXAQ== X-Gm-Message-State: APjAAAVjNcvVKLsyodznzkR8uVHR5kN8Mks537RZhBpeS44KiotdD0i2 etCv9rrS268LHGj8akc1/apEVsf1ZqC9uA== X-Google-Smtp-Source: APXvYqwmdIQgI1bW41DrLEY0Y54nKWTpDNK3D/wj5bORvizEmPG2DWVSGEwZ0D8luJ8Zm97zFLwYxQ== X-Received: by 2002:a63:c046:: with SMTP id z6mr86021366pgi.387.1558482772885; Tue, 21 May 2019 16:52:52 -0700 (PDT) Received: from localhost.localdomain ([120.57.118.207]) by smtp.gmail.com with ESMTPSA id e5sm51571752pgh.35.2019.05.21.16.52.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 16:52:52 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 05:22:12 +0530 Message-Id: <20190521235215.31341-7-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521235215.31341-1-mehta.aaru20@gmail.com> References: <20190521235215.31341-1-mehta.aaru20@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [RFC PATCH 6/9] block/io_uring: implements interfaces for io_uring X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saket.sinha89@gmail.com, Julia Suvorova , qemu-block@nongnu.org, Stefan Hajnoczi , Aarushi Mehta Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Aarushi Mehta --- block/Makefile.objs | 2 + block/io_uring.c | 385 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 387 insertions(+) create mode 100644 block/io_uring.c -- 2.17.1 diff --git a/block/Makefile.objs b/block/Makefile.objs index 7a81892a52..262d413c6d 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -18,6 +18,7 @@ block-obj-y += block-backend.o snapshot.o qapi.o block-obj-$(CONFIG_WIN32) += file-win32.o win32-aio.o block-obj-$(CONFIG_POSIX) += file-posix.o block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o +block-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o block-obj-y += null.o mirror.o commit.o io.o create.o block-obj-y += throttle-groups.o block-obj-$(CONFIG_LINUX) += nvme.o @@ -61,5 +62,6 @@ block-obj-$(if $(CONFIG_LZFSE),m,n) += dmg-lzfse.o dmg-lzfse.o-libs := $(LZFSE_LIBS) qcow.o-libs := -lz linux-aio.o-libs := -laio +io_uring.o-libs := -luring parallels.o-cflags := $(LIBXML2_CFLAGS) parallels.o-libs := $(LIBXML2_LIBS) diff --git a/block/io_uring.c b/block/io_uring.c new file mode 100644 index 0000000000..f8b0df90d4 --- /dev/null +++ b/block/io_uring.c @@ -0,0 +1,385 @@ +/* + * Linux io_uring support. + * + * Copyright (C) 2009 IBM, Corp. + * Copyright (C) 2009 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "block/aio.h" +#include "qemu/queue.h" +#include "block/block.h" +#include "block/raw-aio.h" +#include "qemu/event_notifier.h" +#include "qemu/coroutine.h" +#include "qapi/error.h" + +#include + +/* + * Queue size (per-device). + * + * XXX: eventually we need to communicate this to the guest and/or make it + * tunable by the guest. If we get more outstanding requests at a time + * than this we will get EAGAIN from io_submit which is communicated to + * the guest as an I/O error. + */ +#define MAX_EVENTS 128 + +struct qemu_luringcb { + BlockAIOCB common; + Coroutine *co; + LuringState *ctx; + struct io_uring_sqe sqeq; + int ret; + size_t nbytes; + QEMUIOVector *qiov; + bool is_read; + QSIMPLEQ_ENTRY(qemu_luringcb) next; +}; + +typedef struct { + int plugged; + unsigned int in_queue; + unsigned int in_flight; + bool blocked; + QSIMPLEQ_HEAD(, qemu_luringcb) pending; +} LuringQueue; + +struct LuringState { + AioContext *aio_context; + + struct io_uring ring; + EventNotifier e; + + /* io queue for submit at batch. Protected by AioContext lock. */ + LuringQueue io_q; + + /* I/O completion processing. Only runs in I/O thread. */ + QEMUBH *completion_bh; + int event_idx; + int event_max; +}; + +static void ioq_submit(LuringState *s); + +static inline int32_t io_cqe_ret(struct io_uring_cqe *cqe) +{ + return cqe->res; +} + +/** + * io_getevents_peek: + * @ring: io_uring instance + * @cqes: Completion event array + + * Returns the number of completed events and sets a pointer + * on events queue. This function does not update the head and tail. + */ +static inline unsigned int io_getevents_peek(struct io_uring *ring, + struct io_uring_cqe **cqes) +{ + unsigned int nr; + read_barrier(); + struct io_uring_cq *cq_ring = &ring->cq; + unsigned int head = *cq_ring->khead & *cq_ring->kring_mask; + unsigned int tail = *cq_ring->ktail & *cq_ring->kring_mask; + nr = tail - head; + *cqes = ring->cq.cqes; + return nr; +} + +/** + * qemu_luring_process_completions: + * @s: AIO state + * + * Fetches completed I/O requests, consumes cqes and invokes their callbacks. + * + */ +static void qemu_luring_process_completions(LuringState *s) +{ + struct io_uring_cqe *cqes; + qemu_bh_schedule(s->completion_bh); + + while ((s->event_max = io_getevents_peek(&s->ring, &cqes))) { + for (s->event_idx = 0; s->event_idx < s->event_max; ) { + io_uring_cqe_seen(&s->ring, cqes); + + /* Change counters one-by-one because we can be nested. */ + s->io_q.in_flight--; + s->event_idx++; + } + } + + qemu_bh_cancel(s->completion_bh); + + /* + *If we are nested we have to notify the level above that we are done + * by setting event_max to zero, upper level will then jump out of it's + * own `for` loop. If we are the last all counters dropped to zero. + */ + s->event_max = 0; + s->event_idx = 0; +} + +static void qemu_luring_process_completions_and_submit(LuringState *s) +{ + aio_context_acquire(s->aio_context); + qemu_luring_process_completions(s); + + if (!s->io_q.plugged && !QSIMPLEQ_EMPTY(&s->io_q.pending)) { + ioq_submit(s); + } + aio_context_release(s->aio_context); +} + +static void qemu_luring_completion_bh(void *opaque) +{ + LuringState *s = opaque; + + qemu_luring_process_completions_and_submit(s); +} + +static void qemu_luring_completion_cb(EventNotifier *e) +{ + LuringState *s = container_of(e, LuringState, e); + + if (event_notifier_test_and_clear(&s->e)) { + qemu_luring_process_completions_and_submit(s); + } +} + +static bool qemu_luring_poll_cb(void *opaque) +{ + EventNotifier *e = opaque; + LuringState *s = container_of(e, LuringState, e); + struct io_uring_cqe *cqes; + + if (!io_getevents_peek(&s->ring, &cqes)) { + return false; + } + + qemu_luring_process_completions_and_submit(s); + return true; +} + +static const AIOCBInfo luring_aiocb_info = { + .aiocb_size = sizeof(struct qemu_luringcb), +}; + + +static void ioq_init(LuringQueue *io_q) +{ + QSIMPLEQ_INIT(&io_q->pending); + io_q->plugged = 0; + io_q->in_queue = 0; + io_q->in_flight = 0; + io_q->blocked = false; +} + +static void ioq_submit(LuringState *s) +{ + int ret, len; + struct qemu_luringcb *aiocb; + QSIMPLEQ_HEAD(, qemu_luringcb) completed; + + do { + if (s->io_q.in_flight >= MAX_EVENTS) { + break; + } + len = 0; + QSIMPLEQ_FOREACH(aiocb, &s->io_q.pending, next) { + if (s->io_q.in_flight + len++ >= MAX_EVENTS) { + break; + } + struct io_uring_sqe *sqes = io_uring_get_sqe(&s->ring); + if (sqes) { /* Prep sqe for subission */ + memset(sqes, 0, sizeof(*sqes)); + sqes->opcode = aiocb->sqeq.opcode; + sqes->fd = aiocb->sqeq.fd; + if (sqes->opcode == IORING_OP_FSYNC) { + sqes->fsync_flags = aiocb->sqeq.fsync_flags; + } + else { + sqes->off = aiocb->sqeq.off; + sqes->addr = aiocb->sqeq.addr; + sqes->len = aiocb->sqeq.len; + } + QSIMPLEQ_REMOVE_HEAD(&s->io_q.pending, next); + } + } + + ret = io_uring_submit(&s->ring); + if (ret == -EAGAIN) { + break; + } + + s->io_q.in_flight += ret; + s->io_q.in_queue -= ret; + QSIMPLEQ_SPLIT_AFTER(&s->io_q.pending, aiocb, next, &completed); + } while (!QSIMPLEQ_EMPTY(&s->io_q.pending)); + s->io_q.blocked = (s->io_q.in_queue > 0); + + if (s->io_q.in_flight) { + /* + * We can try to complete something just right away if there are + * still requests in-flight. + */ + qemu_luring_process_completions(s); + } +} + +void luring_io_plug(BlockDriverState *bs, LuringState *s) +{ + s->io_q.plugged++; +} + +void luring_io_unplug(BlockDriverState *bs, LuringState *s) +{ + assert(s->io_q.plugged); + if (--s->io_q.plugged == 0 && + !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending)) { + ioq_submit(s); + } +} + +static int luring_do_submit(int fd, struct qemu_luringcb *luringcb, + off_t offset, int type) +{ + LuringState *s = luringcb->ctx; + struct io_uring_sqe *sqes = io_uring_get_sqe(&s->ring); + if (!sqes) { + sqes = &luringcb->sqeq; + QSIMPLEQ_INSERT_TAIL(&s->io_q.pending, luringcb, next); + } + QEMUIOVector *qiov = luringcb->qiov; + + switch (type) { + case QEMU_AIO_WRITE: + io_uring_prep_writev(sqes, fd, qiov->iov, qiov->niov, offset); + break; + case QEMU_AIO_READ: + io_uring_prep_readv(sqes, fd, qiov->iov, qiov->niov, offset); + break; + case QEMU_AIO_FLUSH: + io_uring_prep_fsync(sqes, fd, 0); + break; + default: + fprintf(stderr, "%s: invalid AIO request type 0x%x.\n", + __func__, type); + return -EIO; + } + + s->io_q.in_queue++; + if (!s->io_q.blocked && + (!s->io_q.plugged || + s->io_q.in_flight + s->io_q.in_queue >= MAX_EVENTS)) { + ioq_submit(s); + } + + return 0; +} + +int coroutine_fn luring_co_submit(BlockDriverState *bs, LuringState *s, int fd, + uint64_t offset, QEMUIOVector *qiov, int type) +{ + int ret; + struct qemu_luringcb luringcb = { + .co = qemu_coroutine_self(), + .nbytes = qiov->size, + .ctx = s, + .ret = -EINPROGRESS, + .is_read = (type == QEMU_AIO_READ), + .qiov = qiov, + }; + + ret = luring_do_submit(fd, &luringcb, offset, type); + if (ret < 0) { + return ret; + } + + if (luringcb.ret == -EINPROGRESS) { + qemu_coroutine_yield(); + } + return luringcb.ret; +} + +BlockAIOCB *luring_submit(BlockDriverState *bs, LuringState *s, int fd, + int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, + BlockCompletionFunc *cb, void *opaque, int type) +{ + struct qemu_luringcb *luringcb; + off_t offset = sector_num * BDRV_SECTOR_SIZE; + int ret; + + luringcb = qemu_aio_get(&luring_aiocb_info, bs, cb, opaque); + luringcb->nbytes = nb_sectors * BDRV_SECTOR_SIZE; + luringcb->ctx = s; + luringcb->ret = -EINPROGRESS; + luringcb->is_read = (type == QEMU_AIO_READ); + luringcb->qiov = qiov; + + ret = luring_do_submit(fd, luringcb, offset, type); + if (ret < 0) { + qemu_aio_unref(luringcb); + return NULL; + } + + return &luringcb->common; +} + +void luring_detach_aio_context(LuringState *s, AioContext *old_context) +{ + aio_set_event_notifier(old_context, &s->e, false, NULL, NULL); + qemu_bh_delete(s->completion_bh); + s->aio_context = NULL; +} + +void luring_attach_aio_context(LuringState *s, AioContext *new_context) +{ + s->aio_context = new_context; + s->completion_bh = aio_bh_new(new_context, qemu_luring_completion_bh, s); + aio_set_event_notifier(new_context, &s->e, false, + qemu_luring_completion_cb, + qemu_luring_poll_cb); +} + +LuringState *luring_init(Error **errp) +{ + int rc; + LuringState *s; + s = g_malloc0(sizeof(*s)); + rc = event_notifier_init(&s->e, false); + if (rc < 0) { + error_setg_errno(errp, -rc, "failed to to initialize event notifier"); + goto out_free_state; + } + + struct io_uring *ring = &s->ring; + rc = io_uring_queue_init(MAX_EVENTS, ring, 0); + if (rc < 0) { + error_setg_errno(errp, -rc, "failed to create linux io_uring queue"); + goto out_close_efd; + } + + ioq_init(&s->io_q); + aio_set_fd_handler(s->aio_context, ring->ring_fd, false, + (IOHandler *)qemu_luring_completion_cb, NULL, NULL, &s); + return s; + +out_close_efd: + event_notifier_cleanup(&s->e); +out_free_state: + g_free(s); + return NULL; +} + +void luring_cleanup(LuringState *s) +{ + event_notifier_cleanup(&s->e); + io_uring_queue_exit(&s->ring); + g_free(s); +} From patchwork Tue May 21 23:52:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aarushi Mehta X-Patchwork-Id: 1103067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pCu8Efb1"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 457t3n2f32z9s6w for ; Wed, 22 May 2019 09:57:25 +1000 (AEST) Received: from localhost ([127.0.0.1]:32815 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEdH-0005oB-9q for incoming@patchwork.ozlabs.org; Tue, 21 May 2019 19:57:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEcQ-0005iQ-1n for qemu-devel@nongnu.org; Tue, 21 May 2019 19:56:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTEYz-0001oN-Th for qemu-devel@nongnu.org; Tue, 21 May 2019 19:52:58 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:41490) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTEYz-0001nm-O7; Tue, 21 May 2019 19:52:57 -0400 Received: by mail-pl1-x644.google.com with SMTP id f12so114243plt.8; Tue, 21 May 2019 16:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bhbpjK0JQSStbd9y2pHNMHs1B0N4hnvXiiUW+QxkFQ4=; b=pCu8Efb1/mghqX2oFjPAH4VPTNqfsIR9hradxpChsTVT/5d0/8+HfAS68CZSYhbBnx v3tQDkf7V+dKDe+27A6TDUh6L4E33z6Iyu7+HbBCp5Rn/p748OBHZjQsgdDi8I8ncG53 JZxs1S6GzV/b9TzowH3uDlNbLFEhzla45xV4nNj1xYlSSdifRoejE4M/aGfyoB0m5pWM qso6WN2t7946wCZgjVgZcStcGEMGW8WTAjobb4SJGl/vCuRzRdE4eGvPtySyJBF4IVuz oMeaJATNwytjqJiVt+xKMrSUUL8tCiuFNTtL9wT4KJLhrUo5y5VOW9AVZ2VUxKqz8qFV amgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bhbpjK0JQSStbd9y2pHNMHs1B0N4hnvXiiUW+QxkFQ4=; b=AwoYs3IO/2devXNHsl8PutwNcujwRdIxhiFMiGa7uWgQ/yKwecvKNndCeOOTowijyS /ntxgFWIDlW3ynIXauMAOkSEGpxYs3VoaVWvFfe5t/fr5H7Q5ShoCH4wYidKhWNhiHUW j59vSj/4ODbTDvIc1CP4HUCJEzQ0r0MfxzkNdbF5kYuK6u8/AMUxohx+dx4oHYpBxFaP xHtLwdYbT2Zi4nGi8TID0ckuhvwcFri6Jr6nY59t3oPgChejvsp352gwFnJDtHb1d+sM dE5Y141aoUYgqjQAXn2A0PKPBZssa9FYnxsUtnVvDPvoRV+qgFQ9wnw/Oh0m0L9f7rjD U9iQ== X-Gm-Message-State: APjAAAW3Zd68X46M9Bu4oSAyiB63/XPMB+/OqpaGFIPey+ZMv/gqpfDj +LIJKBtp20gXgwmybjgcBG5jjSs3M2TIyg== X-Google-Smtp-Source: APXvYqzP6YHMsqEBTfn2Aid7dGuCCRcejMNgdc6FiqDH7CCC6K+JdYK7nw8tWg78JhFFvUrbA1QPMg== X-Received: by 2002:a17:902:28c9:: with SMTP id f67mr67267566plb.190.1558482776506; Tue, 21 May 2019 16:52:56 -0700 (PDT) Received: from localhost.localdomain ([120.57.118.207]) by smtp.gmail.com with ESMTPSA id e5sm51571752pgh.35.2019.05.21.16.52.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 16:52:55 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 05:22:13 +0530 Message-Id: <20190521235215.31341-8-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521235215.31341-1-mehta.aaru20@gmail.com> References: <20190521235215.31341-1-mehta.aaru20@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [RFC PATCH 7/9] blockdev: accept io_uring as option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saket.sinha89@gmail.com, Julia Suvorova , qemu-block@nongnu.org, Stefan Hajnoczi , Aarushi Mehta Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Aarushi Mehta --- blockdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/blockdev.c b/blockdev.c index 79fbac8450..b44b9d660d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -386,6 +386,8 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, if ((aio = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(aio, "native")) { *bdrv_flags |= BDRV_O_NATIVE_AIO; + } else if (!strcmp(aio, "io_uring")) { + *bdrv_flags |= BDRV_O_IO_URING; } else if (!strcmp(aio, "threads")) { /* this is the default */ } else { @@ -4547,7 +4549,7 @@ QemuOptsList qemu_common_drive_opts = { },{ .name = "aio", .type = QEMU_OPT_STRING, - .help = "host AIO implementation (threads, native)", + .help = "host AIO implementation (threads, native, io_uring)", },{ .name = BDRV_OPT_CACHE_WB, .type = QEMU_OPT_BOOL, From patchwork Tue May 21 23:52:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aarushi Mehta X-Patchwork-Id: 1103066 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="To+xm8ZK"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 457t3l2DcBz9sBb for ; Wed, 22 May 2019 09:57:23 +1000 (AEST) Received: from localhost ([127.0.0.1]:32809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEdF-0005mU-86 for incoming@patchwork.ozlabs.org; Tue, 21 May 2019 19:57:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTEcK-0005iQ-Og for qemu-devel@nongnu.org; Tue, 21 May 2019 19:56:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTEZ3-0001qJ-Gn for qemu-devel@nongnu.org; Tue, 21 May 2019 19:53:02 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:39720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTEZ3-0001pz-Ax; Tue, 21 May 2019 19:53:01 -0400 Received: by mail-pg1-x544.google.com with SMTP id w22so307547pgi.6; Tue, 21 May 2019 16:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Gj1H7BTnoNvkp48yhjN3bE5xK+DRFHACTLF5AwUVMgo=; b=To+xm8ZK002sUar6/wjXpBl9tAvuy5A9z3jXm+xU0Iiy1w6G+V+tuhY1asF2WrYl5p M6bLvoPHZ8txQm6GoasW7r+YMT3JdZ/o7CaqQVl8/pLus8y/PFUJWntLHsK2RcQ/P/HY zNZoB293MGQcMSMPhk4t4hb/1indCMrdlrczttY88ImRclPnkg58Nu9NXFrNuef1fx5m fJ4Mt2zdiD34o/V3/p1lwhWt9fCf09qk/7NM1z7p7JYH+YccNSdnV+6qlBY+m9qnyEQK r5wIrMydQ//Cj7c9RrZU/BCE0BrrkWZj2HAJY1wHIbseTdh91VDxJWZWzar+b/RNvGSJ PDEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Gj1H7BTnoNvkp48yhjN3bE5xK+DRFHACTLF5AwUVMgo=; b=aW3HjMIGwB9PMbWhSy4DpH19qLqVMEXWnl6lZNBw/2pMwKk7HgRvM10neSL9Xsaqhb YHV+BkRM7TS0jXzr8CIyqbbOuUMQRm9w0qAI0SclWbil89I9nwEXLE8y/2T0SgQkzLYk iRzTk+1p8CuXnQ0FFfdDkPgbw5JQFiCg2xt1pi5OMBtmwFBEk+NcYtOQQTzvUqH6Qsrw etXPqESjZryBhvrSRqczq7BdVY7TDcGplxSFxu8giFhpzxZ+G61l0UU1zz+YGwW4D5/W wRynUAmKyIaPLYwJ4yyEuqVZ/ra1qprxEkuqhfULys5mOUu86d3ZZfhwCUItvy6S5blY qHWQ== X-Gm-Message-State: APjAAAUjoPUc5uQ8e4yz8qUJ3yDpTHJY8HH2y22teIHfjGQ0+FQy7+Kx zxdiSkO40N52J6sH5pi79xLy46RG96OYaA== X-Google-Smtp-Source: APXvYqwT3SUaOiSoAgO2ZqLusTFeI8bEUt+fZ1bj3jgFgR5m/V3mdXzb1zhj9GK+0gU9Igo5Vsh/RQ== X-Received: by 2002:a65:640c:: with SMTP id a12mr23600702pgv.1.1558482780074; Tue, 21 May 2019 16:53:00 -0700 (PDT) Received: from localhost.localdomain ([120.57.118.207]) by smtp.gmail.com with ESMTPSA id e5sm51571752pgh.35.2019.05.21.16.52.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 16:52:59 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 05:22:14 +0530 Message-Id: <20190521235215.31341-9-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521235215.31341-1-mehta.aaru20@gmail.com> References: <20190521235215.31341-1-mehta.aaru20@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [RFC PATCH 8/9] block/file-posix: extends to use with io_uring X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saket.sinha89@gmail.com, Julia Suvorova , qemu-block@nongnu.org, Stefan Hajnoczi , Aarushi Mehta Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Aarushi Mehta --- block/file-posix.c | 63 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/block/file-posix.c b/block/file-posix.c index 1cf4ee49eb..41952217a4 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -154,6 +154,7 @@ typedef struct BDRVRawState { bool has_write_zeroes:1; bool discard_zeroes:1; bool use_linux_aio:1; + bool use_linux_io_uring; bool page_cache_inconsistent:1; bool has_fallocate; bool needs_alignment; @@ -423,7 +424,7 @@ static QemuOptsList raw_runtime_opts = { { .name = "aio", .type = QEMU_OPT_STRING, - .help = "host AIO implementation (threads, native)", + .help = "host AIO implementation (threads, native, io_uring)", }, { .name = "locking", @@ -494,6 +495,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, goto fail; } s->use_linux_aio = (aio == BLOCKDEV_AIO_OPTIONS_NATIVE); + s->use_linux_io_uring = (aio == BLOCKDEV_AIO_OPTIONS_IO_URING); locking = qapi_enum_parse(&OnOffAuto_lookup, qemu_opt_get(opts, "locking"), @@ -557,7 +559,9 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, s->shared_perm = BLK_PERM_ALL; #ifdef CONFIG_LINUX_AIO - /* Currently Linux does AIO only for files opened with O_DIRECT */ + /* + * Currently Linux does AIO only for files opened with O_DIRECT + */ if (s->use_linux_aio) { if (!(s->open_flags & O_DIRECT)) { error_setg(errp, "aio=native was specified, but it requires " @@ -578,6 +582,21 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, goto fail; } #endif /* !defined(CONFIG_LINUX_AIO) */ +#ifdef CONFIG_LINUX_IO_URING + if (s->use_linux_io_uring) { + if (!aio_setup_linux_io_uring(bdrv_get_aio_context(bs), errp)) { + error_prepend(errp, "Unable to use io_uring: "); + goto fail; + } + } +#else + if (s->use_linux_io_uring) { + error_setg(errp, "aio=io_uring was specified, but is not supported " + "in this build."); + ret = -EINVAL; + goto fail; + } +#endif /* !defined(CONFIG_LINUX_IO_URING) */ s->has_discard = true; s->has_write_zeroes = true; @@ -1870,6 +1889,12 @@ static int coroutine_fn raw_co_prw(BlockDriverState *bs, uint64_t offset, LinuxAioState *aio = aio_get_linux_aio(bdrv_get_aio_context(bs)); assert(qiov->size == bytes); return laio_co_submit(bs, aio, s->fd, offset, qiov, type); +#endif +#ifdef CONFIG_LINUX_IO_URING + } else if (s->use_linux_io_uring) { + LuringState *aio = aio_get_linux_io_uring(bdrv_get_aio_context(bs)); + assert(qiov->size == bytes); + return luring_co_submit(bs, aio, s->fd, offset, qiov, type); #endif } } @@ -1907,24 +1932,40 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, static void raw_aio_plug(BlockDriverState *bs) { -#ifdef CONFIG_LINUX_AIO +#if defined CONFIG_LINUX_AIO || defined CONFIG_LINUX_IO_URING BDRVRawState *s = bs->opaque; +#endif +#ifdef CONFIG_LINUX_AIO if (s->use_linux_aio) { LinuxAioState *aio = aio_get_linux_aio(bdrv_get_aio_context(bs)); laio_io_plug(bs, aio); } #endif +#ifdef CONFIG_LINUX_IO_URING + if (s->use_linux_io_uring) { + LuringState *aio = aio_get_linux_io_uring(bdrv_get_aio_context(bs)); + luring_io_plug(bs, aio); + } +#endif } static void raw_aio_unplug(BlockDriverState *bs) { -#ifdef CONFIG_LINUX_AIO +#if defined CONFIG_LINUX_AIO || defined CONFIG_LINUX_IO_URING BDRVRawState *s = bs->opaque; +#endif +#ifdef CONFIG_LINUX_AIO if (s->use_linux_aio) { LinuxAioState *aio = aio_get_linux_aio(bdrv_get_aio_context(bs)); laio_io_unplug(bs, aio); } #endif +#ifdef CONFIG_LINUX_IO_URING + if (s->use_linux_aio) { + LuringState *aio = aio_get_linux_io_uring(bdrv_get_aio_context(bs)); + luring_io_unplug(bs, aio); + } +#endif } static int raw_co_flush_to_disk(BlockDriverState *bs) @@ -1950,8 +1991,10 @@ static int raw_co_flush_to_disk(BlockDriverState *bs) static void raw_aio_attach_aio_context(BlockDriverState *bs, AioContext *new_context) { +#if defined CONFIG_LINUX_AIO || defined CONFIG_LINUX_IO_URING + BDRVRawState *s = bs->opaque; +#endif #ifdef CONFIG_LINUX_AIO - BDRVRawState *s = bs->opaque; if (s->use_linux_aio) { Error *local_err; if (!aio_setup_linux_aio(new_context, &local_err)) { @@ -1961,6 +2004,16 @@ static void raw_aio_attach_aio_context(BlockDriverState *bs, } } #endif +#ifdef CONFIG_LINUX_IO_URING + if (s->use_linux_io_uring) { + Error *local_err; + if (!aio_setup_linux_io_uring(new_context, &local_err)) { + error_reportf_err(local_err, "Unable to use linux io_uring, " + "falling back to thread pool: "); + s->use_linux_io_uring = false; + } + } +#endif } static void raw_close(BlockDriverState *bs)