From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2208E1AAE27; Mon, 14 Oct 2024 15:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918200; cv=none; b=AxoH4uc0aZDJT4naRx50nd9oY/lecpDYxCaPvLJsjD0jF8gUeZ4BzqDWEZxiRqASXMHF+Uykk02UK1rOrsCpi5b+qmCrID/J3qUQvT94Z2czzq3LcOnZwusHCn5O9jPzt+cXbebjttvGzLjqw+cGP8p1Oxvfk//x2OjYNoM+MWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918200; c=relaxed/simple; bh=JPqNXczwkfFw9d9NjaZ35y/q6JXF3sUOIKTLnrAfbX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E3FmrgaYdkOFrPXbJoD75TlWmqTnrcj6QHvQoh5QC49AfnJ7xQWSsGQvfSj6T1Ulvx/3qx937SxplCHZhlFFfK8e+j+tlcrNQ6bbEpIsF5xMhTVsE/VQn3cT/BOhemXEH9NL4zj3d6/ipmka7PVaswCXilgwA+kdNIxeHZf3Tjg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zhHgUwrN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zhHgUwrN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ABF3C4CEC3; Mon, 14 Oct 2024 15:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728918199; bh=JPqNXczwkfFw9d9NjaZ35y/q6JXF3sUOIKTLnrAfbX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zhHgUwrNXrrtd51JQUZpYDV6BK11QuQCnjSQpv8wQRX4m2pOvNgWkJXSaHGj+yy4I VQTH6Xwf/owji3nMHO5CnPwpX8e1awhkcekWeW0uOc4MY5qYe1AXTzZXoT92GIiphf hMy7URNE0naHpa8xije9E0rVobqGAIWf6uBFEqkY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Junxian Huang , Leon Romanovsky , Sasha Levin Subject: [PATCH 6.1 225/798] RDMA/hns: Optimize hem allocation performance Date: Mon, 14 Oct 2024 16:12:59 +0200 Message-ID: <20241014141226.764747386@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141217.941104064@linuxfoundation.org> References: <20241014141217.941104064@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junxian Huang [ 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 Link: https://patch.msgid.link/20240906093444.3571619-9-huangjunxian6@hisilicon.com Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/hw/hns/hns_roce_hem.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c b/drivers/infiniband/hw/hns/hns_roce_hem.c index 156bc710e0dbb..2c8f0fd9557d1 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hem.c +++ b/drivers/infiniband/hw/hns/hns_roce_hem.c @@ -1175,10 +1175,12 @@ static int hem_list_alloc_mid_bt(struct hns_roce_dev *hr_dev, /* config L1 bt to last bt and link them to corresponding parent */ for (level = 1; level < hopnum; level++) { - cur = hem_list_search_item(&mid_bt[level], offset); - if (cur) { - hem_ptrs[level] = cur; - continue; + if (!hem_list_is_bottom_bt(hopnum, level)) { + cur = hem_list_search_item(&mid_bt[level], offset); + if (cur) { + hem_ptrs[level] = cur; + continue; + } } step = hem_list_calc_ba_range(hopnum, level, unit); -- 2.43.0