The patch titled Subject: hugetlb: break earlier in add_reservation_in_range() when we can has been added to the -mm tree. Its filename is hugetlg-break-earlier-in-add_reservation_in_range-when-we-can.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/hugetlg-break-earlier-in-add_reservation_in_range-when-we-can.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/hugetlg-break-earlier-in-add_reservation_in_range-when-we-can.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: Peter Xu <peterx@xxxxxxxxxx> Subject: hugetlb: break earlier in add_reservation_in_range() when we can All the regions maintained in hugetlb reserved map is inclusive on "from" but exclusive on "to". We can break earlier even if rg->from==t because it already means no possible intersection. This does not need a Fixes in all cases because when it happens (rg->from==t) we'll not break out of the loop while we should, however the next thing we'd do is still add the last file_region we'd need and quit the loop in the next round. So this change is not a bugfix (since the old code should still run okay iiuc), but we'd better still touch it up to make it logically sane. Link: https://lkml.kernel.org/r/20210217233547.93892-3-peterx@xxxxxxxxxx Signed-off-by: Peter Xu <peterx@xxxxxxxxxx> Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Reviewed-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Cc: Alexey Dobriyan <adobriyan@xxxxxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Daniel Vetter <daniel@xxxxxxxx> Cc: David Airlie <airlied@xxxxxxxx> Cc: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> Cc: Gal Pressman <galpress@xxxxxxxxxx> Cc: Jan Kara <jack@xxxxxxx> Cc: Jann Horn <jannh@xxxxxxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxx> Cc: Kirill Shutemov <kirill@xxxxxxxxxxxxx> Cc: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx> Cc: Roland Scheidegger <sroland@xxxxxxxxxx> Cc: VMware Graphics <linux-graphics-maintainer@xxxxxxxxxx> Cc: Wei Zhang <wzam@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/hugetlb.c~hugetlg-break-earlier-in-add_reservation_in_range-when-we-can +++ a/mm/hugetlb.c @@ -409,7 +409,7 @@ static long add_reservation_in_range(str /* When we find a region that starts beyond our range, we've * finished. */ - if (rg->from > t) + if (rg->from >= t) break; /* Add an entry for last_accounted_offset -> rg->from, and _ Patches currently in -mm which might be from peterx@xxxxxxxxxx are hugetlb-pass-vma-into-huge_pte_alloc-and-huge_pmd_share.patch hugetlb-pass-vma-into-huge_pte_alloc-and-huge_pmd_share-fix.patch hugetlb-userfaultfd-forbid-huge-pmd-sharing-when-uffd-enabled.patch mm-hugetlb-move-flush_hugetlb_tlb_range-into-hugetlbh.patch hugetlb-userfaultfd-unshare-all-pmds-for-hugetlbfs-when-register-wp.patch hugetlb-dedup-the-code-to-add-a-new-file_region.patch hugetlg-break-earlier-in-add_reservation_in_range-when-we-can.patch mm-introduce-page_needs_cow_for_dma-for-deciding-whether-cow.patch mm-use-is_cow_mapping-across-tree-where-proper.patch hugetlb-do-early-cow-when-page-pinned-on-src-mm.patch