Re: [PATCH v2 0/8] Introduce a huge-page pre-zeroing mechanism

From: Gregory Price

Date: Tue Jan 20 2026 - 14:53:24 EST


On Tue, Jan 20, 2026 at 07:30:27PM +0000, David Laight wrote:
> > /* Run programs in serial */
> > sh: program_a && program_b
> >
> > in zero_on_alloc():
> > program_a eats zero(10) cost on startup
> > program_b eats zero(5) cost on startup
> > Overall zero(15) cost to start program_b
> >
> > in zero_on_free()
> > program_a eats zero(10) cost on startup
>
> Do you get that cost? - wont all the unused memory be zeros.
>

If program_a was the first to access, wouldn't it have had to zero it?

> > But just trivially, starting from the base case of no pages being
> > zeroed, you're just injecting an additional zero(X) cost if program_a()
> > consumes more hugepages than program_b().
>
> I'd consider a different test:
> for c in $(jot 1 1000); do program_a; done
>
> Regardless of whether you zero on alloc or free all the zeroing is in line.
> Move it to a low priority thread (that uses a non-aggressive loop) and
> there will be reasonable chance of there being pre-zeroed pages available.
> (Most DMA is far too aggressive...)
>
> If you zero on free it might also be a waste of time.
> Maybe the memory is next used to read data from a disk file.
>

Right, both points here being that it's heuristic-y, it only applies in
certain scenarios and trying to optimize for one probably hurts another.

~Gregory