[PATCH 23/33] vhost: add some useful trace-points

Vladimir Sementsov-Ogievskiy posted 33 patches 3 months ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, Zhenwei Pi <pizhenwei@bytedance.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Raphael Norwitz <raphael@enfabrica.net>, Jason Wang <jasowang@redhat.com>, Fam Zheng <fam@euphon.net>, "Alex Bennée" <alex.bennee@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
[PATCH 23/33] vhost: add some useful trace-points
Posted by Vladimir Sementsov-Ogievskiy 3 months ago
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 hw/virtio/trace-events |  8 ++++++++
 hw/virtio/vhost.c      | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
index e5142c27f9..bd595fcd91 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -10,7 +10,15 @@ vhost_reject_section(const char *name, int d) "%s:%d"
 vhost_iotlb_miss(void *dev, int step) "%p step %d"
 vhost_dev_cleanup(void *dev) "%p"
 vhost_dev_start(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
+vhost_dev_start_finish(const char *name) "%s"
 vhost_dev_stop(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
+vhost_dev_stop_finish(const char *name) "%s"
+vhost_virtque_start(const char *name, int idx) "%s %d"
+vhost_virtque_start_finish(const char *name, int idx) "%s %d"
+vhost_virtque_stop(const char *name, int idx) "%s %d"
+vhost_virtque_stop_finish(const char *name, int idx) "%s %d"
+vhost_dev_init(void) ""
+vhost_dev_init_finish(void) ""
 
 
 # vhost-user.c
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index e796ad347d..e7c809400b 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1329,6 +1329,8 @@ int vhost_virtqueue_start(struct vhost_dev *dev,
     };
     struct VirtQueue *vvq = virtio_get_queue(vdev, idx);
 
+    trace_vhost_virtque_start(vdev->name, idx);
+
     r = vhost_vrings_map(dev, vdev, vq, idx);
     if (r <= 0) {
         return r;
@@ -1390,6 +1392,8 @@ int vhost_virtqueue_start(struct vhost_dev *dev,
         }
     }
 
+    trace_vhost_virtque_start_finish(vdev->name, idx);
+
     return 0;
 
 fail:
@@ -1408,6 +1412,8 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
     };
     int r = 0;
 
+    trace_vhost_virtque_stop(vdev->name, idx);
+
     if (virtio_queue_get_desc_addr(vdev, idx) == 0) {
         /* Don't stop the virtqueue which might have not been started */
         return 0;
@@ -1441,6 +1447,8 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
     }
 
     vhost_vrings_unmap(dev, vq, true);
+
+    trace_vhost_virtque_stop_finish(vdev->name, idx);
     return r;
 }
 
@@ -1598,6 +1606,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
 {
     int i, r, n_initialized_vqs = 0;
 
+    trace_vhost_dev_init();
+
     hdev->vdev = NULL;
     hdev->migration_blocker = NULL;
 
@@ -1682,6 +1692,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
         goto fail;
     }
 
+    trace_vhost_dev_init_finish();
+
     return 0;
 
 fail:
@@ -2132,6 +2144,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
         }
     }
     vhost_start_config_intr(hdev);
+
+    trace_vhost_dev_start_finish(vdev->name);
     return 0;
 fail_iotlb:
     if (vhost_dev_has_iommu(hdev) &&
@@ -2210,6 +2224,8 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
     hdev->started = false;
     vdev->vhost_started = false;
     hdev->vdev = NULL;
+
+    trace_vhost_dev_stop_finish(vdev->name);
     return rc;
 }
 
-- 
2.48.1
Re: [PATCH 23/33] vhost: add some useful trace-points
Posted by Raphael Norwitz 1 month ago
On Wed, Aug 13, 2025 at 12:58 PM Vladimir Sementsov-Ogievskiy
<vsementsov@yandex-team.ru> wrote:
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  hw/virtio/trace-events |  8 ++++++++
>  hw/virtio/vhost.c      | 16 ++++++++++++++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
> index e5142c27f9..bd595fcd91 100644
> --- a/hw/virtio/trace-events
> +++ b/hw/virtio/trace-events
> @@ -10,7 +10,15 @@ vhost_reject_section(const char *name, int d) "%s:%d"
>  vhost_iotlb_miss(void *dev, int step) "%p step %d"
>  vhost_dev_cleanup(void *dev) "%p"
>  vhost_dev_start(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
> +vhost_dev_start_finish(const char *name) "%s"
>  vhost_dev_stop(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
> +vhost_dev_stop_finish(const char *name) "%s"
> +vhost_virtque_start(const char *name, int idx) "%s %d"
> +vhost_virtque_start_finish(const char *name, int idx) "%s %d"
> +vhost_virtque_stop(const char *name, int idx) "%s %d"
> +vhost_virtque_stop_finish(const char *name, int idx) "%s %d"
> +vhost_dev_init(void) ""
> +vhost_dev_init_finish(void) ""

Ditto here - I would think this should also have the VirtIODevice/vdev pointer.


>
>
>  # vhost-user.c
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index e796ad347d..e7c809400b 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1329,6 +1329,8 @@ int vhost_virtqueue_start(struct vhost_dev *dev,
>      };
>      struct VirtQueue *vvq = virtio_get_queue(vdev, idx);
>
> +    trace_vhost_virtque_start(vdev->name, idx);
> +
>      r = vhost_vrings_map(dev, vdev, vq, idx);
>      if (r <= 0) {
>          return r;
> @@ -1390,6 +1392,8 @@ int vhost_virtqueue_start(struct vhost_dev *dev,
>          }
>      }
>
> +    trace_vhost_virtque_start_finish(vdev->name, idx);
> +
>      return 0;
>
>  fail:
> @@ -1408,6 +1412,8 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
>      };
>      int r = 0;
>
> +    trace_vhost_virtque_stop(vdev->name, idx);
> +
>      if (virtio_queue_get_desc_addr(vdev, idx) == 0) {
>          /* Don't stop the virtqueue which might have not been started */
>          return 0;
> @@ -1441,6 +1447,8 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
>      }
>
>      vhost_vrings_unmap(dev, vq, true);
> +
> +    trace_vhost_virtque_stop_finish(vdev->name, idx);
>      return r;
>  }
>
> @@ -1598,6 +1606,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>  {
>      int i, r, n_initialized_vqs = 0;
>
> +    trace_vhost_dev_init();
> +
>      hdev->vdev = NULL;
>      hdev->migration_blocker = NULL;
>
> @@ -1682,6 +1692,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
>          goto fail;
>      }
>
> +    trace_vhost_dev_init_finish();
> +
>      return 0;
>
>  fail:
> @@ -2132,6 +2144,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
>          }
>      }
>      vhost_start_config_intr(hdev);
> +
> +    trace_vhost_dev_start_finish(vdev->name);
>      return 0;
>  fail_iotlb:
>      if (vhost_dev_has_iommu(hdev) &&
> @@ -2210,6 +2224,8 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
>      hdev->started = false;
>      vdev->vhost_started = false;
>      hdev->vdev = NULL;
> +
> +    trace_vhost_dev_stop_finish(vdev->name);
>      return rc;
>  }
>
> --
> 2.48.1
>
>
Re: [PATCH 23/33] vhost: add some useful trace-points
Posted by Vladimir Sementsov-Ogievskiy 1 month ago
On 09.10.25 22:08, Raphael Norwitz wrote:
> On Wed, Aug 13, 2025 at 12:58 PM Vladimir Sementsov-Ogievskiy
> <vsementsov@yandex-team.ru> wrote:
>> Signed-off-by: Vladimir Sementsov-Ogievskiy<vsementsov@yandex-team.ru>
>> ---
>>   hw/virtio/trace-events |  8 ++++++++
>>   hw/virtio/vhost.c      | 16 ++++++++++++++++
>>   2 files changed, 24 insertions(+)
>>
>> diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
>> index e5142c27f9..bd595fcd91 100644
>> --- a/hw/virtio/trace-events
>> +++ b/hw/virtio/trace-events
>> @@ -10,7 +10,15 @@ vhost_reject_section(const char *name, int d) "%s:%d"
>>   vhost_iotlb_miss(void *dev, int step) "%p step %d"
>>   vhost_dev_cleanup(void *dev) "%p"
>>   vhost_dev_start(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
>> +vhost_dev_start_finish(const char *name) "%s"
>>   vhost_dev_stop(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
>> +vhost_dev_stop_finish(const char *name) "%s"
>> +vhost_virtque_start(const char *name, int idx) "%s %d"
>> +vhost_virtque_start_finish(const char *name, int idx) "%s %d"
>> +vhost_virtque_stop(const char *name, int idx) "%s %d"
>> +vhost_virtque_stop_finish(const char *name, int idx) "%s %d"
>> +vhost_dev_init(void) ""
>> +vhost_dev_init_finish(void) ""
> Ditto here - I would think this should also have the VirtIODevice/vdev pointer.

Ok

-- 
Best regards,
Vladimir