Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb

2022-04-13 Thread Christoph Hellwig
On Wed, Apr 13, 2022 at 02:10:56PM +0100, Robin Murphy wrote: > Are you sure? AFAICS swiotlb_map() does the right thing, and > dma_direct_{sync,unmap} are working off the DMA address, which is that of > the bounce slot when SWIOTLB is involved (not least, how would the > is_swiotlb_buffer() chec

Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb

2022-04-13 Thread Robin Murphy
On 2022-04-13 05:59, Christoph Hellwig wrote: On Wed, Apr 13, 2022 at 09:02:02AM +0800, Chao Gao wrote: dma_direct_sync_single_for_cpu() also calls arch_sync_dma_for_cpu_all() and arch_dma_mark_clean() in some cases. if SWIOTLB does sync internally, should these two functions be called by SWIOTL

Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb

2022-04-12 Thread Christoph Hellwig
On Wed, Apr 13, 2022 at 01:46:06PM +0800, Chao Gao wrote: > On Wed, Apr 13, 2022 at 06:59:58AM +0200, Christoph Hellwig wrote: > >So for now I'd be happy with the one liner presented here, but > >eventually the whole area could use an overhaul. > > Thanks. Do you want me to post a new version with

Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb

2022-04-12 Thread Chao Gao
On Wed, Apr 13, 2022 at 06:59:58AM +0200, Christoph Hellwig wrote: >So for now I'd be happy with the one liner presented here, but >eventually the whole area could use an overhaul. Thanks. Do you want me to post a new version with the Fixes tag or you will take care of it? Fixes: 55897af63091 ("d

Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb

2022-04-12 Thread Christoph Hellwig
On Wed, Apr 13, 2022 at 09:02:02AM +0800, Chao Gao wrote: > dma_direct_sync_single_for_cpu() also calls arch_sync_dma_for_cpu_all() > and arch_dma_mark_clean() in some cases. if SWIOTLB does sync internally, > should these two functions be called by SWIOTLB? > > Personally, it might be better if s

Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb

2022-04-12 Thread Chao Gao
On Tue, Apr 12, 2022 at 02:33:05PM +0100, Robin Murphy wrote: >On 12/04/2022 12:38 pm, Chao Gao wrote: >> 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

Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb

2022-04-12 Thread Robin Murphy
On 12/04/2022 12:38 pm, Chao Gao wrote: 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 completio

Re: [PATCH] dma-direct: avoid redundant memory sync for swiotlb

2022-04-12 Thread Chao Gao
On Tue, Apr 12, 2022 at 07:38:05PM +0800, Chao Gao wrote: >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 twic

[PATCH] dma-direct: avoid redundant memory sync for swiotlb

2022-04-12 Thread Chao Gao
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_