]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm-hugetlb-fix-missing-call-to-restore_reserve_on_error-v2
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 23 Aug 2022 03:02:06 +0000 (11:02 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Aug 2022 05:02:55 +0000 (22:02 -0700)
remove err == -EEXIST check and retry logic

Link: https://lkml.kernel.org/r/20220823030209.57434-4-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb.c

index b69d7808f4579cc7683b139b2a0470bc7dc29426..8d52827d9f516934585370b1e7aad606765adad8 100644 (file)
@@ -5563,7 +5563,6 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
        if (idx >= size)
                goto out;
 
-retry:
        new_page = false;
        page = find_lock_page(mapping, idx);
        if (!page) {
@@ -5603,10 +5602,15 @@ retry:
                if (vma->vm_flags & VM_MAYSHARE) {
                        int err = huge_add_to_page_cache(page, mapping, idx);
                        if (err) {
+                               /*
+                                * err can't be -EEXIST which implies someone
+                                * else consumed the reservation since hugetlb
+                                * fault mutex is held when add a hugetlb page
+                                * to the page cache. So it's safe to call
+                                * restore_reserve_on_error() here.
+                                */
                                restore_reserve_on_error(h, vma, haddr, page);
                                put_page(page);
-                               if (err == -EEXIST)
-                                       goto retry;
                                goto out;
                        }
                        new_pagecache_page = true;