Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pratyush Yadav <pratyush@kernel.org>
To: Chris Down <chris@chrisdown.name>
Cc: Samiullah Khawaja <skhawaja@google.com>,
	 Pratyush Yadav <pratyush@kernel.org>,
	 Tarun Sahu <tarunsahu@google.com>,
	 Pasha Tatashin <pasha.tatashin@soleen.com>,
	 Mike Rapoport <rppt@kernel.org>,
	 Alexander Graf <graf@amazon.com>,
	 "Andersen, Tycho" <Tycho.Andersen@amd.com>,
	Anthony Yznaga <anthony.yznaga@oracle.com>,
	 Baolu Lu <baolu.lu@linux.intel.com>,
	 David Hildenbrand <david@kernel.org>,
	 David Matlack <dmatlack@google.com>,
	 "Heyne, Maximillian" <mheyne@amazon.de>,
	James Gowans <jgowans@amazon.com>,
	 Jason Gunthorpe <jgg@nvidia.com>,
	Pankaj Gupta <pankaj.gupta.linux@gmail.com>,
	 Praveen Kumar <kpraveen.lkml@gmail.com>,
	 Sagi Shahar <sagis@google.com>,
	 Vipin Sharma <vipinsh@google.com>,
	 Vishal Annapurve <vannapurve@google.com>,
	"Woodhouse, David" <dwmw@amazon.co.uk>,
	 Luca Boccassi <luca.boccassi@gmail.com>,
	 Jork Loeser <jloeser@linux.microsoft.com>,
	Chenghao Duan <duanchenghao@kylinos.cn>,
	 Zhu Yanjun <yanjun.zhu@linux.dev>,
	 Sourabh Jain <sourabhjain@linux.ibm.com>,
	linux-mm@kvack.org,  kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: KHO bootmem without pre-reservation
Date: Thu, 03 Dec 2026 12:59:53 +0000	[thread overview]
Message-ID: <2vxzmrqmtt86.fsf@kernel.org> (raw)
In-Reply-To: <axB_E-nx98Y57s8q@chrisdown.name> (Chris Down's message of "Wed, 02 Dec 2026 12:26:59 -0800")

Hi Chris,

On Wed, Dec 02 2026, Chris Down wrote:

> Hi Samiullah, Pratyush, Tarun,
>
> At Meta, the size of the bootmem reservation is currently the main thing
> stopping us from enabling KHO more widely, so I'd like to spend some time

Why? What exactly breaks due to bootmem size? Did you try with Mike's
sizing fixes?

> on reducing it. Before I start, I want to make sure that I don't duplicate
> or get in the way of what's already planned or in motion.
>
> Here is my understanding of the situation as it is right now. Please let me
> know if I have anything muddled!
>
> - On 21 Sep [0] there was discussion about dropping the pre-reserved
>   areas and relying on dynamically extended bootmem instead, perhaps with
>   a small bootstrap region. Samiullah wrote up the initial ideas.
> - On 19 Oct [1] there was discussion about the report about CMA pinning,
>   and Tarun's work with David on migrating movable pages into CMA.
> - Mike's sizing fixes are now in the liveupdate tree, and the notes in
>   this thread say that the bootmem layout is still expected to change.
>
> I have a few questions:
>
> 1. Samiullah, is the design doc public, or could you share it? I couldn't
>    find a link to it on the list. I also saw there's a mention of a Google
>    Doc attached to the calendar invite, but I didn't find a link to that,
>    only to the Meet link itself.

I don't know if the design doc is public, but I can share a brain dump
of the ideas we discussed.

The main idea is to use kho_discover_noprsrv() as the primary source of
early boot memory. So we probably keep a very small bootmem size to
bootstrap, and then try to discover unpreserved blocks of memory at
boot.

The algorithm currently works with 1G blocks of memory since the main
user is hugetlb 1G pages. But the 1G is a pure hueristic and we can tune
it to something that works better, or perhaps even search at a smaller
block size if larger blocks don't provide enough memory.

I think it is a promising idea, but the main concern I have with this
approach is reliability. The number of blocks the discovery algorithm
can find depends on the placement of preservations. If the preservations
are fragmented enough, you might not end up with enough memory to boot
at all. You are unlikely to run into these situations in testing. In
production, I am worried that a few machines in a large fleet will fail
live update, and it will be quite annoying operationally.

You could further optimize things by computing these unpreserved blocks
from the previous kernel. This also lets you make sure there is enough
memory for the next kernel to actually boot. It is slightly better than
failing the live update _after_ kexec.

If we can solve the reliability problem, I think it is the way to go.

I explored another option that is much simpler but has some big
tradeoffs. We could simply turn off bootmem-only mode right after
memblock is allowed to resize. The cost you pay is that now all
preservations are in memblock so all reservations need to do more work.
You also run into the risk of memblock array not being able to fit in
available bootmem.

If you only do large preservations primarily, like 1G, this idea isn't
too bad. With a large number of 4k allocations though, the performance
really starts to drop.

For the VM use case we have today, I think that is fine because most of
the memory is in 1G pages anyway. But other use cases that need 4k pages
might suffer.

>
> 2. Is anyone working on an implementation at the moment? If not, I'm
>    happy to take this on.

Not that I'm aware of.

>
> 3. Is the main open problem still how to guarantee that the next kernel
>    can boot when the preserved memory is badly fragmented, or has the
>    thinking moved on since LPC?

Yes, that is the main problem in my mind.

>
> 4. Would smaller reductions to the current scheme be welcome in the
>    meantime? I haven't measured anything yet, so please tell me if I'm
>    missing something. :-)

Yes, if the changes are simple enough.

Here's one thing to try. Currently there is a single global bootmem
allocation. This means on NUMA systems, one unlucky node gets the
allocation. This node has more CMA memory than others, and is more
likely to run into memory pressure. We could spread the global bootmem
evenly across nodes to reduce this a bit.

I haven't ever looked at the actual numbers, so I suppose the first
thing would be to measure if it is even worth doing.

>
> Either way, I can measure on top of Mike's fixes and test with our
> workloads, and I'm glad to pick up whichever pieces are useful.

I think you should try Mike's fixes. They reduce bootmem size a lot. You
can also tune down bootmem_scale, but that's a heuristic because you
have to guess how much memory future kernels would need.

>
> I'd also like to propose that as a topic for the next call if that sounds
> good? Is that scheduled yet, by the way?
>
> Thanks,
>
> Chris
>
> [0]: https://lore.kernel.org/r/20260925143000.2729890-1-pasha.tatashin@soleen.com
> [1]: https://lore.kernel.org/r/20261025143601.2564170-1-pasha.tatashin@soleen.com

-- 
Regards,
Pratyush Yadav


      reply	other threads:[~2026-12-03 13:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 20:58 [Hypervisor Live Update] Notes from November 16, 2026 Pasha Tatashin
2026-12-02 20:26 ` KHO bootmem without pre-reservation (was: Re: [Hypervisor Live Update] Notes from November 16, 2026) Chris Down
2026-12-03 12:59   ` Pratyush Yadav [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2vxzmrqmtt86.fsf@kernel.org \
    --to=pratyush@kernel.org \
    --cc=Tycho.Andersen@amd.com \
    --cc=anthony.yznaga@oracle.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=chris@chrisdown.name \
    --cc=david@kernel.org \
    --cc=dmatlack@google.com \
    --cc=duanchenghao@kylinos.cn \
    --cc=dwmw@amazon.co.uk \
    --cc=graf@amazon.com \
    --cc=jgg@nvidia.com \
    --cc=jgowans@amazon.com \
    --cc=jloeser@linux.microsoft.com \
    --cc=kexec@lists.infradead.org \
    --cc=kpraveen.lkml@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luca.boccassi@gmail.com \
    --cc=mheyne@amazon.de \
    --cc=pankaj.gupta.linux@gmail.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=rppt@kernel.org \
    --cc=sagis@google.com \
    --cc=skhawaja@google.com \
    --cc=sourabhjain@linux.ibm.com \
    --cc=tarunsahu@google.com \
    --cc=vannapurve@google.com \
    --cc=vipinsh@google.com \
    --cc=yanjun.zhu@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox