Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750883Ab3IFFUA (ORCPT ); Fri, 6 Sep 2013 01:20:00 -0400 Received: from LGEMRELSE7Q.lge.com ([156.147.1.151]:53328 "EHLO LGEMRELSE7Q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750725Ab3IFFT7 (ORCPT ); Fri, 6 Sep 2013 01:19:59 -0400 X-AuditID: 9c930197-b7b44ae00000347f-58-522965fc97c0 From: Joonsoo Kim To: Andrew Morton Cc: Rik van Riel , Mel Gorman , Michal Hocko , "Aneesh Kumar K.V" , KAMEZAWA Hiroyuki , Hugh Dickins , Davidlohr Bueso , David Gibson , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim , Wanpeng Li , Naoya Horiguchi , Hillf Danton , Joonsoo Kim Subject: [PATCH v3 03/20] mm, hugetlb: fix subpool accounting handling Date: Fri, 6 Sep 2013 14:19:56 +0900 Message-Id: <1378444797-3353-1-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <520c10e8.1kKQVx1mpwqXywyM%akpm@linux-foundation.org> References: <520c10e8.1kKQVx1mpwqXywyM%akpm@linux-foundation.org> X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2168 Lines: 57 There is a case that we attempt to allocate a hugepage with chg = 0 and avoid_reserve = 1. Although chg = 0 means that it has a reserved hugepage, we wouldn't use it, since avoid_reserve = 1 represents that we don't want to allocate a hugepage from a reserved pool. This happens when the parent process that created a MAP_PRIVATE mapping is about to perform a COW due to a shared page count and it attempt to satisfy the allocation without using the existing reserves. In this case, we would not dequeue a reserved hugepage and, instead, try to allocate a new hugepage. Therefore, we should check subpool counter for a new hugepage. This patch implement it. Reviewed-by: Aneesh Kumar K.V Signed-off-by: Joonsoo Kim --- Replenishing commit message and adding reviewed-by tag. diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 12b6581..ea1ae0a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1144,13 +1144,14 @@ static struct page *alloc_huge_page(struct vm_area_struct *vma, chg = vma_needs_reservation(h, vma, addr); if (chg < 0) return ERR_PTR(-ENOMEM); - if (chg) - if (hugepage_subpool_get_pages(spool, chg)) + if (chg || avoid_reserve) + if (hugepage_subpool_get_pages(spool, 1)) return ERR_PTR(-ENOSPC); ret = hugetlb_cgroup_charge_cgroup(idx, pages_per_huge_page(h), &h_cg); if (ret) { - hugepage_subpool_put_pages(spool, chg); + if (chg || avoid_reserve) + hugepage_subpool_put_pages(spool, 1); return ERR_PTR(-ENOSPC); } spin_lock(&hugetlb_lock); @@ -1162,7 +1163,8 @@ static struct page *alloc_huge_page(struct vm_area_struct *vma, hugetlb_cgroup_uncharge_cgroup(idx, pages_per_huge_page(h), h_cg); - hugepage_subpool_put_pages(spool, chg); + if (chg || avoid_reserve) + hugepage_subpool_put_pages(spool, 1); return ERR_PTR(-ENOSPC); } spin_lock(&hugetlb_lock); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/