mm: khugepaged: recalculate min_free_kbytes after memory hotplug as expected by khugepaged

When memory is hotplug added or removed the min_free_kbytes should be
recalculated based on what is expected by khugepaged.  Currently after
hotplug, min_free_kbytes will be set to a lower default and higher
default set when THP enabled is lost.

This change restores min_free_kbytes as expected for THP consumers.

[ v5]

Fixes: f000565adb77 ("thp: set recommended min free kbytes")
Signed-off-by: Vijay Balakrishna <>
Signed-off-by: Andrew Morton <>
Reviewed-by: Pavel Tatashin <>
Acked-by: Michal Hocko <>
Cc: Allen Pais <>
Cc: Andrea Arcangeli <>
Cc: "Kirill A. Shutemov" <>
Cc: Oleg Nesterov <>
Cc: Song Liu <>
Cc: <>
Signed-off-by: Linus Torvalds <>
3 files changed