* [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" @ 2024-10-14 1:27 Ming Lei 2024-10-14 7:23 ` Hannes Reinecke 2024-10-14 15:17 ` Jens Axboe 0 siblings, 2 replies; 12+ messages in thread From: Ming Lei @ 2024-10-14 1:27 UTC (permalink / raw) To: Hamza Mahfooz, Christoph Hellwig, Dan Williams Cc: ming.lei, linux-block, io-uring, linux-raid, iommu, linux-kernel Hello Guys, I got more and more reports on DMA debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" in storage related tests: 1) liburing - test/iopoll-overflow.t - test/sq-poll-dup.t Same buffer is used in more than 1 IO. 2) raid1 driver - same buffer is used in more than 1 bio 3) some storage utilities - dm thin provisioning utility of thin_check - `dt`(https://github.com/RobinTMiller/dt) I looks like same user buffer is used in more than 1 dio. 4) some self cooked test code which does same thing with 1) In storage stack, the buffer provider is far away from the actual DMA controller operating code, which doesn't have the knowledge if DMA_ATTR_SKIP_CPU_SYNC should be set. And suggestions for avoiding this noise? Thanks, Ming ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-14 1:27 [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" Ming Lei @ 2024-10-14 7:23 ` Hannes Reinecke 2024-10-14 7:41 ` Christoph Hellwig 2024-10-14 15:17 ` Jens Axboe 1 sibling, 1 reply; 12+ messages in thread From: Hannes Reinecke @ 2024-10-14 7:23 UTC (permalink / raw) To: Ming Lei, Hamza Mahfooz, Christoph Hellwig, Dan Williams Cc: linux-block, io-uring, linux-raid, iommu, linux-kernel On 10/14/24 03:27, Ming Lei wrote: > Hello Guys, > > I got more and more reports on DMA debug warning "cacheline tracking EEXIST, > overlapping mappings aren't supported" in storage related tests: > > 1) liburing > - test/iopoll-overflow.t > - test/sq-poll-dup.t > > Same buffer is used in more than 1 IO. > > 2) raid1 driver > > - same buffer is used in more than 1 bio > > 3) some storage utilities > - dm thin provisioning utility of thin_check > - `dt`(https://github.com/RobinTMiller/dt) > > I looks like same user buffer is used in more than 1 dio. > > 4) some self cooked test code which does same thing with 1) > > In storage stack, the buffer provider is far away from the actual DMA > controller operating code, which doesn't have the knowledge if > DMA_ATTR_SKIP_CPU_SYNC should be set. > > And suggestions for avoiding this noise? > Can you check if this is the NULL page? Operations like 'discard' will create bios with several bvecs all pointing to the same NULL page. That would be the most obvious culprit. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-14 7:23 ` Hannes Reinecke @ 2024-10-14 7:41 ` Christoph Hellwig 2024-10-14 7:58 ` Ming Lei 2024-10-15 2:31 ` Ming Lei 0 siblings, 2 replies; 12+ messages in thread From: Christoph Hellwig @ 2024-10-14 7:41 UTC (permalink / raw) To: Hannes Reinecke Cc: Ming Lei, Hamza Mahfooz, Christoph Hellwig, Dan Williams, linux-block, io-uring, linux-raid, iommu, linux-kernel On Mon, Oct 14, 2024 at 09:23:14AM +0200, Hannes Reinecke wrote: >> 3) some storage utilities >> - dm thin provisioning utility of thin_check >> - `dt`(https://github.com/RobinTMiller/dt) >> >> I looks like same user buffer is used in more than 1 dio. >> >> 4) some self cooked test code which does same thing with 1) >> >> In storage stack, the buffer provider is far away from the actual DMA >> controller operating code, which doesn't have the knowledge if >> DMA_ATTR_SKIP_CPU_SYNC should be set. >> >> And suggestions for avoiding this noise? >> > Can you check if this is the NULL page? Operations like 'discard' will > create bios with several bvecs all pointing to the same NULL page. > That would be the most obvious culprit. The only case I fully understand without looking into the details is raid1, and that will obviously map the same data multiple times because it writes it out multiple time. Now mapping a buffer multiple times for a DMA_TO_DEVICE is relatively harmless in practice as the data is transferred to the device, but it it still breaks the dma buffer ownership model in the dma which is really helpful to find bugs where people don't think about this at all. Not sure if there is any good solution here. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-14 7:41 ` Christoph Hellwig @ 2024-10-14 7:58 ` Ming Lei 2024-10-14 18:09 ` Robin Murphy 2024-10-15 2:31 ` Ming Lei 1 sibling, 1 reply; 12+ messages in thread From: Ming Lei @ 2024-10-14 7:58 UTC (permalink / raw) To: Christoph Hellwig Cc: Hannes Reinecke, Hamza Mahfooz, Dan Williams, linux-block, io-uring, linux-raid, iommu, linux-kernel On Mon, Oct 14, 2024 at 09:41:51AM +0200, Christoph Hellwig wrote: > On Mon, Oct 14, 2024 at 09:23:14AM +0200, Hannes Reinecke wrote: > >> 3) some storage utilities > >> - dm thin provisioning utility of thin_check > >> - `dt`(https://github.com/RobinTMiller/dt) > >> > >> I looks like same user buffer is used in more than 1 dio. > >> > >> 4) some self cooked test code which does same thing with 1) > >> > >> In storage stack, the buffer provider is far away from the actual DMA > >> controller operating code, which doesn't have the knowledge if > >> DMA_ATTR_SKIP_CPU_SYNC should be set. > >> > >> And suggestions for avoiding this noise? > >> > > Can you check if this is the NULL page? Operations like 'discard' will > > create bios with several bvecs all pointing to the same NULL page. > > That would be the most obvious culprit. > > The only case I fully understand without looking into the details > is raid1, and that will obviously map the same data multiple times The other cases should be concurrent DIOs on same userspace buffer. Thanks, Ming ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-14 7:58 ` Ming Lei @ 2024-10-14 18:09 ` Robin Murphy 2024-10-15 1:59 ` Ming Lei 2024-10-15 4:54 ` Christoph Hellwig 0 siblings, 2 replies; 12+ messages in thread From: Robin Murphy @ 2024-10-14 18:09 UTC (permalink / raw) To: Ming Lei, Christoph Hellwig Cc: Hannes Reinecke, Hamza Mahfooz, Dan Williams, linux-block, io-uring, linux-raid, iommu, linux-kernel On 14/10/2024 8:58 am, Ming Lei wrote: > On Mon, Oct 14, 2024 at 09:41:51AM +0200, Christoph Hellwig wrote: >> On Mon, Oct 14, 2024 at 09:23:14AM +0200, Hannes Reinecke wrote: >>>> 3) some storage utilities >>>> - dm thin provisioning utility of thin_check >>>> - `dt`(https://github.com/RobinTMiller/dt) >>>> >>>> I looks like same user buffer is used in more than 1 dio. >>>> >>>> 4) some self cooked test code which does same thing with 1) >>>> >>>> In storage stack, the buffer provider is far away from the actual DMA >>>> controller operating code, which doesn't have the knowledge if >>>> DMA_ATTR_SKIP_CPU_SYNC should be set. >>>> >>>> And suggestions for avoiding this noise? >>>> >>> Can you check if this is the NULL page? Operations like 'discard' will >>> create bios with several bvecs all pointing to the same NULL page. >>> That would be the most obvious culprit. >> >> The only case I fully understand without looking into the details >> is raid1, and that will obviously map the same data multiple times > > The other cases should be concurrent DIOs on same userspace buffer. active_cacheline_insert() does already bail out for DMA_TO_DEVICE, so it returning -EEXIST to tickle the warning would seem to genuinely imply these are DMA mappings requesting to *write* the same cacheline concurrently, which is indeed broken in general. Thanks, Robin. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-14 18:09 ` Robin Murphy @ 2024-10-15 1:59 ` Ming Lei 2024-10-15 2:22 ` Dan Williams 2024-10-15 4:54 ` Christoph Hellwig 1 sibling, 1 reply; 12+ messages in thread From: Ming Lei @ 2024-10-15 1:59 UTC (permalink / raw) To: Robin Murphy Cc: Christoph Hellwig, Hannes Reinecke, Hamza Mahfooz, Dan Williams, linux-block, io-uring, linux-raid, iommu, linux-kernel On Mon, Oct 14, 2024 at 07:09:08PM +0100, Robin Murphy wrote: > On 14/10/2024 8:58 am, Ming Lei wrote: > > On Mon, Oct 14, 2024 at 09:41:51AM +0200, Christoph Hellwig wrote: > > > On Mon, Oct 14, 2024 at 09:23:14AM +0200, Hannes Reinecke wrote: > > > > > 3) some storage utilities > > > > > - dm thin provisioning utility of thin_check > > > > > - `dt`(https://github.com/RobinTMiller/dt) > > > > > > > > > > I looks like same user buffer is used in more than 1 dio. > > > > > > > > > > 4) some self cooked test code which does same thing with 1) > > > > > > > > > > In storage stack, the buffer provider is far away from the actual DMA > > > > > controller operating code, which doesn't have the knowledge if > > > > > DMA_ATTR_SKIP_CPU_SYNC should be set. > > > > > > > > > > And suggestions for avoiding this noise? > > > > > > > > > Can you check if this is the NULL page? Operations like 'discard' will > > > > create bios with several bvecs all pointing to the same NULL page. > > > > That would be the most obvious culprit. > > > > > > The only case I fully understand without looking into the details > > > is raid1, and that will obviously map the same data multiple times > > > > The other cases should be concurrent DIOs on same userspace buffer. > > active_cacheline_insert() does already bail out for DMA_TO_DEVICE, so it > returning -EEXIST to tickle the warning would seem to genuinely imply these > are DMA mappings requesting to *write* the same cacheline concurrently, > which is indeed broken in general. The two io_uring tests are READ, and the dm thin_check are READ too. For the raid1 case, the warning is from raid1_sync_request() which may have both READ/WRITE IO. Thanks, Ming ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-15 1:59 ` Ming Lei @ 2024-10-15 2:22 ` Dan Williams 0 siblings, 0 replies; 12+ messages in thread From: Dan Williams @ 2024-10-15 2:22 UTC (permalink / raw) To: Ming Lei, Robin Murphy Cc: Christoph Hellwig, Hannes Reinecke, Hamza Mahfooz, Dan Williams, linux-block, io-uring, linux-raid, iommu, linux-kernel Ming Lei wrote: > On Mon, Oct 14, 2024 at 07:09:08PM +0100, Robin Murphy wrote: > > On 14/10/2024 8:58 am, Ming Lei wrote: > > > On Mon, Oct 14, 2024 at 09:41:51AM +0200, Christoph Hellwig wrote: > > > > On Mon, Oct 14, 2024 at 09:23:14AM +0200, Hannes Reinecke wrote: > > > > > > 3) some storage utilities > > > > > > - dm thin provisioning utility of thin_check > > > > > > - `dt`(https://github.com/RobinTMiller/dt) > > > > > > > > > > > > I looks like same user buffer is used in more than 1 dio. > > > > > > > > > > > > 4) some self cooked test code which does same thing with 1) > > > > > > > > > > > > In storage stack, the buffer provider is far away from the actual DMA > > > > > > controller operating code, which doesn't have the knowledge if > > > > > > DMA_ATTR_SKIP_CPU_SYNC should be set. > > > > > > > > > > > > And suggestions for avoiding this noise? > > > > > > > > > > > Can you check if this is the NULL page? Operations like 'discard' will > > > > > create bios with several bvecs all pointing to the same NULL page. > > > > > That would be the most obvious culprit. > > > > > > > > The only case I fully understand without looking into the details > > > > is raid1, and that will obviously map the same data multiple times > > > > > > The other cases should be concurrent DIOs on same userspace buffer. > > > > active_cacheline_insert() does already bail out for DMA_TO_DEVICE, so it > > returning -EEXIST to tickle the warning would seem to genuinely imply these > > are DMA mappings requesting to *write* the same cacheline concurrently, > > which is indeed broken in general. > > The two io_uring tests are READ, and the dm thin_check are READ too. "READ from the device" == "WRITE to the page" (DMA_FROM_DEVICE). > For the raid1 case, the warning is from raid1_sync_request() which may > have both READ/WRITE IO. I don't see an easy way out of this without instrumenting archs that can not support overlapping mappings to opt-in to bounce buffering for these cases. Archs that can support this can skip the opt-in and quiet this test, but some of the value is being able to catch boundary conditions on more widely available systems. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-14 18:09 ` Robin Murphy 2024-10-15 1:59 ` Ming Lei @ 2024-10-15 4:54 ` Christoph Hellwig 2024-10-15 7:40 ` Ming Lei 1 sibling, 1 reply; 12+ messages in thread From: Christoph Hellwig @ 2024-10-15 4:54 UTC (permalink / raw) To: Robin Murphy Cc: Ming Lei, Christoph Hellwig, Hannes Reinecke, Hamza Mahfooz, Dan Williams, linux-block, io-uring, linux-raid, iommu, linux-kernel On Mon, Oct 14, 2024 at 07:09:08PM +0100, Robin Murphy wrote: >>> The only case I fully understand without looking into the details >>> is raid1, and that will obviously map the same data multiple times >> >> The other cases should be concurrent DIOs on same userspace buffer. > > active_cacheline_insert() does already bail out for DMA_TO_DEVICE, so it > returning -EEXIST to tickle the warning would seem to genuinely imply these > are DMA mappings requesting to *write* the same cacheline concurrently, > which is indeed broken in general. Yes, active_cacheline_insert only complains for FROM_DEVICE or BIDIRECTIONAL mappings. I can't see how raid 1 would trigger that given that it only reads from one leg at a time. Ming, can you look a bit more into what is happening here? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-15 4:54 ` Christoph Hellwig @ 2024-10-15 7:40 ` Ming Lei 2024-10-15 7:54 ` Christoph Hellwig 0 siblings, 1 reply; 12+ messages in thread From: Ming Lei @ 2024-10-15 7:40 UTC (permalink / raw) To: Christoph Hellwig Cc: Robin Murphy, Hannes Reinecke, Hamza Mahfooz, Dan Williams, linux-block, io-uring, linux-raid, iommu, linux-kernel On Tue, Oct 15, 2024 at 06:54:13AM +0200, Christoph Hellwig wrote: > On Mon, Oct 14, 2024 at 07:09:08PM +0100, Robin Murphy wrote: > >>> The only case I fully understand without looking into the details > >>> is raid1, and that will obviously map the same data multiple times > >> > >> The other cases should be concurrent DIOs on same userspace buffer. > > > > active_cacheline_insert() does already bail out for DMA_TO_DEVICE, so it > > returning -EEXIST to tickle the warning would seem to genuinely imply these > > are DMA mappings requesting to *write* the same cacheline concurrently, > > which is indeed broken in general. > > Yes, active_cacheline_insert only complains for FROM_DEVICE or > BIDIRECTIONAL mappings. I can't see how raid 1 would trigger that > given that it only reads from one leg at a time. > > Ming, can you look a bit more into what is happening here? All should be READ IO which is FROM_DEVICE, please see my reply: https://lore.kernel.org/linux-block/Zw3MZrK_l7DuFfFd@fedora/ And the raid1 warning is actually from raid1_sync_request(). Thanks, Ming ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-15 7:40 ` Ming Lei @ 2024-10-15 7:54 ` Christoph Hellwig 0 siblings, 0 replies; 12+ messages in thread From: Christoph Hellwig @ 2024-10-15 7:54 UTC (permalink / raw) To: Ming Lei Cc: Christoph Hellwig, Robin Murphy, Hannes Reinecke, Hamza Mahfooz, Dan Williams, linux-block, io-uring, linux-raid, iommu, linux-kernel On Tue, Oct 15, 2024 at 03:40:26PM +0800, Ming Lei wrote: > > Yes, active_cacheline_insert only complains for FROM_DEVICE or > > BIDIRECTIONAL mappings. I can't see how raid 1 would trigger that > > given that it only reads from one leg at a time. > > > > Ming, can you look a bit more into what is happening here? > > All should be READ IO which is FROM_DEVICE, please see my reply: Yes, reads translate to DMA_FROM_DEVICE. > https://lore.kernel.org/linux-block/Zw3MZrK_l7DuFfFd@fedora/ > > And the raid1 warning is actually from raid1_sync_request(). In that case the warnings are perfectly valid because the I/O patterns will create data corruption on non-coherent architectures. For direct I/O from userspace the kernel can't prevent it, but for raid1 we should be able to do something better. As raid1_sync_request is a convoluted and undocumented mess I don't have a straigh shot answer to what it is doing (wrong) and how to fix it unfortunately. > > > Thanks, > Ming ---end quoted text--- ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-14 7:41 ` Christoph Hellwig 2024-10-14 7:58 ` Ming Lei @ 2024-10-15 2:31 ` Ming Lei 1 sibling, 0 replies; 12+ messages in thread From: Ming Lei @ 2024-10-15 2:31 UTC (permalink / raw) To: Christoph Hellwig Cc: Hannes Reinecke, Hamza Mahfooz, Dan Williams, linux-block, io-uring, linux-raid, iommu, linux-kernel, ming.lei, Keith Busch On Mon, Oct 14, 2024 at 09:41:51AM +0200, Christoph Hellwig wrote: > On Mon, Oct 14, 2024 at 09:23:14AM +0200, Hannes Reinecke wrote: > >> 3) some storage utilities > >> - dm thin provisioning utility of thin_check > >> - `dt`(https://github.com/RobinTMiller/dt) > >> > >> I looks like same user buffer is used in more than 1 dio. > >> > >> 4) some self cooked test code which does same thing with 1) > >> > >> In storage stack, the buffer provider is far away from the actual DMA > >> controller operating code, which doesn't have the knowledge if > >> DMA_ATTR_SKIP_CPU_SYNC should be set. > >> > >> And suggestions for avoiding this noise? > >> > > Can you check if this is the NULL page? Operations like 'discard' will > > create bios with several bvecs all pointing to the same NULL page. > > That would be the most obvious culprit. > > The only case I fully understand without looking into the details > is raid1, and that will obviously map the same data multiple times > because it writes it out multiple time. Now mapping a buffer > multiple times for a DMA_TO_DEVICE is relatively harmless in > practice as the data is transferred to the device, but it it > still breaks the dma buffer ownership model in the dma which is > really helpful to find bugs where people don't think about this > at all. Not sure if there is any good solution here. > Another related topic: Recently direct IO buffer alignment changes to just respect DMA controller alignment which is often too relax, such as dma_alignment is just 3 for many host controllers, then two direct IO buffers may cross same DMA mapping cache line. Is this one real problem? Thanks, Ming ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" 2024-10-14 1:27 [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" Ming Lei 2024-10-14 7:23 ` Hannes Reinecke @ 2024-10-14 15:17 ` Jens Axboe 1 sibling, 0 replies; 12+ messages in thread From: Jens Axboe @ 2024-10-14 15:17 UTC (permalink / raw) To: Ming Lei, Hamza Mahfooz, Christoph Hellwig, Dan Williams Cc: linux-block, io-uring, linux-raid, iommu, linux-kernel On 10/13/24 7:27 PM, Ming Lei wrote: > Hello Guys, > > I got more and more reports on DMA debug warning "cacheline tracking EEXIST, > overlapping mappings aren't supported" in storage related tests: This is easily triggerable with dio and reusing a buffer. But it looks like this will only trigger if CONFIG_DMA_API_DEBUG is set, so should not be a prod issue? If so, I'd say that debug printk should be killed. Maybe turn it into a pr_warn_once() or something? -- Jens Axboe ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-10-15 7:54 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-10-14 1:27 [Report] annoyed dma debug warning "cacheline tracking EEXIST, overlapping mappings aren't supported" Ming Lei 2024-10-14 7:23 ` Hannes Reinecke 2024-10-14 7:41 ` Christoph Hellwig 2024-10-14 7:58 ` Ming Lei 2024-10-14 18:09 ` Robin Murphy 2024-10-15 1:59 ` Ming Lei 2024-10-15 2:22 ` Dan Williams 2024-10-15 4:54 ` Christoph Hellwig 2024-10-15 7:40 ` Ming Lei 2024-10-15 7:54 ` Christoph Hellwig 2024-10-15 2:31 ` Ming Lei 2024-10-14 15:17 ` Jens Axboe
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox