* [RFC][PATCH] memcg: show real limit under hierarchy
@ 2008-12-11 3:11 KAMEZAWA Hiroyuki
2008-12-11 3:24 ` KOSAKI Motohiro
0 siblings, 1 reply; 4+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-12-11 3:11 UTC (permalink / raw)
To: linux-mm; +Cc: linux-kernel, kosaki.motohiro, balbir, nishimura
I wonder other people who debugs memcg's hierarchy may use similar patches.
this is my one.
comments ?
==
From:KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Show "real" limit of memcg.
This helps my debugging and maybe useful for users.
While testing hierarchy like this
mount -t cgroup none /cgroup -t memory
mkdir /cgroup/A
set use_hierarchy==1 to "A"
mkdir /cgroup/A/01
mkdir /cgroup/A/01/02
mkdir /cgroup/A/01/03
mkdir /cgroup/A/01/03/04
mkdir /cgroup/A/08
mkdir /cgroup/A/08/01
....
and set each own limit to them, "real" limit of each memcg is unclear.
This patch shows real limit by checking all ancestors in memory.stat.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
mm/memcontrol.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
Index: mmotm-2.6.28-Dec09/mm/memcontrol.c
===================================================================
--- mmotm-2.6.28-Dec09.orig/mm/memcontrol.c
+++ mmotm-2.6.28-Dec09/mm/memcontrol.c
@@ -1758,6 +1758,36 @@ static int mem_cgroup_write(struct cgrou
return ret;
}
+static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg,
+ unsigned long long *mem_limit, unsigned long long *memsw_limit)
+{
+ struct cgroup *cgroup;
+ unsigned long long min_limit, min_memsw_limit, tmp;
+
+ min_limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
+ min_memsw_limit = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
+ cgroup = memcg->css.cgroup;
+ if (!memcg->use_hierarchy)
+ goto out;
+
+ while (cgroup->parent) {
+ cgroup = cgroup->parent;
+ memcg = mem_cgroup_from_cont(cgroup);
+ if (!memcg->use_hierarchy)
+ break;
+ tmp = res_counter_read_u64(&memcg->res, RES_LIMIT);
+ if (tmp < min_limit)
+ min_limit = tmp;
+ tmp = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
+ if (tmp < min_memsw_limit)
+ min_memsw_limit = tmp;
+ }
+out:
+ *mem_limit = min_limit;
+ *memsw_limit = min_memsw_limit;
+ return;
+}
+
static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
{
struct mem_cgroup *mem;
@@ -1831,6 +1861,13 @@ static int mem_control_stat_show(struct
cb->fill(cb, "unevictable", unevictable * PAGE_SIZE);
}
+ {
+ unsigned long long limit, memsw_limit;
+ memcg_get_hierarchical_limit(mem_cont, &limit, &memsw_limit);
+ cb->fill(cb, "hierarchical_memory_limit", limit);
+ if (do_swap_account)
+ cb->fill(cb, "hierarchical_memsw_limit", memsw_limit);
+ }
#ifdef CONFIG_DEBUG_VM
cb->fill(cb, "inactive_ratio", mem_cont->inactive_ratio);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC][PATCH] memcg: show real limit under hierarchy
2008-12-11 3:11 [RFC][PATCH] memcg: show real limit under hierarchy KAMEZAWA Hiroyuki
@ 2008-12-11 3:24 ` KOSAKI Motohiro
2008-12-11 14:00 ` Balbir Singh
0 siblings, 1 reply; 4+ messages in thread
From: KOSAKI Motohiro @ 2008-12-11 3:24 UTC (permalink / raw)
To: KAMEZAWA Hiroyuki
Cc: kosaki.motohiro, linux-mm, linux-kernel, balbir, nishimura
> I wonder other people who debugs memcg's hierarchy may use similar patches.
> this is my one.
> comments ?
> ==
> From:KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> Show "real" limit of memcg.
> This helps my debugging and maybe useful for users.
>
> While testing hierarchy like this
>
> mount -t cgroup none /cgroup -t memory
> mkdir /cgroup/A
> set use_hierarchy==1 to "A"
> mkdir /cgroup/A/01
> mkdir /cgroup/A/01/02
> mkdir /cgroup/A/01/03
> mkdir /cgroup/A/01/03/04
> mkdir /cgroup/A/08
> mkdir /cgroup/A/08/01
> ....
> and set each own limit to them, "real" limit of each memcg is unclear.
> This patch shows real limit by checking all ancestors in memory.stat.
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Great!
I hoped to use this patch at hierarchy inactive_ratio debugging ;)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC][PATCH] memcg: show real limit under hierarchy
2008-12-11 3:24 ` KOSAKI Motohiro
@ 2008-12-11 14:00 ` Balbir Singh
2008-12-12 1:24 ` KAMEZAWA Hiroyuki
0 siblings, 1 reply; 4+ messages in thread
From: Balbir Singh @ 2008-12-11 14:00 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: KAMEZAWA Hiroyuki, linux-mm, linux-kernel, nishimura
On Thu, Dec 11, 2008 at 8:54 AM, KOSAKI Motohiro
<kosaki.motohiro@jp.fujitsu.com> wrote:
>> I wonder other people who debugs memcg's hierarchy may use similar patches.
>> this is my one.
>> comments ?
>> ==
>> From:KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>>
>> Show "real" limit of memcg.
>> This helps my debugging and maybe useful for users.
>>
>> While testing hierarchy like this
>>
>> mount -t cgroup none /cgroup -t memory
>> mkdir /cgroup/A
>> set use_hierarchy==1 to "A"
>> mkdir /cgroup/A/01
>> mkdir /cgroup/A/01/02
>> mkdir /cgroup/A/01/03
>> mkdir /cgroup/A/01/03/04
>> mkdir /cgroup/A/08
>> mkdir /cgroup/A/08/01
>> ....
>> and set each own limit to them, "real" limit of each memcg is unclear.
>> This patch shows real limit by checking all ancestors in memory.stat.
>>
>> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> Great!
>
> I hoped to use this patch at hierarchy inactive_ratio debugging ;)
I like this very much too
I would prefer to use
min_limit = min(tmp, min_limit); and similarly for min_memsw_limit
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Balbir
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC][PATCH] memcg: show real limit under hierarchy
2008-12-11 14:00 ` Balbir Singh
@ 2008-12-12 1:24 ` KAMEZAWA Hiroyuki
0 siblings, 0 replies; 4+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-12-12 1:24 UTC (permalink / raw)
To: Balbir Singh; +Cc: KOSAKI Motohiro, linux-mm, linux-kernel, nishimura
On Thu, 11 Dec 2008 19:30:46 +0530
"Balbir Singh" <balbir@linux.vnet.ibm.com> wrote:
> On Thu, Dec 11, 2008 at 8:54 AM, KOSAKI Motohiro
> <kosaki.motohiro@jp.fujitsu.com> wrote:
> >> I wonder other people who debugs memcg's hierarchy may use similar patches.
> >> this is my one.
> >> comments ?
> >> ==
> >> From:KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> >>
> >> Show "real" limit of memcg.
> >> This helps my debugging and maybe useful for users.
> >>
> >> While testing hierarchy like this
> >>
> >> mount -t cgroup none /cgroup -t memory
> >> mkdir /cgroup/A
> >> set use_hierarchy==1 to "A"
> >> mkdir /cgroup/A/01
> >> mkdir /cgroup/A/01/02
> >> mkdir /cgroup/A/01/03
> >> mkdir /cgroup/A/01/03/04
> >> mkdir /cgroup/A/08
> >> mkdir /cgroup/A/08/01
> >> ....
> >> and set each own limit to them, "real" limit of each memcg is unclear.
> >> This patch shows real limit by checking all ancestors in memory.stat.
> >>
> >> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> >
> > Great!
> >
> > I hoped to use this patch at hierarchy inactive_ratio debugging ;)
>
> I like this very much too
>
> I would prefer to use
>
> min_limit = min(tmp, min_limit); and similarly for min_memsw_limit
>
> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
>
Thanks, I'll upadte this and forward to Andrew.
-Kame
> Balbir
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-12-12 1:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-11 3:11 [RFC][PATCH] memcg: show real limit under hierarchy KAMEZAWA Hiroyuki
2008-12-11 3:24 ` KOSAKI Motohiro
2008-12-11 14:00 ` Balbir Singh
2008-12-12 1:24 ` KAMEZAWA Hiroyuki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox