The patch titled Subject: mm: khugepaged: avoid overriding min_free_kbytes set by user has been added to the -mm tree. Its filename is mm-khugepaged-avoid-overriding-min_free_kbytes-set-by-user.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-khugepaged-avoid-overriding-min_free_kbytes-set-by-user.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-khugepaged-avoid-overriding-min_free_kbytes-set-by-user.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Vijay Balakrishna <vijayb@xxxxxxxxxxxxxxxxxxx> Subject: mm: khugepaged: avoid overriding min_free_kbytes set by user set_recommended_min_free_kbytes need to honor min_free_kbytes set by the user. Post start-of-day THP enable or memory hotplug operations can lose user specified min_free_kbytes, in particular when it is higher than calculated recommended value. Also modifying "recommended_min" variable type to "int" from "unsigned long" to avoid undesired result noticed during testing. It is due to comparing "unsigned long" with "int" type. Link: https://lkml.kernel.org/r/1600204258-13683-2-git-send-email-vijayb@xxxxxxxxxxxxxxxxxxx Signed-off-by: Vijay Balakrishna <vijayb@xxxxxxxxxxxxxxxxxxx> Reviewed-by: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> Cc: "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Oleg Nesterov <oleg@xxxxxxxxxx> Cc: Song Liu <songliubraving@xxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Allen Pais <apais@xxxxxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/khugepaged.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/mm/khugepaged.c~mm-khugepaged-avoid-overriding-min_free_kbytes-set-by-user +++ a/mm/khugepaged.c @@ -2253,7 +2253,7 @@ static void set_recommended_min_free_kby { struct zone *zone; int nr_zones = 0; - unsigned long recommended_min; + int recommended_min; for_each_populated_zone(zone) { /* @@ -2280,12 +2280,12 @@ static void set_recommended_min_free_kby /* don't ever allow to reserve more than 5% of the lowmem */ recommended_min = min(recommended_min, - (unsigned long) nr_free_buffer_pages() / 20); + (int) nr_free_buffer_pages() / 20); recommended_min <<= (PAGE_SHIFT-10); - if (recommended_min > min_free_kbytes) { + if (recommended_min > user_min_free_kbytes) { if (user_min_free_kbytes >= 0) - pr_info("raising min_free_kbytes from %d to %lu to help transparent hugepage allocations\n", + pr_info("raising min_free_kbytes from %d to %d to help transparent hugepage allocations\n", min_free_kbytes, recommended_min); min_free_kbytes = recommended_min; _ Patches currently in -mm which might be from vijayb@xxxxxxxxxxxxxxxxxxx are mm-khugepaged-recalculate-min_free_kbytes-after-memory-hotplug-as-expected-by-khugepaged.patch mm-khugepaged-avoid-overriding-min_free_kbytes-set-by-user.patch