From nobody Wed May 15 15:27:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1559566608; cv=none; d=zoho.com; s=zohoarc; b=ZHg52WdopH2jxFs82WA7YGA4uWpKLdeWgBOq+LPxY2vley7H20L85Zsu+qnrrdpwloVUyXCw6sHWObf1PvxcK3+LMxgE93Q2ZXZ9wvYwzX3WRYOOF38yvJkOt8KrSkXi6wqjdT6HAKG6iVGFMTc+Y33KjCR/+sgt96EuPEp+M7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559566608; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oqhNazyySRIYrazXPTmYq2UuxaK7vSiSAxrOSw+gi18=; b=AzsacVKD7QlcYQVLyCqMUnwIGjpi2J6ymOk5dEI+ywgH/pIHp856D/masrmvSDi6Lr0ZEXjdWV4xbBKejkT5jX657cn5SvOFxuEw0o+gAPJfsONzyRbMcFWKJAszKAtUDUqvQiWlaZkC2V6zZG/QXYuykjNMAs4pkFvPrOJoZaQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559566608626979.0168833810586; Mon, 3 Jun 2019 05:56:48 -0700 (PDT) Received: from localhost ([127.0.0.1]:34800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmVu-0007ak-Bj for importer@patchew.org; Mon, 03 Jun 2019 08:56:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmKz-0007F5-8u for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:45:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXmEi-0006fZ-4E for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:38:49 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:40546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXmEh-0006dJ-U6; Mon, 03 Jun 2019 08:38:48 -0400 Received: by mail-pf1-x443.google.com with SMTP id u17so10554613pfn.7; Mon, 03 Jun 2019 05:38:47 -0700 (PDT) Received: from localhost.localdomain ([136.233.9.100]) by smtp.gmail.com with ESMTPSA id k14sm34860257pga.5.2019.06.03.05.38.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 05:38:45 -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=oqhNazyySRIYrazXPTmYq2UuxaK7vSiSAxrOSw+gi18=; b=X5zU45LkjQ1Ga143ma3aoN7U20HmsbW/2kKh9+4R0rbAHRbnonp4OVOv0OGsgy4S0q wdDxCbPGdZ6LT+J9MJ1BoChgqlYepuZ8tkGXzmG2GTXSSwbyKYZI/TAQxgXo1KEhDto1 uD8l66qORzJuL3F+fcsLdkToC5GX1E99dVBIqu5EbTfIvyLaKlZ6lFWU6BURBF6VLycF jJ0zwe8CwIsGEZSDACa1UjrDJ/OxjJrg9ngai5LzdHxAEHZKXTg3IDCiM32NJAx+PaIv 9oZYgzMGKDroRK+uNPxNqnIJ6bvJoSBh7Ni3FgDmUbhfFpvThfYP0jqbpwmqH4EpygwE z0LQ== 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=oqhNazyySRIYrazXPTmYq2UuxaK7vSiSAxrOSw+gi18=; b=mRK4/EM3iTvcfhG0DtHJ379LvqveuENioNobNjWUbGdIZc1LpxdfKmRxUQWI6n5QCx uyv/Hs0LsycLXw54ywMyesCVDa/g2nyuc0+a44xiC3jEHl/RSvCRuHQOcq5LC9GtAr8j zzWGIKt3+PBZP895LYsU9KjyaPLwmg2/AuMbRjHuqXjZoQcLzkhP3/kudQ9fmV189aBx SXVZbnvEoSjvnkpBBoQhdczyoyIL1SB72WU4TtsLlSOBcTXM2qANvHSC1Dagx6jrCQGH OgOgTMV93QKBUbFn84SQMPiSXUkhsqTdeBZzVQ5bNcdy0YL3dVohTZwBofNiCmyJNgOP 7KGQ== X-Gm-Message-State: APjAAAVrcttFCDgRFv31I53isl+z5RL0bUKeb/LbNsl5bS5l6uxOLqTG JfkzTRB1H+achftrzCgI0U/mNwtc2hyP2w== X-Google-Smtp-Source: APXvYqwVrX5NKCCiwYQBLkeR4n8TGYYjFuVKRa2YBenJ8q8wOn80zybnckBdgHgmBR0wPF8xIiDQpA== X-Received: by 2002:a65:620d:: with SMTP id d13mr28332716pgv.109.1559565526565; Mon, 03 Jun 2019 05:38:46 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 18:08:15 +0530 Message-Id: <20190603123823.32661-2-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603123823.32661-1-mehta.aaru20@gmail.com> References: <20190603123823.32661-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] [PATCH v4 1/9] configure: permit use of 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reviewed-by: Stefan Hajnoczi Signed-off-by: Aarushi Mehta Reviewed-by: Maxim Levitsky --- configure | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/configure b/configure index 6cdcfb2dc3..cb49ef0fcc 100755 --- a/configure +++ b/configure @@ -365,6 +365,7 @@ xen=3D"" xen_ctrl_version=3D"" xen_pci_passthrough=3D"" linux_aio=3D"" +linux_io_uring=3D"" cap_ng=3D"" attr=3D"" libattr=3D"" @@ -1266,6 +1267,10 @@ for opt do ;; --enable-linux-aio) linux_aio=3D"yes" ;; + --disable-linux-io-uring) linux_io_uring=3D"no" + ;; + --enable-linux-io-uring) linux_io_uring=3D"yes" + ;; --disable-attr) attr=3D"no" ;; --enable-attr) attr=3D"yes" @@ -1784,6 +1789,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: vde support for vde network netmap support for netmap network linux-aio Linux AIO support + linux-io-uring Linux io_uring support cap-ng libcap-ng support attr attr and xattr support vhost-net vhost-net kernel acceleration support @@ -3973,6 +3979,21 @@ EOF linux_aio=3Dno fi fi +########################################## +# linux-io-uring probe + +if test "$linux_io_uring" !=3D "no" ; then + if $pkg_config liburing; then + linux_io_uring_cflags=3D$($pkg_config --cflags liburing) + linux_io_uring_libs=3D$($pkg_config --libs liburing) + linux_io_uring=3Dyes + else + if test "$linux_io_uring" =3D "yes" ; then + feature_not_found "linux io_uring" "Install liburing devel" + fi + linux_io_uring=3Dno + fi +fi =20 ########################################## # TPM emulation is only on POSIX @@ -6396,6 +6417,7 @@ echo "PIE $pie" echo "vde support $vde" echo "netmap support $netmap" echo "Linux AIO support $linux_aio" +echo "Linux io_uring support $linux_io_uring" echo "ATTR/XATTR support $attr" echo "Install blobs $blobs" echo "KVM support $kvm" @@ -6876,6 +6898,11 @@ fi if test "$linux_aio" =3D "yes" ; then echo "CONFIG_LINUX_AIO=3Dy" >> $config_host_mak fi +if test "$linux_io_uring" =3D "yes" ; then + echo "CONFIG_LINUX_IO_URING=3Dy" >> $config_host_mak + echo "LINUX_IO_URING_CFLAGS=3D$linux_io_uring_cflags" >> $config_host_mak + echo "LINUX_IO_URING_LIBS=3D$linux_io_uring_libs" >> $config_host_mak +fi if test "$attr" =3D "yes" ; then echo "CONFIG_ATTR=3Dy" >> $config_host_mak fi --=20 2.17.1 From nobody Wed May 15 15:27:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1559566451; cv=none; d=zoho.com; s=zohoarc; b=NQAGkckncVxKdbmll1jjOfTkJPneOyuUusvxnu+gPKM8WVNYXtb4OeHs7XAsucjcTI8uwLpZaCGtihaX8beIVbMZnomIaiW9tzNLT3lWBy8k7Es2LFkGvb4H3sqQgaowHXXUTVf/9tdQMSmL1x7E5mRb9Oq9G2ErmvKROE8kJv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559566451; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LtyXP6pU3wLcU44kzIV+V39Txu8qaO7ubJvSXbC66PQ=; b=ETb0uIpxOPQO2Wvehr59kI4sZxfAGsVm1HZWP3v6AlyQ/5Rz0eBO4AxBygZp0cMwWin5AqKYYXilMBVRPTvmhG+iREClxqntITXJYWw8dfr5PsGm7coNPxw5NlLBr+BOb9c3lX+OBkmPi8Z05tbhPBhtDye+/aT+lypJlFedWSw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559566451898823.8743458048536; Mon, 3 Jun 2019 05:54:11 -0700 (PDT) Received: from localhost ([127.0.0.1]:34736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmTX-0005ZY-Rb for importer@patchew.org; Mon, 03 Jun 2019 08:54:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmKw-0007F5-9U for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXmEp-0006zQ-2e for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:38:55 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:43245) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXmEo-0006xT-Su; Mon, 03 Jun 2019 08:38:55 -0400 Received: by mail-pl1-x642.google.com with SMTP id cl9so1840391plb.10; Mon, 03 Jun 2019 05:38:54 -0700 (PDT) Received: from localhost.localdomain ([136.233.9.100]) by smtp.gmail.com with ESMTPSA id k14sm34860257pga.5.2019.06.03.05.38.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 05:38:52 -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=LtyXP6pU3wLcU44kzIV+V39Txu8qaO7ubJvSXbC66PQ=; b=NyAZuyzTenzksxLOolD3RsBvaYcx7jzYHKUUP4R2rT2R8NpjAZinT34jHYbkhky/Jf YyOk+M/dy1qt5sXpCjoPa1IbVDj3y7pqnN+lesckl+jdIlYBCd025kM9aJceRjfKpcBL EFDP7738cKvid4BT0kES+xRBSKLuMNbEKNYSwiNut7aRyPbE+YehnjfmAZ5dVAZL8wK4 VTIJNpsvU8BKKf34l5NZ6cwNIYXeR9yeUYFbQPZTlB5i5hC7im487OA1DIXDIDtpBoBy yKLbU5FprvNPJd/uZNvtGHWoGxyPi4DaAAgGmNSCBU5/SHl3n32U90jiZLe9s6nhmkoK qm9w== 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=LtyXP6pU3wLcU44kzIV+V39Txu8qaO7ubJvSXbC66PQ=; b=eNNj8oGPkAJ47tmaPbDA5wBMJfzMF9Fst1031tFumrtJxsVl0RVqQu39wPGG2T6cUS UaER9lYW+BU0dIpHmMFGpySH1mZqrQDjgoc0vXHdMKjxe3RTb2jXW6wHOHEBnqMe5qCK jYIFP3FpBIgL+NhJaoksZ/1hd9snqYdQP/wxkvVYwsRHK823BeqKte1QIffas1HangNY jUDGdIMH8z+x+tuxhN3QY2obub5Ekr0lzQbbGhhC6M4m3ZauoDRmgtT8v5ak/PUw36/7 FrJu1z48Cbcld/EIHRUui+8uFDujWuhqJL+2zEKWZoCC3BwkEhjwmFjMKa3expcEY5Yp A6gw== X-Gm-Message-State: APjAAAXDp0aEBj+ov7RpC8izygkobaZfDXG1GtU3yzLC9N7UbjgXOnzs 7p9gvXuH8WLi9Y2ucaz0KGuyz4a8fCDvvg== X-Google-Smtp-Source: APXvYqwa/HzZA0B2BEH39pEgNt2LZ5ZMmI/6BjfqKXy38aLL4ob/Sv18Emfis3KytOb4+XiEhxhK0w== X-Received: by 2002:a17:902:7043:: with SMTP id h3mr29080981plt.292.1559565533487; Mon, 03 Jun 2019 05:38:53 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 18:08:16 +0530 Message-Id: <20190603123823.32661-3-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603123823.32661-1-mehta.aaru20@gmail.com> References: <20190603123823.32661-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] [PATCH v4 2/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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Option only enumerates for hosts that support it. Signed-off-by: Aarushi Mehta Reviewed-by: Maxim Levitsky --- qapi/block-core.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 1defcde048..db7eedd058 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2792,11 +2792,13 @@ # # @threads: Use qemu's thread pool # @native: Use native AIO backend (only Linux and Windows) +# @io_uring: Use linux io_uring (since 4.1) # # Since: 2.9 ## { 'enum': 'BlockdevAioOptions', - 'data': [ 'threads', 'native' ] } + 'data': [ 'threads', 'native', + { 'name': 'io_uring', 'if': 'defined(CONFIG_LINUX_IO_URING)' }= ] } =20 ## # @BlockdevCacheOptions: --=20 2.17.1 From nobody Wed May 15 15:27:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1559566270; cv=none; d=zoho.com; s=zohoarc; b=W1bPxNpyJC+Fw1nDKLYAywS4/XcZIys6cS5kbRZ3GUqVUZtbZaeaAil1/R9VmwlM67kwR5cmxe6hf7B9ViU6yTwwi01chyNa3YQZ6jYYsX6QfTgGt+lmNqwOMwXqJyDhJXqx2/WokhaXY5gaux/c8lFcUGpPKFxqGmXjHlcxYEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559566270; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aXswJJxpFfrIA7pwp5302r5rWLg/Xr77T/ARm6SPMIw=; b=ZArTK4gV2LFAx0yJvDsQ6jVLo0UpwrjB7DQ4KUkOqiYALZ/8UqPezdKflQ8O0s8jgViLn3ZjQmsf3fWQjZaRJ30aSWVbGgpBoya+yW9ZS71EqMG3dvuGWilA5CojcuQwx9IILNyIwdzjqe8l68UEb7PN9DoQsbt1vbyhx2o5CBo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559566270657848.6533169675284; Mon, 3 Jun 2019 05:51:10 -0700 (PDT) Received: from localhost ([127.0.0.1]:34692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmQR-0002vl-Je for importer@patchew.org; Mon, 03 Jun 2019 08:50:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmKu-0007F5-1C for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:45:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXmEv-0007Gp-H9 for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:39:02 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:39474) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXmEv-0007F2-BQ; Mon, 03 Jun 2019 08:39:01 -0400 Received: by mail-pg1-x542.google.com with SMTP id 196so8225134pgc.6; Mon, 03 Jun 2019 05:39:01 -0700 (PDT) Received: from localhost.localdomain ([136.233.9.100]) by smtp.gmail.com with ESMTPSA id k14sm34860257pga.5.2019.06.03.05.38.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 05:38:59 -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=aXswJJxpFfrIA7pwp5302r5rWLg/Xr77T/ARm6SPMIw=; b=ArvqdYK/5FpDAWjfcJN9tc1UQvGEl8RNWETXrGacSHoDfXIAZHAimIzIt0jOahP6bJ YKJgIKvOpZnLf/xyLJKSkM+CGQi1CLS9LttFujcZWaFa5PpwuCIxFH3dK9njKAzvp+um 1c2FoM6q0tDJocU4BRXFDHaG5CGLyQyusUa8Me3L8TEIZGL0ZBPr18Cv32xHUVst6dXy QhaAAcNE5f4JyYB+DrhUnSeqIwyum1awOF7zOv5cv95cKU2J21IQXAhd9/xokdisN7dw PQVl8zpgWTb4v6jio1JLiv6cwS0BIImfDEA+3or7Un77b3yxawbpRk9kt7XcB1Oc6YWR alcg== 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=aXswJJxpFfrIA7pwp5302r5rWLg/Xr77T/ARm6SPMIw=; b=hljDC4MI+72nnLY4pLHMd5mw5wOrQC/TtxQKnNdZ/HbAp7fwbeB8Z1qriKzFVEw6Zn 9CRBnqXN/993b2Z3HasP4FR28tWvs6NdvIOLt0fsOl+4Ev2vv8vEf7nC1iwEvKo7RP1d QWPkk4G+qlpLQexXGzvwr49XyMkmE2jseRWlQO5CI/hRHQVysNrV645rSr/9CKl0AGBV O/1gUaPjRPa2KsYEem/7hedj22EGWrJTOanKLWaox3pKc2sJUWDON6j6lteHNFZ11rhr ocHhVE/sWg9Wzu9n1jwYW2lNPeXnHj+zavrNYpL+fkA5gSTNvKpGzkeCPJtiJEZMK/xB Qp1w== X-Gm-Message-State: APjAAAXIjaFxc6BbyO2jNx0+4KBWggRU+L+b1/DAXJxBotHXXb9cY6Wd Susqrr4tHhfoHiMDBCDCVaIcz5oWeC207g== X-Google-Smtp-Source: APXvYqxwo6a5ZCvVa0+MyJNgh/c79SXi2mFmEw74EQ5TlPYbV65T1Fx5+KuclSKWix3EurXpKOej8g== X-Received: by 2002:a17:90a:a385:: with SMTP id x5mr6474538pjp.76.1559565540039; Mon, 03 Jun 2019 05:39:00 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 18:08:17 +0530 Message-Id: <20190603123823.32661-4-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603123823.32661-1-mehta.aaru20@gmail.com> References: <20190603123823.32661-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::542 Subject: [Qemu-devel] [PATCH v4 3/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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Aarushi Mehta Reviewed-by: Stefan Hajnoczi Reviewed-by: Maxim Levitsky --- include/block/block.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/block/block.h b/include/block/block.h index 9b083e2bca..60f7c6c01c 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 p= ool */ =20 #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH) =20 --=20 2.17.1 From nobody Wed May 15 15:27:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1559566285; cv=none; d=zoho.com; s=zohoarc; b=iTU3Cy3Jd+6oyG1GeIMm2UGFhGyZ52zatHllOMF9TuW5psU/B2TAMhvo3Q7R7eaFKXnSayU6dfNR0mDVC6t6MLDND+13T9o06tPl0LcowlswETuSoSSI7aSJ5viRdwJCba0nVGlZQPgn6DXGDzFu4SQVQGq4789fY+jUSznc5HU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559566285; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=G3ZSglryhsNUt/h90DmGkj8h+92M8tgHTqIsTGOKnJ4=; b=VbgescCm07IPxzAPtM9fRzFSqLI1y3dHEEGFbtZi2dQdmIDDQly45jSGTU1fz5F3S4my8HyZ8vJK7y457lMDDgqAj77QEiBMV1YZLFn/zcnGh28CmVekzX+nptoS6M2Nv6MXRC3Y3q0uo7iBJSS3bMELJ4ui1Ra2WTQz63o/6q8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559566285330548.2924046798602; Mon, 3 Jun 2019 05:51:25 -0700 (PDT) Received: from localhost ([127.0.0.1]:34702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmQm-0003C1-4R for importer@patchew.org; Mon, 03 Jun 2019 08:51:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmKs-0007F5-13 for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:45:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXmF2-0007aD-9D for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:39:10 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:37824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXmF2-0007Y3-1I; Mon, 03 Jun 2019 08:39:08 -0400 Received: by mail-pg1-x542.google.com with SMTP id 20so8228022pgr.4; Mon, 03 Jun 2019 05:39:07 -0700 (PDT) Received: from localhost.localdomain ([136.233.9.100]) by smtp.gmail.com with ESMTPSA id k14sm34860257pga.5.2019.06.03.05.39.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 05:39:05 -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=G3ZSglryhsNUt/h90DmGkj8h+92M8tgHTqIsTGOKnJ4=; b=bbQqmj0M7cOWbQWWIPWYPxGWnOGdmAY3VcDaM2ex39NkPAZEMXi5LUPRV6VdCZIA59 j8Mv+hn/T/T6cZOtrDOSnus2XUNSzWYJTTpBAwdrjzFV4dk61s4j9egPO0v7zKmuinYR X7hK0r6HtNp2qctI1xldnIPp2PYILG/xfA/RLq5g+N6XHSYLEMp6HkIF2c1GbEdjOG+2 /wBdJlN7ZlSAEKljgf6MEtbOEnn3BR58mlCzBDGSfeUAa/d5Ev7jjGAeVkdqnfALLrdC kLD6OFk7XKoht4UNS9/qgOQ/QK8QG9VsLIJLyp+rfv3Yn/zDKHjR6CTzQB2LmPKMkX5N 3ZmQ== 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=G3ZSglryhsNUt/h90DmGkj8h+92M8tgHTqIsTGOKnJ4=; b=cel83nhjVwLCo34cxh1lhjLj1mGga/zvQUYBzLwvE8+IB02jf1Ig02FsiH2Yqhmw9m oxA+ClAz+VfQUNIE2xkPuFPjJGgBOdQLzRKRNdfeLlql+r8Z3oq8LCqlYUNoYb/if//I tY6fKzf3nnvNNVZNZgvFzmaIpPJdykTDpF9gUT5FC8/XYb1qpXdFi+4yPxIjKqBlnDtM baLR0ZA+QyE0VJ0YFFdM/mrWHDW2zmZUUaRgjSFGJdK3JYxtaazEcBXw0IWIRkBsbbKz egRzEWU6oM2ykJVoBC80CR6Ak6I5Nt2JVQ1SmFY3zEoPDsA9JAHNnkbnugip2mSCa6m4 aR/Q== X-Gm-Message-State: APjAAAXSry8/eVIB/HKi2XtMdlggG0kn17/hIN7d9r7ShlYS4nZXuhkF AK32NypGt7/1tCy/1ZKhEfzhtaychO/Q1Q== X-Google-Smtp-Source: APXvYqwPmxjEzBQBnHbLmH4nUxGRfPhlFVJkEFZkGI7DolvYFYe7Af9idnkMv1chUbPP/m3eUNa07w== X-Received: by 2002:a65:6551:: with SMTP id a17mr25787591pgw.1.1559565546585; Mon, 03 Jun 2019 05:39:06 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 18:08:18 +0530 Message-Id: <20190603123823.32661-5-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603123823.32661-1-mehta.aaru20@gmail.com> References: <20190603123823.32661-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::542 Subject: [Qemu-devel] [PATCH v4 4/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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Aborts when sqes cannot be set as sqes cannot be returned to ring. Signed-off-by: Aarushi Mehta --- MAINTAINERS | 7 + block/Makefile.objs | 3 + block/io_uring.c | 315 ++++++++++++++++++++++++++++++++++++++++ include/block/aio.h | 16 +- include/block/raw-aio.h | 12 ++ 5 files changed, 352 insertions(+), 1 deletion(-) create mode 100644 block/io_uring.c diff --git a/MAINTAINERS b/MAINTAINERS index a96829ea83..dcaddec21f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2515,6 +2515,13 @@ F: block/file-posix.c F: block/file-win32.c F: block/win32-aio.c =20 +Linux io_uring +M: Aarushi Mehta +R: Stefan Hajnoczi +L: qemu-block@nongnu.org +S: Maintained +F: block/io_uring.c + qcow2 M: Kevin Wolf M: Max Reitz diff --git a/block/Makefile.objs b/block/Makefile.objs index ae11605c9f..8fde7a23a5 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -18,6 +18,7 @@ block-obj-y +=3D block-backend.o snapshot.o qapi.o block-obj-$(CONFIG_WIN32) +=3D file-win32.o win32-aio.o block-obj-$(CONFIG_POSIX) +=3D file-posix.o block-obj-$(CONFIG_LINUX_AIO) +=3D linux-aio.o +block-obj-$(CONFIG_LINUX_IO_URING) +=3D io_uring.o block-obj-y +=3D null.o mirror.o commit.o io.o create.o block-obj-y +=3D throttle-groups.o block-obj-$(CONFIG_LINUX) +=3D nvme.o @@ -61,5 +62,7 @@ block-obj-$(if $(CONFIG_LZFSE),m,n) +=3D dmg-lzfse.o dmg-lzfse.o-libs :=3D $(LZFSE_LIBS) qcow.o-libs :=3D -lz linux-aio.o-libs :=3D -laio +io_uring.o-cflags :=3D $(LINUX_IO_URING_CFLAGS) +io_uring.o-libs :=3D $(LINUX_IO_URING_LIBS) parallels.o-cflags :=3D $(LIBXML2_CFLAGS) parallels.o-libs :=3D $(LIBXML2_LIBS) diff --git a/block/io_uring.c b/block/io_uring.c new file mode 100644 index 0000000000..536a9fbe87 --- /dev/null +++ b/block/io_uring.c @@ -0,0 +1,315 @@ +/* + * Linux io_uring support. + * + * Copyright (C) 2009 IBM, Corp. + * Copyright (C) 2009 Red Hat, Inc. + * Copyright (C) 2019 Aarushi Mehta + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include +#include "qemu-common.h" +#include "block/aio.h" +#include "qemu/queue.h" +#include "block/block.h" +#include "block/raw-aio.h" +#include "qemu/coroutine.h" +#include "qapi/error.h" + +#define MAX_EVENTS 128 + +typedef struct LuringAIOCB { + Coroutine *co; + struct io_uring_sqe sqeq; + ssize_t ret; + QEMUIOVector *qiov; + bool is_read; + QSIMPLEQ_ENTRY(LuringAIOCB) next; +} LuringAIOCB; + +typedef struct LuringQueue { + int plugged; + unsigned int in_queue; + unsigned int in_flight; + bool blocked; + QSIMPLEQ_HEAD(, LuringAIOCB) sq_overflow; +} LuringQueue; + +typedef struct LuringState { + AioContext *aio_context; + + struct io_uring ring; + + /* 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; +} LuringState; + +/** + * ioq_submit: + * @s: AIO state + * + * Queues pending sqes and submits them + * + */ +static int ioq_submit(LuringState *s); + +/** + * qemu_luring_process_completions: + * @s: AIO state + * + * Fetches completed I/O requests, consumes cqes and invokes their callbac= ks. + * + */ +static void qemu_luring_process_completions(LuringState *s) +{ + struct io_uring_cqe *cqes; + int ret; + + /* + * Request completion callbacks can run the nested event loop. + * Schedule ourselves so the nested event loop will "see" remaining + * completed requests and process them. Without this, completion + * callbacks that wait for other requests using a nested event loop + * would hang forever. + */ + qemu_bh_schedule(s->completion_bh); + + while (io_uring_peek_cqe(&s->ring, &cqes) =3D=3D 0) { + if (!cqes) { + break; + } + LuringAIOCB *luringcb =3D io_uring_cqe_get_data(cqes); + read_barrier(); + ret =3D cqes->res; + + if (ret =3D=3D luringcb->qiov->size) { + ret =3D 0; + } else if (ret >=3D 0) { + /* Short Read/Write */ + if (luringcb->is_read) { + /* Read, pad with zeroes */ + qemu_iovec_memset(luringcb->qiov, ret, 0, + luringcb->qiov->size - ret); + } else { + ret =3D -ENOSPC;; + } + } + luringcb->ret =3D ret; + + io_uring_cqe_seen(&s->ring, cqes); + cqes =3D NULL; + /* Change counters one-by-one because we can be nested. */ + s->io_q.in_flight--; + + /* + * If the coroutine is already entered it must be in ioq_submit() + * and will notice luringcb->ret has been filled in when it + * eventually runs later. Coroutines cannot be entered recursively + * so avoid doing that! + */ + if (!qemu_coroutine_entered(luringcb->co)) { + aio_co_wake(luringcb->co); + } + } + qemu_bh_cancel(s->completion_bh); +} + +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 && !s->io_q.in_queue) { + ioq_submit(s); + } + aio_context_release(s->aio_context); +} + +static void qemu_luring_completion_bh(void *opaque) +{ + LuringState *s =3D opaque; + qemu_luring_process_completions_and_submit(s); +} + +static void qemu_luring_completion_cb(void *opaque) +{ + LuringState *s =3D opaque; + qemu_luring_process_completions_and_submit(s); +} + +static void ioq_init(LuringQueue *io_q) +{ + QSIMPLEQ_INIT(&io_q->sq_overflow); + io_q->plugged =3D 0; + io_q->in_queue =3D 0; + io_q->in_flight =3D 0; + io_q->blocked =3D false; +} + +static int ioq_submit(LuringState *s) +{ + int ret =3D 0; + LuringAIOCB *luringcb, *luringcb_next; + + while (s->io_q.in_queue > 0) { + QSIMPLEQ_FOREACH_SAFE(luringcb, &s->io_q.sq_overflow, next, + luringcb_next) { + struct io_uring_sqe *sqes =3D io_uring_get_sqe(&s->ring); + if (!sqes) { + break; + } + /* Prep sqe for submission */ + *sqes =3D luringcb->sqeq; + QSIMPLEQ_REMOVE_HEAD(&s->io_q.sq_overflow, next); + } + ret =3D io_uring_submit(&s->ring); + /* Prevent infinite loop if submission is repeatedly refused */ + if (ret <=3D 0) { + if (ret =3D=3D -EAGAIN) { + continue; + } + break; + } + s->io_q.in_flight +=3D ret; + s->io_q.in_queue -=3D ret; + } + s->io_q.blocked =3D (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); + } + return ret; +} + +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 =3D=3D 0 && + !s->io_q.blocked && s->io_q.in_queue > 0) { + ioq_submit(s); + } +} + +/** + * luring_do_submit: + * @fd: file descriptor for I/O + * @luringcb: AIO control block + * @s: AIO state + * @offset: offset for request + * @type: type of request + * + * Fetches sqes from ring, adds to pending queue and preps them + * + */ +static int luring_do_submit(int fd, LuringAIOCB *luringcb, LuringState *s, + uint64_t offset, int type) +{ + struct io_uring_sqe *sqes =3D io_uring_get_sqe(&s->ring); + if (!sqes) { + sqes =3D &luringcb->sqeq; + QSIMPLEQ_INSERT_TAIL(&s->io_q.sq_overflow, luringcb, next); + } + + switch (type) { + case QEMU_AIO_WRITE: + io_uring_prep_writev(sqes, fd, luringcb->qiov->iov, + luringcb->qiov->niov, offset); + break; + case QEMU_AIO_READ: + io_uring_prep_readv(sqes, fd, luringcb->qiov->iov, + luringcb->qiov->niov, offset); + break; + case QEMU_AIO_FLUSH: + io_uring_prep_fsync(sqes, fd, 0); + break; + default: + fprintf(stderr, "%s: invalid AIO request type, aborting 0x%x.\n", + __func__, type); + abort(); + } + io_uring_sqe_set_data(sqes, luringcb); + s->io_q.in_queue++; + + if (!s->io_q.blocked && + (!s->io_q.plugged || + s->io_q.in_flight + s->io_q.in_queue >=3D MAX_EVENTS)) { + return ioq_submit(s); + } + return 0; +} + +int coroutine_fn luring_co_submit(BlockDriverState *bs, LuringState *s, in= t fd, + uint64_t offset, QEMUIOVector *qiov, int t= ype) +{ + int ret; + LuringAIOCB luringcb =3D { + .co =3D qemu_coroutine_self(), + .ret =3D -EINPROGRESS, + .qiov =3D qiov, + .is_read =3D (type =3D=3D QEMU_AIO_READ), + }; + + ret =3D luring_do_submit(fd, &luringcb, s, offset, type); + if (ret < 0) { + return ret; + } + + if (luringcb.ret =3D=3D -EINPROGRESS) { + qemu_coroutine_yield(); + } + return luringcb.ret; +} + +void luring_detach_aio_context(LuringState *s, AioContext *old_context) +{ + aio_set_fd_handler(old_context, s->ring.ring_fd, false, NULL, NULL, NU= LL, + s); + qemu_bh_delete(s->completion_bh); + s->aio_context =3D NULL; +} + +void luring_attach_aio_context(LuringState *s, AioContext *new_context) +{ + s->aio_context =3D new_context; + s->completion_bh =3D aio_bh_new(new_context, qemu_luring_completion_bh= , s); + aio_set_fd_handler(s->aio_context, s->ring.ring_fd, false, + qemu_luring_completion_cb, NULL, NULL, s); +} + +LuringState *luring_init(Error **errp) +{ + int rc; + LuringState *s; + s =3D g_malloc0(sizeof(*s)); + struct io_uring *ring =3D &s->ring; + rc =3D io_uring_queue_init(MAX_EVENTS, ring, 0); + if (rc < 0) { + error_setg_errno(errp, errno, "failed to init linux io_uring ring"= ); + g_free(s); + return NULL; + } + + ioq_init(&s->io_q); + return s; + +} + +void luring_cleanup(LuringState *s) +{ + io_uring_queue_exit(&s->ring); + g_free(s); +} diff --git a/include/block/aio.h b/include/block/aio.h index 0ca25dfec6..9da3fd9793 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; =20 struct AioContext { GSource source; @@ -118,11 +119,19 @@ struct AioContext { struct ThreadPool *thread_pool; =20 #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 Linux io_uring. Uses aio_context_acquire/release for + * locking. + */ + struct LuringState *linux_io_uring; +#endif =20 /* 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); =20 +/* 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..1885b086e6 100644 --- a/include/block/raw-aio.h +++ b/include/block/raw-aio.h @@ -58,6 +58,18 @@ void laio_attach_aio_context(LinuxAioState *s, AioContex= t *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, in= t fd, + uint64_t offset, QEMUIOVector *qiov, int t= ype); +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 =20 #ifdef _WIN32 typedef struct QEMUWin32AIOState QEMUWin32AIOState; --=20 2.17.1 From nobody Wed May 15 15:27:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1559566057; cv=none; d=zoho.com; s=zohoarc; b=hXTUOccLVl+RiApIXQ97jwQjalMfH+fnSNa09XEuQtofLtrirMUO0wIF+IgnbkAxYDXwcHR5jhUK13+DA9AiWST7KvKbZJuRC7iVqfWTgPkAIIwdT34bRr0s7s9g80eAoEKC8AnzDAw4pnNeJK20JTtotVy3/ACj757u++vmo+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559566057; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=0zPchgJi6YzPvMMFd4UjDrg2UEfvsfzn5zpjZoO+8yc=; b=KGgsHI/TV3NsPsg/6HOXTQ3eKnvEwNA6Qgrr283qLGnwSWzDAfdmR8xuacAVAIHIRjAWeQkDEZt+KhBMo4VRx54R1UXdKDCZ3WJfjyCtEjMo32iZBh2x9X/LWucXzHjCT9DicJt6frRDk8REEeaq/cSwWfVQVOQ2/elBtX+yMPg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155956605719773.30622878818394; Mon, 3 Jun 2019 05:47:37 -0700 (PDT) Received: from localhost ([127.0.0.1]:34623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmN9-0000HG-R8 for importer@patchew.org; Mon, 03 Jun 2019 08:47:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmKg-0007Hi-3w for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:45:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXmF9-0007ux-BW for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:39:16 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:34575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXmF9-0007sj-0n; Mon, 03 Jun 2019 08:39:15 -0400 Received: by mail-pg1-x541.google.com with SMTP id h2so4981933pgg.1; Mon, 03 Jun 2019 05:39:14 -0700 (PDT) Received: from localhost.localdomain ([136.233.9.100]) by smtp.gmail.com with ESMTPSA id k14sm34860257pga.5.2019.06.03.05.39.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 05:39:13 -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=0zPchgJi6YzPvMMFd4UjDrg2UEfvsfzn5zpjZoO+8yc=; b=GN+JDPE5sHE8TneYV18T0327b0x23aI20VULiCdCbsuYnRb0diJix1TQA49Fte/pei W55EMiRlLx8E78r4ezDG2TaCisS3zaH0Vf5nTfkip193qxBDjL1zT8LQmU4UADDCgkfY bV5DS+fMC0gIQ2WyqV5Httf60uMe4CKp0VhIsZvGtGtOuwt0QorIQ3AKpsgDGt9TWzOW 5tW+v8IyKEQ5DFPrT6kjHrURCuIWdJwwXL+lqjewVKn65yW2ZU5lsiNrb+nsxAUwPZUk JotK/gvRt9Soruci7N1MrMrddPLVYHJj1f6Hg2J3cZLkZzrvIBihW4i/GbTdU6QR7PO3 TuRg== 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=0zPchgJi6YzPvMMFd4UjDrg2UEfvsfzn5zpjZoO+8yc=; b=O3J3+8BcHhvRs5gZdcGHTMgroqKwKfovhnoJFTpsvfJJ3SZSoSE4/85z81qfISfsep cWonka+65U+NmxZV0k28KEAQQFg36cUh41n+ItkOaF3xamJ4iQXDimdcQI9yTK9VhNso yWs1SNpBLGCusrO3tNfjW3ZHVJuDWH5HQYEboFPXIHMLz/J2qc32zV6O32AEeDTQIhAG DGHMneTQee9Gurzr0F/bQeiiZNmo3ZYRPJYhDA9I9exXB44MYAHseSAW2+zrZhSv3UwY ZvOQsSIGmDOykQxUCgXj+NNFMzGbputFxqHafiFf1krSbDWy7qARjJHnV0IEucXYNwx6 kyVw== X-Gm-Message-State: APjAAAVbbiadK0eQHMlqvkGSTWAAtTxbkRak6Gf464GuvY+gAQg7H5CH hZPkaWnFzZUQ3Py62Cux4MQZ1P5b/zgG+A== X-Google-Smtp-Source: APXvYqwgzY4p26lmGP+Vl/Aqmqdi7qNa1/vcxHVIypoU36BDXIAFg7LTiMk9WGz/D5WgX/IB6+3vBg== X-Received: by 2002:a63:fa16:: with SMTP id y22mr28139592pgh.15.1559565553736; Mon, 03 Jun 2019 05:39:13 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 18:08:19 +0530 Message-Id: <20190603123823.32661-6-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603123823.32661-1-mehta.aaru20@gmail.com> References: <20190603123823.32661-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::541 Subject: [Qemu-devel] [PATCH v4 5/9] stubs: add stubs for io_uring interface 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Aarushi Mehta Reviewed-by: Stefan Hajnoczi --- MAINTAINERS | 1 + stubs/Makefile.objs | 1 + stubs/io_uring.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 stubs/io_uring.c diff --git a/MAINTAINERS b/MAINTAINERS index dcaddec21f..e30f62024e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2521,6 +2521,7 @@ R: Stefan Hajnoczi L: qemu-block@nongnu.org S: Maintained F: block/io_uring.c +F: stubs/io_uring.c =20 qcow2 M: Kevin Wolf diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 9c7393b08c..5cf160a9c8 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -13,6 +13,7 @@ stub-obj-y +=3D iothread.o stub-obj-y +=3D iothread-lock.o stub-obj-y +=3D is-daemonized.o stub-obj-$(CONFIG_LINUX_AIO) +=3D linux-aio.o +stub-obj-$(CONFIG_LINUX_IO_URING) +=3D io_uring.o stub-obj-y +=3D machine-init-done.o stub-obj-y +=3D migr-blocker.o stub-obj-y +=3D 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 late= r. + * 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(); +} --=20 2.17.1 From nobody Wed May 15 15:27:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1559566080; cv=none; d=zoho.com; s=zohoarc; b=N/0bzyLRPWRQJcXHld+nyv8hAp+nyopBBubjEqK54qMxm6sbYRuz7gaZoA773iQKUybHoy+t/mFx7HhTUiyjWORpU+gDqxy2YPkxIRNJCMryY5EgPjXP37pS41pkNgwlp0mFBg9cYzt1t+42tmXeseXf5yWZOeTcYl8LIl3bFwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559566080; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2n2TNPYPU066kE92JQNbBm7Ypw4YV4ofgNfP3dVPw+E=; b=mhSuYAUILWVj8H/LfUdOrBQ4pNpAQNfuwS0BnUqnm4xDvdyZiZ9X3Jm1vTTDP1dHiYuBhvtuyJCnjcZebn2gqnSlpVIf5+XIVCPl52l+RwARxjTVv7g9jka+rkUhV7uWms+nwqpMzNv9pOFfJe18pxuS9ZtVO1OmfoXIkMQvL5w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559566080219998.8839870345263; Mon, 3 Jun 2019 05:48:00 -0700 (PDT) Received: from localhost ([127.0.0.1]:34625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmNW-0000VR-41 for importer@patchew.org; Mon, 03 Jun 2019 08:47:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmKp-0007F5-Ns for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:45:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXmFF-00089x-6v for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:39:22 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:38389) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXmFF-000883-0r; Mon, 03 Jun 2019 08:39:21 -0400 Received: by mail-pl1-x643.google.com with SMTP id f97so6958256plb.5; Mon, 03 Jun 2019 05:39:20 -0700 (PDT) Received: from localhost.localdomain ([136.233.9.100]) by smtp.gmail.com with ESMTPSA id k14sm34860257pga.5.2019.06.03.05.39.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 05:39:19 -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=2n2TNPYPU066kE92JQNbBm7Ypw4YV4ofgNfP3dVPw+E=; b=b3y5vYnQjEXFQ76uHJujX4qrMGjTf6sme8zfuRomZuIKay8FZj0Qe7L2Fr/XBumxcX rCeurwOclbe6ZwKaeZin5UBxVUEWh9B5T6CFYwWJ1wPGnC7Pbh5IePY1UeLW4JAzXT9/ CTwS1fOqcaMuLSogBklmTRN5kxw8bH6X9ODk/6ZVrVNUncWeJWfSPHZ0+N6iCfDGcm3O lGosMhgOhwOWQ96Kk9M5DWC60a0MLgpTmIGryAIvUTJjH5gTdU0G6UQLgBvVsnU7t4K7 xFWHpbMQXR9cWeWSPo5IhGyfILJ/huBsy67KoCWTQgng62f1mK4ZGW9l5PRNajWa8hvZ YWaA== 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=2n2TNPYPU066kE92JQNbBm7Ypw4YV4ofgNfP3dVPw+E=; b=aX/PZe2JqC+XFJoUjiarTTJIpyygtIuE9tP0u5n0RqBy/RnXj6OHTfNlna12x0drqX pETa7xmuzTpAbX7ewIe0vsVYB3BrWVcY4g+RN2BqNIEZuupdaQzvMc/wnQW/RejgSJcA m6ox6GBKCgbAczXiv8etyHvQ0NPlE0BP2dYO6bF6jp1lgEOxazH+KoVjA2/2iMfQ+ws2 BO+3yiEkblaYWQ21ix/nvsP3MivrkMeJDztnAY3EEg7igGLzk6/pawxNaNtETJHw5oPX l8WsjuLhR6N7ysEaB1IxEZ0MzIvG7Oedh2aq5++ECdkG0XUmbV5fe2drtYzq8CgWxTqm oSBg== X-Gm-Message-State: APjAAAX2DiwVmw8B7mmHV9YEmLxsZ/Aywarp6hAy+dtsQcRJ57f166YO lKvj4TXIWwrg0X0MXsb7qy6VHWy6a4DfYg== X-Google-Smtp-Source: APXvYqxFp4Hj/SE/43w0jiQXnGH3O30SQrJGDw2nQeIjE0uXxnYpnINNBP4YFf9il5Ej2i/yy2WL4g== X-Received: by 2002:a17:902:5ac9:: with SMTP id g9mr29729911plm.134.1559565559775; Mon, 03 Jun 2019 05:39:19 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 18:08:20 +0530 Message-Id: <20190603123823.32661-7-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603123823.32661-1-mehta.aaru20@gmail.com> References: <20190603123823.32661-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::643 Subject: [Qemu-devel] [PATCH v4 6/9] util/async: 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Aarushi Mehta Reviewed-by: Stefan Hajnoczi --- util/async.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/util/async.c b/util/async.c index c10642a385..2709f0edc3 100644 --- a/util/async.c +++ b/util/async.c @@ -277,6 +277,14 @@ aio_ctx_finalize(GSource *source) } #endif =20 +#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 =3D NULL; + } +#endif + assert(QSLIST_EMPTY(&ctx->scheduled_coroutines)); qemu_bh_delete(ctx->co_schedule_bh); =20 @@ -341,6 +349,29 @@ LinuxAioState *aio_get_linux_aio(AioContext *ctx) } #endif =20 +#ifdef CONFIG_LINUX_IO_URING +LuringState *aio_setup_linux_io_uring(AioContext *ctx, Error **errp) +{ + if (ctx->linux_io_uring) { + return ctx->linux_io_uring; + } + + ctx->linux_io_uring =3D luring_init(errp); + if (!ctx->linux_io_uring) { + return NULL; + } + + 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 +463,11 @@ AioContext *aio_context_new(Error **errp) #ifdef CONFIG_LINUX_AIO ctx->linux_aio =3D NULL; #endif + +#ifdef CONFIG_LINUX_IO_URING + ctx->linux_io_uring =3D NULL; +#endif + ctx->thread_pool =3D NULL; qemu_rec_mutex_init(&ctx->lock); timerlistgroup_init(&ctx->tlg, aio_timerlist_notify, ctx); --=20 2.17.1 From nobody Wed May 15 15:27:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1559566079; cv=none; d=zoho.com; s=zohoarc; b=AUWNk/ENRZhxtp22S9PlsasTOoA4FX27uABh0/nHUSh4GeZKl/STFSlnFD/VoBeQ3uy1CWE0nfx68zP4Fc89GI231SW2HUBlI5cavaKuaQiPzvb6zGO8Je/ccb7iMDuM0fxJTUn1bComuLUqpLvHETlnqCtLjc2H89MEBlXxGWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559566079; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=K42CkPeucn8W+B9II/bfKD2EsCVdQuGyHCr2h0lXa8c=; b=nGOXsbZNMOhR+eFRV7ngOcx+bIEogMZ0JcfPRvFQ3nQAe8XUFOOVVflx3KOEjCAAmiWIitcnLMpp7T0yKfS3bYaZQwpQanKXrCWoTq7FDRfOCfTx2dxVFJREMi9Nhxwa65YHfWCTLlrassgfCqTLmY+Ac/Usj0hQK9dIvBT3IQk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559566079233593.5478829202099; Mon, 3 Jun 2019 05:47:59 -0700 (PDT) Received: from localhost ([127.0.0.1]:34627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmNX-0000Xp-71 for importer@patchew.org; Mon, 03 Jun 2019 08:47:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmKn-0007F5-IS for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXmFL-0008TR-PX for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:39:28 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:34116) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXmFL-0008R7-K9; Mon, 03 Jun 2019 08:39:27 -0400 Received: by mail-pf1-x442.google.com with SMTP id c85so1764766pfc.1; Mon, 03 Jun 2019 05:39:27 -0700 (PDT) Received: from localhost.localdomain ([136.233.9.100]) by smtp.gmail.com with ESMTPSA id k14sm34860257pga.5.2019.06.03.05.39.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 05:39:25 -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=K42CkPeucn8W+B9II/bfKD2EsCVdQuGyHCr2h0lXa8c=; b=n+X/NxBbs+Hq5iDd8EJXRunXYWS19W1ohehfKN5ZQ+oDJ4zjqN9Y7ICL5fzLsAL/VF LCrbLgmNkNeSRCF9Xz1XTp8T9KEgFr/3XKD4YMkQ8X4nMKggVKXomQBpKRGK+Kamu2us 6qDgPyGd5Gr6djULxU3m6aEhnxpZa8C9fAT/nu27H+HpF1kbaA4N+EQj9Zrcn95q/Tch DuD1wfmi94DUkAElixlp1iIjBtzHDF16RoOOiJcooZX0/MS6VPgofs1v5fUe7Z0zDTPI 0J7ChZV1MS5thn7tk4Jp26zn+cAvdEyBDcLuKKMP4nQSNFLmzjY+dZbn+Y/r5wmODuLe NDPQ== 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=K42CkPeucn8W+B9II/bfKD2EsCVdQuGyHCr2h0lXa8c=; b=gk1eNgEtdSwrUIskOgkPDc6Dbe1dE9GLCFojIQHD9FG5VzLrzfoprocWKOKA3Vaffs EVkItYSufbielPpJLAYG6UzofZYVZx6+CYCjXOAS+c38LtGgzCA6fD2bLDAik+WL0ChY oVaEEhwgw9xdm4SV/f3nIPSzzzrtzp3civrCsu5yN+BiHf1EAKR2n4yLKn1p3ut6xwy6 u8f8oLhrZHdRCR1lvZFa8kvXq3WxM3lSQu/62wXZk3SNg7wDaNkoFy8y+qgLfQWeN9l3 pAzQxXqJHNnJgUZYo3BHynUyEBl+PjfQdn3Q/NyYUErP5KZO1q3gznocRoS9gbPvzO0q pLsg== X-Gm-Message-State: APjAAAWJOhgtwj7tubGETqaeHv98gWXkwBoHLUdSEHBbXyLfgInR22OZ of0NolKVq1HQ7FwRtjOwAb2vkf6yEa3s4g== X-Google-Smtp-Source: APXvYqzxUDtkvYmYzexVz2tGG3u/FzIydbknrZ6oCErX0tBtLwqoKYwifYNM6vJ/WwFQjS0zdZE0VQ== X-Received: by 2002:a63:dc15:: with SMTP id s21mr14644859pgg.215.1559565566293; Mon, 03 Jun 2019 05:39:26 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 18:08:21 +0530 Message-Id: <20190603123823.32661-8-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603123823.32661-1-mehta.aaru20@gmail.com> References: <20190603123823.32661-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::442 Subject: [Qemu-devel] [PATCH v4 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reviewed-by: Stefan Hajnoczi Signed-off-by: Aarushi Mehta --- blockdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 17c2d801d7..58a9e69268 100644 --- a/blockdev.c +++ b/blockdev.c @@ -386,6 +386,8 @@ static void extract_common_blockdev_options(QemuOpts *o= pts, int *bdrv_flags, if ((aio =3D qemu_opt_get(opts, "aio")) !=3D NULL) { if (!strcmp(aio, "native")) { *bdrv_flags |=3D BDRV_O_NATIVE_AIO; + } else if (!strcmp(aio, "io_uring")) { + *bdrv_flags |=3D BDRV_O_IO_URING; } else if (!strcmp(aio, "threads")) { /* this is the default */ } else { @@ -4568,7 +4570,7 @@ QemuOptsList qemu_common_drive_opts =3D { },{ .name =3D "aio", .type =3D QEMU_OPT_STRING, - .help =3D "host AIO implementation (threads, native)", + .help =3D "host AIO implementation (threads, native, io_uring)= ", },{ .name =3D BDRV_OPT_CACHE_WB, .type =3D QEMU_OPT_BOOL, --=20 2.17.1 From nobody Wed May 15 15:27:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1559566414; cv=none; d=zoho.com; s=zohoarc; b=KTP4LYNCYVc4wMdcmvhJWrHd1s0DDy+TN/6POCKWPSAqVfWZN8Rwin2ku6ob/M6BnbAVeVIgoZb5kl1zFO9A8ez/LMN93n4LpGERFdkjws3jTRAYmgKxrBuaT4nBMYqX88FLd5CcVhicKQTBMpxqcsHgebkgR+QlJ2g/mULDT7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559566414; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BkrqkXKw+QojOLRD6HxRpYEmbe+jRwaGL11dLaGKZ5o=; b=GN2WWOyrVZqHVqmqj3Yhq4a4bWG2WYLKn9CIR89IVQgushf9dsOWS9cghHY/bwWPWYl5Va3egpR0KhZtO2TrlPjD4rK1JPuNl6LzxhJNetYuXOIzZHen+pOOwehnjZM6ulZpm9a13NFSW5A8ogygTrq1OSsmOpvTpZjGZww7nTg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559566414118715.0796077918918; Mon, 3 Jun 2019 05:53:34 -0700 (PDT) Received: from localhost ([127.0.0.1]:34726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmSs-00051h-Qo for importer@patchew.org; Mon, 03 Jun 2019 08:53:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmKm-0007F5-0Y for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:45:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXmFR-0000HL-FE for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:39:34 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:36423) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXmFR-0000FZ-8c; Mon, 03 Jun 2019 08:39:33 -0400 Received: by mail-pf1-x442.google.com with SMTP id u22so10558295pfm.3; Mon, 03 Jun 2019 05:39:33 -0700 (PDT) Received: from localhost.localdomain ([136.233.9.100]) by smtp.gmail.com with ESMTPSA id k14sm34860257pga.5.2019.06.03.05.39.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 05:39:31 -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=BkrqkXKw+QojOLRD6HxRpYEmbe+jRwaGL11dLaGKZ5o=; b=fPKeCWWI4ktjwVzu8ojv9GHnCAj13pQhweYrol21bnQ7IJjGJBz6ObxuCbvQY8Tkpq c8jOUf8M/C+etyebGi+lEWwv/rd9UKOxzc0A4cp+ZZkkpHAIHPzvZYdplKmw4UI7XMn/ z6vWxs/dTdm3R2V1ZVBDtGYNLbFr/V1bMGVwBq7x1i8oI4xI1WYhRYuZ3mWmqlA/Ezqn x3rGxCkENUk88VXW+R+7bczXcMB82/1tARhtdjT1LhMmJvzbELKCrLH01MsXM5ki8TmT 8pPdAb+Pc1R0Tu/ytJhofrFU5m9n2ywWFHlctYmBd8cmPmcMOy4yI80HiMtvb7hquL8p AIiQ== 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=BkrqkXKw+QojOLRD6HxRpYEmbe+jRwaGL11dLaGKZ5o=; b=KHmfhL1/oNhj4qbvQ2xT9pYzZzPw2zcm+BIIQ/AgCU0XpK8e9xSLY3S/OcGT1xqtdE u9qm8ALxC45+1Dl8GPAjiAg7RYdYV8haw0G0enqs5zYy7+eVGTGhyTuTVhoPi0Zt7QoI oBnT24lFpZ6m2vxcdP9diLUN3DBxIq0x+Bc65hQtJZPGmkoS4PfxDcl5TkhhKT8ItO7e e/hhp1OsHrZc//WFgk9uKVEyvMRlmUIsbNFan3rKf4GStj9asmhr1YkOCa4uk93YuL6V 9R09NioHDAR0uHFApMJ22fDbP3KavBYpsPBRmw2ppa5QLsrOFgUT2DaiL7ciYbBnjzz7 qi/g== X-Gm-Message-State: APjAAAXb3a0QZjyPSaGsVpSeQdduoTC6+bf8eFuUg4YXGrlE+SuvrUa6 O8nlBTQsfrFysBieVq7yzHhKgXyAHHyorQ== X-Google-Smtp-Source: APXvYqxqMyuPXArhABNHBL88RQE0jTV6EOg2MO2v3XPw76Zs/Zha98iyDDem9VnNQ84BvhoiXzKbKg== X-Received: by 2002:a63:5014:: with SMTP id e20mr26557339pgb.2.1559565572052; Mon, 03 Jun 2019 05:39:32 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 18:08:22 +0530 Message-Id: <20190603123823.32661-9-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603123823.32661-1-mehta.aaru20@gmail.com> References: <20190603123823.32661-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::442 Subject: [Qemu-devel] [PATCH v4 8/9] block/file-posix.c: extend to use 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Aarushi Mehta --- block/file-posix.c | 85 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index d018429672..211dfe5337 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:1; bool page_cache_inconsistent:1; bool has_fallocate; bool needs_alignment; @@ -423,7 +424,7 @@ static QemuOptsList raw_runtime_opts =3D { { .name =3D "aio", .type =3D QEMU_OPT_STRING, - .help =3D "host AIO implementation (threads, native)", + .help =3D "host AIO implementation (threads, native, io_uring)= ", }, { .name =3D "locking", @@ -482,9 +483,15 @@ static int raw_open_common(BlockDriverState *bs, QDict= *options, goto fail; } =20 - aio_default =3D (bdrv_flags & BDRV_O_NATIVE_AIO) - ? BLOCKDEV_AIO_OPTIONS_NATIVE - : BLOCKDEV_AIO_OPTIONS_THREADS; + if (bdrv_flags & BDRV_O_NATIVE_AIO) { + aio_default =3D BLOCKDEV_AIO_OPTIONS_NATIVE; +#ifdef CONFIG_LINUX_IO_URING + } else if (bdrv_flags & BDRV_O_IO_URING) { + aio_default =3D BLOCKDEV_AIO_OPTIONS_IO_URING; +#endif + } else { + aio_default =3D BLOCKDEV_AIO_OPTIONS_THREADS; + } aio =3D qapi_enum_parse(&BlockdevAioOptions_lookup, qemu_opt_get(opts, "aio"), aio_default, &local_err); @@ -493,7 +500,11 @@ static int raw_open_common(BlockDriverState *bs, QDict= *options, ret =3D -EINVAL; goto fail; } + s->use_linux_aio =3D (aio =3D=3D BLOCKDEV_AIO_OPTIONS_NATIVE); +#ifdef CONFIG_LINUX_IO_URING + s->use_linux_io_uring =3D (aio =3D=3D BLOCKDEV_AIO_OPTIONS_IO_URING); +#endif =20 locking =3D qapi_enum_parse(&OnOffAuto_lookup, qemu_opt_get(opts, "locking"), @@ -557,7 +568,7 @@ static int raw_open_common(BlockDriverState *bs, QDict = *options, s->shared_perm =3D BLK_PERM_ALL; =20 #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=3Dnative was specified, but it requires " @@ -579,6 +590,22 @@ static int raw_open_common(BlockDriverState *bs, QDict= *options, } #endif /* !defined(CONFIG_LINUX_AIO) */ =20 +#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=3Dio_uring was specified, but is not support= ed " + "in this build."); + ret =3D -EINVAL; + goto fail; + } +#endif /* !defined(CONFIG_LINUX_IO_URING) */ + s->has_discard =3D true; s->has_write_zeroes =3D true; if ((bs->open_flags & BDRV_O_NOCACHE) !=3D 0) { @@ -1875,16 +1902,20 @@ static int coroutine_fn raw_co_prw(BlockDriverState= *bs, uint64_t offset, * If this is the case tell the low-level driver that it needs * to copy the buffer. */ - if (s->needs_alignment) { - if (!bdrv_qiov_is_aligned(bs, qiov)) { - type |=3D QEMU_AIO_MISALIGNED; + if (s->needs_alignment && !bdrv_qiov_is_aligned(bs, qiov)) { + type |=3D QEMU_AIO_MISALIGNED; +#ifdef CONFIG_LINUX_IO_URING + } else if (s->use_linux_io_uring) { + LuringState *aio =3D aio_get_linux_io_uring(bdrv_get_aio_context(b= s)); + assert(qiov->size =3D=3D bytes); + return luring_co_submit(bs, aio, s->fd, offset, qiov, type); +#endif #ifdef CONFIG_LINUX_AIO - } else if (s->use_linux_aio) { - LinuxAioState *aio =3D aio_get_linux_aio(bdrv_get_aio_context(= bs)); - assert(qiov->size =3D=3D bytes); - return laio_co_submit(bs, aio, s->fd, offset, qiov, type); + } else if (s->use_linux_aio && s->needs_alignment) { + LinuxAioState *aio =3D aio_get_linux_aio(bdrv_get_aio_context(bs)); + assert(qiov->size =3D=3D bytes); + return laio_co_submit(bs, aio, s->fd, offset, qiov, type); #endif - } } =20 acb =3D (RawPosixAIOData) { @@ -1920,24 +1951,36 @@ static int coroutine_fn raw_co_pwritev(BlockDriverS= tate *bs, uint64_t offset, =20 static void raw_aio_plug(BlockDriverState *bs) { + BDRVRawState __attribute__((unused)) *s =3D bs->opaque; #ifdef CONFIG_LINUX_AIO - BDRVRawState *s =3D bs->opaque; if (s->use_linux_aio) { LinuxAioState *aio =3D 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 =3D aio_get_linux_io_uring(bdrv_get_aio_context(b= s)); + luring_io_plug(bs, aio); + } +#endif } =20 static void raw_aio_unplug(BlockDriverState *bs) { + BDRVRawState __attribute__((unused)) *s =3D bs->opaque; #ifdef CONFIG_LINUX_AIO - BDRVRawState *s =3D bs->opaque; if (s->use_linux_aio) { LinuxAioState *aio =3D aio_get_linux_aio(bdrv_get_aio_context(bs)); laio_io_unplug(bs, aio); } #endif +#ifdef CONFIG_LINUX_IO_URING + if (s->use_linux_io_uring) { + LuringState *aio =3D aio_get_linux_io_uring(bdrv_get_aio_context(b= s)); + luring_io_unplug(bs, aio); + } +#endif } =20 static int raw_co_flush_to_disk(BlockDriverState *bs) @@ -1963,8 +2006,8 @@ static int raw_co_flush_to_disk(BlockDriverState *bs) static void raw_aio_attach_aio_context(BlockDriverState *bs, AioContext *new_context) { + BDRVRawState __attribute__((unused)) *s =3D bs->opaque; #ifdef CONFIG_LINUX_AIO - BDRVRawState *s =3D bs->opaque; if (s->use_linux_aio) { Error *local_err; if (!aio_setup_linux_aio(new_context, &local_err)) { @@ -1974,6 +2017,16 @@ static void raw_aio_attach_aio_context(BlockDriverSt= ate *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 =3D false; + } + } +#endif } =20 static void raw_close(BlockDriverState *bs) --=20 2.17.1 From nobody Wed May 15 15:27:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1559566227; cv=none; d=zoho.com; s=zohoarc; b=GVrqsWrODNEU92/01ThoZEydybIvvAeW8SFhYqC2lusqr+8F6qP9uhJGhPbl72GRiqkkMcpegEg/xMnbKlu9DvMumU3q3H6LsOtOr3cs2T9Mv3oW6QxurbB2zMJnOT7HYvaiIEWGcyYcc7Fq7eaMuTgY68yK9T2/HJX74jLE9kY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559566227; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=exvxrzkjOwxuFB3cwxOAuZc0lL7VPvQ7Qj9JqFUo65E=; b=WK/FXm/+Zjj39lc3KoaaL/ahcVRh/FxtNjaeWQhY1XugKy9wfY2Om9DzIXRPKZxKKZWXV2eYJ1fcFIWz6G6pQCVFqmvdbhceiZa0itPJXIANyuu14TvoGOwCMLRNBmdb0s/be3GLHt/U9LjiD0cnsd6VHgM4yBcsqd68giMjysM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559566227392774.9762761907145; Mon, 3 Jun 2019 05:50:27 -0700 (PDT) Received: from localhost ([127.0.0.1]:34656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmPt-0002SM-3K for importer@patchew.org; Mon, 03 Jun 2019 08:50:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXmKk-0007F5-NN for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:45:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXmFX-0000XE-Eb for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:39:40 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:35199) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXmFX-0000VG-8S; Mon, 03 Jun 2019 08:39:39 -0400 Received: by mail-pf1-x444.google.com with SMTP id d126so10573977pfd.2; Mon, 03 Jun 2019 05:39:39 -0700 (PDT) Received: from localhost.localdomain ([136.233.9.100]) by smtp.gmail.com with ESMTPSA id k14sm34860257pga.5.2019.06.03.05.39.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 05:39:37 -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=exvxrzkjOwxuFB3cwxOAuZc0lL7VPvQ7Qj9JqFUo65E=; b=gFXEito+I80q41xrNzphhouu3Ysd2EFCHnSAkLKD2C5U9U2EK0U2CBpFRgpBT9+y1b kcO+SSK2AdlhFZZDFC4Idp6CoYlRrXRrm8SfqkWhgPHyJMd+W9WmLZkAM6+prQLpKhqk CF/KM+df+Eg1+pem+5+RIY65bJRhlMEWSfobp9u4uyA3gD0PVBSfH1N8n+xTEHRNLHBs BgFhi/45ov8ZRcjYuYlVfQTxlUGRgJaD0LmR22cZArv/SQTcbQeCpDAL19mfO9TAglNN cbLG6zrrfBAC8Ac1TyOexiTSRjeX570ef5g79AfdjEFwWi7Y0HiP/3xEfdZwhIYaJ+eZ KQwQ== 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=exvxrzkjOwxuFB3cwxOAuZc0lL7VPvQ7Qj9JqFUo65E=; b=ZESSXe6m6+g6RxRs3fdLL5pp5+lQF33fGDrgBkzsA+Vk00TWml2gaYbvtpK1J3I1IR qjRGF9ZEuMFYh9kM1LMhUsWvT2sZbRsRxUiCF2UHxA5J8vpGa2cqP+0SzGOGWNUQQFR2 MewRusJn/hKv23BMUPw8LOmT4jCIfDmV54/p2Qe9tj72JDJqWqraXvFmoZg1SVGxhc62 rmDckxkZORUoIFKgncO/yG8qjSmMAH/lSrneQ3dXGxlnogXXKHX3rhdJremvo1FYY5Ne m/v4UqCOzg/6g9oLS51OkgtCMSKfAx54rVj6TGsyp2kRbX9kK6Oe+PCa/3W54xUbwAnI CfJQ== X-Gm-Message-State: APjAAAXUnleBaMbbboYeUJ71JpQ65OjD2VomJ2zQQ4Pj5h3OwmQ0FkKY oojVVvNl1YZYAgeXk6VzGkhZqaPriLvIpg== X-Google-Smtp-Source: APXvYqzvdO4Z2vKk/9N0P5zOWQyGZaN8WYSkakUoMxEA+Va3/OPb4g1Qw/bHybiGuCDuaYfSitYgmw== X-Received: by 2002:a62:160b:: with SMTP id 11mr30724598pfw.30.1559565577877; Mon, 03 Jun 2019 05:39:37 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 18:08:23 +0530 Message-Id: <20190603123823.32661-10-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603123823.32661-1-mehta.aaru20@gmail.com> References: <20190603123823.32661-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] [PATCH v4 9/9] block: add trace events 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , Paolo Bonzini , Julia Suvorova , Aarushi Mehta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Aarushi Mehta --- block/io_uring.c | 14 ++++++++++++-- block/trace-events | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/block/io_uring.c b/block/io_uring.c index 536a9fbe87..e92e45ccca 100644 --- a/block/io_uring.c +++ b/block/io_uring.c @@ -17,6 +17,7 @@ #include "block/raw-aio.h" #include "qemu/coroutine.h" #include "qapi/error.h" +#include "trace.h" =20 #define MAX_EVENTS 128 =20 @@ -192,12 +193,15 @@ static int ioq_submit(LuringState *s) =20 void luring_io_plug(BlockDriverState *bs, LuringState *s) { + trace_luring_io_plug(); s->io_q.plugged++; } =20 void luring_io_unplug(BlockDriverState *bs, LuringState *s) { assert(s->io_q.plugged); + trace_luring_io_unplug(s->io_q.blocked, s->io_q.plugged, + s->io_q.in_queue, s->io_q.in_flight); if (--s->io_q.plugged =3D=3D 0 && !s->io_q.blocked && s->io_q.in_queue > 0) { ioq_submit(s); @@ -218,6 +222,7 @@ void luring_io_unplug(BlockDriverState *bs, LuringState= *s) static int luring_do_submit(int fd, LuringAIOCB *luringcb, LuringState *s, uint64_t offset, int type) { + int ret; struct io_uring_sqe *sqes =3D io_uring_get_sqe(&s->ring); if (!sqes) { sqes =3D &luringcb->sqeq; @@ -243,11 +248,14 @@ static int luring_do_submit(int fd, LuringAIOCB *luri= ngcb, LuringState *s, } io_uring_sqe_set_data(sqes, luringcb); s->io_q.in_queue++; - + trace_luring_do_submit(s->io_q.blocked, s->io_q.plugged, + s->io_q.in_queue, s->io_q.in_flight); if (!s->io_q.blocked && (!s->io_q.plugged || s->io_q.in_flight + s->io_q.in_queue >=3D MAX_EVENTS)) { - return ioq_submit(s); + ret =3D ioq_submit(s); + trace_luring_do_submit_done(ret); + return ret; } return 0; } @@ -295,6 +303,7 @@ LuringState *luring_init(Error **errp) int rc; LuringState *s; s =3D g_malloc0(sizeof(*s)); + trace_luring_init_state((void *)s, sizeof(*s)); struct io_uring *ring =3D &s->ring; rc =3D io_uring_queue_init(MAX_EVENTS, ring, 0); if (rc < 0) { @@ -312,4 +321,5 @@ void luring_cleanup(LuringState *s) { io_uring_queue_exit(&s->ring); g_free(s); + trace_luring_cleanup_state(); } diff --git a/block/trace-events b/block/trace-events index 1e0653ce6d..038ff14815 100644 --- a/block/trace-events +++ b/block/trace-events @@ -60,6 +60,14 @@ qmp_block_stream(void *bs, void *job) "bs %p job %p" file_paio_submit(void *acb, void *opaque, int64_t offset, int count, int t= ype) "acb %p opaque %p offset %"PRId64" count %d type %d" file_copy_file_range(void *bs, int src, int64_t src_off, int dst, int64_t = dst_off, int64_t bytes, int flags, int64_t ret) "bs %p src_fd %d offset %"P= RIu64" dst_fd %d offset %"PRIu64" bytes %"PRIu64" flags %d ret %"PRId64 =20 +#io_uring.c +luring_init_state(void *s, size_t size) "s %p size %zu" +luring_cleanup_state(void) "s freed" +disable luring_io_plug(void) "plug" +disable luring_io_unplug(int blocked, int plugged, int queued, int infligh= t) "blocked %d plugged %d queued %d inflight %d" +disable luring_do_submit(int blocked, int plugged, int queued, int infligh= t) "blocked %d plugged %d queued %d inflight %d" +disable luring_do_submit_done(int ret) "submitted to kernel %d" + # qcow2.c qcow2_writev_start_req(void *co, int64_t offset, int bytes) "co %p offset = 0x%" PRIx64 " bytes %d" qcow2_writev_done_req(void *co, int ret) "co %p ret %d" --=20 2.17.1