[v2,5/5] vhost: add statistics for IOTLB

Message ID 20220324124638.32672-6-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vhost: introduce per-virtqueue stats API |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build fail github build: failed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-broadcom-Functional fail Functional Testing issues
ci/Intel-compilation fail Compilation issues
ci/intel-Testing success Testing PASS

Commit Message

Maxime Coquelin March 24, 2022, 12:46 p.m. UTC
  This patch adds statistics for IOTLB hits and misses.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/vhost/vhost.c | 10 +++++++++-
 lib/vhost/vhost.h |  3 +++
 2 files changed, 12 insertions(+), 1 deletion(-)
  

Comments

Chenbo Xia April 25, 2022, 12:10 p.m. UTC | #1
Hi Maxime,

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Thursday, March 24, 2022 8:47 PM
> 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 v2 5/5] vhost: add statistics for IOTLB
> 
> This patch adds statistics for IOTLB hits and misses.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  lib/vhost/vhost.c | 10 +++++++++-
>  lib/vhost/vhost.h |  3 +++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
> index 58b58fc40e..7f4fafdcb0 100644
> --- a/lib/vhost/vhost.c
> +++ b/lib/vhost/vhost.c
> @@ -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;
> 
> diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
> index 13c5c2266d..e876fc157b 100644
> --- a/lib/vhost/vhost.h
> +++ b/lib/vhost/vhost.h
> @@ -134,6 +134,9 @@ 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;
> +	uint64_t iotlb_errors;

This seems defined but never used.

Thanks,
Chenbo

>  };
> 
>  /**
> --
> 2.35.1
  
Maxime Coquelin May 10, 2022, 2:15 p.m. UTC | #2
On 4/25/22 14:10, Xia, Chenbo wrote:
> Hi Maxime,
> 
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Sent: Thursday, March 24, 2022 8:47 PM
>> 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 v2 5/5] vhost: add statistics for IOTLB
>>
>> This patch adds statistics for IOTLB hits and misses.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> ---
>>   lib/vhost/vhost.c | 10 +++++++++-
>>   lib/vhost/vhost.h |  3 +++
>>   2 files changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
>> index 58b58fc40e..7f4fafdcb0 100644
>> --- a/lib/vhost/vhost.c
>> +++ b/lib/vhost/vhost.c
>> @@ -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;
>>
>> diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
>> index 13c5c2266d..e876fc157b 100644
>> --- a/lib/vhost/vhost.h
>> +++ b/lib/vhost/vhost.h
>> @@ -134,6 +134,9 @@ 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;
>> +	uint64_t iotlb_errors;
> 
> This seems defined but never used.

Good catch, I'll remove it in next revision.

Regards,
Maxime

> Thanks,
> Chenbo
> 
>>   };
>>
>>   /**
>> --
>> 2.35.1
>
  

Patch

diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 58b58fc40e..7f4fafdcb0 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -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;
 
diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
index 13c5c2266d..e876fc157b 100644
--- a/lib/vhost/vhost.h
+++ b/lib/vhost/vhost.h
@@ -134,6 +134,9 @@  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;
+	uint64_t iotlb_errors;
 };
 
 /**