Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2693211rdb; Tue, 26 Dec 2023 01:42:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqN02kE1SE/3NkLH9xPioMLOjMGMzh+pJD7YNqZ97unB62S7mVdFGxU1QnhPuFbb3Zadbf X-Received: by 2002:a17:90a:c250:b0:28b:e993:32f7 with SMTP id d16-20020a17090ac25000b0028be99332f7mr1913892pjx.24.1703583750976; Tue, 26 Dec 2023 01:42:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703583750; cv=none; d=google.com; s=arc-20160816; b=By6S6PqdgjYvrkMlPoe+D7Bxl5/7yXCfjT74Jzm/fiP44ZqS3s3wZRzKz4MNtGhj1g u8ay62KRWrDCjOV9acbcg7FhFz+5S8OHlmfMTANMf7s/qiZdMBWgS8/Pk2oEa2fBS2px OYMIEVhlv3uxY/uxYqlGCXAlZWcZMNL4L21pcNocGc/rBMO/N/f0zTz62egG8DgDciTo wiI6tAXdp/84S9hKbI726+ePWRJQvGNFv1AxaR5EsAyWV8ZXSv7kaAOUfJU/zqfp+Dtu xoBYYqkEI70qf47cTVU1odcZbe60hyOfFTrg7hV1dgtiNCaLgtWgvO65lhQdAYGBX58E ux6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4aO2aLf0xH3C8kEAJ8rN43sDm3LM1H5KFLEolDvvzhk=; fh=DQ4iYRSMLAEi5vZHJLJxXHYGayqB3vG83MXII+z0OHs=; b=0J+qsG8nzmqEkmvGEegFwi+xaSeIfZIfo09wbkm6MerBFFwQyb2npgwBIF/aX66h+U 8uuGC4Rx9pT0cuw0xQRo5H/IvMpSDJEmihMSxSXk8HHg+Jb7LQKBc6U5evFBqM8tpJ4u iiVy/FDgbJt5pvb7BQ+MaAtBq0U4uOo8rlIx5drV+vrrCJcZ4TMu2SPckvYukGsjInKV cn8fJ7Qjo0ly0j61V8N5YDLkJAgJ1kYJkqs6kmmcrbHg9TXC7lunSDpYISSqxmAMkdjp 4eMRMQmm0P9Ld66jn00D/pzitFTnEN6VH8JHSVjq3WZpTzdsQwEWs9M434xnA5NWkVqr SPzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="sBY+/xTU"; spf=pass (google.com: domain of linux-kernel+bounces-11448-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11448-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ot13-20020a17090b3b4d00b0028c2df873bdsi5439976pjb.103.2023.12.26.01.42.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 01:42:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11448-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="sBY+/xTU"; spf=pass (google.com: domain of linux-kernel+bounces-11448-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11448-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 A3119282057 for ; Tue, 26 Dec 2023 09:42:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F3E94D129; Tue, 26 Dec 2023 09:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sBY+/xTU" X-Original-To: linux-kernel@vger.kernel.org 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 B0F244D102; Tue, 26 Dec 2023 09:42:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AE1EC433C7; Tue, 26 Dec 2023 09:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703583742; bh=Tsmg+MnN4G6iohoVCMTbtuf++BSfs/xm9Czu/0qaSKI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sBY+/xTUXxm9VeY9c5lBhJweeyQVDX7DKjV7HvlP5iWYwZmcmyv4/PqPMhfz3oaHF NXV0/2SSXT++xN7EyODtQ/v5gjMxq9SGkKOGqNa+sR18nuTJnYdDr9D/yoWYvmFzHp 2RWPLqMGs/Gja7Xrdtu3sjL6Nk0xr+iWuWjciLzgBbTEjDO/zlZEZ/ReiFRmN5MwdK Fif2mImrslkJdIVitjWYf7nSl2gzT2OMF8oDANvlt1Jdo7z+GQSBc/GOob0wmyNgK5 5NbAaLCK55jrZKZe0+uLClHcqs+6JCeljwVhHp7cLMVuIGsSOyVLOITer8VmPIqmCZ vXzXf/IEaUcAg== Date: Tue, 26 Dec 2023 11:42:18 +0200 From: Leon Romanovsky To: Junxian Huang Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org, linuxarm@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH for-next 4/6] RDMA/hns: Support flexible pagesize Message-ID: <20231226094218.GA17182@unreal> References: <20231225075330.4116470-1-huangjunxian6@hisilicon.com> <20231225075330.4116470-5-huangjunxian6@hisilicon.com> <20231226085202.GA13350@unreal> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Dec 26, 2023 at 05:16:33PM +0800, Junxian Huang wrote: > > > 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. Thanks, let's give a chance to Jason to provide his feedback. I have a strong feeling that this code duplicates something in the kernel. Thanks > > +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