RDMA/mlx5: Implement mkeys management via LIFO queue
Subsystems (2)
PATCH 1/1 RDMA/mlx5: Implement mkeys management via LIFO queue
From: Shay Drory <[email protected]>
Currently, mkeys are managed via xarray. This implementation leads to a degradation in cases many MRs are unregistered in parallel, due to xarray internal implementation, for example: deregistration 1M MRs via 64 threads is taking ~15% more time[1].
Hence, implement mkeys management via LIFO queue, which solved the degradation.
[1]
2.8us in kernel v5.19 compare to 3.2us in kernel v6.4
--- drivers/infiniband/hw/mlx5/mlx5_ib.h | 19 +- drivers/infiniband/hw/mlx5/mr.c | 324 ++++++++++++--------------- drivers/infiniband/hw/mlx5/umr.c | 4 +- 3 files changed, 167 insertions(+), 180 deletions(-)
drivers/infiniband/hw/mlx5/mlx5_ib.h +16 -3
@@ -753,10 +753,23 @@ struct umr_common {unsigned int state; }; +#define NUM_MKEYS_PER_PAGE (PAGE_SIZE / sizeof(u32)) + +struct mlx5_mkeys_page { +u32 mkeys[NUM_MKEYS_PER_PAGE ]; +struct list_head list; +}; + +struct mlx5_mkeys_queue { +struct list_head pages_list; +u32 num_pages; +unsigned long ci; +spinlock_t lock;/* sync list ops */ +}; +struct mlx5_cache_ent { -struct xarray mkeys; -unsigned long stored; -unsigned long reserved; +struct mlx5_mkeys_queue mkeys_queue; +u32 pending;char name[4 ];
drivers/infiniband/hw/mlx5/mr.c +149 -175
589 lines not on this page · raw message
drivers/infiniband/hw/mlx5/umr.c +2 -2
@@ -332,8 +332,8 @@ static int mlx5r_umr_post_send_wait(struct mlx5_ib_dev *dev, u32 mkey,WARN_ON_ONCE (1 );mlx5_ib_warn (dev, -"reg umr failed (%u). Trying to recover and resubmit the flushed WQEs\n" , - umr_context.status); +"reg umr failed (%u). Trying to recover and resubmit the flushed WQEs, mkey = %u\n" , + umr_context.status, mkey);mutex_lock (&umrc->lock); err =mlx5r_umr_recover (dev);mutex_unlock (&umrc->lock);
Signature · 1 line
2.41.0
Jason Gunthorpe
maintainerQuoted 26 lines · Leon Romanovsky
From: Shay Drory <[email protected]>
Currently, mkeys are managed via xarray. This implementation leads to a degradation in cases many MRs are unregistered in parallel, due to xarray internal implementation, for example: deregistration 1M MRs via 64 threads is taking ~15% more time[1].
Hence, implement mkeys management via LIFO queue, which solved the degradation.
[1]
2.8us in kernel v5.19 compare to 3.2us in kernel v6.4Signed-off-by Shay Drory <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- drivers/infiniband/hw/mlx5/mlx5_ib.h | 19 +- drivers/infiniband/hw/mlx5/mr.c | 324 ++++++++++++--------------- drivers/infiniband/hw/mlx5/umr.c | 4 +- 3 files changed, 167 insertions(+), 180 deletions(-)drivers/infiniband/hw/mlx5/mlx5_ib.h +0
-0
drivers/infiniband/hw/mlx5/mlx5_ib.h struct umr_common { · line 761
Quoted 9 lines
drivers/infiniband/hw/mlx5/mlx5_ib.h +6
-0@@ -753,10 +753,23 @@ struct umr_common {unsigned int state; }; +#define NUM_MKEYS_PER_PAGE (PAGE_SIZE / sizeof(u32)) + +struct mlx5_mkeys_page { +u32 mkeys[NUM_MKEYS_PER_PAGE ]; +struct list_head list; +};
Er, isn't the point of this to be PAGE_SIZE big?
Add an
static_assert(sizeof(struct mlx5_mkeys_page) == PAGE_SIZE)
And fix it so it is true..
Jason
Quoted 30 lines · Jason Gunthorpe
Quoted 29 lines · Leon Romanovsky
From: Shay Drory <[email protected]>
Currently, mkeys are managed via xarray. This implementation leads to a degradation in cases many MRs are unregistered in parallel, due to xarray internal implementation, for example: deregistration 1M MRs via 64 threads is taking ~15% more time[1].
Hence, implement mkeys management via LIFO queue, which solved the degradation.
[1]
2.8us in kernel v5.19 compare to 3.2us in kernel v6.4Signed-off-by Shay Drory <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- drivers/infiniband/hw/mlx5/mlx5_ib.h | 19 +- drivers/infiniband/hw/mlx5/mr.c | 324 ++++++++++++--------------- drivers/infiniband/hw/mlx5/umr.c | 4 +- 3 files changed, 167 insertions(+), 180 deletions(-)drivers/infiniband/hw/mlx5/mlx5_ib.h +0
-0@@ -753,10 +753,23 @@ struct umr_common {unsigned int state; };
Quoted 8 lines
drivers/infiniband/hw/mlx5/mlx5_ib.h struct umr_common { · line 761
Quoted 6 lines
drivers/infiniband/hw/mlx5/mlx5_ib.h +6
-0+#define NUM_MKEYS_PER_PAGE (PAGE_SIZE / sizeof(u32)) + +struct mlx5_mkeys_page { +u32 mkeys[NUM_MKEYS_PER_PAGE ]; +struct list_head list; +};Er, isn't the point of this to be
PAGE_SIZEbig?
The more important part is preallocation of whole struct mlx5_mkeys_page to hold multiple keys in one shot. The PAGE_SIZE alignment can definitely help to make it even more efficient, but it is not culprit of this patch.
I will change.
Thanks
Quoted 8 lines
Add an
static_assert(sizeof(struct mlx5_mkeys_page) == PAGE_SIZE)And fix it so it is true..
Jason