Re: [PATCH 2/2] mm: kmemleak: scan the struct page array in MAX_SCAN_SIZE batches

From: Catalin Marinas

Date: Wed Sep 23 2026 - 07:05:00 EST


On Tue, Sep 22, 2026 at 06:39:21PM -0700, Andrew Morton wrote:
> On Tue, 22 Sep 2026 10:51:46 +0100 Catalin Marinas <catalin.marinas@xxxxxxx> wrote:
>
> > On Mon, Sep 21, 2026 at 05:30:27AM -0700, Breno Leitao wrote:
> > > scan_zone_pages() scans the struct page array one page per scan_block()
> > > call:
> > >
> > > if (scan_block(page, page + 1, NULL))
> > >
> > > scan_block() takes kmemleak_lock with interrupts disabled for the
> > > duration of the call, so this acquires the lock once per online PFN to
> > > scan a single struct page.
> > >
> > > Gather runs of adjacent eligible struct pages and pass each run to
> > > scan_block() in one call, capped at MAX_SCAN_SIZE.
> > >
> > > The longest kmemleak_lock is now held is MAX_SCAN_SIZE worth of words,
> >
> > Remove an 'is'.
>
> That was actually correct, but it doesn't read well.

Ah, yes, you can read it in a correct way as well ;).

> > Also, MAX_SCAN_SIZE worth of bytes rather than words.
>
> edited, thanks.
>
> How's this?
>
> : The longest kmemleak_lock hold duration is now MAX_SCAN_SIZE worth of
> : bytes. The same bound scan_large_block() already applies to the data
> : sections and the per-CPU areas.

Looks good. Thanks!

--
Catalin