Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2684640rdb; Tue, 26 Dec 2023 01:16:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5vppfjDb/MOKZj9s/5wx+fF82s5PqrcIwub4SmPiMbSsa7i/GRyvCJPgR8psiBrXx7gOz X-Received: by 2002:a05:6808:10c6:b0:3b8:b402:74de with SMTP id s6-20020a05680810c600b003b8b40274demr7501143ois.32.1703582214528; Tue, 26 Dec 2023 01:16:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703582214; cv=none; d=google.com; s=arc-20160816; b=p4zZvyMQ4uLRIR7dhjod3CX2BTdcsR0o92AZMbaoRhnavWq9HMGk9dMxHs6m+G/kQr RGVMiubDjndvdID+OAT/OuO9hi92uOCoT+TFeXkJ2p87Uoenu0HKE0ALAkSPbFfQkb44 lUJTe3uJzH8wdLR1S6OvLRgw+Tz6ExMCLZrJ6Wfty7pACD58q7HEPbso7SnCOOLyMMSc cy5Mn99BMKO5MVf1o+/i4jxh+BIkV8PthoVstFnPGkvQ5fG5n8jxXy71d8graIzd99tN ++G4Eg/2YOhR0ArJLs2dvC8VmeWqN8pxEhYDh96yOY5Ru5nMHJGreejtD8tjqX0yonwh hwNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=H7unMg9Mu9bxO4kn9cdCbWbAhEyGtqCxM7tjpEB1h8Q=; fh=/0b1uayxl6xObb+ppBuwyrMHN3i6f8LQGamT2h+wQt8=; b=09wSt98L8ExKSxe5zSMuFz2NDib3bdV9mmpysVeOKhp7iIgDb007Prc0A7VXwQ6Hra 4n8xsR+EmrajOvONjTBvIW6Wp5yUQS8IEiBq5+w2ppYRPgaiHnSLmTC4Pfk/CsZn257v 9PeRrsASex4T78chffcGFx2GiheQSjsFoF9fhkvGVMytXthHXIRGU90FMhC0q9YykVYd 6jXEUO965/ya6JyBiAaQcXP8CsDmDOHL8IDjzY+BQjyqL1KHk5OzmjWguwXhlX+RU5hx mqVeceZokCxz0jXKZU02wJYUkJw1RJKNeiV8sD8fWNwu2YBrjUVBMqYKmLzPkZ39yVmQ hwHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11436-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id lk10-20020a17090b33ca00b0028be7630b52si9568790pjb.75.2023.12.26.01.16.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 01:16:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11436-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11436-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2BD142811A2 for ; Tue, 26 Dec 2023 09:16:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A7024D102; Tue, 26 Dec 2023 09:16:47 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (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 1865E4CE09; Tue, 26 Dec 2023 09:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hisilicon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hisilicon.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SzpzZ1Vgpz1Q6q7; Tue, 26 Dec 2023 17:16:10 +0800 (CST) Received: from kwepemi500006.china.huawei.com (unknown [7.221.188.68]) by mail.maildlp.com (Postfix) with ESMTPS id CA6C31800B9; Tue, 26 Dec 2023 17:16:34 +0800 (CST) Received: from [10.67.120.168] (10.67.120.168) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 26 Dec 2023 17:16:34 +0800 Message-ID: Date: Tue, 26 Dec 2023 17:16:33 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 Subject: Re: [PATCH for-next 4/6] RDMA/hns: Support flexible pagesize Content-Language: en-US To: Leon Romanovsky CC: , , , References: <20231225075330.4116470-1-huangjunxian6@hisilicon.com> <20231225075330.4116470-5-huangjunxian6@hisilicon.com> <20231226085202.GA13350@unreal> From: Junxian Huang In-Reply-To: <20231226085202.GA13350@unreal> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500006.china.huawei.com (7.221.188.68) On 2023/12/26 16:52, Leon Romanovsky wrote: > On Mon, Dec 25, 2023 at 03:53:28PM +0800, Junxian Huang wrote: >> From: Chengchang Tang >> >> In the current implementation, a fixed page size is used to >> configure the PBL, which is not flexible enough and is not >> conducive to the performance of the HW. >> >> Signed-off-by: Chengchang Tang >> Signed-off-by: Junxian Huang >> --- >> drivers/infiniband/hw/hns/hns_roce_alloc.c | 6 - >> drivers/infiniband/hw/hns/hns_roce_device.h | 9 ++ >> drivers/infiniband/hw/hns/hns_roce_mr.c | 168 +++++++++++++++----- >> 3 files changed, 139 insertions(+), 44 deletions(-) > > I'm wonder if the ib_umem_find_best_pgsz() API should be used instead. > What is missing there? > > Thanks Actually this API is used for umem. For kmem, we add hns_roce_find_buf_best_pgsz() to do a similar job. +static int get_best_page_shift(struct hns_roce_dev *hr_dev, + struct hns_roce_mtr *mtr, + struct hns_roce_buf_attr *buf_attr) +{ + unsigned int page_sz; + + if (!buf_attr->adaptive || buf_attr->type != MTR_PBL) + return 0; + + if (mtr->umem) + page_sz = ib_umem_find_best_pgsz(mtr->umem, + hr_dev->caps.page_size_cap, + buf_attr->iova); + else + page_sz = hns_roce_find_buf_best_pgsz(hr_dev, mtr->kmem); + + if (!page_sz) + return -EINVAL; + + buf_attr->page_shift = order_base_2(page_sz); + return 0; +} Thanks, Junxian