[PATCH RFC] mm/hugetlb_cgroup: Add huge_page_order check to avoid incorrectly uncharge

From: Wanpeng Li
Date: Tue Jul 10 2012 - 06:05:45 EST


From: Wanpeng Li <liwp@xxxxxxxxxxxxxxxxxx>

Against linux-next:

Function 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.

Signed-off-by: Wanpeng Li <liwp.linux@xxxxxxxxx>
---
mm/hugetlb_cgroup.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index b834e8d..2b9e214 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -252,6 +252,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;
--
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/