Hi Ying, 2011/4/13 Ying Han <yinghan@xxxxxxxxxx>: > +static void setup_per_memcg_wmarks(struct mem_cgroup *mem) > +{ > + Â Â Â u64 limit; > + Â Â Â unsigned long wmark_ratio; > + > + Â Â Â wmark_ratio = get_wmark_ratio(mem); > + Â Â Â limit = mem_cgroup_get_limit(mem); mem_cgroup_get_limit doesn't return the correct limit for you, actually it's only for OOM killer. You should use limit = res_counter_read_u64(&mem->res, RES_LIMIT) directly. Otherwise in the box which has swapon, you will get a huge number here. e.g. [root@zyh-fedora a]# echo 500m > memory.limit_in_bytes [root@zyh-fedora a]# cat memory.limit_in_bytes 524288000 [root@zyh-fedora a]# cat memory.reclaim_wmarks low_wmark 9114218496 high_wmark 9114218496 Regards, Zhu Yanhai > + Â Â Â if (wmark_ratio == 0) { > + Â Â Â Â Â Â Â res_counter_set_low_wmark_limit(&mem->res, limit); > + Â Â Â Â Â Â Â res_counter_set_high_wmark_limit(&mem->res, limit); > + Â Â Â } else { > + Â Â Â Â Â Â Â unsigned long low_wmark, high_wmark; > + Â Â Â Â Â Â Â unsigned long long tmp = (wmark_ratio * limit) / 100; > + > + Â Â Â Â Â Â Â low_wmark = tmp; > + Â Â Â Â Â Â Â high_wmark = tmp - (tmp >> 8); > + Â Â Â Â Â Â Â res_counter_set_low_wmark_limit(&mem->res, low_wmark); > + Â Â Â Â Â Â Â res_counter_set_high_wmark_limit(&mem->res, high_wmark); > + Â Â Â } > +} > + > Â/* > Â* Following LRU functions are allowed to be used without PCG_LOCK. > Â* Operations are called by routine of global LRU independently from memcg. > @@ -1195,6 +1219,16 @@ static unsigned int get_swappiness(struct mem_cgroup *memcg) > Â Â Â Âreturn memcg->swappiness; > Â} > > +static unsigned long get_wmark_ratio(struct mem_cgroup *memcg) > +{ > + Â Â Â struct cgroup *cgrp = memcg->css.cgroup; > + > + Â Â Â VM_BUG_ON(!cgrp); > + Â Â Â VM_BUG_ON(!cgrp->parent); > + > + Â Â Â return memcg->wmark_ratio; > +} > + > Âstatic void mem_cgroup_start_move(struct mem_cgroup *mem) > Â{ > Â Â Â Âint cpu; > @@ -3205,6 +3239,7 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg, > Â Â Â Â Â Â Â Â Â Â Â Âelse > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âmemcg->memsw_is_minimum = false; > Â Â Â Â Â Â Â Â} > + Â Â Â Â Â Â Â setup_per_memcg_wmarks(memcg); > Â Â Â Â Â Â Â Âmutex_unlock(&set_limit_mutex); > > Â Â Â Â Â Â Â Âif (!ret) > @@ -3264,6 +3299,7 @@ static int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg, > Â Â Â Â Â Â Â Â Â Â Â Âelse > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âmemcg->memsw_is_minimum = false; > Â Â Â Â Â Â Â Â} > + Â Â Â Â Â Â Â setup_per_memcg_wmarks(memcg); > Â Â Â Â Â Â Â Âmutex_unlock(&set_limit_mutex); > > Â Â Â Â Â Â Â Âif (!ret) > @@ -4521,6 +4557,22 @@ static void __init enable_swap_cgroup(void) > Â} > Â#endif > > +int mem_cgroup_watermark_ok(struct mem_cgroup *mem, > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int charge_flags) > +{ > + Â Â Â long ret = 0; > + Â Â Â int flags = CHARGE_WMARK_LOW | CHARGE_WMARK_HIGH; > + > + Â Â Â VM_BUG_ON((charge_flags & flags) == flags); > + > + Â Â Â if (charge_flags & CHARGE_WMARK_LOW) > + Â Â Â Â Â Â Â ret = res_counter_check_under_low_wmark_limit(&mem->res); > + Â Â Â if (charge_flags & CHARGE_WMARK_HIGH) > + Â Â Â Â Â Â Â ret = res_counter_check_under_high_wmark_limit(&mem->res); > + > + Â Â Â return ret; > +} > + > Âstatic int mem_cgroup_soft_limit_tree_init(void) > Â{ > Â Â Â Âstruct mem_cgroup_tree_per_node *rtpn; > -- > 1.7.3.1 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@xxxxxxxxxx ÂFor more info on Linux MM, > see: http://www.linux-mm.org/ . > Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ > Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a> > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxxx For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href