Re: Bug in add_dma_entry()'s debugging code

From: Alan Stern
Date: Tue Dec 05 2023 - 13:28:29 EST


On Fri, Dec 01, 2023 at 05:42:52PM +0000, Catalin Marinas wrote:
> Indeed, so to be sure we don't trip over other false alarms, we'd also
> need to force ARCH_DMA_MINALIGN to be at least a cache-line size. That's
> used in some structures to force a static alignment of various members
> that take DMA transfers. After that, anything reported might actually be
> a potential issue, not a false alarm.
>
> However, I wonder whether we'd actually hide some genuine problems.
> Let's say x86 gets some DMA corruption when it tries to DMA 8 bytes
> into two adjacent buffers because of some DMA buffer overflow, nothing
> to do with cache lines. You enable the DMA API debugging to see if it
> reports anything and it suddenly starts working because of the forced
> minimum alignment.

In the long run, it may turn out that trying to detect memory usage
patterns that could cause problems for architectures other than the one
currently running is not workable. Certainly it is a bad idea to have a
debugging infrastructure that changes the behavior of other parts of the
system -- particularly when those other parts may be the ones you're
trying to debug.

You may end up needing to make a choice here. Which evil is lesser?

Alan Stern