]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
RDMA/mlx5: Optimize DMABUF mkey page size
authorEdward Srouji <edwards@nvidia.com>
Wed, 9 Jul 2025 06:42:11 +0000 (09:42 +0300)
committerLeon Romanovsky <leon@kernel.org>
Sun, 13 Jul 2025 07:14:19 +0000 (03:14 -0400)
commite73242aa14d2ec7f4a1a13688366bb36dc0fe5b7
tree7a72479722fee6cb71bd2cafa74b5fd1d128a5d4
parentfcfb03597b7d7737aac6bdfda1f7b5d152cfed73
RDMA/mlx5: Optimize DMABUF mkey page size

The current implementation of DMABUF memory registration uses a fixed
page size for the memory key (mkey), which can lead to suboptimal
performance when the underlying memory layout may offer better page
size.

The optimization improves performance by reducing the number of page
table entries required for the mkey, leading to less MTT/KSM descriptors
that the HCA must go through to find translations, fewer cache-lines,
and shorter UMR work requests on mkey updates such as when
re-registering or reusing a cacheable mkey.

To ensure safe page size updates, the implementation uses a 5-step
process:
1. Make the first X entries non-present, while X is calculated to be
   minimal according to a large page shift that can be used to cover the
   MR length.
2. Update the page size to the large supported page size
3. Load the remaining N-X entries according to the (optimized)
   page shift
4. Update the page size according to the (optimized) page shift
5. Load the first X entries with the correct translations

This ensures that at no point is the MR accessible with a partially
updated translation table, maintaining correctness and preventing
access to stale or inconsistent mappings, such as having an mkey
advertising the new page size while some of the underlying page table
entries still contain the old page size translations.

Signed-off-by: Edward Srouji <edwards@nvidia.com>
Reviewed-by: Michael Guralnik <michaelgur@nvidia.com>
Link: https://patch.msgid.link/bc05a6b2142c02f96a90635f9a4458ee4bbbf39f.1751979184.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/infiniband/hw/mlx5/odp.c
drivers/infiniband/hw/mlx5/umr.c
drivers/infiniband/hw/mlx5/umr.h