Skip to content

Commit 9879bdd

Browse files
committed
Optimize DMABUF mkey page size in mlx5
From Edward: This patch series enables the mlx5 driver to dynamically choose the optimal page size for a DMABUF-based memory key (mkey), rather than always registering with a fixed page size. Previously, DMABUF memory registration used a fixed 4K page size for mkeys which could lead to suboptimal performance when the underlying memory layout may offer better page sizes. This approach did not take advantage of larger page size capabilities advertised by the HCA, and the driver was not setting the proper page size mask in the mkey mask when performing page size changes, potentially leading to invalid registrations when updating to a very large pages. This series improves DMABUF performance by dynamically selecting the best page size for a given memory region (MR) both at creation time and on page fault occurrences, based on the underlying layout and fixing related gaps and bugs. By doing so, we reduce the number of page table entries (and thus MTT/ KSM descriptors) that the HCA must traverse, which in turn reduces cache-line fetches. Thanks * mlx5-next: RDMA/mlx5: Fix UMR modifying of mkey page size net/mlx5: Expose HCA capability bits for mkey max page size Signed-off-by: Leon Romanovsky <leon@kernel.org>
2 parents 9826939 + c4f9697 commit 9879bdd

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/infiniband/hw/mlx5/umr.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ static __be64 get_umr_disable_mr_mask(void)
3232
return cpu_to_be64(result);
3333
}
3434

35-
static __be64 get_umr_update_translation_mask(void)
35+
static __be64 get_umr_update_translation_mask(struct mlx5_ib_dev *dev)
3636
{
3737
u64 result;
3838

3939
result = MLX5_MKEY_MASK_LEN |
4040
MLX5_MKEY_MASK_PAGE_SIZE |
4141
MLX5_MKEY_MASK_START_ADDR;
42+
if (MLX5_CAP_GEN_2(dev->mdev, umr_log_entity_size_5))
43+
result |= MLX5_MKEY_MASK_PAGE_SIZE_5;
4244

4345
return cpu_to_be64(result);
4446
}
@@ -654,7 +656,7 @@ static void mlx5r_umr_final_update_xlt(struct mlx5_ib_dev *dev,
654656
flags & MLX5_IB_UPD_XLT_ENABLE || flags & MLX5_IB_UPD_XLT_ADDR;
655657

656658
if (update_translation) {
657-
wqe->ctrl_seg.mkey_mask |= get_umr_update_translation_mask();
659+
wqe->ctrl_seg.mkey_mask |= get_umr_update_translation_mask(dev);
658660
if (!mr->ibmr.length)
659661
MLX5_SET(mkc, &wqe->mkey_seg, length64, 1);
660662
}

include/linux/mlx5/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ enum {
280280
MLX5_MKEY_MASK_SMALL_FENCE = 1ull << 23,
281281
MLX5_MKEY_MASK_RELAXED_ORDERING_WRITE = 1ull << 25,
282282
MLX5_MKEY_MASK_FREE = 1ull << 29,
283+
MLX5_MKEY_MASK_PAGE_SIZE_5 = 1ull << 42,
283284
MLX5_MKEY_MASK_RELAXED_ORDERING_READ = 1ull << 47,
284285
};
285286

include/linux/mlx5/mlx5_ifc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,9 @@ struct mlx5_ifc_cmd_hca_cap_2_bits {
21712171
u8 min_mkey_log_entity_size_fixed_buffer[0x5];
21722172
u8 ec_vf_vport_base[0x10];
21732173

2174-
u8 reserved_at_3a0[0xa];
2174+
u8 reserved_at_3a0[0x2];
2175+
u8 max_mkey_log_entity_size_fixed_buffer[0x6];
2176+
u8 reserved_at_3a8[0x2];
21752177
u8 max_mkey_log_entity_size_mtt[0x6];
21762178
u8 max_rqt_vhca_id[0x10];
21772179

0 commit comments

Comments
 (0)