]> www.infradead.org Git - users/jedix/linux-maple.git/commit
RDMA/mlx5: Limit usage of over-sized mkeys from the MR cache
authorMichael Guralnik <michaelgur@nvidia.com>
Tue, 3 Sep 2024 11:24:49 +0000 (14:24 +0300)
committerLeon Romanovsky <leon@kernel.org>
Mon, 9 Sep 2024 18:17:09 +0000 (21:17 +0300)
commitee6d57a2e13d11ce9050cfc3e3b69ef707a44a63
treed5a0b82113ba4a490177661c0ab59f9bf74031b0
parent6f5cd6ac9a4201e4ba6f10b76a9da8044d6e38b0
RDMA/mlx5: Limit usage of over-sized mkeys from the MR cache

When searching the MR cache for suitable cache entries, don't use mkeys
larger than twice the size required for the MR.
This should ensure the usage of mkeys closer to the minimal required size
and reduce memory waste.

On driver init we create entries for mkeys with clear attributes and
powers of 2 sizes from 4 to the max supported size.
This solves the issue for anyone using mkeys that fit these
requirements.

In the use case where an MR is registered with different attributes,
like an access flag we can't UMR, we'll create a new cache entry to store
it upon dereg.
Without this fix, any later registration with same attributes and smaller
size will use the newly created cache entry and it's mkeys, disregarding
the memory waste of using mkeys larger than required.

For example, one worst-case scenario can be when registering and
deregistering a 1GB mkey with ATS enabled which will cause the creation of
a new cache entry to hold those type of mkeys. A user registering a 4k MR
with ATS will end up using the new cache entry and an mkey that can
support a 1GB MR, thus wasting x250k memory than actually needed in the HW.

Additionally, allow all small registration to use the smallest size
cache entry that is initialized on driver load even if size is larger
than twice the required size.

Fixes: 73d09b2fe833 ("RDMA/mlx5: Introduce mlx5r_cache_rb_key")
Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Link: https://patch.msgid.link/8ba3a6e3748aace2026de8b83da03aba084f78f4.1725362530.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/mlx5/mr.c