diff mbox series

[net-next,v6,1/3] net/mlx4: Track RX allocation failures in a stat

Message ID 20240528181139.515070-2-jdamato@fastly.com (mailing list archive)
State Not Applicable
Headers show
Series mlx4: Add support for netdev-genl API | expand

Commit Message

Joe Damato May 28, 2024, 6:11 p.m. UTC
mlx4_en_alloc_frags currently returns -ENOMEM when mlx4_alloc_page
fails but does not increment a stat field when this occurs.

A new field called alloc_fail has been added to struct mlx4_en_rx_ring
which is now incremented in mlx4_en_rx_ring when -ENOMEM occurs.

Signed-off-by: Joe Damato <jdamato@fastly.com>
Tested-by: Martin Karsten <mkarsten@uwaterloo.ca>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 1 +
 drivers/net/ethernet/mellanox/mlx4/en_rx.c     | 4 +++-
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

Comments

Jacob Keller May 30, 2024, 9:08 p.m. UTC | #1
On 5/28/2024 11:11 AM, Joe Damato wrote:
> mlx4_en_alloc_frags currently returns -ENOMEM when mlx4_alloc_page
> fails but does not increment a stat field when this occurs.
> 
> A new field called alloc_fail has been added to struct mlx4_en_rx_ring
> which is now incremented in mlx4_en_rx_ring when -ENOMEM occurs.
> 
> Signed-off-by: Joe Damato <jdamato@fastly.com>
> Tested-by: Martin Karsten <mkarsten@uwaterloo.ca>
> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
> ---
>  drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 1 +
>  drivers/net/ethernet/mellanox/mlx4/en_rx.c     | 4 +++-
>  drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   | 1 +
>  3 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> index 4c089cfa027a..4d2f8c458346 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> @@ -2073,6 +2073,7 @@ static void mlx4_en_clear_stats(struct net_device *dev)
>  		priv->rx_ring[i]->csum_ok = 0;
>  		priv->rx_ring[i]->csum_none = 0;
>  		priv->rx_ring[i]->csum_complete = 0;
> +		priv->rx_ring[i]->alloc_fail = 0;
>  	}
>  }
>  
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> index 8328df8645d5..15c57e9517e9 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> @@ -82,8 +82,10 @@ static int mlx4_en_alloc_frags(struct mlx4_en_priv *priv,
>  
>  	for (i = 0; i < priv->num_frags; i++, frags++) {
>  		if (!frags->page) {
> -			if (mlx4_alloc_page(priv, frags, gfp))
> +			if (mlx4_alloc_page(priv, frags, gfp)) {
> +				ring->alloc_fail++;
>  				return -ENOMEM;
> +			}
>  			ring->rx_alloc_pages++;
>  		}
>  		rx_desc->data[i].addr = cpu_to_be64(frags->dma +
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> index efe3f97b874f..cd70df22724b 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> @@ -355,6 +355,7 @@ struct mlx4_en_rx_ring {
>  	unsigned long xdp_tx;
>  	unsigned long xdp_tx_full;
>  	unsigned long dropped;
> +	unsigned long alloc_fail;
>  	int hwtstamp_rx_filter;
>  	cpumask_var_t affinity_mask;
>  	struct xdp_rxq_info xdp_rxq;

This patch does not appear to extend either a netdev, ethtool, devlink,
or any other interface to report this new counter.

How is a user supposed to obtain this information from the driver?
Jacob Keller May 30, 2024, 9:12 p.m. UTC | #2
On 5/30/2024 2:08 PM, Jacob Keller wrote:
> 
> 
> On 5/28/2024 11:11 AM, Joe Damato wrote:
>> mlx4_en_alloc_frags currently returns -ENOMEM when mlx4_alloc_page
>> fails but does not increment a stat field when this occurs.
>>
>> A new field called alloc_fail has been added to struct mlx4_en_rx_ring
>> which is now incremented in mlx4_en_rx_ring when -ENOMEM occurs.
>>
>> Signed-off-by: Joe Damato <jdamato@fastly.com>
>> Tested-by: Martin Karsten <mkarsten@uwaterloo.ca>
>> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
>> ---
>>  drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 1 +
>>  drivers/net/ethernet/mellanox/mlx4/en_rx.c     | 4 +++-
>>  drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   | 1 +
>>  3 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> index 4c089cfa027a..4d2f8c458346 100644
>> --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> @@ -2073,6 +2073,7 @@ static void mlx4_en_clear_stats(struct net_device *dev)
>>  		priv->rx_ring[i]->csum_ok = 0;
>>  		priv->rx_ring[i]->csum_none = 0;
>>  		priv->rx_ring[i]->csum_complete = 0;
>> +		priv->rx_ring[i]->alloc_fail = 0;
>>  	}
>>  }
>>  
>> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
>> index 8328df8645d5..15c57e9517e9 100644
>> --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
>> +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
>> @@ -82,8 +82,10 @@ static int mlx4_en_alloc_frags(struct mlx4_en_priv *priv,
>>  
>>  	for (i = 0; i < priv->num_frags; i++, frags++) {
>>  		if (!frags->page) {
>> -			if (mlx4_alloc_page(priv, frags, gfp))
>> +			if (mlx4_alloc_page(priv, frags, gfp)) {
>> +				ring->alloc_fail++;
>>  				return -ENOMEM;
>> +			}
>>  			ring->rx_alloc_pages++;
>>  		}
>>  		rx_desc->data[i].addr = cpu_to_be64(frags->dma +
>> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
>> index efe3f97b874f..cd70df22724b 100644
>> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
>> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
>> @@ -355,6 +355,7 @@ struct mlx4_en_rx_ring {
>>  	unsigned long xdp_tx;
>>  	unsigned long xdp_tx_full;
>>  	unsigned long dropped;
>> +	unsigned long alloc_fail;
>>  	int hwtstamp_rx_filter;
>>  	cpumask_var_t affinity_mask;
>>  	struct xdp_rxq_info xdp_rxq;
> 
> This patch does not appear to extend either a netdev, ethtool, devlink,
> or any other interface to report this new counter.
> 
> How is a user supposed to obtain this information from the driver?

Ah. Its used in the 3rd patch.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 4c089cfa027a..4d2f8c458346 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2073,6 +2073,7 @@  static void mlx4_en_clear_stats(struct net_device *dev)
 		priv->rx_ring[i]->csum_ok = 0;
 		priv->rx_ring[i]->csum_none = 0;
 		priv->rx_ring[i]->csum_complete = 0;
+		priv->rx_ring[i]->alloc_fail = 0;
 	}
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 8328df8645d5..15c57e9517e9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -82,8 +82,10 @@  static int mlx4_en_alloc_frags(struct mlx4_en_priv *priv,
 
 	for (i = 0; i < priv->num_frags; i++, frags++) {
 		if (!frags->page) {
-			if (mlx4_alloc_page(priv, frags, gfp))
+			if (mlx4_alloc_page(priv, frags, gfp)) {
+				ring->alloc_fail++;
 				return -ENOMEM;
+			}
 			ring->rx_alloc_pages++;
 		}
 		rx_desc->data[i].addr = cpu_to_be64(frags->dma +
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index efe3f97b874f..cd70df22724b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -355,6 +355,7 @@  struct mlx4_en_rx_ring {
 	unsigned long xdp_tx;
 	unsigned long xdp_tx_full;
 	unsigned long dropped;
+	unsigned long alloc_fail;
 	int hwtstamp_rx_filter;
 	cpumask_var_t affinity_mask;
 	struct xdp_rxq_info xdp_rxq;