From: Joonsoo Kim Date: Wed, 11 Sep 2013 21:21:51 +0000 (-0700) Subject: mm, hugetlb: protect reserved pages when soft offlining a hugepage X-Git-Tag: firefly_0821_release~3680^2~103^2^2~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c7a3da2d42c7e18de851c9e173f38ce61d36bd7c;p=firefly-linux-kernel-4.4.55.git mm, hugetlb: protect reserved pages when soft offlining a hugepage Don't use the reserve pool when soft offlining a hugepage. Check we have free pages outside the reserve pool before we dequeue the huge page. Otherwise, we can steal other's reserve page. Signed-off-by: Joonsoo Kim Reviewed-by: Aneesh Kumar Cc: Naoya Horiguchi Reviewed-by: Davidlohr Bueso Cc: David Gibson Cc: Wanpeng Li Cc: Hillf Danton Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit 4ef91848043679b272a1a5b8e2879acf696ba9e2) Signed-off-by: Mark Brown --- diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 864af85704e9..d9d03ca5075a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -938,10 +938,11 @@ static struct page *alloc_buddy_huge_page(struct hstate *h, int nid) */ struct page *alloc_huge_page_node(struct hstate *h, int nid) { - struct page *page; + struct page *page = NULL; spin_lock(&hugetlb_lock); - page = dequeue_huge_page_node(h, nid); + if (h->free_huge_pages - h->resv_huge_pages > 0) + page = dequeue_huge_page_node(h, nid); spin_unlock(&hugetlb_lock); if (!page)