Re: [PATCH v3] mm: remove min_free_kbytes adjustment for THP

From: Zi Yan

Date: Tue Sep 01 2026 - 16:08:29 EST


On 1 Sep 2026, at 15:01, Nimrod Oren wrote:

> When THP is enabled, set_recommended_min_free_kbytes() may raise
> min_free_kbytes using a heuristic that scales with pageblock_nr_pages.
> Commit f000565adb77 ("thp: set recommended min free kbytes") added this
> heuristic to help keep pageblocks free and reduce fragmentation for THP
> allocations.
>
> The recommendation scales poorly with larger base page sizes. With the
> default arm64 pageblock sizes, the contribution per eligible zone
> before applying the existing cap of 5% of low memory is:
>
> 4 KiB pages: 2 MiB pageblock, 22 MiB per zone
> 16 KiB pages: 32 MiB pageblock, 352 MiB per zone
> 64 KiB pages: 512 MiB pageblock, 5.5 GiB per zone
>
> Even with that cap, min_free_kbytes can reach excessive levels.
>
> The automatic min_free_kbytes increase predates proactive compaction
> and many subsequent changes to compaction. Given those changes,
> increasing min_free_kbytes for THP by default is no longer clearly
> justified.
>
> Remove set_recommended_min_free_kbytes() and all associated
> recalculation paths. With this policy gone, min_free_kbytes is
> controlled only by the page allocator's default calculation and the
> vm.min_free_kbytes sysctl. Users who want additional headroom may set a
> higher value via that sysctl.
>
> Link: https://lore.kernel.org/r/20260831075635.2244437-1-noren@xxxxxxxxxx/
> Suggested-by: Michal Hocko <mhocko@xxxxxxxx>
> Signed-off-by: Nimrod Oren <noren@xxxxxxxxxx>
> ---
> v3:
> * Replace the 1 GiB cap with removal of the THP-driven min_free_kbytes
> increase as suggested by Michal.
> * Remove all associated recalculation paths.
> * Make min_free_kbytes, user_min_free_kbytes,
> calculate_min_free_kbytes(), and setup_per_zone_wmarks() static.
> * Drop the now-unused declarations and khugepaged's page_alloc.h include.
> * Drop the obsolete v2 documentation addition.
>
> v2:
> * Use a named constant for the cap.
> * Drop explicit linux/sizes.h include.
> * Update min_free_kbytes documentation.
> https://lore.kernel.org/r/20260831075635.2244437-1-noren@xxxxxxxxxx/
>
> v1:
> * Cap the final recommendation at 1 GiB as suggested by Lorenzo.
> https://lore.kernel.org/r/20260728202014.2517142-1-noren@xxxxxxxxxx/
>
> RFC v1:
> https://lore.kernel.org/r/20260716173504.760369-1-noren@xxxxxxxxxx/
> ---
> include/linux/khugepaged.h | 5 ----
> mm/huge_memory.c | 14 ---------
> mm/internal.h | 8 -----
> mm/khugepaged.c | 60 --------------------------------------
> mm/page_alloc.c | 11 +++----
> mm/page_alloc.h | 2 --
> mm/shmem.c | 7 -----
> 7 files changed, 4 insertions(+), 103 deletions(-)
>

The stats look nice. Like you said in the commit message, user can still
have the old behavior by increasing vm.min_free_kbytes. Thanks.

Acked-by: Zi Yan <ziy@xxxxxxxxxx>

Best Regards,
Yan, Zi