[patch 07/29] hugetlb: break earlier in add_reservation_in_range() when we can
From: Andrew Morton <akpm@linux-foundation.org>
Date: 2021-03-13 05:07:26
Also in:
mm-commits
From: Peter Xu <peterx@redhat.com> 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@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Mike Kravetz <redacted> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com> Cc: Alexey Dobriyan <redacted> Cc: Andrea Arcangeli <redacted> Cc: Christoph Hellwig <hch@lst.de> Cc: Daniel Vetter <redacted> Cc: David Airlie <redacted> Cc: David Gibson <redacted> Cc: Gal Pressman <redacted> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Kirill Shutemov <redacted> Cc: Kirill Tkhai <redacted> Cc: Matthew Wilcox <willy@infradead.org> Cc: Mike Rapoport <redacted> Cc: Roland Scheidegger <redacted> Cc: VMware Graphics <redacted> Cc: Wei Zhang <redacted> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- 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@@ -387,7 +387,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
_