[PATCH v2 16/18] memblock: make HugeTLB bootmem allocation work with KHO
Mike Rapoport
rppt at kernel.org
Mon Jun 15 12:40:00 PDT 2026
On Mon, Jun 15, 2026 at 03:35:39PM +0200, Pratyush Yadav wrote:
> On Sun, Jun 14 2026, Mike Rapoport wrote:
> > On Fri, 05 Jun 2026 20:34:49 +0200, Pratyush Yadav <pratyush at kernel.org> wrote:
> >
> >> First, it does not use mirrored memory for hugetlb. Mirrored memory is a
> >> limited resource that is best saved for kernel data structures, not user
> >> memory.
> >>
> >> Second, if the memory found overlaps with KHO scratch areas, it discards
> >> the memory and retries.
> >
> > This sentence is somewhat hard to parse.
>
> Okay, let me retry:
>
> Second, if the free memory area found by memblock_find_in_range_node()
> is a part of a KHO scratch area, the free area is not used. Allocation
> is retried starting after the free area to ensure no hugepages come from
> KHO scratch.
>
> Any better?
Yep :)
> >
> >>
> >>
> >> diff --git a/mm/memblock.c b/mm/memblock.c
> >> index 6349c48154f4..131e54dd5d8d 100644
> >> --- a/mm/memblock.c
> >> +++ b/mm/memblock.c
> >> @@ -1756,6 +1761,69 @@ void * __init memblock_alloc_try_nid_raw(
> >> [ ... skip 51 lines ... ]
> >> + if (memblock_bottom_up())
> >> + start = addr + size;
> >> + else
> >> + start = addr - size;
> >> +
> >> + goto retry;
> >
> > Hmm, two goto retry don't seem nice :/
> > Although I can't see how to imporove it really.
>
> Dunno, looked easy enough to understand to me.
> >
> > Maybe add a helper for going the node fallback?
>
> There is a small downside. There will then be no way to know the
> fallback was tried already, so if a retry is done because of scratch
> overlap, the fallback needs to be done again.
>
> I don't think it should be too bad, so if you still prefer this then I
> can do it.
Let's keep it for now, maybe will find something smarter later.
> --
> Regards,
> Pratyush Yadav
--
Sincerely yours,
Mike.
More information about the kexec
mailing list