]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/hugetlb_cgroup: Add huge_page_order check to avoid incorrectly uncharge
authorWanpeng Li <liwp@linux.vnet.ibm.com>
Sat, 21 Jul 2012 00:54:02 +0000 (10:54 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 25 Jul 2012 03:02:25 +0000 (13:02 +1000)
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 <mhocko@suse.cz>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Wanpeng Li <liwp.linux@gmail.com>
Cc: David Rientjes <rientjes@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hillf Danton <dhillf@gmail.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb_cgroup.c

index 709cf77f7f1d0545c5b2d1e596146c13957309b1..63e04cfa437dc1e754f324a363e2bdcd98c41142 100644 (file)
@@ -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;
 }