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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 59888C3ABA5 for ; Mon, 28 Apr 2025 20:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2WLXXc1Yi64psx1K8SyCH/DyA6CIUelvdICwIFrC5sQ=; b=fOBErGosu+IXsj9t8mEPa1DAZg rqpZ7ygXSFcr9Lm8CYGGcxsmETCB1WJmBr1A3BlOwDFcfLGK+kZj+yGdyU/2ySwkHrB2vH8o/Z/x2 mPX+tvRW7EBuzteL5vgf16xE9M17VQKyIVNXEWw/1Pu5kS5EGn6cpu5f/Czjb+CBKqFHZNhq2s4z5 S8VkYcKunjus3WbFZ9piDVbTx2bpttpf+QudCnIDuIk8RxA07UVa1BTFTjD3fvOFI4TUTr/Awp2e7 9qIlaEjIV397Ggfqlb2rBE1JLQxMHWh5IK24fnLm9PGl8kT55aSPCYC7jSRTyrrl05NdimTEcx2II J3IGt/wA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u9UqH-00000007QUh-1ibJ; Mon, 28 Apr 2025 20:12:41 +0000 Received: from verein.lst.de ([213.95.11.211]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1u9OPC-00000006RWU-2Ubr for linux-nvme@lists.infradead.org; Mon, 28 Apr 2025 13:20:20 +0000 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> 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250428_062018_773142_1E0443B4 X-CRM114-Status: GOOD ( 17.93 ) X-Mailman-Approved-At: Mon, 28 Apr 2025 13:12:39 -0700 X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org 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.