[PATCH 22/33] vhost-user-blk: 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 22/33] vhost-user-blk: add some useful trace-points
Posted by Vladimir Sementsov-Ogievskiy 3 months ago
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 hw/block/trace-events     | 10 ++++++++++
 hw/block/vhost-user-blk.c | 15 +++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/hw/block/trace-events b/hw/block/trace-events
index cc9a9f2460..3b5fd2a599 100644
--- a/hw/block/trace-events
+++ b/hw/block/trace-events
@@ -58,6 +58,16 @@ virtio_blk_handle_zone_mgmt(void *vdev, void *req, uint8_t op, int64_t sector, i
 virtio_blk_handle_zone_reset_all(void *vdev, void *req, int64_t sector, int64_t len) "vdev %p req %p sector 0x%" PRIx64 " cap 0x%" PRIx64 ""
 virtio_blk_handle_zone_append(void *vdev, void *req, int64_t sector) "vdev %p req %p, append sector 0x%" PRIx64 ""
 
+# vhost-user-blk.c
+vhost_user_blk_start(void) ""
+vhost_user_blk_start_finish(void) ""
+vhost_user_blk_stop(void) ""
+vhost_user_blk_stop_finish(void) ""
+vhost_user_blk_connect(void) ""
+vhost_user_blk_connect_finish(void) ""
+vhost_user_blk_device_realize(void) ""
+vhost_user_blk_device_realize_finish(void) ""
+
 # hd-geometry.c
 hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p LCHS %d %d %d"
 hd_geometry_guess(void *blk, uint32_t cyls, uint32_t heads, uint32_t secs, int trans) "blk %p CHS %u %u %u trans %d"
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index de7a810c93..c8bc2c78e6 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -31,6 +31,7 @@
 #include "hw/virtio/virtio-access.h"
 #include "system/system.h"
 #include "system/runstate.h"
+#include "trace.h"
 
 static const int user_feature_bits[] = {
     VIRTIO_BLK_F_SIZE_MAX,
@@ -137,6 +138,8 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp)
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
     int i, ret;
 
+    trace_vhost_user_blk_start();
+
     if (!k->set_guest_notifiers) {
         error_setg(errp, "binding does not support guest notifiers");
         return -ENOSYS;
@@ -192,6 +195,8 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp)
     }
     s->started_vu = true;
 
+    trace_vhost_user_blk_start_finish();
+
     return ret;
 
 err_guest_notifiers:
@@ -212,6 +217,8 @@ static int vhost_user_blk_stop(VirtIODevice *vdev)
     int ret;
     bool force_stop = false;
 
+    trace_vhost_user_blk_stop();
+
     if (!s->started_vu) {
         return 0;
     }
@@ -233,6 +240,8 @@ static int vhost_user_blk_stop(VirtIODevice *vdev)
     }
 
     vhost_dev_disable_notifiers(&s->dev, vdev);
+
+    trace_vhost_user_blk_stop_finish();
     return ret;
 }
 
@@ -340,6 +349,8 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
     VHostUserBlk *s = VHOST_USER_BLK(vdev);
     int ret = 0;
 
+    trace_vhost_user_blk_connect();
+
     if (s->connected) {
         return 0;
     }
@@ -365,6 +376,7 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
         ret = vhost_user_blk_start(vdev, errp);
     }
 
+    trace_vhost_user_blk_connect_finish();
     return ret;
 }
 
@@ -455,6 +467,8 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
     int retries;
     int i, ret;
 
+    trace_vhost_user_blk_device_realize();
+
     if (!s->chardev.chr) {
         error_setg(errp, "chardev is mandatory");
         return;
@@ -514,6 +528,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
     qemu_chr_fe_set_handlers(&s->chardev,  NULL, NULL,
                              vhost_user_blk_event, NULL, (void *)dev,
                              NULL, true);
+    trace_vhost_user_blk_device_realize_finish();
     return;
 
 virtio_err:
-- 
2.48.1
Re: [PATCH 22/33] vhost-user-blk: add some useful trace-points
Posted by Raphael Norwitz 1 month ago
On Wed, Aug 13, 2025 at 1:01 PM Vladimir Sementsov-Ogievskiy
<vsementsov@yandex-team.ru> wrote:
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  hw/block/trace-events     | 10 ++++++++++
>  hw/block/vhost-user-blk.c | 15 +++++++++++++++
>  2 files changed, 25 insertions(+)
>
> diff --git a/hw/block/trace-events b/hw/block/trace-events
> index cc9a9f2460..3b5fd2a599 100644
> --- a/hw/block/trace-events
> +++ b/hw/block/trace-events
> @@ -58,6 +58,16 @@ virtio_blk_handle_zone_mgmt(void *vdev, void *req, uint8_t op, int64_t sector, i
>  virtio_blk_handle_zone_reset_all(void *vdev, void *req, int64_t sector, int64_t len) "vdev %p req %p sector 0x%" PRIx64 " cap 0x%" PRIx64 ""
>  virtio_blk_handle_zone_append(void *vdev, void *req, int64_t sector) "vdev %p req %p, append sector 0x%" PRIx64 ""
>
> +# vhost-user-blk.c
> +vhost_user_blk_start(void) ""
> +vhost_user_blk_start_finish(void) ""
> +vhost_user_blk_stop(void) ""
> +vhost_user_blk_stop_finish(void) ""
> +vhost_user_blk_connect(void) ""
> +vhost_user_blk_connect_finish(void) ""
> +vhost_user_blk_device_realize(void) ""
> +vhost_user_blk_device_realize_finish(void) ""

Should we also trace the VirtIODevice/vdev pointer like in virtio-blk.c?


> +
>  # hd-geometry.c
>  hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p LCHS %d %d %d"
>  hd_geometry_guess(void *blk, uint32_t cyls, uint32_t heads, uint32_t secs, int trans) "blk %p CHS %u %u %u trans %d"
> diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
> index de7a810c93..c8bc2c78e6 100644
> --- a/hw/block/vhost-user-blk.c
> +++ b/hw/block/vhost-user-blk.c
> @@ -31,6 +31,7 @@
>  #include "hw/virtio/virtio-access.h"
>  #include "system/system.h"
>  #include "system/runstate.h"
> +#include "trace.h"
>
>  static const int user_feature_bits[] = {
>      VIRTIO_BLK_F_SIZE_MAX,
> @@ -137,6 +138,8 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp)
>      VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
>      int i, ret;
>
> +    trace_vhost_user_blk_start();
> +
>      if (!k->set_guest_notifiers) {
>          error_setg(errp, "binding does not support guest notifiers");
>          return -ENOSYS;
> @@ -192,6 +195,8 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp)
>      }
>      s->started_vu = true;
>
> +    trace_vhost_user_blk_start_finish();
> +
>      return ret;
>
>  err_guest_notifiers:
> @@ -212,6 +217,8 @@ static int vhost_user_blk_stop(VirtIODevice *vdev)
>      int ret;
>      bool force_stop = false;
>
> +    trace_vhost_user_blk_stop();
> +
>      if (!s->started_vu) {
>          return 0;
>      }
> @@ -233,6 +240,8 @@ static int vhost_user_blk_stop(VirtIODevice *vdev)
>      }
>
>      vhost_dev_disable_notifiers(&s->dev, vdev);
> +
> +    trace_vhost_user_blk_stop_finish();
>      return ret;
>  }
>
> @@ -340,6 +349,8 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
>      VHostUserBlk *s = VHOST_USER_BLK(vdev);
>      int ret = 0;
>
> +    trace_vhost_user_blk_connect();
> +
>      if (s->connected) {
>          return 0;
>      }
> @@ -365,6 +376,7 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
>          ret = vhost_user_blk_start(vdev, errp);
>      }
>
> +    trace_vhost_user_blk_connect_finish();
>      return ret;
>  }
>
> @@ -455,6 +467,8 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
>      int retries;
>      int i, ret;
>
> +    trace_vhost_user_blk_device_realize();
> +
>      if (!s->chardev.chr) {
>          error_setg(errp, "chardev is mandatory");
>          return;
> @@ -514,6 +528,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
>      qemu_chr_fe_set_handlers(&s->chardev,  NULL, NULL,
>                               vhost_user_blk_event, NULL, (void *)dev,
>                               NULL, true);
> +    trace_vhost_user_blk_device_realize_finish();
>      return;
>
>  virtio_err:
> --
> 2.48.1
>
>
Re: [PATCH 22/33] vhost-user-blk: add some useful trace-points
Posted by Vladimir Sementsov-Ogievskiy 1 month ago
On 09.10.25 22:07, Raphael Norwitz wrote:
> On Wed, Aug 13, 2025 at 1:01 PM Vladimir Sementsov-Ogievskiy
> <vsementsov@yandex-team.ru> wrote:
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>> ---
>>   hw/block/trace-events     | 10 ++++++++++
>>   hw/block/vhost-user-blk.c | 15 +++++++++++++++
>>   2 files changed, 25 insertions(+)
>>
>> diff --git a/hw/block/trace-events b/hw/block/trace-events
>> index cc9a9f2460..3b5fd2a599 100644
>> --- a/hw/block/trace-events
>> +++ b/hw/block/trace-events
>> @@ -58,6 +58,16 @@ virtio_blk_handle_zone_mgmt(void *vdev, void *req, uint8_t op, int64_t sector, i
>>   virtio_blk_handle_zone_reset_all(void *vdev, void *req, int64_t sector, int64_t len) "vdev %p req %p sector 0x%" PRIx64 " cap 0x%" PRIx64 ""
>>   virtio_blk_handle_zone_append(void *vdev, void *req, int64_t sector) "vdev %p req %p, append sector 0x%" PRIx64 ""
>>
>> +# vhost-user-blk.c
>> +vhost_user_blk_start(void) ""
>> +vhost_user_blk_start_finish(void) ""
>> +vhost_user_blk_stop(void) ""
>> +vhost_user_blk_stop_finish(void) ""
>> +vhost_user_blk_connect(void) ""
>> +vhost_user_blk_connect_finish(void) ""
>> +vhost_user_blk_device_realize(void) ""
>> +vhost_user_blk_device_realize_finish(void) ""
> 
> Should we also trace the VirtIODevice/vdev pointer like in virtio-blk.c?
> 

Agree, it may help to debug a setup with several disk, and just for consistency with virtio-blk.c


> 
>> +
>>   # hd-geometry.c
>>   hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p LCHS %d %d %d"
>>   hd_geometry_guess(void *blk, uint32_t cyls, uint32_t heads, uint32_t secs, int trans) "blk %p CHS %u %u %u trans %d"
>> diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
>> index de7a810c93..c8bc2c78e6 100644
>> --- a/hw/block/vhost-user-blk.c
>> +++ b/hw/block/vhost-user-blk.c
>> @@ -31,6 +31,7 @@
>>   #include "hw/virtio/virtio-access.h"
>>   #include "system/system.h"
>>   #include "system/runstate.h"
>> +#include "trace.h"
>>
>>   static const int user_feature_bits[] = {
>>       VIRTIO_BLK_F_SIZE_MAX,
>> @@ -137,6 +138,8 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp)
>>       VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
>>       int i, ret;
>>
>> +    trace_vhost_user_blk_start();
>> +
>>       if (!k->set_guest_notifiers) {
>>           error_setg(errp, "binding does not support guest notifiers");
>>           return -ENOSYS;
>> @@ -192,6 +195,8 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp)
>>       }
>>       s->started_vu = true;
>>
>> +    trace_vhost_user_blk_start_finish();
>> +
>>       return ret;
>>
>>   err_guest_notifiers:
>> @@ -212,6 +217,8 @@ static int vhost_user_blk_stop(VirtIODevice *vdev)
>>       int ret;
>>       bool force_stop = false;
>>
>> +    trace_vhost_user_blk_stop();
>> +
>>       if (!s->started_vu) {
>>           return 0;
>>       }
>> @@ -233,6 +240,8 @@ static int vhost_user_blk_stop(VirtIODevice *vdev)
>>       }
>>
>>       vhost_dev_disable_notifiers(&s->dev, vdev);
>> +
>> +    trace_vhost_user_blk_stop_finish();
>>       return ret;
>>   }
>>
>> @@ -340,6 +349,8 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
>>       VHostUserBlk *s = VHOST_USER_BLK(vdev);
>>       int ret = 0;
>>
>> +    trace_vhost_user_blk_connect();
>> +
>>       if (s->connected) {
>>           return 0;
>>       }
>> @@ -365,6 +376,7 @@ static int vhost_user_blk_connect(DeviceState *dev, Error **errp)
>>           ret = vhost_user_blk_start(vdev, errp);
>>       }
>>
>> +    trace_vhost_user_blk_connect_finish();
>>       return ret;
>>   }
>>
>> @@ -455,6 +467,8 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
>>       int retries;
>>       int i, ret;
>>
>> +    trace_vhost_user_blk_device_realize();
>> +
>>       if (!s->chardev.chr) {
>>           error_setg(errp, "chardev is mandatory");
>>           return;
>> @@ -514,6 +528,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
>>       qemu_chr_fe_set_handlers(&s->chardev,  NULL, NULL,
>>                                vhost_user_blk_event, NULL, (void *)dev,
>>                                NULL, true);
>> +    trace_vhost_user_blk_device_realize_finish();
>>       return;
>>
>>   virtio_err:
>> --
>> 2.48.1
>>
>>


-- 
Best regards,
Vladimir

Re: [PATCH 22/33] vhost-user-blk: add some useful trace-points
Posted by Philippe Mathieu-Daudé 3 months ago
On 13/8/25 18:48, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>   hw/block/trace-events     | 10 ++++++++++
>   hw/block/vhost-user-blk.c | 15 +++++++++++++++
>   2 files changed, 25 insertions(+)
> 
> diff --git a/hw/block/trace-events b/hw/block/trace-events
> index cc9a9f2460..3b5fd2a599 100644
> --- a/hw/block/trace-events
> +++ b/hw/block/trace-events


> +# vhost-user-blk.c
> +vhost_user_blk_start(void) ""
> +vhost_user_blk_start_finish(void) ""
> +vhost_user_blk_stop(void) ""
> +vhost_user_blk_stop_finish(void) ""
> +vhost_user_blk_connect(void) ""
> +vhost_user_blk_connect_finish(void) ""
> +vhost_user_blk_device_realize(void) ""
> +vhost_user_blk_device_realize_finish(void) ""

Maybe use _in / _out suffixes? Naming is hard...
Re: [PATCH 22/33] vhost-user-blk: add some useful trace-points
Posted by Vladimir Sementsov-Ogievskiy 3 months ago
On 14.08.25 07:58, Philippe Mathieu-Daudé wrote:
> On 13/8/25 18:48, Vladimir Sementsov-Ogievskiy wrote:
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>> ---
>>   hw/block/trace-events     | 10 ++++++++++
>>   hw/block/vhost-user-blk.c | 15 +++++++++++++++
>>   2 files changed, 25 insertions(+)
>>
>> diff --git a/hw/block/trace-events b/hw/block/trace-events
>> index cc9a9f2460..3b5fd2a599 100644
>> --- a/hw/block/trace-events
>> +++ b/hw/block/trace-events
> 
> 
>> +# vhost-user-blk.c
>> +vhost_user_blk_start(void) ""
>> +vhost_user_blk_start_finish(void) ""
>> +vhost_user_blk_stop(void) ""
>> +vhost_user_blk_stop_finish(void) ""
>> +vhost_user_blk_connect(void) ""
>> +vhost_user_blk_connect_finish(void) ""
>> +vhost_user_blk_device_realize(void) ""
>> +vhost_user_blk_device_realize_finish(void) ""
> 
> Maybe use _in / _out suffixes? Naming is hard...

Agree, will change.

-- 
Best regards,
Vladimir