From: Zhu Yanhai <zhu.yanhai@gmail.com>
To: Ying Han <yinghan@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Pavel Emelyanov <xemul@openvz.org>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
Li Zefan <lizf@cn.fujitsu.com>, Mel Gorman <mel@csn.ul.ie>,
Christoph Lameter <cl@linux.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Rik van Riel <riel@redhat.com>, Hugh Dickins <hughd@google.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Tejun Heo <tj@kernel.org>, Michal Hocko <mhocko@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>,
Dave Hansen <dave@linux.vnet.ibm.com>,
linux-mm@kvack.org
Subject: Re: [PATCH V3 2/7] Add per memcg reclaim watermarks
Date: Thu, 14 Apr 2011 16:24:27 +0800 [thread overview]
Message-ID: <BANLkTimR+Tn+AccUt3dxqXhSVA8tUp_xDg@mail.gmail.com> (raw)
In-Reply-To: <1302678187-24154-3-git-send-email-yinghan@google.com>
Hi Ying,
2011/4/13 Ying Han <yinghan@google.com>:
> +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@kvack.org. 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@kvack.org"> email@kvack.org </a>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. 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@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-04-14 8:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-13 7:03 [PATCH V3 0/7] memcg: per cgroup background reclaim Ying Han
2011-04-13 7:03 ` [PATCH V3 1/7] Add kswapd descriptor Ying Han
2011-04-13 7:03 ` [PATCH V3 2/7] Add per memcg reclaim watermarks Ying Han
2011-04-13 8:25 ` KAMEZAWA Hiroyuki
2011-04-13 18:40 ` Ying Han
2011-04-14 0:27 ` KAMEZAWA Hiroyuki
2011-04-14 8:24 ` Zhu Yanhai [this message]
2011-04-14 17:43 ` Ying Han
2011-04-13 7:03 ` [PATCH V3 3/7] New APIs to adjust per-memcg wmarks Ying Han
2011-04-13 8:30 ` KAMEZAWA Hiroyuki
2011-04-13 18:46 ` Ying Han
2011-04-13 7:03 ` [PATCH V3 4/7] Infrastructure to support per-memcg reclaim Ying Han
2011-04-14 3:57 ` Zhu Yanhai
2011-04-14 6:32 ` Ying Han
2011-04-13 7:03 ` [PATCH V3 5/7] Per-memcg background reclaim Ying Han
2011-04-13 8:58 ` KAMEZAWA Hiroyuki
2011-04-13 22:45 ` Ying Han
2011-04-13 7:03 ` [PATCH V3 6/7] Enable per-memcg " Ying Han
2011-04-13 9:05 ` KAMEZAWA Hiroyuki
2011-04-13 21:20 ` Ying Han
2011-04-14 0:30 ` KAMEZAWA Hiroyuki
2011-04-13 7:03 ` [PATCH V3 7/7] Add some per-memcg stats Ying Han
2011-04-13 7:47 ` [PATCH V3 0/7] memcg: per cgroup background reclaim KAMEZAWA Hiroyuki
2011-04-13 17:53 ` Ying Han
2011-04-14 0:14 ` KAMEZAWA Hiroyuki
2011-04-14 17:38 ` Ying Han
2011-04-14 21:59 ` Ying Han
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BANLkTimR+Tn+AccUt3dxqXhSVA8tUp_xDg@mail.gmail.com \
--to=zhu.yanhai@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=cl@linux.com \
--cc=dave@linux.vnet.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
--cc=mel@csn.ul.ie \
--cc=mhocko@suse.cz \
--cc=nishimura@mxp.nes.nec.co.jp \
--cc=riel@redhat.com \
--cc=tj@kernel.org \
--cc=xemul@openvz.org \
--cc=yinghan@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).