The patch titled Subject: mm: khugepaged: remove redundant check for VM_NO_KHUGEPAGED has been added to the -mm tree. Its filename is mm-khugepaged-remove-redundant-check-for-vm_no_khugepaged.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-khugepaged-remove-redundant-check-for-vm_no_khugepaged.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-khugepaged-remove-redundant-check-for-vm_no_khugepaged.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: Yang Shi <shy828301@xxxxxxxxx> Subject: mm: khugepaged: remove redundant check for VM_NO_KHUGEPAGED The hugepage_vma_check() called by khugepaged_enter_vma_merge() does check VM_NO_KHUGEPAGED. Remove the check from caller and move the check in hugepage_vma_check() up. More checks may be run for VM_NO_KHUGEPAGED vmas, but MADV_HUGEPAGE is definitely not a hot path, so cleaner code does outweigh. Link: https://lkml.kernel.org/r/20220404200250.321455-3-shy828301@xxxxxxxxx Signed-off-by: Yang Shi <shy828301@xxxxxxxxx> Reviewed-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Acked-by: Song Liu <song@xxxxxxxxxx> Cc: "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxxx> Cc: Theodore Ts'o <tytso@xxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Zi Yan <ziy@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/khugepaged.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/mm/khugepaged.c~mm-khugepaged-remove-redundant-check-for-vm_no_khugepaged +++ a/mm/khugepaged.c @@ -365,8 +365,7 @@ int hugepage_madvise(struct vm_area_stru * register it here without waiting a page fault that * may not happen any time soon. */ - if (!(*vm_flags & VM_NO_KHUGEPAGED) && - khugepaged_enter_vma_merge(vma, *vm_flags)) + if (khugepaged_enter_vma_merge(vma, *vm_flags)) return -ENOMEM; break; case MADV_NOHUGEPAGE: @@ -445,6 +444,9 @@ static bool hugepage_vma_check(struct vm if (!transhuge_vma_enabled(vma, vm_flags)) return false; + if (vm_flags & VM_NO_KHUGEPAGED) + return false; + if (vma->vm_file && !IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff, HPAGE_PMD_NR)) return false; @@ -470,7 +472,8 @@ static bool hugepage_vma_check(struct vm return false; if (vma_is_temporary_stack(vma)) return false; - return !(vm_flags & VM_NO_KHUGEPAGED); + + return true; } int __khugepaged_enter(struct mm_struct *mm) _ Patches currently in -mm which might be from shy828301@xxxxxxxxx are sched-coredumph-clarify-the-use-of-mmf_vm_hugepage.patch mm-khugepaged-remove-redundant-check-for-vm_no_khugepaged.patch mm-khugepaged-skip-dax-vma.patch mm-thp-only-regular-file-could-be-thp-eligible.patch mm-khugepaged-make-khugepaged_enter-void-function.patch mm-khugepaged-move-some-khugepaged_-functions-to-khugepagedc.patch mm-khugepaged-introduce-khugepaged_enter_vma-helper.patch mm-mmap-register-suitable-readonly-file-vmas-for-khugepaged.patch