From: Robin Murphy <robin.murphy@arm.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, linux-mm@kvack.org, harry@kernel.org,
vbabka@kernel.org, akpm@linux-foundation.org,
stern@rowland.harvard.edu, linux@roeck-us.net,
andy.shevchenko@gmail.com, hch@lst.de, Jeff.kirsher@gmail.com,
catalin.marinas@arm.com
Subject: Re: [PATCH v2] dma-debug: suppress cacheline overlap warning when arch has no DMA alignment requirement
Date: Wed, 1 Apr 2026 13:11:20 +0100 [thread overview]
Message-ID: <c9ded35b-fc10-47d8-bfaa-cecb4fa91add@arm.com> (raw)
In-Reply-To: <6270d4f0-85e4-496d-8db4-87ccb791ca4d@samsung.com>
On 2026-03-30 8:44 am, Marek Szyprowski wrote:
> On 27.03.2026 13:41, Mikhail Gavrilov wrote:
>> When CONFIG_DMA_API_DEBUG is enabled, the DMA debug infrastructure
>> tracks active mappings per cacheline and warns if two different DMA
>> mappings share the same cacheline ("cacheline tracking EEXIST,
>> overlapping mappings aren't supported").
>>
>> On x86_64, ARCH_KMALLOC_MINALIGN defaults to 8, so small kmalloc
>> allocations (e.g. the 8-byte hub->buffer and hub->status in the USB
>> hub driver) frequently land in the same 64-byte cacheline. When both
>> are DMA-mapped, this triggers a false positive warning.
>>
>> This has been reported repeatedly since v5.14 (when the EEXIST check
>> was added) across various USB host controllers and devices including
>> xhci_hcd with USB hubs, USB audio devices, and USB ethernet adapters.
>>
>> The cacheline overlap is only a real concern on architectures that
>> require DMA buffer alignment to cacheline boundaries (i.e. where
>> ARCH_DMA_MINALIGN >= L1_CACHE_BYTES). On architectures like x86_64
>> where dma_get_cache_alignment() returns 1, the hardware is
>> cache-coherent and overlapping cacheline mappings are harmless.
>>
>> Suppress the EEXIST warning when dma_get_cache_alignment() is less
>> than L1_CACHE_BYTES, indicating the architecture does not require
>> cacheline-aligned DMA buffers.
Really the value of this check is for mappings of structure members or
array elements which have no inherent guarantee of being individually
aligned to ARCH_DMA_MINALIGN, and while x86 can also get away with that,
it represents a genuine issue for non-coherent architectures. USB's
mapping of a dedicated tiny allocation is, if anything, rather the
special case.
TBH I'd be inclined to have CONFIG_DMA_DEBUG raise ARCH_DMA_MINALIGN as
appropriate such that genuine false-positives can't happen, rather than
effectively defeat the whole check, but I suppose that might carry a
risk of tripping up arch code that doesn't expect it... Oh well.
Thanks,
Robin.
>> Verified with a kernel module reproducer that performs two kmalloc(8)
>> allocations back-to-back and DMA-maps both:
>>
>> Before: allocations share a cacheline, EEXIST fires within ~50 pairs
>> After: same cacheline pair found, but no warning emitted
>>
>> Fixes: 2b4bbc6231d7 ("dma-debug: report -EEXIST errors in add_dma_entry")
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=215740
>> Suggested-by: Harry Yoo <harry@kernel.org>
>> Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
>> Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
>
> Applied to dma-mapping-fixes. Thanks!
>
>> ---
>>
>> v1 -> v2:
>> - Moved fix from include/linux/slab.h (ARCH_KMALLOC_MINALIGN)
>> to kernel/dma/debug.c per Harry Yoo's suggestion.
>> - Instead of forcing cacheline-aligned allocations, suppress
>> the warning when the architecture has no DMA alignment
>> requirement (dma_get_cache_alignment() < L1_CACHE_BYTES).
>>
>> v1: https://lore.kernel.org/all/20260327055846.248829-1-mikhail.v.gavrilov@gmail.com/
>>
>> Reproducer module that triggers the bug reliably:
>> https://bugzilla.kernel.org/attachment.cgi?id=309769
>>
>> kernel/dma/debug.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
>> index 0677918f06a8..1a725edbbbf6 100644
>> --- a/kernel/dma/debug.c
>> +++ b/kernel/dma/debug.c
>> @@ -615,6 +615,7 @@ static void add_dma_entry(struct dma_debug_entry *entry, unsigned long attrs)
>> } else if (rc == -EEXIST &&
>> !(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
>> !(entry->is_cache_clean && overlap_cache_clean) &&
>> + dma_get_cache_alignment() >= L1_CACHE_BYTES &&
>> !(IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) &&
>> is_swiotlb_active(entry->dev))) {
>> err_printk(entry->dev, entry,
>
> Best regards
next prev parent reply other threads:[~2026-04-01 12:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20260327124211eucas1p10425a28f67736d2043e7e4dd77d58e72@eucas1p1.samsung.com>
2026-03-27 12:41 ` Mikhail Gavrilov
2026-03-30 7:44 ` Marek Szyprowski
2026-04-01 12:11 ` Robin Murphy [this message]
2026-04-01 13:25 ` Andy Shevchenko
2026-04-01 15:26 ` Robin Murphy
2026-04-02 11:26 ` Marek Szyprowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9ded35b-fc10-47d8-bfaa-cecb4fa91add@arm.com \
--to=robin.murphy@arm.com \
--cc=Jeff.kirsher@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andy.shevchenko@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=harry@kernel.org \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=m.szyprowski@samsung.com \
--cc=mikhail.v.gavrilov@gmail.com \
--cc=stern@rowland.harvard.edu \
--cc=vbabka@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox