From nobody Wed May 8 11:08:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1653996316; cv=none; d=zohomail.com; s=zohoarc; b=dHXcPRmtSh9RvNyKYj9ayuWvEC1P9O5G6WfBP4is8+Vmf6jElRfG7w7nv+jXeX/hSUmk5WMfctOxV9va5P6TlTRw5utjiQTFE/gYMew0LIFRy4V3cUE98J3tPIzEL8a1DLvcL/k55UNPJULrA7Ux7Ig3J6EVGfZBZEpQSQ1r3Eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653996316; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=WXd7IseUjcKOiQu5akVggQkBFpKnXiYCwOPparFgzvM=; b=exknict2dutSdwoDTFboKMWOajYaKS2mpFrOvQ6w5Vyp7Sjs5TKsEEQ3TNTPYXNzLo3PdXp7ARumDZokdGypDWA2+dXfO2qUwOSUZTRPzD/33+m7CvkPI9rdWeibk3xGcIzhj6zEKBWP1QpTEKv5ziX6u+MELJu7148YLX1ffbI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16539963167201004.8756550439306; Tue, 31 May 2022 04:25:16 -0700 (PDT) Received: from localhost ([::1]:36048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvzzv-0000MF-4j for importer@patchew.org; Tue, 31 May 2022 07:25:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvzT6-0001TU-Cs for qemu-devel@nongnu.org; Tue, 31 May 2022 06:51:22 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:40671) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nvzT4-0005rD-Nn for qemu-devel@nongnu.org; Tue, 31 May 2022 06:51:20 -0400 Received: by mail-pf1-x42f.google.com with SMTP id z17so306427pff.7 for ; Tue, 31 May 2022 03:51:18 -0700 (PDT) Received: from fedora.. ([101.206.169.117]) by smtp.gmail.com with ESMTPSA id mn1-20020a17090b188100b001e2f383110bsm1634080pjb.11.2022.05.31.03.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 03:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WXd7IseUjcKOiQu5akVggQkBFpKnXiYCwOPparFgzvM=; b=PRnE3rmIlovwuuJnA8eZ/ns1foi9w1YiWOjsC07qudNsS+ztXmL0jQrfML3xOpxGq6 ibr/g5mgdlSgpDTX6SGXLQ8yhi2COibQwVd6UDPXf/YjlBiq2BPfYJZmH6vyvWSWDIzL LQlckzW7dkLrbO9x6hDy5AFShARiU/HdhgGY3sV9Yx/KplmM/ckoR7vVmzD7DG1dl5R1 JjYWeoRynjCMzIfS7xCTT/hLaOo+oB1M8ibaqNTSzFq9Wma1ssRbdmWAT10OrUbOlsjW ZhLdpiM/JvovvAVdxloChTgQkhmcI9qeIkttklFVDZnPgGuGNn2Uy5JTcdeQNnDIAil8 +V8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WXd7IseUjcKOiQu5akVggQkBFpKnXiYCwOPparFgzvM=; b=N/016DOkH5QKqDVnBUbJXj6nfSK9+ypwSknISPmbqlAu3BIAUm3P83Oo3M2kiAjSYF VaHnsMr+SVd8M3GuU2RE8kqC4XApL+OJ80LCXbqsoU3DJRidPKYMgdbFSpQBf5pErKSu vFoAOXLlK6hEZwSrVaCFx0I4DaiEtiMxOTde+3VBUfSppb9OXfkP1BxfS5WyBkLrGgSJ Pqmr8ASn+pZ8Po3bEk54u+xClhHrk+TMtwPeWWWEEEcyZQQGvq+h2lTBppmWWCkIupM5 +OLhzLhNsM6xY87gDD2FBmqt/2ozojw0SbcDdfwkzyMklZM2FEOdmOwqRa32ZwCfDdvu vZfw== X-Gm-Message-State: AOAM530Pcny98D8ncNXhMqVPs7MzancawG8ML7nW1o/aMo2c/g7AoNYm 7phIyN6fteGDmseMEGRc93jtStyLmPBm1A== X-Google-Smtp-Source: ABdhPJx5YSkgJhR82NG0nM20xDprwMvlhGvEamSUejCqu+UmO16RwsWbNueSPo2X5C2j71v5BKhxDw== X-Received: by 2002:a65:6250:0:b0:3c6:8a09:249 with SMTP id q16-20020a656250000000b003c68a090249mr52578015pgv.389.1653994277012; Tue, 31 May 2022 03:51:17 -0700 (PDT) From: Sam Li To: qemu-devel Cc: Stefan Hajnoczi , Damien Le Moal , Dmitry Fomichev , Hannes Reinecke , Sam Li Subject: [PATCH v6] Use io_uring_register_ring_fd() to skip fd operations Date: Tue, 31 May 2022 18:50:11 +0800 Message-Id: <20220531105011.111082-1-faithilikerun@gmail.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=faithilikerun@gmail.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1653996318973100001 Content-Type: text/plain; charset="utf-8" Linux recently added a new io_uring(7) optimization API that QEMU doesn't take advantage of yet. The liburing library that QEMU uses has added a corresponding new API calling io_uring_register_ring_fd(). When this API is called after creating the ring, the io_uring_submit() library function passes a flag to the io_uring_enter(2) syscall allowing it to skip the ring file descriptor fdget()/fdput() operations. This saves some CPU cycles. Signed-off-by: Sam Li --- block/io_uring.c | 12 +++++++++++- meson.build | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/block/io_uring.c b/block/io_uring.c index 0b401512b9..d48e472e74 100644 --- a/block/io_uring.c +++ b/block/io_uring.c @@ -18,6 +18,7 @@ #include "qapi/error.h" #include "trace.h" =20 + /* io_uring ring size */ #define MAX_ENTRIES 128 =20 @@ -434,8 +435,17 @@ LuringState *luring_init(Error **errp) } =20 ioq_init(&s->io_q); - return s; +#ifdef CONFIG_LIBURING_REGISTER_RING_FD + if (io_uring_register_ring_fd(&s->ring) < 0) { + /* + * Only warn about this error: we will fallback to the non-optimiz= ed + * io_uring operations. + */ + warn_report("failed to register linux io_uring ring file descripto= r"); + } +#endif =20 + return s; } =20 void luring_cleanup(LuringState *s) diff --git a/meson.build b/meson.build index 9ebc00f032..9ffc74d8ed 100644 --- a/meson.build +++ b/meson.build @@ -1733,6 +1733,7 @@ config_host_data.set('CONFIG_LIBNFS', libnfs.found()) config_host_data.set('CONFIG_LIBSSH', libssh.found()) config_host_data.set('CONFIG_LINUX_AIO', libaio.found()) config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found()) +config_host_data.set('CONFIG_LIBURING_REGISTER_RING_FD', cc.has_function('= io_uring_register_ring_fd', prefix: '#include ', dependencies:l= inux_io_uring)) config_host_data.set('CONFIG_LIBPMEM', libpmem.found()) config_host_data.set('CONFIG_NUMA', numa.found()) config_host_data.set('CONFIG_OPENGL', opengl.found()) --=20 2.35.3