[RFC] [PATCH 1/9] memcg:make root no limit

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: KAMEZAWA Hiroyuki
Date: Thursday, September 11, 2008 - 4:11 am

Make root cgroup of memory resource controller to have no limit.

By this, users cannot set limit to root group. This is for making root cgroup
as a kind of trash-can.

For accounting pages which has no owner, which are created by force_empty,
we need some cgroup with no_limit. A patch for rewriting force_empty will
will follow this one.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

---
 Documentation/controllers/memory.txt |    4 ++++
 mm/memcontrol.c                      |    7 +++++++
 2 files changed, 11 insertions(+)

Index: mmtom-2.6.27-rc5+/mm/memcontrol.c
===================================================================
--- mmtom-2.6.27-rc5+.orig/mm/memcontrol.c
+++ mmtom-2.6.27-rc5+/mm/memcontrol.c
@@ -136,6 +136,9 @@ struct mem_cgroup {
 };
 static struct mem_cgroup init_mem_cgroup;
 
+#define is_root_cgroup(cgrp)	((cgrp) == &init_mem_cgroup)
+
+
 /*
  * We use the lower bit of the page->page_cgroup pointer as a bit spin
  * lock.  We need to ensure that page->page_cgroup is at least two
@@ -937,6 +940,10 @@ static int mem_cgroup_write(struct cgrou
 
 	switch (cft->private) {
 	case RES_LIMIT:
+		if (is_root_cgroup(memcg)) {
+			ret = -EINVAL;
+			break;
+		}
 		/* This function does all necessary parse...reuse it */
 		ret = res_counter_memparse_write_strategy(buffer, &val);
 		if (!ret)
Index: mmtom-2.6.27-rc5+/Documentation/controllers/memory.txt
===================================================================
--- mmtom-2.6.27-rc5+.orig/Documentation/controllers/memory.txt
+++ mmtom-2.6.27-rc5+/Documentation/controllers/memory.txt
@@ -121,6 +121,9 @@ The corresponding routines that remove a
 a page from Page Cache is used to decrement the accounting counters of the
 cgroup.
 
+The root cgroup is not allowed to be set limit but usage is accounted.
+For controlling usage of memory, you need to create a cgroup.
+
 2.3 Shared Page Accounting
 
 Shared pages are accounted on the basis of the first touch approach. The
@@ -172,6 +175,7 @@ We can alter the memory limit:
 
 NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo,
 mega or gigabytes.
+Note: root cgroup is not able to be set limit.
 
 # cat /cgroups/0/memory.limit_in_bytes
 4194304

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC] [PATCH 0/9] remove page_cgroup pointer (with some e ..., KAMEZAWA Hiroyuki, (Thu Sep 11, 4:08 am)
[RFC] [PATCH 1/9] memcg:make root no limit, KAMEZAWA Hiroyuki, (Thu Sep 11, 4:11 am)
[RFC] [PATCH 2/9] memcg: atomic page_cgroup flags, KAMEZAWA Hiroyuki, (Thu Sep 11, 4:13 am)
[RFC] [PATCH 3/9] memcg: move_account between groups, KAMEZAWA Hiroyuki, (Thu Sep 11, 4:14 am)
[RFC] [PATCH 4/9] memcg: new force empty, KAMEZAWA Hiroyuki, (Thu Sep 11, 4:16 am)
[RFC] [PATCH 5/9] memcg: set mapping null before uncharge, KAMEZAWA Hiroyuki, (Thu Sep 11, 4:17 am)
[RFC] [PATCH 6/9] memcg: optimize stat, KAMEZAWA Hiroyuki, (Thu Sep 11, 4:18 am)
[RFC] [PATCH 7/9] memcg: charge likely success, KAMEZAWA Hiroyuki, (Thu Sep 11, 4:20 am)
[RFC] [PATCH 8/9] memcg: remove page_cgroup pointer from m ..., KAMEZAWA Hiroyuki, (Thu Sep 11, 4:22 am)
[RFC] [PATCH 9/9] memcg: percpu page cgroup lookup cache, KAMEZAWA Hiroyuki, (Thu Sep 11, 4:24 am)
Re: [RFC] [PATCH 3/9] memcg: move_account between groups, KAMEZAWA Hiroyuki, (Thu Sep 11, 9:36 pm)
Re: [RFC] [PATCH 0/9] remove page_cgroup pointer (with so ..., KAMEZAWA Hiroyuki, (Fri Sep 12, 2:35 am)
Re: [RFC] [PATCH 0/9] remove page_cgroup pointer (with so ..., KAMEZAWA Hiroyuki, (Fri Sep 12, 3:18 am)
memcg: lazy_lru (was Re: [RFC] [PATCH 8/9] memcg: remove p ..., KAMEZAWA Hiroyuki, (Tue Sep 16, 5:13 am)
[RFC][PATCH 10/9] get/put page at charge/uncharge, KAMEZAWA Hiroyuki, (Tue Sep 16, 5:17 am)
[RFC][PATCH 11/9] lazy lru free vector for memcg, KAMEZAWA Hiroyuki, (Tue Sep 16, 5:19 am)
[RFC] [PATCH 12/9] lazy lru add vie per cpu vector for memcg., KAMEZAWA Hiroyuki, (Tue Sep 16, 5:21 am)
Re: [RFC][PATCH 11/9] lazy lru free vector for memcg, Pavel Emelyanov, (Tue Sep 16, 5:23 am)
Re: Re: [RFC][PATCH 11/9] lazy lru free vector for memcg, kamezawa.hiroyu, (Tue Sep 16, 6:02 am)