@samitouri / QOSamiQemu / commits / 2d5e87062b

vhost: add some useful trace-points

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Daniil Tatianin <d-tatianin@yandex-team.ru> Reviewed-by: Raphael Norwitz <raphael.s.norwitz@gmail.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260420200339.708640-23-vsementsov@yandex-team.ru>

Vladimir Sementsov-Ogievskiy committed Apr 20, 2026 at 23:03 UTC 2d5e87062b6fc283c1effe58ae81d902a57097b8
2 files changed +28 -4
hw/virtio/trace-events
+10 -2
@@ -9,8 +9,16 @@ vhost_section(const char *name) "%s"
9 vhost_reject_section(const char *name, int d) "%s:%d"
10 vhost_iotlb_miss(void *dev, int step) "%p step %d"
11 vhost_dev_cleanup(void *dev) "%p"
12 -vhost_dev_start(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
13 -vhost_dev_stop(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
12 +vhost_dev_start_in(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
13 +vhost_dev_start_out(void *dev, const char *name) "%p:%s"
14 +vhost_dev_stop_in(void *dev, const char *name, bool vrings) "%p:%s vrings:%d"
15 +vhost_dev_stop_out(void *dev, const char *name) "%p:%s"
16 +vhost_virtqueue_start_in(void *dev, const char *name, int idx) "%p:%s %d"
17 +vhost_virtqueue_start_out(void *dev, const char *name, int idx) "%p:%s %d"
18 +vhost_virtqueue_stop_in(void *dev, const char *name, int idx) "%p:%s %d"
19 +vhost_virtqueue_stop_out(void *dev, const char *name, int idx) "%p:%s %d"
20 +vhost_dev_init_in(void *dev) "%p"
21 +vhost_dev_init_out(void *dev) "%p"
22
23
24 # vhost-user.c
hw/virtio/vhost.c
+18 -2
@@ -1337,6 +1337,8 @@ int vhost_virtqueue_start(struct vhost_dev *dev,
1337 };
1338 struct VirtQueue *vvq = virtio_get_queue(vdev, idx);
1339
1340 + trace_vhost_virtqueue_start_in(dev, vdev->name, idx);
1341 +
1342 r = vhost_vrings_map(dev, vdev, vq, idx);
1343 if (r <= 0) {
1344 return r;
@@ -1397,6 +1399,8 @@ int vhost_virtqueue_start(struct vhost_dev *dev,
1399 }
1400 }
1401
1402 + trace_vhost_virtqueue_start_out(dev, vdev->name, idx);
1403 +
1404 return 0;
1405
1406 fail:
@@ -1415,6 +1419,8 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
1419 };
1420 int r = 0;
1421
1422 + trace_vhost_virtqueue_stop_in(dev, vdev->name, idx);
1423 +
1424 if (virtio_queue_get_desc_addr(vdev, idx) == 0) {
1425 /* Don't stop the virtqueue which might have not been started */
1426 return 0;
@@ -1448,6 +1454,8 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
1454 }
1455
1456 vhost_vrings_unmap(dev, vq, true);
1457 +
1458 + trace_vhost_virtqueue_stop_out(dev, vdev->name, idx);
1459 return r;
1460 }
1461
@@ -1581,6 +1589,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
1589 unsigned int used, reserved, limit;
1590 int i, r, n_initialized_vqs = 0;
1591
1592 + trace_vhost_dev_init_in(hdev);
1593 +
1594 hdev->vdev = NULL;
1595 hdev->migration_blocker = NULL;
1596
@@ -1694,6 +1704,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
1704 goto fail;
1705 }
1706
1707 + trace_vhost_dev_init_out(hdev);
1708 +
1709 return 0;
1710
1711 fail:
@@ -2098,7 +2110,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
2110 /* should only be called after backend is connected */
2111 assert(hdev->vhost_ops);
2112
2101 - trace_vhost_dev_start(hdev, vdev->name, vrings);
2113 + trace_vhost_dev_start_in(hdev, vdev->name, vrings);
2114
2115 vdev->vhost_started = true;
2116 hdev->started = true;
@@ -2183,6 +2195,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
2195 }
2196 }
2197 vhost_start_config_intr(hdev);
2198 +
2199 + trace_vhost_dev_start_out(hdev, vdev->name);
2200 return 0;
2201 fail_iotlb:
2202 if (vhost_dev_has_iommu(hdev) &&
@@ -2232,7 +2246,7 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
2246 event_notifier_cleanup(
2247 &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
2248
2235 - trace_vhost_dev_stop(hdev, vdev->name, vrings);
2249 + trace_vhost_dev_stop_in(hdev, vdev->name, vrings);
2250
2251 if (hdev->vhost_ops->vhost_dev_start) {
2252 hdev->vhost_ops->vhost_dev_start(hdev, false);
@@ -2262,6 +2276,8 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
2276 hdev->started = false;
2277 vdev->vhost_started = false;
2278 hdev->vdev = NULL;
2279 +
2280 + trace_vhost_dev_stop_out(hdev, vdev->name);
2281 return rc;
2282 }
2283