Re: [PATCH 2/3] dma-debug: skip irrelevant buckets for partial syncs
From: Juanlu Herrero
Date: Fri Dec 04 2026 - 15:35:44 EST
On Fri, Dec 04, 2026 at 04:16:48PM +0100, Marek Szyprowski wrote:
> On 03.12.2026 18:38, Robin Murphy wrote:
> > On 2026-11-10 9:36 pm, Juanlu Herrero wrote:
> >> Partial syncs may start after a mapping's first hash bucket. Finding the
> >> mapping then requires locking earlier buckets.
> >>
> >> Keep a conservative size bound per bucket and skip those that cannot
> >> span the sync range. Raise the bound on insertion and reset it when the
> >> bucket empties. Stale larger bounds only add searches, so removal needs
> >> no list rescan to update the bound.
> >>
> >> This relies on ordered map publication before sync and unmapping after
> >> sync. The bucket lock carries earlier bound updates through later
> >> insertions even when the bound is unchanged.
> >
> > Doesn't this then run the risk of then mis-reporting a sync/unmap with a larger-than-mapped size? The whole point of dma-debug is to catch bad API usage, so obviously it cannot rely on callers being correct. It is an explicit choice for developers who want to check correctness and accept the massive performance impact of doing so, so any reduction of robustness/coverage for the sake of making the inherently slow thing a little less slow seems like a wrong move, and rather missing the point.
>
>
> If I got it right, this optimization only speeds up the lookup of the
> entries. When entry is found then all checks on it are still being
> performed and same issues are reported as without this speedup. The
> only thing that might be improved to ensure proper reporting of all
> possible API violations is to redo the full search if no entry has been
> found and some buckets has been skipped.
>
That is correct and sounds good on redoing the full search if no entry
is found. I will incorporate that into v2 (along with only sending the
dma-debug changes in the patchset and the net-next portion).
--
Juanlu Herrero