Re: [RFC] mm: khugepaged: use largest enabled hugepage order for min_free_kbytes

Lorenzo Stoakes
2025-06-10T14:04:27Z

On Mon, Jun 09, 2025 at 03:49:52PM -0400, Zi Yan wrote:
[snip]
> > I really think a hard cap, expressed in KB/MB, on pageblock size is the way to
> > go (but overrideable for people crazy enough to truly want 512 MB pages - and
> > who cannot then complain about watermarks).
>
> I agree. Basically, I am thinking:
> 1) use something like 2MB as default pageblock size for all arch (the value can
> be set differently if some arch wants a different pageblock size due to other reasons), this can be done by modifying PAGE_BLOCK_MAX_ORDER’s default
> value;

I don't think we can set this using CONFIG_PAGE_BLOCK_MAX_ORDER.

Because the 'order' will be a different size depending on page size obviously.

So I'm not sure how this would achieve what we want?

It seems to me we should have CONFIG_PAGE_BLOCK_MAX_SIZE_MB or something like
this, and we take min(page_size << CONFIG_PAGE_BLOCK_MAX_ORDER,
CONFIG_PAGE_BLOCK_MAX_SIZE_MB << 20) as the size.

>
> 2) make pageblock_order a boot time parameter, so that user who wants
> 512MB pages can still get it by changing pageblock order at boot time.
>

Again, I don't think order is the right choice here, though having it boot time
configurable (perhaps overriding the default config there) seems sensible.

> WDYT?

>
> >
> >>
> >> Often, user just ask for an impossible combination: they
> >> want to use all free memory, because they paid for it, and they
> >> want THPs, because they want max performance. When PMD THP is
> >> small like 2MB, the “unusable” free memory is not that noticeable,
> >> but when PMD THP is as large as 512MB, user just cannot unsee it. :)
> >
> > Well, users asking for crazy things then being surprised when they get them
> > is nothing new :P
> >
> >>
> >>
> >> Best Regards,
> >> Yan, Zi
> >
> > Thanks for your input!
> >
> > Cheers, Lorenzo
>
>
> Best Regards,
> Yan, Zi