From nobody Fri Apr 4 05:14:20 2025 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=1739887004; cv=none; d=zohomail.com; s=zohoarc; b=g/POnB+8XLy8gP8BlnyDWEv6/qyxAdo408x8cgENZJWb//whEkaMO3XtEp6sBvtZlr49PSOD9BufGN5vOrXhQgyP2q1fSNsq1Tt6ZsxZWrxpdNW9Vzy4BoOCl5l4Mwuf7hH2lNW1lNrJx6hkdgpQQoigM/KliHi/5eaWpom7tC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739887004; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SOltQryFNQSMGMN53NvBCGByy/u489tUeoJSX0NlizI=; b=mJ0SjjGcF1SjUs75+rOd3x7iBcLXgcIQg+wKQgqdjjj5QOIKQum5wYgWKzEl/E/xvIRc+GHjIrCLag0vwPTqVnNRq3C8iNF+KfuBlT6MkOkZ+XRN3IEcjfs1BpTfHNCWjJayn9i1LtJSdeQkqldsbo5P/uMY+KMzAt8ckYHfXsk= 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 1739887004856744.073414200928; Tue, 18 Feb 2025 05:56:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tkO4b-00060d-Dy; Tue, 18 Feb 2025 08:55:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkJ2o-0004qn-RR for qemu-devel@nongnu.org; Tue, 18 Feb 2025 03:33:30 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tkJ2n-0002bL-58 for qemu-devel@nongnu.org; Tue, 18 Feb 2025 03:33:30 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-220c92c857aso80900285ad.0 for ; Tue, 18 Feb 2025 00:33:28 -0800 (PST) Received: from localhost.localdomain (172-234-80-15.ip.linodeusercontent.com. [172.234.80.15]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-220d545c8d1sm83315925ad.113.2025.02.18.00.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2025 00:33:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739867607; x=1740472407; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=SOltQryFNQSMGMN53NvBCGByy/u489tUeoJSX0NlizI=; b=CrWJqe2Ld+w9qxjaKg4lWG6pnR8DHx9A1I0MkfE1xjiv+d3wQ/M+LVaPWQUAtPpeHn Yx8SjhdapUARjXe65BojPTRUw/osn32ACGcPuPcEvkSA4XLEPBgyug81qttFCMmIrDPB JKHTMdYhGV4CEVzsgK7kAb8lb/4I9WHdSvxgcIp75i8hbBSUrSkr8eWUdbllfSC1Sazh J+dn5HSfQf+fx4unJPEeTsHN5fPtvm9Q0ZhnfwN/kWyhzkYJ/AWOraiVyrGZ6cAB9y/Z q/6gzJBUo8G/nyIBAHx3fo1iq+iXUOS8T5h1MDunlvfc+WApzU2S7hFKgyIGTdf9JCtg yfSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739867607; x=1740472407; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SOltQryFNQSMGMN53NvBCGByy/u489tUeoJSX0NlizI=; b=nKsfHRBGHj0TI9FOgGkVZWBZ87RnM94E4uLBSyWvlHu79sjH9mlpO0WQFMxvAuZ5vC ljUn6gO9WqJQO+tJMTM2ZQpMH5G3l5S6YVhhfJZgbLeEWYZ8ShXm4qTUXSTnfqm8bK3X skVrFVT0iy7mDQYtxhGX60etPVV1PBGOVlzwB754xQYnIbMMtvlcTkHCPlKHp5b1GiBp dsRhYEo+ra6MiCM9zUQPxpWTnyqwHz/pIJ/xGbdP+t8yYBUNxUk4iOAYAjDOh7EHQIvc OSXKf8PESjXrJ55A+hWSDegODTe5BIl35M0bgxC4oc7yvoUs7rG0prYqRUoQ9kTp8i9j 0HTw== X-Gm-Message-State: AOJu0Yz8Sv1yaRksDqIKURf5ngXxcxmaqtKxpEBfwb6UTgMClQfoEN/X XiVvOUGAaROE6yOmPZbFBEgCcaB4PClvRc8UeNl5S9cniYUc5opp X-Gm-Gg: ASbGncu4dLOTLjwk7Pp5PnjHUZF5HZqiuuW/uNJ6pZjze4FQ88/GZkbSum7AcjKTS96 ylnzi87cz3q/j1V7+3h2KCH84VQInQuzpL/bFkQfw04lUf0FNE34voTj8NiKMxRUE2UpZIbZMkj Ti+uSGVtE0lqDqYSan21qEzBYGDxBzQxNW0RnY1IvFoBOFjYg52vHSW0W6ZXkyZ0si9czvEVGFg ul3m0HXyNbFg0gYodz/Np2eyH6grw9f/9yMt9B2MRT5UO6TxTmM6p6l1acjiKOioAIW2J3cE56t bGWB6Y6tAiNBkURpdqYatlcYdOfIdJA749OKlK6tOuOPkz7rPJfCjoP8Nn1r2TVhseOzR3Oauw= = X-Google-Smtp-Source: AGHT+IF9n5luPvR4x3NZzuzbiZfJ8ovT5kJVjcYGbVtt947882dUEVF4zKTz1Hmh+rBG+6e2QrqhYQ== X-Received: by 2002:a17:902:f60b:b0:21f:2e:4e4e with SMTP id d9443c01a7336-221043951bbmr180884075ad.5.1739867606991; Tue, 18 Feb 2025 00:33:26 -0800 (PST) From: oenhan@gmail.com X-Google-Original-From: hanht2@chinatelecom.cn To: mst@redhat.com, sgarzare@redhat.com Cc: qemu-devel@nongnu.org, Huaitong Han , Zhiyuan Yuan Subject: [PATCH] vhost: Don't set vring call if guest notifier is disabled Date: Tue, 18 Feb 2025 16:32:08 +0800 Message-ID: <20250218083208.78465-1-hanht2@chinatelecom.cn> X-Mailer: git-send-email 2.43.5 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::636; envelope-from=oenhan@gmail.com; helo=mail-pl1-x636.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 18 Feb 2025 08:55:39 -0500 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1739887006034019100 Content-Type: text/plain; charset="utf-8" From: Huaitong Han The vring call fd is set even when the guest does not use MSIX (e.g., virtio PMD). This results in unnecessary CPU overhead for handling virtio interrup= ts. The previous patch only optimized the condition when query_queue_notifier w= as enabled and the vector was unset. However, if query_queue_notifier is disab= led, the vring call FD should also be unset to avoid this inefficiency. Reported-by: Zhiyuan Yuan Signed-off-by: Huaitong Han Tested-by: Lei Yang --- hw/virtio/vhost.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 6aa72fd434..d17e7cc6fe 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1342,8 +1342,8 @@ int vhost_virtqueue_start(struct vhost_dev *dev, } =20 if (k->query_guest_notifiers && - k->query_guest_notifiers(qbus->parent) && - virtio_queue_vector(vdev, idx) =3D=3D VIRTIO_NO_VECTOR) { + (!k->query_guest_notifiers(qbus->parent) || + virtio_queue_vector(vdev, idx) =3D=3D VIRTIO_NO_VECTOR)) { file.fd =3D -1; r =3D dev->vhost_ops->vhost_set_vring_call(dev, &file); if (r) { --=20 2.43.5