Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp261315lqg; Fri, 1 Mar 2024 04:42:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWsctAKUtc6LlLUN3NXbk/n8PZu+r5au3TBjRfgnWaATCXJ9cqgKdghHM8stzT9rgWw/WEYKLfeJNCOQHmY7FAA2X0TfcWMe2BpywbEUQ== X-Google-Smtp-Source: AGHT+IFC6Tsb7aswV+lUcJ89GdFcUGxoWoYfGCffgAl7Wk0YzGzjmsNtgIywiuPZNukW7zY/nZ14 X-Received: by 2002:a05:6a00:1707:b0:6e3:c568:47aa with SMTP id h7-20020a056a00170700b006e3c56847aamr1954693pfc.24.1709296973819; Fri, 01 Mar 2024 04:42:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709296973; cv=pass; d=google.com; s=arc-20160816; b=fjX40aFbtlwpHfloGGrLoGF0HeOXJUnvIbbtAUalwvukUtGPnlwnc6P9mEAOOsZ1r1 h8igdVPhLnGy8zoo76EeJe/sneoIkuOJe+gh6rwdc2tuuH4mRtEZg2Bje2f21PAiCjfd EwrihTCWwYDAaQuxLDHQNppEjHxrWRkjXmK88LCVYOMn5wGVIETroT5ULprBbUkhqHmk N+ipZkdPWBqmi5nv8WOJLouXiNfzh+4NQlFyv9rEKj7/kgTmuufNz+IANc9hs8paSS08 K1MuAmj9mIs8M+FlzBcbJmygWKk8FlFi99WZfl6jVjJbGFq2YFXWt4q5gBMNjaymUAeg OIIA== ARC-Message-Signature: i=2; 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=c2u8UrHcodLo6SGL/Nz7BONK1x4iVwsDqQyow+tthrI=; fh=nIdiBZtiTJ9ymEgOEy77a+xUZR6zwkOnjTgnfJb9QN4=; b=iFbkzbC+C6+NRxWoHUOMVVEXdklkNazd/HgMbj22JKY7zXUgTQ8ZWzebr5Cl4mQ40u 4C5gCFsKXgW0EL8WSVbCNkFvyVd+31y2N/ZUO9oRNMYZfPJwZR4cv+uQmiCzjeMJIEZ8 +t9txRU+cO7fBeAAVlapaXanZS1Sswx2T5u0d++qJ7UGw+LhQ98ser46qEflF4DEUWzG QmdhR8fwdb6csQVzn4Id2yM/aXlezEcky4NMDtXcpzbhYYvwvIwWcatX7q38xRvr62jQ r6Mo9+ZiG7+kXavNJRXN4VAkRGfU6avq12XVF1DK8czYqUAwR0XlBkxi4X+BknvVlrQT OIpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-88409-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88409-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v13-20020a63480d000000b005dc4328dc23si3500537pga.780.2024.03.01.04.42.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 04:42:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88409-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-88409-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88409-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DF9ABB2262C for ; Fri, 1 Mar 2024 12:42:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 378E23E48C; Fri, 1 Mar 2024 12:42:45 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 920F733CD0 for ; Fri, 1 Mar 2024 12:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709296964; cv=none; b=Pqw7Oxh4lOzpcmNLep/s/fEpS8waiIN18dofkP3amqvD4keJiCzLH8C1rF7BlR293FlUt5333b6cJeUc9wGGacOCIkIVzQYq7A64geSL76YGNFjeae0xWoveRpurA0IbEdbKCG85q79YW5YYLel4hl8LZKkHdXImnWV5+HwhQZo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709296964; c=relaxed/simple; bh=t992hf53Vycc3JIlhL128nsP3WDitkm3C4upBjGdDZw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=c/zRYITYn9iLbPOGoQ8V02MI93Du6fah05lxNjC9JMwUFQ2qbLFRU1n0tVKjMfefDkk6dUkVWLRaT3MFsBmsqtKtFEYvDOLL1oXp24sRiZLVW+NdcMUgbT3Nb+JiqNE5zQ6V/BNDAcBhDfIxzsAoFu3XnJ6LgfjX04olOEosEAo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 002921FB; Fri, 1 Mar 2024 04:43:20 -0800 (PST) Received: from [10.57.67.78] (unknown [10.57.67.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4F6A43F6C4; Fri, 1 Mar 2024 04:42:40 -0800 (PST) Message-ID: Date: Fri, 1 Mar 2024 12:42:39 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC] dma-mapping: introduce dma_can_skip_unmap() Content-Language: en-GB To: "Michael S. Tsirkin" Cc: Xuan Zhuo , linux-kernel@vger.kernel.org, Joerg Roedel , Will Deacon , Christoph Hellwig , Marek Szyprowski , iommu@lists.linux.dev, Zelin Deng References: <20240301071918.64631-1-xuanzhuo@linux.alibaba.com> <64be2e23-c526-45d3-bb7b-29e31241bbef@arm.com> <20240301064632-mutt-send-email-mst@kernel.org> From: Robin Murphy In-Reply-To: <20240301064632-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024-03-01 11:50 am, Michael S. Tsirkin wrote: > On Fri, Mar 01, 2024 at 11:38:25AM +0000, Robin Murphy wrote: >> Not only is this idea not viable, the entire premise seems flawed - the >> reasons for virtio needing to use the DMA API at all are highly likely to be >> the same reasons for it needing to use the DMA API *properly* anyway. > > The idea has nothing to do with virtio per se Sure, I can see that, but if virtio is presented as the justification for doing this then it's the justification I'm going to look at first. And the fact is that it *does* seem to have particular significance, since having up to 19 DMA addresses involved in a single transfer is very much an outlier compared to typical hardware drivers. Furthermore the fact that DMA API support was retrofitted to the established virtio design means I would always expect it to run up against more challenges than a hardware driver designed around the expectation that DMA buffers have DMA addresses. > - we are likely not the > only driver that wastes a lot of memory (hot in cache, too) keeping DMA > addresses around for the sole purpose of calling DMA unmap. On a bunch > of systems unmap is always a nop and we could save some memory if there > was a way to find out. What is proposed is an API extension allowing > that for anyone - not just virtio. And the point I'm making is that that "always" is a big assumption, and in fact for the situations where it is robustly true we already have the DEFINE_DMA_UNMAP_{ADDR,LEN} mechanism. I'd consider it rare for DMA addresses to be stored in isolation, as opposed to being part of some kind of buffer descriptor (or indeed struct scatterlist, for an obvious example) that a driver or subsystem still has to keep track of anyway, so in general I believe the scope for saving decidedly small amounts of memory at runtime is also considerably less than you might be imagining. Thanks, Robin.