Re: [PATCHv4 1/8] mm: Add support for unaccepted memory

From: Kirill A. Shutemov
Date: Wed Apr 13 2022 - 12:23:00 EST


On Wed, Apr 13, 2022 at 08:36:52AM -0700, Dave Hansen wrote:
> On 4/13/22 04:30, Kirill A. Shutemov wrote:
> >> 2) Fast boot; after boot, all memory will slowly but steadily get
> >> accepted in the background. After a while, all memory is accepted and
> >> can be signaled to user space.
> ...
> > Frankly, I think option 2 is the worst one. You still CPU cycles from the
> > workload after boot to do the job that may or may not be needed. It is an
> > half-measure that helps nobody.
>
> Let's not be too hyperbolic here. "Worst" is entirely subjective and it
> totally depends on your perspective and what you care about.
>
> There are basically four options:
>
> * Accept everything in early boot
> * Accept with deferred page free
> * Accept with kthread after boot
> * Accept on demand
>
> and four things that matter:
>
> * Code complexity
> * Time to a shell prompt
> * CPU/Memory waste
> * Deterministic overhead
>
> Did I miss any?

"Time to shell" is not equal to "time to do the job". Real workloads do
stuff beyond memory allocations. But, yes, it is harder quantify.

> News flash: none of the options wins on all the things that matter.
> We're going to have to pick one (or maybe two). I'm also not horribly
> convinced that there's a problem here worth solving, especially one that
> requires surgery in the core of the buddy allocator.
>
> This is essentially making a performance argument: it takes too long to
> boot if we go with a simpler solution. Yet, I haven't seen any data. I
> think we need to go with the simplest approach(es) until there's some
> actual data to guide us here.
>
> Here's another way to look at it:
>
> > https://docs.google.com/spreadsheets/d/1Fpv0Yp0CTF5_JXHR2pywvNtImTwUVGTxDMlJ5t8qiis/edit?usp=sharing

The link is view-only.

AFAICS, complexity of the kthread approach is on par or greater comparing
to on-demand. You need coordination between allocator and the thread.
It can be hard to hit right balance for the kthread between being CPU hog
and not providing enough accepted memory.

--
Kirill A. Shutemov