Re: [PATCH v2 1/3] mm: khugepaged: export set_recommended_min_free_kbytes()
From: Lorenzo Stoakes (Oracle)
Date: Fri Mar 06 2026 - 06:23:52 EST
On Thu, Mar 05, 2026 at 06:04:53AM -0800, Breno Leitao wrote:
> Make set_recommended_min_free_kbytes() callable from outside
> khugepaged.c by removing the static qualifier and adding a
> declaration in include/linux/khugepaged.h.
>
> This allows callers that change THP settings to recalculate
> watermarks without going through start_stop_khugepaged().
>
> Suggested-by: Lorenzo Stoakes (Oracle) <ljs@xxxxxxxxxx>
> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
> ---
> include/linux/khugepaged.h | 1 +
> mm/khugepaged.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h
> index d7a9053ff4fed..76252865fca4b 100644
> --- a/include/linux/khugepaged.h
> +++ b/include/linux/khugepaged.h
> @@ -16,6 +16,7 @@ extern void __khugepaged_exit(struct mm_struct *mm);
> extern void khugepaged_enter_vma(struct vm_area_struct *vma,
> vm_flags_t vm_flags);
> extern void khugepaged_min_free_kbytes_update(void);
> +extern void set_recommended_min_free_kbytes(void);
Please drop the extern, it's a historic artifact that we clean up when we add
new entries (I don't blame you for including it, it's a sort of 'unwritten'
convention :P)
Also, can we put this in mm/internal.h please? As we want to limit who can call
this even in-kernel.
> extern bool current_is_khugepaged(void);
> void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr,
> bool install_pmd);
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 1dd3cfca610db..56a41c21b44c9 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2630,7 +2630,7 @@ static int khugepaged(void *none)
> return 0;
> }
>
> -static void set_recommended_min_free_kbytes(void)
> +void set_recommended_min_free_kbytes(void)
> {
> struct zone *zone;
> int nr_zones = 0;
>
> --
> 2.47.3
>
THanks, Lorenzo