diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2009-01-07 21:07:57 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-08 11:31:05 -0500 |
commit | c077719be8e9e6b55702117513d1b5f41d80404a (patch) | |
tree | 3369f02d87390a40f5867d0482972bac506424a8 /mm | |
parent | d13d144309d2e5a3e6ad978b16c1d0226ddc9231 (diff) |
memcg: mem+swap controller Kconfig
Config and control variable for mem+swap controller.
This patch adds CONFIG_CGROUP_MEM_RES_CTLR_SWAP
(memory resource controller swap extension.)
For accounting swap, it's obvious that we have to use additional memory to
remember "who uses swap". This adds more overhead. So, it's better to
offer "choice" to users. This patch adds 2 choices.
This patch adds 2 parameters to enable swap extension or not.
- CONFIG
- boot option
Reviewed-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7288e9d85ca7..59dd8c116372 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -41,6 +41,15 @@ | |||
41 | struct cgroup_subsys mem_cgroup_subsys __read_mostly; | 41 | struct cgroup_subsys mem_cgroup_subsys __read_mostly; |
42 | #define MEM_CGROUP_RECLAIM_RETRIES 5 | 42 | #define MEM_CGROUP_RECLAIM_RETRIES 5 |
43 | 43 | ||
44 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP | ||
45 | /* Turned on only when memory cgroup is enabled && really_do_swap_account = 0 */ | ||
46 | int do_swap_account __read_mostly; | ||
47 | static int really_do_swap_account __initdata = 1; /* for remember boot option*/ | ||
48 | #else | ||
49 | #define do_swap_account (0) | ||
50 | #endif | ||
51 | |||
52 | |||
44 | /* | 53 | /* |
45 | * Statistics for memory cgroup. | 54 | * Statistics for memory cgroup. |
46 | */ | 55 | */ |
@@ -1404,6 +1413,18 @@ static void mem_cgroup_free(struct mem_cgroup *mem) | |||
1404 | } | 1413 | } |
1405 | 1414 | ||
1406 | 1415 | ||
1416 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP | ||
1417 | static void __init enable_swap_cgroup(void) | ||
1418 | { | ||
1419 | if (!mem_cgroup_subsys.disabled && really_do_swap_account) | ||
1420 | do_swap_account = 1; | ||
1421 | } | ||
1422 | #else | ||
1423 | static void __init enable_swap_cgroup(void) | ||
1424 | { | ||
1425 | } | ||
1426 | #endif | ||
1427 | |||
1407 | static struct cgroup_subsys_state * | 1428 | static struct cgroup_subsys_state * |
1408 | mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) | 1429 | mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) |
1409 | { | 1430 | { |
@@ -1419,6 +1440,9 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) | |||
1419 | for_each_node_state(node, N_POSSIBLE) | 1440 | for_each_node_state(node, N_POSSIBLE) |
1420 | if (alloc_mem_cgroup_per_zone_info(mem, node)) | 1441 | if (alloc_mem_cgroup_per_zone_info(mem, node)) |
1421 | goto free_out; | 1442 | goto free_out; |
1443 | /* root ? */ | ||
1444 | if (cont->parent == NULL) | ||
1445 | enable_swap_cgroup(); | ||
1422 | 1446 | ||
1423 | return &mem->css; | 1447 | return &mem->css; |
1424 | free_out: | 1448 | free_out: |
@@ -1490,3 +1514,13 @@ struct cgroup_subsys mem_cgroup_subsys = { | |||
1490 | .attach = mem_cgroup_move_task, | 1514 | .attach = mem_cgroup_move_task, |
1491 | .early_init = 0, | 1515 | .early_init = 0, |
1492 | }; | 1516 | }; |
1517 | |||
1518 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP | ||
1519 | |||
1520 | static int __init disable_swap_account(char *s) | ||
1521 | { | ||
1522 | really_do_swap_account = 0; | ||
1523 | return 1; | ||
1524 | } | ||
1525 | __setup("noswapaccount", disable_swap_account); | ||
1526 | #endif | ||