From: Wanpeng Li Date: Sat, 21 Jul 2012 00:54:02 +0000 (+1000) Subject: mm/hugetlb_cgroup: Add huge_page_order check to avoid incorrectly uncharge X-Git-Tag: next-20120725~1^2~239 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7b11fc5cba0d9d928aebfe9fc9900d0332d11cab;p=karo-tx-linux.git mm/hugetlb_cgroup: Add huge_page_order check to avoid incorrectly uncharge alloc_huge_page() will call hugetlb_cgroup_charge_cgroup() to charge pages, the compound page have less than 3 pages will not charge to hugetlb cgroup. When alloc_huge_page fails it will call hugetlb_cgroup_uncharge_cgroup to uncharge pages, however, hugetlb_cgroup_uncharge_cgroup doesn't have huge_page_order check. That means it will uncharge pages even if the compound page have less than 3 pages. Add huge_page_order check to avoid this incorrectly uncharge. Reviewed-by: Michal Hocko Reviewed-by: Aneesh Kumar K.V Signed-off-by: Wanpeng Li Cc: David Rientjes Cc: KAMEZAWA Hiroyuki Cc: Hillf Danton Cc: KOSAKI Motohiro Signed-off-by: Andrew Morton --- diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 709cf77f7f1d..63e04cfa437d 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -184,6 +184,9 @@ void hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages, if (hugetlb_cgroup_disabled() || !h_cg) return; + if (huge_page_order(&hstates[idx]) < HUGETLB_CGROUP_MIN_ORDER) + return; + res_counter_uncharge(&h_cg->hugepage[idx], csize); return; }