RE: [PATH v1 2/2] vdpa/mlx5: Add support for reading descriptor statistics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Eli Cohen <elic@xxxxxxxxxx>
> Sent: Wednesday, November 24, 2021 10:26 PM
> Implement the get_vq_stats calback of vdpa_config_ops to return the statistics
> for a virtqueue.
> 
> Signed-off-by: Eli Cohen <elic@xxxxxxxxxx>
> ---
> V0 -> V1:
> Use mutex to sync stats query with change of number of queues
> 
>  drivers/vdpa/mlx5/net/mlx5_vnet.c  | 143 +++++++++++++++++++++++++++++
>  include/linux/mlx5/mlx5_ifc.h      |   1 +
>  include/linux/mlx5/mlx5_ifc_vdpa.h |  39 ++++++++
>  3 files changed, 183 insertions(+)
> 
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index 9b7d8c721354..465e832f2ad1 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -119,6 +119,7 @@ struct mlx5_vdpa_virtqueue {
>  	struct mlx5_vdpa_umem umem2;
>  	struct mlx5_vdpa_umem umem3;
> 
> +	u32 counter_set_id;
>  	bool initialized;
>  	int index;
>  	u32 virtq_id;
> @@ -164,6 +165,8 @@ struct mlx5_vdpa_net {
>  	u32 cur_num_vqs;
>  	struct notifier_block nb;
>  	struct vdpa_callback config_cb;
> +	/* sync access to virtqueues statistics */
> +	struct mutex numq_lock;
It is better to use rw_semaphore, than mutex. 
So get_stats do down/up_read() and change_num_qps() do down/up_write().
This helps to better annotate stats getter is only a reader and handle_ctrl_mq() is updater.
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux