public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] memcg: VM overcommit accounting and handling
@ 2008-06-09 23:32 Andrea Righi
  2008-06-10  0:14 ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Righi @ 2008-06-09 23:32 UTC (permalink / raw)
  To: balbir
  Cc: menage, kamezawa.hiroyu, kosaki.motohiro, xemul, linux-kernel,
	containers


Provide distinct cgroup VM overcommit accounting and handling using the memory
resource controller.

Patchset against latest Linus git tree.

This patchset allows to set different per-cgroup overcommit rules and,
according to them, it's possible to return a memory allocation failure (ENOMEM)
to the applications, instead of always triggering the OOM killer via
mem_cgroup_out_of_memory() when cgroup memory limits are exceeded.

Default overcommit settings are taken from vm.overcommit_memory and
vm.overcommit_ratio sysctl values. Child cgroups initially inherits the VM
overcommit parent's settings.

Cgroup overcommit settings can be overridden using memory.overcommit_memory and
memory.overcommit_ratio files under the cgroup filesystem.

For example:

1. Initialize a cgroup with 50MB memory limit:
# mount -t cgroup none /cgroups -o memory
# mkdir /cgroups/0
# /bin/echo $$ >  /cgroups/0/tasks
# /bin/echo 50M > /cgroups/0/memory.limit_in_bytes

2. Use the "never overcommit" policy with 50% ratio:
# /bin/echo 2 > /cgroups/0/memory.overcommit_memory
# /bin/echo 50 > /cgroups/0/memory.overcommit_ratio

Assuming we have no swap space, cgroup 0 can allocate up to 25MB of virtual
memory. If that limit is exceeded all the further allocation attempts made by
userspace applications will receive a -ENOMEM.

4. Show committed VM statistics:
# cat /cgroups/0/memory.overcommit_as
CommitLimit:     25600 kB
Committed_AS:     9844 kB

5. Use "always overcommmit":
# /bin/echo 1 > /cgroups/0/memory.overcommit_memory

This is very similar to the default memory controller configuration: overcommit
is allowed, but when there's no more available memory oom-killer is invoked.

TODO:
- shared memory is not taken in account (i.e. files in tmpfs)

-Andrea

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH 0/5] memcg: VM overcommit accounting and handling
  2008-06-09 23:32 [RFC PATCH 0/5] memcg: VM overcommit accounting and handling Andrea Righi
@ 2008-06-10  0:14 ` KAMEZAWA Hiroyuki
  2008-06-10  5:13   ` Balbir Singh
  0 siblings, 1 reply; 5+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-06-10  0:14 UTC (permalink / raw)
  To: Andrea Righi
  Cc: balbir, menage, kosaki.motohiro, xemul, linux-kernel, containers

On Tue, 10 Jun 2008 01:32:58 +0200
Andrea Righi <righi.andrea@gmail.com> wrote:

> 
> Provide distinct cgroup VM overcommit accounting and handling using the memory
> resource controller.
> 

Could you explain the benefits of this even when we have memrlimit controller ?
(If unsure, see 2.6.26-rc5-mm1 and search memrlimit controller.)

And this kind of virtual-address-handling things should be implemented on
memrlimit controller (means not on memory-resource-controller.).
It seems this patch doesn't need to handle page_group.

Considering hierarchy, putting several kinds of features on one controller is
not good, I think. Balbir, how do you think ?

Thanks,
-Kame


> Patchset against latest Linus git tree.
> 
> This patchset allows to set different per-cgroup overcommit rules and,
> according to them, it's possible to return a memory allocation failure (ENOMEM)
> to the applications, instead of always triggering the OOM killer via
> mem_cgroup_out_of_memory() when cgroup memory limits are exceeded.
> 
> Default overcommit settings are taken from vm.overcommit_memory and
> vm.overcommit_ratio sysctl values. Child cgroups initially inherits the VM
> overcommit parent's settings.
> 
> Cgroup overcommit settings can be overridden using memory.overcommit_memory and
> memory.overcommit_ratio files under the cgroup filesystem.
> 
> For example:
> 
> 1. Initialize a cgroup with 50MB memory limit:
> # mount -t cgroup none /cgroups -o memory
> # mkdir /cgroups/0
> # /bin/echo $$ >  /cgroups/0/tasks
> # /bin/echo 50M > /cgroups/0/memory.limit_in_bytes
> 
> 2. Use the "never overcommit" policy with 50% ratio:
> # /bin/echo 2 > /cgroups/0/memory.overcommit_memory
> # /bin/echo 50 > /cgroups/0/memory.overcommit_ratio
> 
> Assuming we have no swap space, cgroup 0 can allocate up to 25MB of virtual
> memory. If that limit is exceeded all the further allocation attempts made by
> userspace applications will receive a -ENOMEM.
> 
> 4. Show committed VM statistics:
> # cat /cgroups/0/memory.overcommit_as
> CommitLimit:     25600 kB
> Committed_AS:     9844 kB
> 
> 5. Use "always overcommmit":
> # /bin/echo 1 > /cgroups/0/memory.overcommit_memory
> 
> This is very similar to the default memory controller configuration: overcommit
> is allowed, but when there's no more available memory oom-killer is invoked.
> 
> TODO:
> - shared memory is not taken in account (i.e. files in tmpfs)
> 
> -Andrea
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH 0/5] memcg: VM overcommit accounting and handling
  2008-06-10  0:14 ` KAMEZAWA Hiroyuki
@ 2008-06-10  5:13   ` Balbir Singh
  2008-06-10  7:52     ` Pavel Emelyanov
  0 siblings, 1 reply; 5+ messages in thread
From: Balbir Singh @ 2008-06-10  5:13 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: Andrea Righi, menage, kosaki.motohiro, xemul, linux-kernel,
	containers

KAMEZAWA Hiroyuki wrote:
> On Tue, 10 Jun 2008 01:32:58 +0200
> Andrea Righi <righi.andrea@gmail.com> wrote:
> 
>> Provide distinct cgroup VM overcommit accounting and handling using the memory
>> resource controller.
>>
> 
> Could you explain the benefits of this even when we have memrlimit controller ?
> (If unsure, see 2.6.26-rc5-mm1 and search memrlimit controller.)
> 
> And this kind of virtual-address-handling things should be implemented on
> memrlimit controller (means not on memory-resource-controller.).
> It seems this patch doesn't need to handle page_group.
> 
> Considering hierarchy, putting several kinds of features on one controller is
> not good, I think. Balbir, how do you think ?
> 

I would tend to agree. With the memrlimit controller, can't we do this in user
space now? Figure out the overcommit value and based on that setup the memrlimit?


-- 
	Warm Regards,
	Balbir Singh
	Linux Technology Center
	IBM, ISTL

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH 0/5] memcg: VM overcommit accounting and handling
  2008-06-10  5:13   ` Balbir Singh
@ 2008-06-10  7:52     ` Pavel Emelyanov
  2008-06-10  8:30       ` Andrea Righi
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Emelyanov @ 2008-06-10  7:52 UTC (permalink / raw)
  To: Andrea Righi
  Cc: balbir, KAMEZAWA Hiroyuki, menage, kosaki.motohiro, linux-kernel,
	containers

Balbir Singh wrote:
> KAMEZAWA Hiroyuki wrote:
>> On Tue, 10 Jun 2008 01:32:58 +0200
>> Andrea Righi <righi.andrea@gmail.com> wrote:
>>
>>> Provide distinct cgroup VM overcommit accounting and handling using the memory
>>> resource controller.
>>>
>> Could you explain the benefits of this even when we have memrlimit controller ?
>> (If unsure, see 2.6.26-rc5-mm1 and search memrlimit controller.)
>>
>> And this kind of virtual-address-handling things should be implemented on
>> memrlimit controller (means not on memory-resource-controller.).
>> It seems this patch doesn't need to handle page_group.
>>
>> Considering hierarchy, putting several kinds of features on one controller is
>> not good, I think. Balbir, how do you think ?
>>
> 
> I would tend to agree. With the memrlimit controller, can't we do this in user
> space now? Figure out the overcommit value and based on that setup the memrlimit?

I also agree with Balbir and Kamezawa. Separate controller for VM (i.e. vma-s
lengths) is more preferable, rather than yet another fancy feature on top of 
the existing rss one.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH 0/5] memcg: VM overcommit accounting and handling
  2008-06-10  7:52     ` Pavel Emelyanov
@ 2008-06-10  8:30       ` Andrea Righi
  0 siblings, 0 replies; 5+ messages in thread
From: Andrea Righi @ 2008-06-10  8:30 UTC (permalink / raw)
  To: Pavel Emelyanov, balbir, KAMEZAWA Hiroyuki
  Cc: menage, kosaki.motohiro, linux-kernel, containers

Pavel Emelyanov wrote:
> Balbir Singh wrote:
>> KAMEZAWA Hiroyuki wrote:
>>> On Tue, 10 Jun 2008 01:32:58 +0200
>>> Andrea Righi <righi.andrea@gmail.com> wrote:
>>>
>>>> Provide distinct cgroup VM overcommit accounting and handling using the memory
>>>> resource controller.
>>>>
>>> Could you explain the benefits of this even when we have memrlimit controller ?
>>> (If unsure, see 2.6.26-rc5-mm1 and search memrlimit controller.)
>>>
>>> And this kind of virtual-address-handling things should be implemented on
>>> memrlimit controller (means not on memory-resource-controller.).
>>> It seems this patch doesn't need to handle page_group.
>>>
>>> Considering hierarchy, putting several kinds of features on one controller is
>>> not good, I think. Balbir, how do you think ?
>>>
>> I would tend to agree. With the memrlimit controller, can't we do this in user
>> space now? Figure out the overcommit value and based on that setup the memrlimit?
> 
> I also agree with Balbir and Kamezawa. Separate controller for VM (i.e. vma-s
> lengths) is more preferable, rather than yet another fancy feature on top of 
> the existing rss one.
> 

Yep! it seems I totally miss the memrlimit controller. I was trying to
implement pretty the same functionalities, using a different approach.
However, I agree that a separate controller seems to be a better
solution.

Thank you all for pointing in the right direction. I'll test memrlimit
controller and give a feedback.

-Andrea

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-06-10  8:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-09 23:32 [RFC PATCH 0/5] memcg: VM overcommit accounting and handling Andrea Righi
2008-06-10  0:14 ` KAMEZAWA Hiroyuki
2008-06-10  5:13   ` Balbir Singh
2008-06-10  7:52     ` Pavel Emelyanov
2008-06-10  8:30       ` Andrea Righi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox