vhost: add statistics for in-flight packets

This patch adds statistics for packets in-flight submission
and completion, when Vhost async mode is used.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
This commit is contained in:
Maxime Coquelin 2022-05-10 22:17:20 +02:00
parent 7247b7464e
commit 69c94e35d5
3 changed files with 10 additions and 0 deletions

View File

@ -45,6 +45,8 @@ static const struct vhost_vq_stats_name_off vhost_vq_stat_strings[] = {
{"guest_notifications", offsetof(struct vhost_virtqueue, stats.guest_notifications)},
{"iotlb_hits", offsetof(struct vhost_virtqueue, stats.iotlb_hits)},
{"iotlb_misses", offsetof(struct vhost_virtqueue, stats.iotlb_misses)},
{"inflight_submitted", offsetof(struct vhost_virtqueue, stats.inflight_submitted)},
{"inflight_completed", offsetof(struct vhost_virtqueue, stats.inflight_completed)},
};
#define VHOST_NB_VQ_STATS RTE_DIM(vhost_vq_stat_strings)

View File

@ -136,6 +136,8 @@ struct virtqueue_stats {
uint64_t guest_notifications;
uint64_t iotlb_hits;
uint64_t iotlb_misses;
uint64_t inflight_submitted;
uint64_t inflight_completed;
};
/**

View File

@ -2115,6 +2115,7 @@ rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count, dma_id, vchan_id);
vhost_queue_stats_update(dev, vq, pkts, n_pkts_cpl);
vq->stats.inflight_completed += n_pkts_cpl;
out:
rte_spinlock_unlock(&vq->access_lock);
@ -2158,6 +2159,9 @@ rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,
n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count, dma_id, vchan_id);
vhost_queue_stats_update(dev, vq, pkts, n_pkts_cpl);
vq->stats.inflight_completed += n_pkts_cpl;
return n_pkts_cpl;
}
@ -2207,6 +2211,8 @@ virtio_dev_rx_async_submit(struct virtio_net *dev, uint16_t queue_id,
nb_tx = virtio_dev_rx_async_submit_split(dev, vq, queue_id,
pkts, count, dma_id, vchan_id);
vq->stats.inflight_submitted += nb_tx;
out:
if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))
vhost_user_iotlb_rd_unlock(vq);