net/mlx4: Track RX allocation failures in a stat
authorJoe Damato <jdamato@fastly.com>
Tue, 28 May 2024 18:11:36 +0000 (18:11 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 31 May 2024 00:14:45 +0000 (17:14 -0700)
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>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20240528181139.515070-2-jdamato@fastly.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/en_rx.c
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h

index 4c089cf..4d2f8c4 100644 (file)
@@ -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;
        }
 }
 
index 8328df8..15c57e9 100644 (file)
@@ -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 +
index efe3f97..cd70df2 100644 (file)
@@ -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;