Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1615760pxf; Fri, 19 Mar 2021 11:07:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUVDkO8cLTXRu7k/BHh/4xjrDgKbp23T3BW2Lzl9e50p+3+dD0iVTQlNUAJ8u3mVu2dwmn X-Received: by 2002:a17:906:2504:: with SMTP id i4mr5901787ejb.115.1616177221695; Fri, 19 Mar 2021 11:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616177221; cv=none; d=google.com; s=arc-20160816; b=wWIDFSI62Mxy4KpQEx5Zkqqm+wPlkJKnqg+b1ycv2jDxNr/NTnGAttWCjsQ/u3lvPx L94Op+tqi5TTMqMZcz+k5tgNsChPEEylc9kESeE92yb87COGsjM5CXvC7coBWvZm0SSI 83iMPlnZe79k4o+NRF0j69CIpEWKiEYqTUYx7LOUz9Vk1W86FkbdCPKg64glYciVYWvC QK1XbozWREK5+7qECzsqD+OeX+BZHWGdnJhTr84f2ybKok+Om4n3oEMGZYaUi2b2qDRK LHEHESv/yU6jd3l17+Fi5kE/sZmTqdSvpx/c4xPp72LNj8Hd7xgAVwskB15JCF0gA1bq NMjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=7vlwSLfL5+l5qt9s2ig5dSTcNX3HLSk3Rm6J4WEL0sU=; b=jtp0VYcFdS2cQIMBJvkceEpGInt4FcGAeO6vrtBnYsyTc/c8D5P7NStB/UpbKCLtu6 /fapmnOtMmKb3KzOi4nrQhFXbXJRaQi2/12z4+GSv27lTLoedUUAokGhGdzW9F05tiDi PzMlys82TrTPzlXl/a+UYiCQMDgaAlyzp4KfFmdOxsKpYegexuftxycZm8Wnr3lpNFwF lYCimYp+gCgh00GE/arLiN/+oe0QwdlqKgWtpTT7QASfx91xU/xxexuVjfoRMo5DBgd1 eo2imz46nKApWp1MO0xNoCVfIKAGas1LykUG02Wi8gfAZKxpbv8wxysFtKlH4mFWoAzg 7ZiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l24si4831383eds.501.2021.03.19.11.06.35; Fri, 19 Mar 2021 11:07:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhCSSEk (ORCPT + 99 others); Fri, 19 Mar 2021 14:04:40 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2719 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbhCSSEQ (ORCPT ); Fri, 19 Mar 2021 14:04:16 -0400 Received: from fraeml707-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4F2BVc5JBFz681CR; Sat, 20 Mar 2021 01:59:36 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml707-chm.china.huawei.com (10.206.15.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Fri, 19 Mar 2021 19:04:14 +0100 Received: from [10.47.10.104] (10.47.10.104) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Fri, 19 Mar 2021 18:04:13 +0000 Subject: Re: [PATCH 5/6] dma-mapping/iommu: Add dma_set_max_opt_size() To: Robin Murphy , , , , , , CC: , , , References: <1616160348-29451-1-git-send-email-john.garry@huawei.com> <1616160348-29451-6-git-send-email-john.garry@huawei.com> <9ecb6980-7f40-0333-572f-f9d4b8238353@arm.com> From: John Garry Message-ID: Date: Fri, 19 Mar 2021 18:02:02 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <9ecb6980-7f40-0333-572f-f9d4b8238353@arm.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.10.104] X-ClientProxiedBy: lhreml717-chm.china.huawei.com (10.201.108.68) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/03/2021 17:00, Robin Murphy wrote: > On 2021-03-19 13:25, John Garry wrote: >> Add a function to allow the max size which we want to optimise DMA >> mappings >> for. > > It seems neat in theory - particularly for packet-based interfaces that > might have a known fixed size of data unit that they're working on at > any given time - but aren't there going to be many cases where the > driver has no idea because it depends on whatever size(s) of request > userspace happens to throw at it? Even if it does know the absolute > maximum size of thing it could ever transfer, that could be > impractically large in areas like video/AI/etc., so it could still be > hard to make a reasonable decision. So if you consider the SCSI stack, which is my interest, we know the max segment size and we know the max number of segments per request, so we should know the theoretical upper limit of the actual IOVA length we can get. Indeed, from my experiment on my SCSI host, max IOVA len is found to be 507904, which is PAGE_SIZE * 124 (that is max sg ents there). Incidentally that means that we want RCACHE RANGE MAX of 8, not 6. > > Being largely workload-dependent is why I still think this should be a > command-line or sysfs tuneable - we could set the default based on how > much total memory is available, but ultimately it's the end user who > knows what the workload is going to be and what they care about > optimising for. If that hardware is only found in a server, then the extra memory cost would be trivial, so setting to max is standard approach. > > Another thought (which I'm almost reluctant to share) is that I would > *love* to try implementing a self-tuning strategy that can detect high > contention on particular allocation sizes and adjust the caches on the > fly, but I can easily imagine that having enough inherent overhead to > end up being an impractical (but fun) waste of time. > For now, I just want to recover the performance lost recently :) Thanks, John