Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp60406rdd; Mon, 8 Jan 2024 17:47:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDvM7/6fvlmxHox9BAit6LwCUdCg56oiaQYaEGI7gzCe9zi0kUBJqiCUKEtUz4I+txH6Wd X-Received: by 2002:a05:6358:281a:b0:172:caa7:74ca with SMTP id k26-20020a056358281a00b00172caa774camr4420421rwb.36.1704764873774; Mon, 08 Jan 2024 17:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704764873; cv=none; d=google.com; s=arc-20160816; b=gaxoTS1L51wOhpn2iQzCicQZ7i/gWI8PXrDW9YpT1h/yPSgIo7aTRrYCiNZgssFRpZ 5KrcrBNOHh6V0o1yNXAQewVb2WCMsXNF7EZeFsON5lepnBAw30ggqXMLkYRu/eaiWEKw mnB43ktdxLu/24xeBTIgTWLBwPhaEpkhSjIlsWQZUaBI+L+96HFfK+Q0wdo48MlCcztF 4DaOGt5WRaQFhoHpNvl5cIKlCWfJGEbjl0k4PiqzCoMAOJFGU94REeIq3M/McIBGyVDF N1sq3Yg2N0IvSupTIrYPCFgjC1agMv048oRR+7Kayr4Ny+sb2VSM1UT7rqJqsTJNr1fv uGCg== 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=VooMWe6G7qt0/c9sW6oLRrAfyTe2oblc+3nCaX6InOk=; fh=CXpVxMpAnJU6p5AYWsRVHITtvnKSWWFoAaOTM9AmpTY=; b=wAws4KUyPtNTPp2M7E74kY7LwHXjRHTC+J7tgO9SlKPhIWpY25ELFNxlPVzoXDEuEM dOKtd4C5PQET5I+0aNzBFUY2NO2RvPyHzUD4PlQJ6q4DJAqfaJVbtZ9eO+B3PF48bD7d 5ILEh7amp8XhVVtsd1Eh4LANopCxe3MbCB8jYvE436SBmW1dwRJ2wkE0OhC4HJwVQRGn Lq10GWVOW+yrDH5QPVFEKLwYSTxJ+MDhraE5sjo09q8/chkXy5O3wydZMHFbuR7K051G SbUgogZbpoLeupfjw7KAYyi0eRiAT6bM/ExqAf90A5Va5z4DAHARMo0ZVH75PhywufJV DoRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-20264-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20264-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. [139.178.88.99]) by mx.google.com with ESMTPS id b14-20020a63d30e000000b005cef24b3f87si673074pgg.400.2024.01.08.17.47.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 17:47:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20264-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; spf=pass (google.com: domain of linux-kernel+bounces-20264-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20264-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 689F22857C1 for ; Tue, 9 Jan 2024 01:47:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2E1220FB; Tue, 9 Jan 2024 01:47:46 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 D4E0815AA; Tue, 9 Jan 2024 01:47:43 +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 szxga01-in.huawei.com (SkyGuard) with ESMTP id 4T8DLh40cVzsVRM; Tue, 9 Jan 2024 09:46:52 +0800 (CST) Received: from kwepemi500006.china.huawei.com (unknown [7.221.188.68]) by mail.maildlp.com (Postfix) with ESMTPS id 44C1818005E; Tue, 9 Jan 2024 09:47:35 +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, 9 Jan 2024 09:47:34 +0800 Message-ID: <4894db95-817e-ed88-c374-5f4dc118e5b7@hisilicon.com> Date: Tue, 9 Jan 2024 09:47:34 +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: Jason Gunthorpe CC: Leon Romanovsky , , , References: <20231225075330.4116470-1-huangjunxian6@hisilicon.com> <20231225075330.4116470-5-huangjunxian6@hisilicon.com> <20231226085202.GA13350@unreal> <20240104202902.GD50608@ziepe.ca> <3d4cdc2e-0053-f486-7323-72127027886f@hisilicon.com> <20240105141849.GE50608@ziepe.ca> From: Junxian Huang In-Reply-To: <20240105141849.GE50608@ziepe.ca> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500006.china.huawei.com (7.221.188.68) On 2024/1/5 22:18, Jason Gunthorpe wrote: > On Fri, Jan 05, 2024 at 01:55:11PM +0800, Junxian Huang wrote: >> >> >> On 2024/1/5 4:29, Jason Gunthorpe wrote: >>> 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. >>> >>> But why do you need to do something like this for kmem? It looked to >>> me like kmem knows its allocation size when it was allocated, how come >>> you need to iterate over all of it again? >>> >>> Jason >>> >> >> kmem was split into multiple small pages for allocation to prevent allocation >> failure due to memory fragmentation. >> >> And now we add this function to confirm whether these small pages have contiguous >> address. If so, they can be combined into one huge page for use, which is more >> likely when iommu/smmu is enabled. > > That seems unncessary. The chances you get contiguous pages from > a lot of random allocations is really slim. > > If you care about this optimization then you should have the allocator > explicitly request contiguous pages with high order allocations in a > manner that quickly fails and falls back to PAGE_SIZE. > > Then you just use the size that the allocator was able to get, not try > to figure it out after the fact. > > Jason Thanks for the suggestion! We'll consider a new implementation. For this patch, I'll drop the kmem modification and re-send a v2. Junxian