[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1289265320-7025-1-git-send-email-gthelen@google.com>
Date: Mon, 8 Nov 2010 17:15:20 -0800
From: Greg Thelen <gthelen@...gle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Balbir Singh <balbir@...ux.vnet.ibm.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Daisuke Nishimura <nishimura@....nes.nec.co.jp>,
Johannes Weiner <hannes@...xchg.org>,
Wu Fengguang <fengguang.wu@...el.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Greg Thelen <gthelen@...gle.com>
Subject: [PATCH] memcg: avoid overflow in memcg_hierarchical_free_pages()
Use page counts rather than byte counts to avoid overflowing
unsigned long local variables.
Signed-off-by: Greg Thelen <gthelen@...gle.com>
---
mm/memcontrol.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6c7115d..b287afd 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1345,17 +1345,17 @@ memcg_hierarchical_free_pages(struct mem_cgroup *mem)
{
unsigned long free, min_free;
- min_free = global_page_state(NR_FREE_PAGES) << PAGE_SHIFT;
+ min_free = global_page_state(NR_FREE_PAGES);
while (mem) {
- free = res_counter_read_u64(&mem->res, RES_LIMIT) -
- res_counter_read_u64(&mem->res, RES_USAGE);
+ free = (res_counter_read_u64(&mem->res, RES_LIMIT) -
+ res_counter_read_u64(&mem->res, RES_USAGE)) >>
+ PAGE_SHIFT;
min_free = min(min_free, free);
mem = parent_mem_cgroup(mem);
}
- /* Translate free memory in pages */
- return min_free >> PAGE_SHIFT;
+ return min_free;
}
/*
--
1.7.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists