From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6699C43334 for ; Wed, 29 Jun 2022 11:58:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3B68640610; Wed, 29 Jun 2022 11:58:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3B68640610 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SU6ifBLTbqRs; Wed, 29 Jun 2022 11:58:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id F0AE040002; Wed, 29 Jun 2022 11:58:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org F0AE040002 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C1153C0039; Wed, 29 Jun 2022 11:58:00 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 04CE6C002D for ; Wed, 29 Jun 2022 11:57:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E0EFF410A5 for ; Wed, 29 Jun 2022 11:57:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E0EFF410A5 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8yKsk4_hevyH for ; Wed, 29 Jun 2022 11:57:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 826CA409FE Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 826CA409FE for ; Wed, 29 Jun 2022 11:57:57 +0000 (UTC) Received: from fraeml739-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LY0Lr1xbbz67yhs; Wed, 29 Jun 2022 19:57:08 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml739-chm.china.huawei.com (10.206.15.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 29 Jun 2022 13:57:53 +0200 Received: from [10.195.245.77] (10.195.245.77) 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.2375.24; Wed, 29 Jun 2022 12:57:52 +0100 Message-ID: <416ebe33-28ed-eef0-0001-83efd83a9d0f@huawei.com> Date: Wed, 29 Jun 2022 12:57:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v4 1/5] dma-mapping: Add dma_opt_mapping_size() To: Robin Murphy References: <1656343521-62897-1-git-send-email-john.garry@huawei.com> <1656343521-62897-2-git-send-email-john.garry@huawei.com> In-Reply-To: X-Originating-IP: [10.195.245.77] X-ClientProxiedBy: lhreml751-chm.china.huawei.com (10.201.108.201) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-doc@vger.kernel.org, will@kernel.org, damien.lemoal@opensource.wdc.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linuxarm@huawei.com, linux-ide@vger.kernel.org, iommu@lists.linux.dev, hch@lst.de, jejb@linux.ibm.com X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: John Garry via iommu Reply-To: John Garry Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" T24gMjgvMDYvMjAyMiAxMjoyNywgSm9obiBHYXJyeSB2aWEgaW9tbXUgd3JvdGU6Cj4gT24gMjgv MDYvMjAyMiAxMjoyMywgUm9iaW4gTXVycGh5IHdyb3RlOgo+Pj4gKwo+Pj4gK8KgwqDCoCBzaXpl X3QKPj4+ICvCoMKgwqAgZG1hX29wdF9tYXBwaW5nX3NpemUoc3RydWN0IGRldmljZSAqZGV2KTsK Pj4+ICsKPj4+ICtSZXR1cm5zIHRoZSBtYXhpbXVtIG9wdGltYWwgc2l6ZSBvZiBhIG1hcHBpbmcg Zm9yIHRoZSBkZXZpY2UuIAo+Pj4gTWFwcGluZyBsYXJnZQo+Pj4gK2J1ZmZlcnMgbWF5IHRha2Ug bG9uZ2VyIHNvIGRldmljZSBkcml2ZXJzIGFyZSBhZHZpc2VkIHRvIGxpbWl0IHRvdGFsIAo+Pj4g RE1BCj4+PiArc3RyZWFtaW5nIG1hcHBpbmdzIGxlbmd0aCB0byB0aGUgcmV0dXJuZWQgdmFsdWUu Cj4+Cj4+IE5pdDogSSdtIG5vdCBzdXJlICJhZHZpc2VkIiBpcyBuZWNlc3NhcmlseSB0aGUgcmln aHQgdGhpbmcgdG8gc2F5IGluIAo+PiBnZW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dWVzdCBsaWZldGltZS4gQXMgc3VjaCwgaWYgc3BsaXR0aW5nIGxh cmdlciByZXF1ZXN0cyBpbmN1cnMgbm8gCnNpZ25pZmljYW50IHBlcmZvcm1hbmNlIHBlbmFsdHks IHRoZW4gZGV2aWNlIGRyaXZlcnMgYXJlIGFkdmlzZWQgdG8gCmxpbWl0IHRvdGFsIERNQSBzdHJl YW1pbmcgbWFwcGluZ3MgbGVuZ3RoIHRvIHRoZSByZXR1cm5lZCB2YWx1ZS4KCkxldCBtZSBrbm93 IGlmIHlvdSB3b3VsZCBsaWtlIGl0IGZ1cnRoZXIgYW1lbmRlZC4KCkNoZWVycywKSm9obgpfX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fXwppb21tdSBtYWlsaW5n IGxpc3QKaW9tbXVAbGlzdHMubGludXgtZm91bmRhdGlvbi5vcmcKaHR0cHM6Ly9saXN0cy5saW51 eGZvdW5kYXRpb24ub3JnL21haWxtYW4vbGlzdGluZm8vaW9tbXU= From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 2E10A7A for ; Wed, 29 Jun 2022 11:57:57 +0000 (UTC) Received: from fraeml739-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LY0Lr1xbbz67yhs; Wed, 29 Jun 2022 19:57:08 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml739-chm.china.huawei.com (10.206.15.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 29 Jun 2022 13:57:53 +0200 Received: from [10.195.245.77] (10.195.245.77) 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.2375.24; Wed, 29 Jun 2022 12:57:52 +0100 Message-ID: <416ebe33-28ed-eef0-0001-83efd83a9d0f@huawei.com> Date: Wed, 29 Jun 2022 12:57:54 +0100 Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v4 1/5] dma-mapping: Add dma_opt_mapping_size() To: Robin Murphy CC: , , , , , , , , , , , , , References: <1656343521-62897-1-git-send-email-john.garry@huawei.com> <1656343521-62897-2-git-send-email-john.garry@huawei.com> From: John Garry In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.195.245.77] X-ClientProxiedBy: lhreml751-chm.china.huawei.com (10.201.108.201) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Message-ID: <20220629115754.DnfCpPqC3bthqnYc7sMrN2McG2kjGE4N7bKcsS1Dn6k@z> On 28/06/2022 12:27, John Garry via iommu wrote: > On 28/06/2022 12:23, Robin Murphy wrote: >>> + >>> +    size_t >>> +    dma_opt_mapping_size(struct device *dev); >>> + >>> +Returns the maximum optimal size of a mapping for the device. >>> Mapping large >>> +buffers may take longer so device drivers are advised to limit total >>> DMA >>> +streaming mappings length to the returned value. >> >> Nit: I'm not sure "advised" is necessarily the right thing to say in >> general - that's only really true for a caller who cares about >> throughput of churning through short-lived mappings more than anything >> else, and doesn't take a significant hit overall from splitting up >> larger requests. I do think it's good to clarify the exact context of >> "optimal" here, but I'd prefer to be objectively clear that it's for >> workloads where the up-front mapping overhead dominates. > I'm going to go with something like this: size_t dma_opt_mapping_size(struct device *dev); Returns the maximum optimal size of a mapping for the device. Mapping larger buffers may take much longer in certain scenarios. In addition, for high-rate short-lived streaming mappings the upfront time spent on the mapping may account for an appreciable part of the total request lifetime. As such, if splitting larger requests incurs no significant performance penalty, then device drivers are advised to limit total DMA streaming mappings length to the returned value. Let me know if you would like it further amended. Cheers, John