[patch 1/4] memcg: use native word to represent dirtyable pages

From: Johannes Weiner
Date: Sun Nov 07 2010 - 17:15:52 EST


The memory cgroup dirty info calculation currently uses a signed
64-bit type to represent the amount of dirtyable memory in pages.

This can instead be changed to an unsigned word, which will allow the
formula to function correctly with up to 160G of LRU pages on a 32-bit
system, assuming 4k pages. That should be plenty even when taking
racy folding of the per-cpu counters into account.

This fixes a compilation error on 32-bit systems as this code tries to
do 64-bit division.

Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
Reported-by: Dave Young <hidave.darkstar@xxxxxxxxx>
---
mm/memcontrol.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1222,9 +1222,10 @@ static void __mem_cgroup_dirty_param(str
bool mem_cgroup_dirty_info(unsigned long sys_available_mem,
struct dirty_info *info)
{
- s64 available_mem;
struct vm_dirty_param dirty_param;
+ unsigned long available_mem;
struct mem_cgroup *memcg;
+ s64 value;

if (mem_cgroup_disabled())
return false;
@@ -1238,11 +1239,11 @@ bool mem_cgroup_dirty_info(unsigned long
__mem_cgroup_dirty_param(&dirty_param, memcg);
rcu_read_unlock();

- available_mem = mem_cgroup_page_stat(MEMCG_NR_DIRTYABLE_PAGES);
- if (available_mem < 0)
+ value = mem_cgroup_page_stat(MEMCG_NR_DIRTYABLE_PAGES);
+ if (value < 0)
return false;

- available_mem = min((unsigned long)available_mem, sys_available_mem);
+ available_mem = min((unsigned long)value, sys_available_mem);

if (dirty_param.dirty_bytes)
info->dirty_thresh =


--
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/