vhost: add statistics for IOTLB

This patch adds statistics for IOTLB hits and misses.

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:19 +02:00
parent 1ea74efd7f
commit 7247b7464e
2 changed files with 11 additions and 1 deletions

View File

@ -43,6 +43,8 @@ static const struct vhost_vq_stats_name_off vhost_vq_stat_strings[] = {
{"size_1024_1518_packets", offsetof(struct vhost_virtqueue, stats.size_bins[6])},
{"size_1519_max_packets", offsetof(struct vhost_virtqueue, stats.size_bins[7])},
{"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)},
};
#define VHOST_NB_VQ_STATS RTE_DIM(vhost_vq_stat_strings)
@ -60,8 +62,14 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
tmp_size = *size;
vva = vhost_user_iotlb_cache_find(vq, iova, &tmp_size, perm);
if (tmp_size == *size)
if (tmp_size == *size) {
if (dev->flags & VIRTIO_DEV_STATS_ENABLED)
vq->stats.iotlb_hits++;
return vva;
}
if (dev->flags & VIRTIO_DEV_STATS_ENABLED)
vq->stats.iotlb_misses++;
iova += tmp_size;

View File

@ -134,6 +134,8 @@ struct virtqueue_stats {
/* Size bins in array as RFC 2819, undersized [0], 64 [1], etc */
uint64_t size_bins[8];
uint64_t guest_notifications;
uint64_t iotlb_hits;
uint64_t iotlb_misses;
};
/**