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.