]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/mlx5: Fix calculation of total invalidated pages
authorChiara Meiohas <cmeiohas@nvidia.com>
Thu, 13 Mar 2025 14:29:54 +0000 (16:29 +0200)
committerLeon Romanovsky <leon@kernel.org>
Tue, 18 Mar 2025 10:34:28 +0000 (06:34 -0400)
When invalidating an address range in mlx5, there is an optimization to
do UMR operations in chunks.
Previously, the invalidation counter was incorrectly updated for the
same indexes within a chunk. Now, the invalidation counter is updated
only when a chunk is complete and mlx5r_umr_update_xlt() is called.
This ensures that the counter accurately represents the number of pages
invalidated using UMR.

Fixes: a3de94e3d61e ("IB/mlx5: Introduce ODP diagnostic counters")
Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Reviewed-by: Michael Guralnik <michaelgur@nvidia.com>
Link: https://patch.msgid.link/560deb2433318e5947282b070c915f3c81fef77f.1741875692.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/mlx5/odp.c

index f1e23583e6c08e065e4fbd958cc60f30616dcb44..de9683344f5e877fe2464e147c41f422ba200a0f 100644 (file)
@@ -308,9 +308,6 @@ static bool mlx5_ib_invalidate_range(struct mmu_interval_notifier *mni,
                                blk_start_idx = idx;
                                in_block = 1;
                        }
-
-                       /* Count page invalidations */
-                       invalidations += idx - blk_start_idx + 1;
                } else {
                        u64 umr_offset = idx & umr_block_mask;
 
@@ -320,14 +317,19 @@ static bool mlx5_ib_invalidate_range(struct mmu_interval_notifier *mni,
                                                     MLX5_IB_UPD_XLT_ZAP |
                                                     MLX5_IB_UPD_XLT_ATOMIC);
                                in_block = 0;
+                               /* Count page invalidations */
+                               invalidations += idx - blk_start_idx + 1;
                        }
                }
        }
-       if (in_block)
+       if (in_block) {
                mlx5r_umr_update_xlt(mr, blk_start_idx,
                                     idx - blk_start_idx + 1, 0,
                                     MLX5_IB_UPD_XLT_ZAP |
                                     MLX5_IB_UPD_XLT_ATOMIC);
+               /* Count page invalidations */
+               invalidations += idx - blk_start_idx + 1;
+       }
 
        mlx5_update_odp_stats_with_handled(mr, invalidations, invalidations);