From: "Kiryl Shutsemau (Meta)" <[email protected]> The floor on the order a collapse will build is a property of collapse, not of khugepaged. MADV_COLLAPSE reaches the same code and is held to the same floor.
Move KHUGEPAGED_MIN_MTHP_ORDER to the shared header as COLLAPSE_MIN_MTHP_ORDER. Preparation for the collapse engine, which sizes its per-window arrays from the same floor. No functional change intended. Assisted-by: Claude-Code:claude-opus-5 Signed-off-by: Kiryl Shutsemau (Meta) <[email protected]> --- mm/collapse.h | 3 +++ mm/khugepaged.c | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/collapse.h b/mm/collapse.h index 44f52ea5bbb8..1e969292edcb 100644 --- a/mm/collapse.h +++ b/mm/collapse.h @@ -7,6 +7,9 @@ #include <linux/pgtable.h> #include <linux/types.h> +/* The smallest order a collapse will build, and so the finest window it cuts */ +#define COLLAPSE_MIN_MTHP_ORDER 2 + enum scan_result { SCAN_FAIL, SCAN_SUCCEED, diff --git a/mm/khugepaged.c b/mm/khugepaged.c index eebc044a930e..f31689bf75a6 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -67,8 +67,6 @@ static DEFINE_READ_MOSTLY_HASHTABLE(mm_slots_hash, MM_SLOTS_HASH_BITS); static struct kmem_cache *mm_slot_cache __ro_after_init; -#define KHUGEPAGED_MIN_MTHP_ORDER 2 - /** * struct khugepaged_scan - cursor for scanning * @mm_head: the head of the mm list to scan @@ -1540,8 +1538,8 @@ static enum scan_result mthp_collapse(struct mm_struct *mm, * any smaller order enabled. When at the smallest order * we must always move to the next offset. */ - if (order > KHUGEPAGED_MIN_MTHP_ORDER && - (enabled_orders & GENMASK(order - 1, 0))) { + if (order > COLLAPSE_MIN_MTHP_ORDER && + (enabled_orders & GENMASK(order - 1, 0))) { order--; continue; } -- 2.54.0
