linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@openvz.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>,
	Paul Menage <menage@google.com>,
	Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
	Linux Containers <containers@lists.osdl.org>,
	Linux MM <linux-mm@kvack.org>
Subject: Re: [PATCH 2/2] Make res_counter hierarchical
Date: Tue, 11 Mar 2008 11:15:56 +0300	[thread overview]
Message-ID: <47D63FBC.1010805@openvz.org> (raw)
In-Reply-To: <20080308134514.434f38f4.kamezawa.hiroyu@jp.fujitsu.com>

KAMEZAWA Hiroyuki wrote:
> On Fri, 07 Mar 2008 18:32:20 +0300
> Pavel Emelyanov <xemul@openvz.org> wrote:
> 
>> This allows us two things basically:
>>
>> 1. If the subgroup has the limit higher than its parent has
>>    then the one will get more memory than allowed.
>> 2. When we will need to account for a resource in more than
>>    one place, we'll be able to use this technics.
>>
>>    Look, consider we have a memory limit and swap limit. The
>>    memory limit is the limit for the sum of RSS, page cache
>>    and swap usage. To account for this gracefuly, we'll set
>>    two counters:
>>
>> 	   res_counter mem_counter;
>> 	   res_counter swap_counter;
>>
>>    attach mm to the swap one
>>
>> 	   mm->mem_cnt = &swap_counter;
>>
>>    and make the swap_counter be mem's child. That's it. If we
>>    want hierarchical support, then the tree will look like this:
>>
>>    mem_counter_top
>>     swap_counter_top <- mm_struct living at top
>>      mem_counter_sub
>>       swap_counter_sub <- mm_struct living at sub
>>
> Hmm? seems strange.
> 
> IMO, a parent's usage is just sum of all childs'.
> And, historically, memory overcommit is done agaist "memory usage + swap".
> 
> How about this ?
>     <mem_counter_top, swap_counter_top>
> 	<mem_counter_sub, swap_counter_sub>
> 	<mem_counter_sub, swap_counter_sub>
> 	<mem_counter_sub, swap_counter_sub>
> 
>    mem_counter_top.usage == sum of all mem_coutner_sub.usage
>    swap_counter_sub.usage = sum of all swap_counter_sub.usage

I've misprinted in y tree, sorry.
The correct hierarchy as I see it is

<mem_couter_0>
 + -- <swap_counter_0>
 + -- <mem_counter_1>
 |     + -- <swap_counter_1>
 |     + -- <mem_counter_11>
 |     |     + -- <swap_counter_11>
 |     + -- <mem_counter_12>
 |           + -- <swap_counter_12>
 + -- <mem_counter_2>
 |     + -- <swap_counter_2>
 |     + -- <mem_counter_21>
 |     |     + -- <swap_counter_21>
 |     + -- <mem_counter_22>
 |           + -- <swap_counter_22>
 + -- <mem_counter_N>
       + -- <swap_counter_N>
       + -- <mem_counter_N1>
       |     + -- <swap_counter_N1>
       + -- <mem_counter_N2>
             + -- <swap_counter_N2>

> 
>> @@ -976,19 +976,22 @@ static void free_mem_cgroup_per_zone_info(struct mem_cgroup *mem, int node)
>>  static struct cgroup_subsys_state *
>>  mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
>>  {
>> -	struct mem_cgroup *mem;
>> +	struct mem_cgroup *mem, *parent;
>>  	int node;
>>  
>>  	if (unlikely((cont->parent) == NULL)) {
>>  		mem = &init_mem_cgroup;
>>  		init_mm.mem_cgroup = mem;
>> -	} else
>> +		parent = NULL;
>> +	} else {
>>  		mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL);
>> +		parent = mem_cgroup_from_cont(cont->parent);
>> +	}
>>  
>>  	if (mem == NULL)
>>  		return ERR_PTR(-ENOMEM);
>>  
>> -	res_counter_init(&mem->res);
>> +	res_counter_init(&mem->res, parent ? &parent->res : NULL);
>>  
> I have no objection to add some hierarchical support to res_counter.
> 
> But we should wait to add it to mem_cgroup because we have to add 
> some amount of codes to handle hierarchy under mem_cgroup in reasonable way.
> for example) 
> 	- hierarchical memory reclaim
> 	- keeping fairness between sub memory controllers.
> 	  etc...
> 
> Thanks,
> -Kame
> 
> 

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

  reply	other threads:[~2008-03-11  8:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-07 15:32 [PATCH 2/2] Make res_counter hierarchical Pavel Emelyanov
2008-03-08  4:45 ` KAMEZAWA Hiroyuki
2008-03-11  8:15   ` Pavel Emelyanov [this message]
2008-03-11  8:32     ` KAMEZAWA Hiroyuki
2008-03-11  8:38       ` Pavel Emelyanov
2008-03-11  9:03         ` Daisuke Nishimura
2008-03-11  9:07         ` KAMEZAWA Hiroyuki
2008-03-11  8:57     ` Paul Menage
2008-03-11  9:13       ` KAMEZAWA Hiroyuki
2008-03-11  9:11         ` Paul Menage
2008-03-11  9:16           ` Balbir Singh
2008-03-11  9:39             ` KAMEZAWA Hiroyuki
2008-03-11  9:53               ` Balbir Singh
2008-03-11 10:03                 ` KAMEZAWA Hiroyuki
2008-03-11 15:56             ` Paul Menage
2008-03-11 15:59               ` Balbir Singh
2008-03-08 19:06 ` Balbir Singh
2008-03-11  8:17   ` Pavel Emelyanov
2008-03-11  8:24     ` Balbir Singh
2008-03-11  8:40       ` Pavel Emelyanov
2008-03-12 23:05 ` YAMAMOTO Takashi
2008-03-12 23:36   ` YAMAMOTO Takashi
2008-03-13  8:56   ` Pavel Emelyanov
     [not found] ` <47D16004.7050204-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2008-04-02 15:26   ` Balbir Singh
     [not found]     ` <47F3A5BF.1080301-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-04-03 12:26       ` Pavel Emelyanov

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=47D63FBC.1010805@openvz.org \
    --to=xemul@openvz.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=containers@lists.osdl.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=menage@google.com \
    --cc=nishimura@mxp.nes.nec.co.jp \
    /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).