mm/hugetlb: fix missing call to restore_reserve_on_error()
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 16 Aug 2022 13:05:50 +0000 (21:05 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 Sep 2022 03:25:55 +0000 (20:25 -0700)
commit3a5497a2dae381cb1b201fb20847fb32a059da25
tree982fec911000769c7cfc8cc7c8aa3c4f7a6143a3
parent3a6bdda0b58bab883da8dc3a0503e2a13b9d7456
mm/hugetlb: fix missing call to restore_reserve_on_error()

When huge_add_to_page_cache() fails, the page is freed directly without
calling restore_reserve_on_error() to restore reserve for newly allocated
pages not in page cache.  Fix this by calling restore_reserve_on_error()
when huge_add_to_page_cache fails.

[linmiaohe@huawei.com: remove err == -EEXIST check and retry logic]
Link: https://lkml.kernel.org/r/20220823030209.57434-4-linmiaohe@huawei.com
Link: https://lkml.kernel.org/r/20220816130553.31406-4-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb.c