From nobody Mon Feb 9 00:01:42 2026 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1671104080; cv=none; d=zohomail.com; s=zohoarc; b=KreLenXamsw0S9woki4YfkChwDOeREyWGX/pbr1eFBB6NSfqF2gqtS9CEAkuvFLp/P/8PXefDHyeJe1tY11BLVBHfnlYbcWu/vqekM4xQ14SXQMCDrKpocmQqBsFsmg3I60JtLYs1Y9XPuEEHzKYBh23H3zg3fSHmyRawhBVV2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671104080; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/Rfuwpr+kShoJMYQJoTJHzLoWWsJJtsbRxz+cbi+3HQ=; b=Gb6wpMcTsKIZYfxUNUEsOjMbN4Hnfdp4VHt0ldnCRUCR11zGHW7UvyUbARER+V0vxrYrdLusCWVhMQB/3P2W6Ct/WS0UF/z12EhbWC3wNdrt5fH4fCBouimpGNCi9eCE7jt4o9Ksvff7fkQyOUM5+u466gp1CNrg7Gfaqj0X4cA= 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 1671104080811358.37182147751616; Thu, 15 Dec 2022 03:34:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5mTP-0002cP-Ii; Thu, 15 Dec 2022 06:32:23 -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 1p5mTN-0002b7-PL for qemu-devel@nongnu.org; Thu, 15 Dec 2022 06:32:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5mTM-0006lF-4r for qemu-devel@nongnu.org; Thu, 15 Dec 2022 06:32:21 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-615-ByS1VDxMM7208FTfBg8kGw-1; Thu, 15 Dec 2022 06:32:16 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9168F3C11046; Thu, 15 Dec 2022 11:32:15 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id E469F2166B26; Thu, 15 Dec 2022 11:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671103939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Rfuwpr+kShoJMYQJoTJHzLoWWsJJtsbRxz+cbi+3HQ=; b=TVHWcOqQgF9/fZpfdyjXz7v0m51s8ga5jQpMLHdktwJlPxpXH5TuBgsDyTa7kvT1pV+Bp7 6EWvjJnjkbrF9vHphYXmaAxOOiH9J2LR+NnupJFDs5JkrxCb2Hpk1ae1YuYamMnHNe372g E3Z+/7B6yhNVTQNhy1KQCP/A8EWVBDg= X-MC-Unique: ByS1VDxMM7208FTfBg8kGw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Liuxiangdong , Stefano Garzarella , Zhu Lingshan , Si-Wei Liu , Laurent Vivier , "Gonglei (Arei)" , Stefan Hajnoczi , Jason Wang , "Michael S. Tsirkin" , Cindy Lu , Gautam Dawar , Eli Cohen , Cornelia Huck , Paolo Bonzini , Longpeng , Harpreet Singh Anand , Parav Pandit , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v9 06/12] vdpa: request iova_range only once Date: Thu, 15 Dec 2022 12:31:38 +0100 Message-Id: <20221215113144.322011-7-eperezma@redhat.com> In-Reply-To: <20221215113144.322011-1-eperezma@redhat.com> References: <20221215113144.322011-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1671104081289100001 Currently iova range is requested once per queue pair in the case of net. Reduce the number of ioctls asking it once at initialization and reusing that value for each vhost_vdpa. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 15 --------------- net/vhost-vdpa.c | 27 ++++++++++++++------------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 691bcc811a..9b7f4ef083 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -365,19 +365,6 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev= , uint8_t status) return 0; } =20 -static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v) -{ - int ret =3D vhost_vdpa_call(v->dev, VHOST_VDPA_GET_IOVA_RANGE, - &v->iova_range); - if (ret !=3D 0) { - v->iova_range.first =3D 0; - v->iova_range.last =3D UINT64_MAX; - } - - trace_vhost_vdpa_get_iova_range(v->dev, v->iova_range.first, - v->iova_range.last); -} - /* * The use of this function is for requests that only need to be * applied once. Typically such request occurs at the beginning @@ -465,8 +452,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void = *opaque, Error **errp) goto err; } =20 - vhost_vdpa_get_iova_range(v); - if (!vhost_vdpa_first_dev(dev)) { return 0; } diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 2c0ff6d7b0..b6462f0192 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -541,14 +541,15 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_s= vq_ops =3D { }; =20 static NetClientState *net_vhost_vdpa_init(NetClientState *peer, - const char *device, - const char *name, - int vdpa_device_fd, - int queue_pair_index, - int nvqs, - bool is_datapath, - bool svq, - VhostIOVATree *iova_tree) + const char *device, + const char *name, + int vdpa_device_fd, + int queue_pair_index, + int nvqs, + bool is_datapath, + bool svq, + struct vhost_vdpa_iova_range iova_r= ange, + VhostIOVATree *iova_tree) { NetClientState *nc =3D NULL; VhostVDPAState *s; @@ -567,6 +568,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, s->vhost_vdpa.device_fd =3D vdpa_device_fd; s->vhost_vdpa.index =3D queue_pair_index; s->vhost_vdpa.shadow_vqs_enabled =3D svq; + s->vhost_vdpa.iova_range =3D iova_range; s->vhost_vdpa.iova_tree =3D iova_tree; if (!is_datapath) { s->cvq_cmd_out_buffer =3D qemu_memalign(qemu_real_host_page_size(), @@ -646,6 +648,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, int vdpa_device_fd; g_autofree NetClientState **ncs =3D NULL; g_autoptr(VhostIOVATree) iova_tree =3D NULL; + struct vhost_vdpa_iova_range iova_range; NetClientState *nc; int queue_pairs, r, i =3D 0, has_cvq =3D 0; =20 @@ -689,14 +692,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, return queue_pairs; } =20 + vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range); if (opts->x_svq) { - struct vhost_vdpa_iova_range iova_range; - if (!vhost_vdpa_net_valid_svq_features(features, errp)) { goto err_svq; } =20 - vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range); iova_tree =3D vhost_iova_tree_new(iova_range.first, iova_range.las= t); } =20 @@ -705,7 +706,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, for (i =3D 0; i < queue_pairs; i++) { ncs[i] =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 2, true, opts->x_s= vq, - iova_tree); + iova_range, iova_tree); if (!ncs[i]) goto err; } @@ -713,7 +714,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, if (has_cvq) { nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 1, false, - opts->x_svq, iova_tree); + opts->x_svq, iova_range, iova_tree); if (!nc) goto err; } --=20 2.31.1