diff mbox series

[5/5] vhost: add statistics for in-flight packets

Message ID 20220510201720.1262368-6-maxime.coquelin@redhat.com (mailing list archive)
State Awaiting Upstream
Delegated to: Maxime Coquelin
Headers show
Series vhost: introduce per-virtqueue stats API | expand

Checks

Context Check Description
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Maxime Coquelin May 10, 2022, 8:17 p.m. UTC
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>
---
 lib/vhost/vhost.c      | 2 ++
 lib/vhost/vhost.h      | 2 ++
 lib/vhost/virtio_net.c | 6 ++++++
 3 files changed, 10 insertions(+)

Comments

Xia, Chenbo May 11, 2022, 1:57 p.m. UTC | #1
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Wednesday, May 11, 2022 4:17 AM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>;
> david.marchand@redhat.com; i.maximets@ovn.org
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH 5/5] 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>
> ---
>  lib/vhost/vhost.c      | 2 ++
>  lib/vhost/vhost.h      | 2 ++
>  lib/vhost/virtio_net.c | 6 ++++++
>  3 files changed, 10 insertions(+)
> 
> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
> index 721b3a3247..d9d31b2d03 100644
> --- a/lib/vhost/vhost.c
> +++ b/lib/vhost/vhost.c
> @@ -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)
> diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
> index 872675207e..1573d0afe9 100644
> --- a/lib/vhost/vhost.h
> +++ b/lib/vhost/vhost.h
> @@ -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;
>  };
> 
>  /**
> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> index b1ea9fa4a5..c8905c770a 100644
> --- a/lib/vhost/virtio_net.c
> +++ b/lib/vhost/virtio_net.c
> @@ -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);
> --
> 2.35.1

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
diff mbox series

Patch

diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 721b3a3247..d9d31b2d03 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -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)
diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
index 872675207e..1573d0afe9 100644
--- a/lib/vhost/vhost.h
+++ b/lib/vhost/vhost.h
@@ -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;
 };
 
 /**
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index b1ea9fa4a5..c8905c770a 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -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);