|
@@ -1386,24 +1386,17 @@ static struct page *alloc_huge_page(struct vm_area_struct *vma,
|
|
|
return ERR_PTR(-ENOSPC);
|
|
|
|
|
|
ret = hugetlb_cgroup_charge_cgroup(idx, pages_per_huge_page(h), &h_cg);
|
|
|
- if (ret) {
|
|
|
- if (chg || avoid_reserve)
|
|
|
- hugepage_subpool_put_pages(spool, 1);
|
|
|
- return ERR_PTR(-ENOSPC);
|
|
|
- }
|
|
|
+ if (ret)
|
|
|
+ goto out_subpool_put;
|
|
|
+
|
|
|
spin_lock(&hugetlb_lock);
|
|
|
page = dequeue_huge_page_vma(h, vma, addr, avoid_reserve, chg);
|
|
|
if (!page) {
|
|
|
spin_unlock(&hugetlb_lock);
|
|
|
page = alloc_buddy_huge_page(h, NUMA_NO_NODE);
|
|
|
- if (!page) {
|
|
|
- hugetlb_cgroup_uncharge_cgroup(idx,
|
|
|
- pages_per_huge_page(h),
|
|
|
- h_cg);
|
|
|
- if (chg || avoid_reserve)
|
|
|
- hugepage_subpool_put_pages(spool, 1);
|
|
|
- return ERR_PTR(-ENOSPC);
|
|
|
- }
|
|
|
+ if (!page)
|
|
|
+ goto out_uncharge_cgroup;
|
|
|
+
|
|
|
spin_lock(&hugetlb_lock);
|
|
|
list_move(&page->lru, &h->hugepage_activelist);
|
|
|
/* Fall through */
|
|
@@ -1415,6 +1408,13 @@ static struct page *alloc_huge_page(struct vm_area_struct *vma,
|
|
|
|
|
|
vma_commit_reservation(h, vma, addr);
|
|
|
return page;
|
|
|
+
|
|
|
+out_uncharge_cgroup:
|
|
|
+ hugetlb_cgroup_uncharge_cgroup(idx, pages_per_huge_page(h), h_cg);
|
|
|
+out_subpool_put:
|
|
|
+ if (chg || avoid_reserve)
|
|
|
+ hugepage_subpool_put_pages(spool, 1);
|
|
|
+ return ERR_PTR(-ENOSPC);
|
|
|
}
|
|
|
|
|
|
/*
|