Re: [PATCH] mm/slab: align kmalloc to cacheline when DMA API debugging is active

From: Andy Shevchenko

Date: Fri Mar 27 2026 - 08:35:55 EST


On Fri, Mar 27, 2026 at 2:26 PM Catalin Marinas <catalin.marinas@xxxxxxx> wrote:
> On Fri, Mar 27, 2026 at 10:58:46AM +0500, Mikhail Gavrilov wrote:


> TL;DR: I think this is fine:
>
> Reviewed-by: Catalin Marinas <catalin.marinas@xxxxxxx>
>
> I'm not sure that's the best way to hide the warning but there
> are no great solutions either. On one hand, we want the DMA debug to
> capture potential problems on architectures it's not running on. OTOH,
> we also want to avoid false positives on coherent architectures/devices.
> I don't think reconciling the two requirements is easy.
>
> When DMA_API_DEBUG is enabled, the above will change the x86 behaviour
> that could have implications beyond DMA (e.g. may not catch some buffer
> overflow because it's within L1_CACHE_BYTES). Similarly for non-coherent
> architectures that select DMA_BOUNCE_UNALIGNED_KMALLOC (arm64 and riscv
> currently). arm64 defines ARCH_DMA_MINALIGN to 128 but
> ARCH_KMALLOC_MINALIGN to 8 (why 128 is larger than L1_CACHE_BYTES is
> another matter but let's ignore it for now).

Maybe for the cases where we do not warn we should introduce a
dev_dbg_/pr_debug_once()? At least users may be informed about potential issues.


--
With Best Regards,
Andy Shevchenko