From nobody Fri May 3 07:48:55 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=1558944348; cv=none; d=zoho.com; s=zohoarc; b=N0hZVzorlFLb5/anGi7X/hPxRjTnHVqWPqsDIOu2AasgzQfJyijJzylBS5DA69TflFWhqyDaDkImNLBPoBP/5oetNf8MeapeAiIJh/hTa/CpN3lfypYYpz+c3EONEKGJkXv/qZKmPeZVetY9v01dsn4mgxuN5YYAhnQzX5Jxlms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558944348; 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=qVBNipnG6rsnaNkm/763xu7zNt/J2OahkNzsU67wdcA=; b=H1o7HVBMM86wbLlzzrT2Rk6jvyX8HcNMs37Plyb+1D2+vFs5teyFanV5CCs3IGLccy1zJLvJwYYCI/RgNmEuT+FiMjft7IKlYd6xxaRG+Ebq6Ry0I876EC7mSo+3KhmaQfoD95zUWJwlZA5bKwK0o/DO10XtPn8spQiVhvaAc+k= 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 1558944348883173.63153422075357; Mon, 27 May 2019 01:05:48 -0700 (PDT) Received: from localhost ([127.0.0.1]:41657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAdc-0008Ut-T6 for importer@patchew.org; Mon, 27 May 2019 04:05:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAbr-0007Wt-95 for qemu-devel@nongnu.org; Mon, 27 May 2019 04:03:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVAbq-0001VF-7I for qemu-devel@nongnu.org; Mon, 27 May 2019 04:03:55 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45156) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVAbq-0001Ux-2Q; Mon, 27 May 2019 04:03:54 -0400 Received: by mail-pl1-x641.google.com with SMTP id a5so6735699pls.12; Mon, 27 May 2019 01:03:54 -0700 (PDT) Received: from localhost.localdomain ([120.57.119.140]) by smtp.gmail.com with ESMTPSA id j5sm10030853pfa.15.2019.05.27.01.03.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 01:03: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=qVBNipnG6rsnaNkm/763xu7zNt/J2OahkNzsU67wdcA=; b=e+XQL79tdrGQnheHAzlSbkIfDZzmcqSzZMPo4KDiXhsp250SY0rXYiaDYGI0x1RGt5 5bbJqzvBi6FbdSgl9CsXt/U/wZAamM4pZydg2LnmcFQWK5WOqbhm1tRpp214rv/MClJb 4RQ2RloAnzk43CSREAu541yYj+vP1o5XOQjFnAtQ82WM4kKMGc4yqOlZFyD2zggcAOTL v7dzPs5Ej1DkZ5geQk27fslVqGHufoBHIp9C0ZR8kKdq75qycJuqzWngREr9cm/rMLoz AAf52PVooUGKbGrYGKobnekhYJE6bJ2QdZJNcQh76I5jAzWadIZUHvVQlKfqASLCLZTr eEMg== 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=qVBNipnG6rsnaNkm/763xu7zNt/J2OahkNzsU67wdcA=; b=iBwKrd3U2tNMQTFI1bCILn2djOsJczSps1XU3wNiGbo2V9pLwFemH9izdWuCvJ/hgU lp77Xm3D1bLK0DYxTD6OUhLHE+rJD09+Q8SIUOOKAeeh7bxPT+lBxYI5jkDCGAGjE92T 1HjutF+mDtc2JVcg078RrzoL5CrvV8s90YEClmdw7qAgDpXx7qTRVxaMHNW+3KQhrHWh ShZPTZzq5Vx7VLJflVkFpzcan4+umgfnYZVukWCXrJsbR/QBTfT2zVWBIyZYlVAsqqhW kfm7URQQCc0WrDt2ZqFrD/bMXYswXFRPqOTPnJ9IIyhhj/iOpnI2sS8P8UI39tsQD2kF Glwg== X-Gm-Message-State: APjAAAUXnjb7/FSmQNbzHSz/+L8UFCMzspwKGXs0q5QnIzRdiKVFT1DN Ji9CE9YtiQ3cviS5GxpGIIz/sBWvEB1CXA== X-Google-Smtp-Source: APXvYqz6S1a8Nv3ZC6oVz/kOhQF23mnvsVy9vfre3UGsKjTFhgBt5e9f1cWXjw5inlEDlos7hR/QGw== X-Received: by 2002:a17:902:ab90:: with SMTP id f16mr16883401plr.262.1558944232751; Mon, 27 May 2019 01:03:52 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 27 May 2019 13:33:20 +0530 Message-Id: <20190527080327.10780-2-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527080327.10780-1-mehta.aaru20@gmail.com> References: <20190527080327.10780-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::641 Subject: [Qemu-devel] [PATCH v3 1/8] 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , 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 --- configure | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/configure b/configure index 528b9ff705..acbdf04168 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"" @@ -1255,6 +1256,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" @@ -1773,6 +1778,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 @@ -3962,6 +3968,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 @@ -6378,6 +6399,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" @@ -6858,6 +6880,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 Fri May 3 07:48:55 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=1558944477; cv=none; d=zoho.com; s=zohoarc; b=AM3QP8dJRLVO6L9tPAyWroW3bfn/ukPvI3FCNYGMa5Exd+FL+4R2SKE7LrKU3p/CJdM+/11y/fmRLJCZdVjlhriTJvQgpojic/+F5NqTezW5IVQW5w5mvptbNTmMDLXBjX3Lm9W56PrVqOv2PC8rLRpJfli4iVBdindJCGaTx2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558944477; 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=RQSGLuAPTqBgY+6tSr5KG+5jBdzMRsNl3Fb9Hoj28xg=; b=lw4qsME9FbR63/FjIJwUppjO3ffoXcX7IyRaQtGNRoPwALzOVRZY7LoGrmQnPEsKbG7fCrgqpvWc26NUvASZWBgLTYZpRroSIOz6nvZUwknvoNLsjyLwmVlWfbdoX9U/9Dw1iNljVClzFT2sbFISwxzOrQxL5SiXkoyhzduDE3c= 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 15589444777311004.3168750052649; Mon, 27 May 2019 01:07:57 -0700 (PDT) Received: from localhost ([127.0.0.1]:41689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAfh-0001yE-Jl for importer@patchew.org; Mon, 27 May 2019 04:07:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAbw-0007bZ-3h for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVAbv-0001YB-8C for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:00 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:37049) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVAbv-0001Xd-3S; Mon, 27 May 2019 04:03:59 -0400 Received: by mail-pf1-x431.google.com with SMTP id a23so9138416pff.4; Mon, 27 May 2019 01:03:59 -0700 (PDT) Received: from localhost.localdomain ([120.57.119.140]) by smtp.gmail.com with ESMTPSA id j5sm10030853pfa.15.2019.05.27.01.03.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 01:03:56 -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=RQSGLuAPTqBgY+6tSr5KG+5jBdzMRsNl3Fb9Hoj28xg=; b=QQuJlr3ExTcROQnlJjQC16RXxnWMwDp6nSHjtiJd+2QdwAidySjBZpsQg8nJn3kP/Z q2Gme8d7CL8pveG8KYs/plMNh4CpYWXVd+z/ozm/8fexw0exgp+dlkNWBhmVFVyQwLlN ++/h0SjtoKeC1EWXXWtWJblJYe9JVdrcphX3HSdeMmZpdWFJuPF5rR3P14d9csdHuxjv iBLOsrpRRIHk5x+ONc1txP2eKM8AQT89MfDV2TaKyDMSzB94K1fnMq3hZsjyOt/JlPxL 0j7K55PLgtujCgmayZ3Mj1ugGRK5S5QmSNRSGsgK7EbzeJPzIdumyaX3Kiieevbd2uKJ y+2Q== 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=RQSGLuAPTqBgY+6tSr5KG+5jBdzMRsNl3Fb9Hoj28xg=; b=Vc6SBKuXpyQhCntPyQVd7qzcpsisvZPP5v30J+c3ZxLQf5WbZvxQKGI5OuABeKEb2+ hm1kPq/Oq8B+rGl4hE5eSlG21+vAX1H8E4xipzALBEA9NfPq4YhdOXVARtDKKaRmviuM 0f68UQud3+LxBiLOYk83INNpGVbl6KiJRQym82p8snwhYVIkWqp6/+TzWZ/e846HF5HJ UZFuPbrDEhklQE1kr8EvfHaxNMLzBAgvIJ98M9zJbFm/nxaK1y/CdtIHDwfStz6h4jSB LcKrwe3pzCJVMFp6XyDv5z41PNyxznb+vMP6VAcnYbt5hh4TmAUdYib9jjnOSUNC23+e 6png== X-Gm-Message-State: APjAAAWWiLvve4fzD015kSr3qqqWbvNg1eG4+TIMFRtG3ryUFRgDACD4 5KX3++jHLOlRWGgwUnE38H7JWWjPaW4daA== X-Google-Smtp-Source: APXvYqydHjz5nZ6RqAli1KUFP1FchkUrvrrgAJLJVZUCUEeyl4/NvIiZ5nGVgVjnAt0SP20ExYLYrA== X-Received: by 2002:a63:cc4e:: with SMTP id q14mr121609234pgi.84.1558944237556; Mon, 27 May 2019 01:03:57 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 27 May 2019 13:33:21 +0530 Message-Id: <20190527080327.10780-3-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527080327.10780-1-mehta.aaru20@gmail.com> References: <20190527080327.10780-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::431 Subject: [Qemu-devel] [PATCH v3 2/8] 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , 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 --- qapi/block-core.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 7ccbfff9d0..2773803890 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2776,11 +2776,13 @@ # # @threads: Use qemu's thread pool # @native: Use native AIO backend (only Linux and Windows) +# @io_uring: Use linux io_uring (only Linux) # -# Since: 2.9 +# Since: 2.9 @iouring Since: 4.1 ## { '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 Fri May 3 07:48:55 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=1558944366; cv=none; d=zoho.com; s=zohoarc; b=BOWvAme6fWFrSgM/soiXbcjiQXt00v1zMcUgzM4AF4B9NAKNVAoWvxBb2mtT3vkawCXCXbjglWKhVBs5s2VXLj4dn2LgfPnKT0+JTlecxb3g7YwtZ/65pdPzSNBttHjmraIR6epDH4raWlAGmseo805xxkw3oMV2pHzxyKb44Kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558944366; 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=3FKBJA17va/jv2u1TvUxLDB1xiagIFwWCBsEV/clovc=; b=L3A3spNrAwNQvaHKVFqHdbRMdLKiDMh2IMfrpy6Zidnnxd8pOQvIzB+xTgJwEbf0AAGzUzsQGAZ/99H0J8OGtT1mdjhMYCHleBQgYlge/ouFJH9v+/Xe6/p3xeb75myv/F9M5JePBFRTUyblE/6ZoYTXRIsj5Ab4WZXEO74BRpE= 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 1558944366094615.7290460454747; Mon, 27 May 2019 01:06:06 -0700 (PDT) Received: from localhost ([127.0.0.1]:41662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAdu-0000MU-5t for importer@patchew.org; Mon, 27 May 2019 04:06:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAc1-0007dF-1E for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVAc0-0001bD-6M for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:04 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVAc0-0001ax-1d; Mon, 27 May 2019 04:04:04 -0400 Received: by mail-pl1-x641.google.com with SMTP id c5so6743488pll.11; Mon, 27 May 2019 01:04:03 -0700 (PDT) Received: from localhost.localdomain ([120.57.119.140]) by smtp.gmail.com with ESMTPSA id j5sm10030853pfa.15.2019.05.27.01.03.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 01:04:02 -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=3FKBJA17va/jv2u1TvUxLDB1xiagIFwWCBsEV/clovc=; b=klDEPBG04+RmJ4+QGwvb3hwPdCqQcsLwMiL8ftkr+KlDViv3oFmVyXwa43iRuule3G zp/qIP4iNvK59xAf+553dZqa8UDjmP2cIf4fIAJrNiwFPWs5Q7SoGfXoIYX6GDmGzn/5 Ln/CRjSSLGuhf7g8nDnQ0xu0IbnxNjMFCbAn32EFJwz35dug1BBxyk1mTxxI+Wf+0oiL s2PQiDuVaOxnu+3dtoTpN21oCs+RarkNwHiR/vXScAfnqdwT7ciZ/tQ+PwZzSipeT+zh pnR2wZqunaeEwyFzSx6lK2vUCOH5NQp08J7t0Jcm+c5Je/5fq6ZtKEo7H4miWsOYRlgq YZWw== 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=3FKBJA17va/jv2u1TvUxLDB1xiagIFwWCBsEV/clovc=; b=rKuk9e2VBtxitrpio16GXYIdX/lmAXnZ78MYgcd6bTH60YXEKo8Lr8fjvyj+GoM3I8 gk33qwc506PUcuqKNSdgQNuHjwaPFhaEnkeWgkcT0dpUtKb7+CcT2qSDNxTmAKzWVbSR YTX0NDHK9MyljF4DXXBNp8IfJmtUuwsrilNsCOqtA+actlBaEWuqmw7d991EMG4wkeL1 4KjoXQ/MESSiRv6XkLDRQeEo9UeNmRO9pVh1U6e/1FPTXw110HWbsAo64GdxMtb/7kA7 0gj1UGQKhOwvJ+Wp0jnzPaKWzpe4NHu+mNqGjnjWAFMQnuEr1aDHa2EdZeZb2YBIdmOT bj5g== X-Gm-Message-State: APjAAAUeXRrpSAm8cMpBIXTq/wFVZc9HruVuRucw1qMCXBL0qkKVFFN8 q/QbH4Q1f+pAorPzcYpxHB0JxXWYRM0o7w== X-Google-Smtp-Source: APXvYqx8szK/Ee5gqOwDdJcgrOxryRKBr37ENvkZry2XacCKwJhO+9AHaJUUwOC2G//yL7wPVGg33A== X-Received: by 2002:a17:902:158b:: with SMTP id m11mr85445017pla.268.1558944242814; Mon, 27 May 2019 01:04:02 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 27 May 2019 13:33:22 +0530 Message-Id: <20190527080327.10780-4-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527080327.10780-1-mehta.aaru20@gmail.com> References: <20190527080327.10780-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::641 Subject: [Qemu-devel] [PATCH v3 3/8] 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , 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 --- 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 Fri May 3 07:48:55 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=1558944500; cv=none; d=zoho.com; s=zohoarc; b=GIxnrDH5HZ24Ucq5wQq9jjTXMbUYjgAkRGtgn3a5SN1GUaHVKGI5LV5Dtk5LGq2uDFdE1AYFAgHOR9EBN7RriUzKtCbIzFB6SMJHzy4fiMdhLBIpSjsqI6BH3ixLSn/oEUuvSdxl8IZ5nUDvJmQIM1r2aVDRzzLo+B3w0/MwF6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558944500; 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=q5UalSCQoMEla8Jfhq2XT1FqtWrDT6iYKSbikZw7dPY=; b=iQk8PebCizy+OavAiYHLlg0zUoBex+WhheQoD8ebEBiOulA+VUS6RPoFVi+Ctm/MAK/n4HBRElMS9VtT0o/PeRp4DrnwHFViATGCCxjWWEkT+R0j1ocd9/b2ogj3XqefuLvJM2CxT4w+aXw+UntcPt47UnPmR8lZvEZMfmGMdb0= 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 1558944500228637.6443300991841; Mon, 27 May 2019 01:08:20 -0700 (PDT) Received: from localhost ([127.0.0.1]:41691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAg4-0002BA-3k for importer@patchew.org; Mon, 27 May 2019 04:08:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAc7-0007js-Hi for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVAc5-0001p2-K9 for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:11 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:39051) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVAc5-0001mt-DL; Mon, 27 May 2019 04:04:09 -0400 Received: by mail-pf1-x441.google.com with SMTP id z26so9128180pfg.6; Mon, 27 May 2019 01:04:09 -0700 (PDT) Received: from localhost.localdomain ([120.57.119.140]) by smtp.gmail.com with ESMTPSA id j5sm10030853pfa.15.2019.05.27.01.04.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 01:04:07 -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=q5UalSCQoMEla8Jfhq2XT1FqtWrDT6iYKSbikZw7dPY=; b=vSvb09pqYeX3EuL6ac2INKq9oBI1s2JkMaYfxn8EePc0wm1YCPqJJsTLoQZAg8pbUl 5OsZkivd2+jJ3vI3bBBYuUnUjhdeEc2MARrNEUBdyGqScZcKyMshUT+OO+9nuznaqIpK gVDc5UitXU8Ak1KWOutIfzbHtWxA3u6OQpyF7GxLB4LQOQSWMT59r0Gqmr6Kl1vIR5zA IbBnXhFhNXvxXULLNnDJSdup9rwYx3zEI3FY+iBGnTjzKio6C/BRNgl9+Qj/IDzjQV5U 2PfNfYqnjhJZ+AHfV3E7VP47xJq9jXZ+ioI0YM/I+e9bwB4iUb6vRhS/JTAdf6rlVKnk 5SuA== 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=q5UalSCQoMEla8Jfhq2XT1FqtWrDT6iYKSbikZw7dPY=; b=sHWLONDB/bTfdJfxi6layk29GmTcrhuHbriZjw5UBSv7CfZj28DHWxJfBCiNC3c3jv Gep1M8HiBItKBIloUaABKV3BaXTljMmqajMJmJ+8mZHVyYy4+CwUidM2J0Fh85UnRTPk NXlK2MefWn8zP+G95CVmLCiF027OBEL2mLW4ia4QTbojsUECHSPnnmskfbFrFxIArQrJ n8dofUu8IdxXGIDC97vXgVpFHO9OJbeOXEztguFi1mOgvaF5JKgXS1sPpmGLCfEKxSbh xsrDG2X3xwznE9x64J7qUnipV1x+7CeP0TE8ueQkLMinhV7D6Pv3XRBmJ+rZiT+bmjbT U3tQ== X-Gm-Message-State: APjAAAVQ7JYHyYt+crE1Hn15iW/AlFMMghCSbcrRJGUik3QsuiupN7I4 9WStHzC1VDSEW9K3YiaKvdSjV5JwmEpcZA== X-Google-Smtp-Source: APXvYqz2UhopOBIpKSz8bp3yRLzizpf5IejXx43rH9kRKgBdoSD59dJJ5bHU81S4ANqx1P5ASWHC2Q== X-Received: by 2002:a62:87c6:: with SMTP id i189mr135495897pfe.65.1558944247899; Mon, 27 May 2019 01:04:07 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 27 May 2019 13:33:23 +0530 Message-Id: <20190527080327.10780-5-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527080327.10780-1-mehta.aaru20@gmail.com> References: <20190527080327.10780-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] [PATCH v3 4/8] 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , 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 --- We need nested loops in ioq_submit because overflowed requests may be permitted to submit if existing ones are cleared. Hence, failure to=20 fulfill an overflow request must break separately from normal submission. For now, to prevent any infinite loops, if the kernel fails to submit for any reason, we break (ie when number of submissions is zero).=20 Now this is tested with a kali img with trace events to ensure it is=20 actually running. The initramfs boots switched to threads. =20 MAINTAINERS | 7 + block/Makefile.objs | 3 + block/io_uring.c | 301 ++++++++++++++++++++++++++++++++++++++++ include/block/aio.h | 16 ++- include/block/raw-aio.h | 15 ++ 5 files changed, 341 insertions(+), 1 deletion(-) create mode 100644 block/io_uring.c diff --git a/MAINTAINERS b/MAINTAINERS index 3cacd751bf..462c00a021 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2504,6 +2504,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 7a81892a52..348a003af5 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..2a8c48a7dc --- /dev/null +++ b/block/io_uring.c @@ -0,0 +1,301 @@ +/* + * 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 { + BlockAIOCB common; + Coroutine *co; + struct io_uring_sqe sqeq; + int ret; + 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; + +static void ioq_submit(LuringState *s); + +static inline int io_cqe_ret(struct io_uring_cqe *cqe) +{ + return cqe->res; +} + +/** + * 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; + /* + * 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)) { + io_uring_cqe_seen(&s->ring, cqes); + + LuringAIOCB *luringcb =3D io_uring_cqe_get_data(cqes); + luringcb->ret =3D io_cqe_ret(cqes); + if (luringcb->co) { + /* + * If the coroutine is already entered it must be in ioq_submi= t() + * and will notice luringcb->ret has been filled in when it + * eventually runs later. Coroutines cannot be entered recursi= vely + * so avoid doing that! + */ + if (!qemu_coroutine_entered(luringcb->co)) { + aio_co_wake(luringcb->co); + } + } else { + luringcb->common.cb(luringcb->common.opaque, luringcb->ret); + qemu_aio_unref(luringcb); + } + /* Change counters one-by-one because we can be nested. */ + s->io_q.in_flight--; + } + 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 const AIOCBInfo luring_aiocb_info =3D { + .aiocb_size =3D sizeof(LuringAIOCB), +}; + +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 void ioq_submit(LuringState *s) +{ + int ret; + LuringAIOCB *luringcb, *luringcb_next; + + while(!s->io_q.in_queue) { + 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; + io_uring_sqe_set_data(sqes, luringcb); + QSIMPLEQ_REMOVE_HEAD(&s->io_q.sq_overflow, next); + } + ret =3D io_uring_submit(&s->ring); + if (ret <=3D 0) {=20 + /* TODO error handling */ + 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); + } +} + +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); + } +} + +static int luring_do_submit(int fd, LuringAIOCB *luringcb, LuringState *s, + uint64_t offset, QEMUIOVector *qiov, 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, 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, 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)) { + 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, + }; + + ret =3D luring_do_submit(fd, &luringcb, s, offset, qiov, type); + if (ret < 0) { + return ret; + } + + if (luringcb.ret =3D=3D -EINPROGRESS) { + qemu_coroutine_yield(); + } + return luringcb.ret; +} + +BlockAIOCB *luring_submit(BlockDriverState *bs, LuringState *s, int fd, + int64_t sector_num, QEMUIOVector *qiov, BlockCompletionFunc *cb, + void *opaque, int type) +{ + LuringAIOCB *luringcb; + off_t offset =3D sector_num * BDRV_SECTOR_SIZE; + int ret; + + luringcb =3D qemu_aio_get(&luring_aiocb_info, bs, cb, opaque); + luringcb->ret =3D -EINPROGRESS; + ret =3D luring_do_submit(fd, luringcb, s, offset, qiov, 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_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 =3D=3D -1) { + error_setg_errno(errp, -rc, "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..28a836151e 100644 --- a/include/block/raw-aio.h +++ b/include/block/raw-aio.h @@ -58,6 +58,21 @@ 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); +BlockAIOCB *luring_submit(BlockDriverState *bs, LuringState *s, int fd, + int64_t sector_num, QEMUIOVector *qiov, 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 =20 #ifdef _WIN32 typedef struct QEMUWin32AIOState QEMUWin32AIOState; --=20 2.17.1 From nobody Fri May 3 07:48:55 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=1558944624; cv=none; d=zoho.com; s=zohoarc; b=WX0EjqBbmuTyCwwyjv7ZLfTSrG4U/NuDx749k7nY31gvAoss0IMfmQektugr6SSKP7XiCRtc0C0BC9l9QIolSWEClhh2E9qhsUFwh+8KA+Tugtbzp4WzHBuh9Z6+7hjHy2VDk5jiS77etOi33HYduGBmwhBvEDOoTIDS/PEBGOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558944624; 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=9iDE2hU2W31yYscdifZjS5ZJYVdn4yXv1JMbOqGrwXk=; b=HHxXE7TCWCn2lo7k8VaBAgRtm9wSBh1ccSusovEidcfYaUEs/GfN1BjTZfqGow+8IAvhRaeU4mI8/m9JAQViR60gS4OLW3RymxEMiYrKQI61i1sKcy96CHPh+v7KH7Quz2FofNuYYPTyaWN5RmUZ5jFWwzBS9sv1KWA4A6S+e7c= 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 1558944624738158.75779016870138; Mon, 27 May 2019 01:10:24 -0700 (PDT) Received: from localhost ([127.0.0.1]:41709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAhw-0003X2-M0 for importer@patchew.org; Mon, 27 May 2019 04:10:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAcC-0007o2-5q for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVAcB-00021a-6y for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:16 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:43060) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVAcB-000216-2I; Mon, 27 May 2019 04:04:15 -0400 Received: by mail-pl1-x642.google.com with SMTP id gn7so6724635plb.10; Mon, 27 May 2019 01:04:14 -0700 (PDT) Received: from localhost.localdomain ([120.57.119.140]) by smtp.gmail.com with ESMTPSA id j5sm10030853pfa.15.2019.05.27.01.04.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 01:04:12 -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=9iDE2hU2W31yYscdifZjS5ZJYVdn4yXv1JMbOqGrwXk=; b=irb0GuOobJ8X6wooKiggxIt1r+uXzbnfijGrHUrbpE8JD7TPbTgBYuGZZrJzrq698S a87+cnt6qGvswxrAevmc7yir52tlyPtFvGL/kpyKHjSWz7xkrShPwHRJqV6fwtYqc0W3 Rv+s9qB10BUPUNLPczSWhXvwvgZbdHInZ3xolOLGcRvIS6rAOyyxOQS9pIOITEOriRW1 EVBLcbpwmhwHIJUZc7Tn3CHRQUpm+DHKVcCi2at/Ygx27TtgQMsfnOhUBBfNBCUU7Eyy m660hfgZGYwGlq52IhODYR+2rz1f+dTstPYb1OkUYya3sR6D4RzZ+ckZSwew4g9tYkVw sp9A== 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=9iDE2hU2W31yYscdifZjS5ZJYVdn4yXv1JMbOqGrwXk=; b=H0GFyC5nH2q9vBQRa/EFjfGQC5RioQ2fBfdEfMjnP2jDU1euA1b6+Cxkz53zhX4Bhh Ygj6AnuuavKl91dT4f71Lu3/oaFgu/S0fsRzfSZvY+kknr/tKwc7JtfR5BDMeOrfEHY5 xBOYSTxPeikLXso0cJChoSK4wFvI0KixzF1zcJ0QnxYD6pUHucOW6mpqoXyiVcw7af9p Iz4lUlYDkFnZNOtVNvUKjFAjIFamoHVNM7j3SmbdrVUZwAYWwKJ2G+HijCLk0HBw7iqG Js5zAZl6LfjgTP2s7uYYqiY8vlQukhNrZcKKFKrmB1Aik5mpppZFFk7HHRAKOMBaojMo 63qw== X-Gm-Message-State: APjAAAVQZWdWGxiZgflaFcXZ4v75X0SLYtz//VoxVIufVDc8/7WJNKG0 i2ESmS/oKmYMbnF7Ks6qx2BwcFz9RbYmvA== X-Google-Smtp-Source: APXvYqzUc/sCy2vsPirblMP2i4aqpvVH5EWJ6M3vARFEuApRLt2xBNtJrH2CZDQ2wr3Qj1SjWxHsYw== X-Received: by 2002:a17:902:1021:: with SMTP id b30mr24438282pla.324.1558944253367; Mon, 27 May 2019 01:04:13 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 27 May 2019 13:33:24 +0530 Message-Id: <20190527080327.10780-6-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527080327.10780-1-mehta.aaru20@gmail.com> References: <20190527080327.10780-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 v3 5/8] 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , 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 462c00a021..6c6672bda3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2510,6 +2510,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 73452ad265..ea158cf0ee 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 Fri May 3 07:48:55 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=1558944777; cv=none; d=zoho.com; s=zohoarc; b=Pgr6JOsZoeC5So5x9e0daew6f4HOAAFqqRHzxoP/RvcdFTPLNDWHdfAA/rsrST+HMIxqD7BeAEskE9eCetjRsp6AgS1CK9oQb3X9d3p3zZ8fa7Hfrzn1b3n1nauxP2ZrmZ/n77N8rwzJHY5gPu2HMo2m8kGh7zDTyH17fKJoZtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558944777; 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=myA6hpuj1l3Td7j2YCfGOb/tONJWLIFrLRvHHW5M2fYeDZDVUf3ANiG3/Dv5Niz4SyZbbtfiou7WlT9o1juDivchXe5cl36TzG3s3eqRfEY8uyy/79t2xuDesStFW38Y/CBZV7wXJvFVFPz1iFagY1iGDVYLik6VoTqXXdJo13c= 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 1558944777735394.56245612087685; Mon, 27 May 2019 01:12:57 -0700 (PDT) Received: from localhost ([127.0.0.1]:41759 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAkU-0005oS-Md for importer@patchew.org; Mon, 27 May 2019 04:12:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAcG-0007tu-DM for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVAcF-00023q-Fa for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:20 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34992) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVAcF-00023a-9C; Mon, 27 May 2019 04:04:19 -0400 Received: by mail-pf1-x441.google.com with SMTP id d126so6936141pfd.2; Mon, 27 May 2019 01:04:19 -0700 (PDT) Received: from localhost.localdomain ([120.57.119.140]) by smtp.gmail.com with ESMTPSA id j5sm10030853pfa.15.2019.05.27.01.04.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 01:04:17 -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=thsPzzkPiu2fe9UtZVHJfIOE+kgK38nL/p11GA+Q9UTd+KYy8/XF+TZMpiOHKHWPhJ 2F98WGwFmQgGrHI4FkHw45twSIu/ETxH/ezhJ3teIAbzGu26XKnml/4nEDY4+tX6J1nw zaSoLkd62GJ97O1N506qYA3Jkze2htyA9eRDGGYNJHudAfEXa0Jet2OKG4Cv8LssJXm9 hthKtuDMyEBZT3DbD2xeGe9FJappw9LzbFskgDmVejWgrUHQ0ZEiESOYp+TXtqP/crNR RGCR08b8KEhM2uBaawjISWLgQQLWECy/1KkKsocYoyPek01HDH35oDZzFe6dOX7QwRvI JJxg== 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=tW4Jr2Br0soyzfHb3f4rn9dCgife00b67ZmvntdL1EVeNtzDXHjJtSxHp6wK9Gy1OH UBlNJZ1HjCJ+2EFbpzdcRMnrYeYi+iHJ3FcYAHR1PuA86ToGPKAI2WQgLgKWMIn5NJWJ e2U0aZQbyPed8jlfV+a9ETd8L8GSM6wmWCgSapInqduX74FRFdA9DrLAAfUHP7CXQ2it Fep8lXD2owO0/4PMD5Z5XfPLIMXZpSnwP/5Anjr3oFffY9pFX9Ew+flgD1BeUwE7GUve F3ygp4zztnQlTCPGffMAm4QPix8P3O2XwUgqD2DN8zzADQKKMMTw3Z732BAcN9jx0YS7 10pw== X-Gm-Message-State: APjAAAUC1YjIM+dlv1PPyeMsUjHKTTiIXtJOIpgYMv0RBNzdSmivdgWK oU6A1ClFn8ukt9JEL5x5AMHYoynQaUSsuA== X-Google-Smtp-Source: APXvYqzyhR5YSQWVNrOFfD3ERBj8oIBYLUZEbD8YpxB6+agjcWvZFvKLVeFQ5v6ze9Gdaa/MPl9GnQ== X-Received: by 2002:a17:90a:9a6:: with SMTP id 35mr28885965pjo.66.1558944257986; Mon, 27 May 2019 01:04:17 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 27 May 2019 13:33:25 +0530 Message-Id: <20190527080327.10780-7-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527080327.10780-1-mehta.aaru20@gmail.com> References: <20190527080327.10780-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] [PATCH v3 6/8] 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , 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 Fri May 3 07:48:55 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=1558944645; cv=none; d=zoho.com; s=zohoarc; b=GBAiIQCG9RXMzuWBUzoItP+07OUKJnwA58GLPT2bYCnSj+T/3bxwDuB6QazAi/VO032UX+e3zlLuCpaoOus1jVyx33hoD9Zz/o4TwWh2lZAVjjpLXAG9826MmjUtJxmld24iCIy3pVhb8FGJ4IZDGRqAnrQ5St8fPUxuI9U9Aew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558944645; 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=MFg2cgK1UD9qppoRZ6lodJb1OfcqVBWlAqCRvi/E8TQ=; b=Z23MAoPAtvO0wuux7fBJfMW2lbKsnBBn3mB9/HpXdK0nyKOLycNEZBOIuwXyE0nnH+Bv8r4g2hSgfBOyfanklnH1yUuuB4gp2xzKzhD0aYKysJnilqwQpm+/uJsAvcURBwXlv1Xgt6x3wvEup9a9/ypuuWPYkv1ndW1Bb4924J0= 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 1558944645608618.2488368900429; Mon, 27 May 2019 01:10:45 -0700 (PDT) Received: from localhost ([127.0.0.1]:41735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAiN-0003r1-G7 for importer@patchew.org; Mon, 27 May 2019 04:10:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAcT-00082s-Fs for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVAcN-0002Yt-QZ for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:31 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:35745) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVAcL-0002OA-JV; Mon, 27 May 2019 04:04:26 -0400 Received: by mail-pg1-x543.google.com with SMTP id t1so8669966pgc.2; Mon, 27 May 2019 01:04:24 -0700 (PDT) Received: from localhost.localdomain ([120.57.119.140]) by smtp.gmail.com with ESMTPSA id j5sm10030853pfa.15.2019.05.27.01.04.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 01:04:22 -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=MFg2cgK1UD9qppoRZ6lodJb1OfcqVBWlAqCRvi/E8TQ=; b=vEeVKQRP1HzDNXw/l2c6xsCYrNcPnXy248/ntoSjdrB8t+qsFQuTi8isiSSrbJUdRV 4bi/ypUQpPRLg6EX4dJAXXQPpy+00cT+IanpbwtyABVzhGxLM1Na01/ZlwHTXPFBejJQ Aw6B8IUIyu9jXSJL5SWYOtlEokdoQTyFAaMCEDtCN7gSmPXCYkb+XmImnAEj7DgqobEX iKshDgZOjLsnB5CEgjZzmn+XrwCFaSaOl1OoCbvYXgDL4z+jc6oIBQTdHHB4kkwzWXke 67TFtadwek9dYO+j2y8lHS8gWdYyso9dfeto4LVLPu3MJ/RqB3fs0MFxCzE4a4RcaX8+ Lblg== 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=MFg2cgK1UD9qppoRZ6lodJb1OfcqVBWlAqCRvi/E8TQ=; b=QVmj5/0ZkSZkV/b7gnmJCgCYQgqJOPGgN/4VqTcE2nLqo7gfxF5kM2ZEFbNQZX41pa 8QppGBO6PAafgyhLlohKrKZzyIOevWPljDkVtS+Ac6Ua9SayXf0pNCPlkZlX/HkS+48R 7oI+1v16b7r/5v3mFsdamJafx4BQuXm2tgTzI7JnOm/3drHlm12buZUGKRMGd3CS2iGo 6MBK2Y2HqMwxX/G0StU18QLQHiJGaAoZ5VRduVEUihBHp9sncX6pNv/732bhTJCMP4Dy W1rIARLLyU7C/T2gYGPRPdSBzO6/g/3xcAYcXtO2IIIou6J3fcLlxCENIuATBSaYYuaS nZKw== X-Gm-Message-State: APjAAAVwdkZVTsIKHiv8HEAh7JEpfgjkvGqb9mVMmwBx43o6IiHujArn 01xQHO0Xgt5XGyjKsqxFi50Lw+IHhEpUAA== X-Google-Smtp-Source: APXvYqx2kZ6riUoghHRvFuiXYVdNqkyzkuixO0sqMPa9IoRsvp9CcXRW/cKTZR8iY136kYvuQx6ltw== X-Received: by 2002:a63:2b92:: with SMTP id r140mr37337317pgr.363.1558944263225; Mon, 27 May 2019 01:04:23 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 27 May 2019 13:33:26 +0530 Message-Id: <20190527080327.10780-8-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527080327.10780-1-mehta.aaru20@gmail.com> References: <20190527080327.10780-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::543 Subject: [Qemu-devel] [PATCH v3 7/8] 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , 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 --- blockdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 *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 { @@ -4547,7 +4549,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 Fri May 3 07:48:55 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=1558944784; cv=none; d=zoho.com; s=zohoarc; b=PRUzEVxR5H/R7CTbg6RWG/E16PAzyiQg2hjmXzf+kWuN1aZBRjplcuX2OYC8cw0YNaz+bOK6hMLUkSF56hvqw7u92hMUm2YKk1C5HpLTDAyWrAkyLz/t9IRK+FbeMEOo1rxvDX9b3uZDqHWscBaI8OB6wvyQk4b6+ROwH7gLmIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558944784; 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=Uwb/EZQuCfGDY5z7rHaCbNCqdMyI7SEsgEZivjIIJAI=; b=EUVb1BdKCMjXTo2ci2V7d0kbQAB6FG67ihyFxGxg1L2geFQbnxftVFBuI7/baxxPzlMByuabPjxSBf8axnvp7wX5gP8eMm6YQc2IcF53cLlGb+QDk4wJYre624AsNj+mUiddEx0yTtvFaQ3cHBqg+8zQVXm4oJeiLjxjp3Y+hZs= 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 1558944784947482.5720812376186; Mon, 27 May 2019 01:13:04 -0700 (PDT) Received: from localhost ([127.0.0.1]:41761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAkb-0005sB-R3 for importer@patchew.org; Mon, 27 May 2019 04:12:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVAca-00086D-RG for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVAcT-0002vJ-Hv for qemu-devel@nongnu.org; Mon, 27 May 2019 04:04:37 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:36542) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVAcT-0002eA-9v; Mon, 27 May 2019 04:04:33 -0400 Received: by mail-pg1-x544.google.com with SMTP id a3so8668403pgb.3; Mon, 27 May 2019 01:04:29 -0700 (PDT) Received: from localhost.localdomain ([120.57.119.140]) by smtp.gmail.com with ESMTPSA id j5sm10030853pfa.15.2019.05.27.01.04.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 01:04:27 -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=Uwb/EZQuCfGDY5z7rHaCbNCqdMyI7SEsgEZivjIIJAI=; b=o1UML6ikBlzPKty4fWKliLrER8SCt2l8psnpi74SvvCmozjKZG3N6BzMugTyqi8acf TMSuGs41VdbYjEg4MScP0YXz3kKW+LrsBatpPVjCJ2tYVYlPqWbJZXZHa2eTd/EVxR9Q fF+abMJJWOp1cZyx8pNq8a/G4t3pyZYGUgUVpsSDEHWhi/D7Ti7L0htO6lMJiJZ21OSV JOz8mz2I1N9K7fJhL8mYDrDOG5R0bfIzw0BhL+/75yh1IGbpdmJ13vi8bHCf7OO+U3Dt DkkGge9G2ABXomkuDn06fToK4s8WqyHUAavb++h/37pH2BUkOy5M81qhD7r22GhfzMtH KImw== 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=Uwb/EZQuCfGDY5z7rHaCbNCqdMyI7SEsgEZivjIIJAI=; b=cg8trVVyzStnz8rQEeJttLVq0qZqC349tG7R50nGm8uQh5YeHDkjM4XNnpMfNsD4Vl VrslguyqH1lurMWLv5OJ2L9Zt5vfKsvcV65V2WkftW4MB6eRPhxOfLIjPEk92jLRjInF 6kcKZw/fOm15wlpMqQb0zWcaJduhqgqywCd3gUfpbbZBcSoLW6nYMQnSGgGcDv8WzpcB puXMNd8c/BUCeVr++2o3wswqbCjHx0J9Y6YJ9n39tXxwiQ9wJws1cwJHN8+7zY4Ca1lI dIYisS5uqQfj5KvsBbfZMHo5MyAT9i/vLex8EN4UCF9UcCCOeC+GDcCsFnZTZckZJpcE DaWQ== X-Gm-Message-State: APjAAAUeeQpzI332NzMhzYDLWmOEist8OUtv3VmvbvImkn1vITgzQnJo JnPWJRt0DRnEhhmHXFrI2wW1XAnICtz5gg== X-Google-Smtp-Source: APXvYqy2qM0/Rvsu/oKehb1yjv2eoxi3PRcw8dcJ6ptpdkM4dHoHIXOOeKUnEgqjHvs1jxRdx83J1w== X-Received: by 2002:aa7:9217:: with SMTP id 23mr34543747pfo.80.1558944268240; Mon, 27 May 2019 01:04:28 -0700 (PDT) From: Aarushi Mehta To: qemu-devel@nongnu.org Date: Mon, 27 May 2019 13:33:27 +0530 Message-Id: <20190527080327.10780-9-mehta.aaru20@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527080327.10780-1-mehta.aaru20@gmail.com> References: <20190527080327.10780-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] [PATCH v3 8/8] block/fileposix: 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , saket.sinha89@gmail.com, Stefan Hajnoczi , 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 | 65 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index d018429672..50899064df 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", @@ -494,6 +495,9 @@ static int raw_open_common(BlockDriverState *bs, QDict = *options, 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 +561,9 @@ 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 " @@ -578,6 +584,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=3Dio_uring was specified, but is not support= ed " + "in this build."); + ret =3D -EINVAL; + goto fail; + } +#endif /* !defined(CONFIG_LINUX_IO_URING) */ =20 s->has_discard =3D true; s->has_write_zeroes =3D true; @@ -1883,6 +1904,12 @@ static int coroutine_fn raw_co_prw(BlockDriverState = *bs, uint64_t offset, 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 +#ifdef CONFIG_LINUX_IO_URING + } else if (s->use_linux_io_uring) { + LuringState *aio =3D aio_get_linux_io_uring(bdrv_get_aio_conte= xt(bs)); + assert(qiov->size =3D=3D bytes); + return luring_co_submit(bs, aio, s->fd, offset, qiov, type); #endif } } @@ -1920,24 +1947,40 @@ static int coroutine_fn raw_co_pwritev(BlockDriverS= tate *bs, uint64_t offset, =20 static void raw_aio_plug(BlockDriverState *bs) { -#ifdef CONFIG_LINUX_AIO +#if defined CONFIG_LINUX_AIO || defined CONFIG_LINUX_IO_URING BDRVRawState *s =3D bs->opaque; +#endif +#ifdef CONFIG_LINUX_AIO 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) { -#ifdef CONFIG_LINUX_AIO +#if defined CONFIG_LINUX_AIO || defined CONFIG_LINUX_IO_URING BDRVRawState *s =3D bs->opaque; +#endif +#ifdef CONFIG_LINUX_AIO 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_aio) { + 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,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 =3D bs->opaque; +#endif #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 +2019,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