From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (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 663C286323 for ; Mon, 28 Apr 2025 13:20:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.95.11.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745846413; cv=none; b=s8ZXeZ/T7HVVQg0xrbyIQP+4Ie9FQPizza/pZJzHJ726wJ8wzRb4k3OqpsBEEErFcQFXNg0NpBlhWEqBbRVddW1hivvswPbmo64jHVBbbKKYU5gQmKrk3iKPdJCmDe6zZKzK5rCj0ZsPAQWE7gToTuf3Bw6gXo6ELIOqe2O7vuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745846413; c=relaxed/simple; bh=j5yKBIk0ChsBmEbxwXBtdSmj61Lr30e37k9LA8CJ3MA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hk+eCCLNdqlbJ+kWn+Zgkm8D8yyDCNycrygZPF358WL5UF5zJNTC/tgqnyzlO+Z79dOb0hM+ZVhP1pRrgZ6f0mgwMEIHXLBZCC27TbZPYNV8u4qqoXt8xao6rhyjG4nH+Ri59yqnaYJeiBtnQ+iVEidkKU7vUjkCLlVG384wsys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lst.de; spf=pass smtp.mailfrom=lst.de; arc=none smtp.client-ip=213.95.11.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Received: by verein.lst.de (Postfix, from userid 2407) id 3A2B668C4E; Mon, 28 Apr 2025 15:20:06 +0200 (CEST) Date: Mon, 28 Apr 2025 15:20:06 +0200 From: Christoph Hellwig To: Leon Romanovsky Cc: Luis Chamberlain , Marek Szyprowski , Jens Axboe , Christoph Hellwig , Keith Busch , Jake Edge , Jonathan Corbet , Jason Gunthorpe , Zhu Yanjun , Robin Murphy , Joerg Roedel , Will Deacon , Sagi Grimberg , Bjorn Helgaas , Logan Gunthorpe , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , =?iso-8859-1?B?Suly9G1l?= Glisse , Andrew Morton , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, Niklas Schnelle , Chuck Lever , Matthew Wilcox , Dan Williams , Kanchan Joshi , Chaitanya Kulkarni Subject: Re: [PATCH v9 07/24] dma-mapping: Implement link/unlink ranges API Message-ID: <20250428132006.GA30966@lst.de> References: <2d6ca43ef8d26177d7674b9e3bdf0fe62b55a7ed.1745394536.git.leon@kernel.org> <20250427081312.GE5848@unreal> Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250427081312.GE5848@unreal> User-Agent: Mutt/1.5.17 (2007-11-01) On Sun, Apr 27, 2025 at 11:13:12AM +0300, Leon Romanovsky wrote: > > So arch_sync_dma_for_device() is a no-op on some architectures, notably x86. > > So since you're doing this work and given the above pattern is common on > > the non iova case, we could save ourselves 2 branches checks on x86 on > > __dma_iova_link() and also generalize savings for the non-iova case as > > well. For the non-iova case we have two use cases, one with the attrs on > > initial mapping, and one without on subsequent sync ops. For the iova > > case the attr is always consistently used. > > I want to believe that compiler will discards these "if (!coherent && > !(attrs & DMA_ATTR_SKIP_CPU_SYNC)))" branch if case is empty. Yes, it is the poster child for dead code elimination using the IS_ENABLED() helper. > checks are scattered over all dma-iommu.c file with different > combinations. While we can do new static functions for small number of > use cases, it will be half-solution. Don't bother.