From nobody Sat Oct 25 21:42:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521602558387699.2925197616574; Tue, 20 Mar 2018 20:22:38 -0700 (PDT) Received: from localhost ([::1]:52603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyUKj-0005ZK-KF for importer@patchew.org; Tue, 20 Mar 2018 23:22:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyUJt-0005FV-66 for qemu-devel@nongnu.org; Tue, 20 Mar 2018 23:21:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyUJp-0001Vx-7E for qemu-devel@nongnu.org; Tue, 20 Mar 2018 23:21:45 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37798 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eyUJp-0001V7-3Y for qemu-devel@nongnu.org; Tue, 20 Mar 2018 23:21:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B21AA4040070 for ; Wed, 21 Mar 2018 03:21:34 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD8AA111DCFB; Wed, 21 Mar 2018 03:21:25 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Mar 2018 11:21:24 +0800 Message-Id: <20180321032124.24028-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 21 Mar 2018 03:21:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 21 Mar 2018 03:21:34 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] vhost: add trace for IOTLB miss 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: Jason Wang , peterx@redhat.com, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add some trace points for IOTLB translation for vhost. After vhost-user is setup, the only IO path that QEMU will participate should be the IOMMU translation, so it'll be good we can track this with explicit timestamps when needed to see how long time we take to do the translation, and whether there's anything stuck inside. It might be useful for triaging vhost-user problems. Signed-off-by: Peter Xu --- hw/virtio/trace-events | 1 + hw/virtio/vhost.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 742ff0f90b..933eaab133 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -5,6 +5,7 @@ vhost_commit(bool started, bool changed) "Started: %d Chang= ed: %d" vhost_region_add_section(const char *name, uint64_t gpa, uint64_t size, ui= nt64_t host) "%s: 0x%"PRIx64"+0x%"PRIx64" @ 0x%"PRIx64 vhost_region_add_section_abut(const char *name, uint64_t new_size) "%s: 0x= %"PRIx64 vhost_section(const char *name, int r) "%s:%d" +vhost_iotlb_miss(void *dev, int step) "%p step %d" =20 # hw/virtio/virtio.c virtqueue_alloc_element(void *elem, size_t sz, unsigned in_num, unsigned o= ut_num) "elem %p size %zd in_num %u out_num %u" diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index d8d0ef92e1..aa68f79510 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -839,12 +839,15 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, ui= nt64_t iova, int write) =20 rcu_read_lock(); =20 + trace_vhost_iotlb_miss(dev, 1); + iotlb =3D address_space_get_iotlb_entry(dev->vdev->dma_as, iova, write); if (iotlb.target_as !=3D NULL) { ret =3D vhost_memory_region_lookup(dev, iotlb.translated_addr, &uaddr, &len); if (ret) { + trace_vhost_iotlb_miss(dev, 3); error_report("Fail to lookup the translated address " "%"PRIx64, iotlb.translated_addr); goto out; @@ -856,10 +859,14 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, ui= nt64_t iova, int write) ret =3D vhost_backend_update_device_iotlb(dev, iova, uaddr, len, iotlb.perm); if (ret) { + trace_vhost_iotlb_miss(dev, 4); error_report("Fail to update device iotlb"); goto out; } } + + trace_vhost_iotlb_miss(dev, 2); + out: rcu_read_unlock(); =20 --=20 2.14.3