]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
RDMA/hns: Optimize hem allocation performance
authorJunxian Huang <huangjunxian6@hisilicon.com>
Fri, 6 Sep 2024 09:34:43 +0000 (17:34 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:33:12 +0000 (16:33 +0200)
commite4724f92065d99a55b34775996474e0df7f37140
tree5e08539e6a0c1798c59b4f3fda677bb7777e91aa
parent27d7572bb9473000de8c13e39e516ce50892e7b2
RDMA/hns: Optimize hem allocation performance

[ Upstream commit fe51f6254d81f5a69c31df16353d6539b2b51630 ]

When allocating MTT hem, for each hop level of each hem that is being
allocated, the driver iterates the hem list to find out whether the
bt page has been allocated in this hop level. If not, allocate a new
one and splice it to the list. The time complexity is O(n^2) in worst
cases.

Currently the allocation for-loop uses 'unit' as the step size. This
actually has taken into account the reuse of last-hop-level MTT bt
pages by multiple buffer pages. Thus pages of last hop level will
never have been allocated, so there is no need to iterate the hem list
in last hop level.

Removing this unnecessary iteration can reduce the time complexity to
O(n).

Fixes: 38389eaa4db1 ("RDMA/hns: Add mtr support for mixed multihop addressing")
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20240906093444.3571619-9-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/hns/hns_roce_hem.c