linux/kernel/dma
Chao Gao 4459946e86 dma-direct: avoid redundant memory sync for swiotlb
commit 9e02977bfad006af328add9434c8bffa40e053bb upstream.

When we looked into FIO performance with swiotlb enabled in VM, we found
swiotlb_bounce() is always called one more time than expected for each DMA
read request.

It turns out that the bounce buffer is copied to original DMA buffer twice
after the completion of a DMA request (one is done by in
dma_direct_sync_single_for_cpu(), the other by swiotlb_tbl_unmap_single()).
But the content in bounce buffer actually doesn't change between the two
rounds of copy. So, one round of copy is redundant.

Pass DMA_ATTR_SKIP_CPU_SYNC flag to swiotlb_tbl_unmap_single() to
skip the memory copy in it.

This fix increases FIO 64KB sequential read throughput in a guest with
swiotlb=force by 5.6%.

Fixes: 55897af630 ("dma-direct: merge swiotlb_dma_ops into the dma_direct code")
Reported-by: Wang Zhaoyang1 <zhaoyang1.wang@intel.com>
Reported-by: Gao Liang <liang.gao@intel.com>
Signed-off-by: Chao Gao <chao.gao@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-20 09:19:39 +02:00
..
Kconfig dma-mapping: remove arch_dma_mmap_pgprot 2019-08-29 16:43:22 +02:00
Makefile dma-mapping: improve selection of dma_declare_coherent availability 2019-02-20 07:26:35 -07:00
coherent.c dma-coherent: fix integer overflow in the reserved-memory dma allocation 2020-04-23 10:36:30 +02:00
contiguous.c dma-direct: fix zone selection after an unaddressable CMA allocation 2019-08-21 07:14:10 +09:00
debug.c dma-debug: fix return value of __setup handlers 2022-04-15 14:18:18 +02:00
direct.c dma-direct: avoid redundant memory sync for swiotlb 2022-04-20 09:19:39 +02:00
dummy.c dma-mapping: factor out dummy DMA ops 2018-12-13 21:06:12 +01:00
mapping.c dma-mapping: Fix dma_pgprot() for unencrypted coherent pages 2020-04-17 10:50:01 +02:00
remap.c dma-mapping: fix false positivse warnings in dma_common_free_remap() 2019-10-05 10:24:17 +02:00
swiotlb.c swiotlb: fix info leak with DMA_FROM_DEVICE 2022-04-15 14:17:55 +02:00
virt.c dma-mapping: zero memory returned from dma_alloc_* 2018-12-20 08:13:52 +01:00