diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9846f617115d..e72fb2b4a7d8 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -471,6 +471,7 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm, | |||
471 | { | 471 | { |
472 | struct mem_cgroup *mem; | 472 | struct mem_cgroup *mem; |
473 | int nr_retries = MEM_CGROUP_RECLAIM_RETRIES; | 473 | int nr_retries = MEM_CGROUP_RECLAIM_RETRIES; |
474 | struct res_counter *fail_res; | ||
474 | /* | 475 | /* |
475 | * We always charge the cgroup the mm_struct belongs to. | 476 | * We always charge the cgroup the mm_struct belongs to. |
476 | * The mm_struct's mem_cgroup changes on task migration if the | 477 | * The mm_struct's mem_cgroup changes on task migration if the |
@@ -499,11 +500,12 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm, | |||
499 | int ret; | 500 | int ret; |
500 | bool noswap = false; | 501 | bool noswap = false; |
501 | 502 | ||
502 | ret = res_counter_charge(&mem->res, PAGE_SIZE); | 503 | ret = res_counter_charge(&mem->res, PAGE_SIZE, &fail_res); |
503 | if (likely(!ret)) { | 504 | if (likely(!ret)) { |
504 | if (!do_swap_account) | 505 | if (!do_swap_account) |
505 | break; | 506 | break; |
506 | ret = res_counter_charge(&mem->memsw, PAGE_SIZE); | 507 | ret = res_counter_charge(&mem->memsw, PAGE_SIZE, |
508 | &fail_res); | ||
507 | if (likely(!ret)) | 509 | if (likely(!ret)) |
508 | break; | 510 | break; |
509 | /* mem+swap counter fails */ | 511 | /* mem+swap counter fails */ |
@@ -1709,22 +1711,26 @@ static void __init enable_swap_cgroup(void) | |||
1709 | static struct cgroup_subsys_state * | 1711 | static struct cgroup_subsys_state * |
1710 | mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) | 1712 | mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) |
1711 | { | 1713 | { |
1712 | struct mem_cgroup *mem; | 1714 | struct mem_cgroup *mem, *parent; |
1713 | int node; | 1715 | int node; |
1714 | 1716 | ||
1715 | mem = mem_cgroup_alloc(); | 1717 | mem = mem_cgroup_alloc(); |
1716 | if (!mem) | 1718 | if (!mem) |
1717 | return ERR_PTR(-ENOMEM); | 1719 | return ERR_PTR(-ENOMEM); |
1718 | 1720 | ||
1719 | res_counter_init(&mem->res); | ||
1720 | res_counter_init(&mem->memsw); | ||
1721 | |||
1722 | for_each_node_state(node, N_POSSIBLE) | 1721 | for_each_node_state(node, N_POSSIBLE) |
1723 | if (alloc_mem_cgroup_per_zone_info(mem, node)) | 1722 | if (alloc_mem_cgroup_per_zone_info(mem, node)) |
1724 | goto free_out; | 1723 | goto free_out; |
1725 | /* root ? */ | 1724 | /* root ? */ |
1726 | if (cont->parent == NULL) | 1725 | if (cont->parent == NULL) { |
1727 | enable_swap_cgroup(); | 1726 | enable_swap_cgroup(); |
1727 | parent = NULL; | ||
1728 | } else | ||
1729 | parent = mem_cgroup_from_cont(cont->parent); | ||
1730 | |||
1731 | res_counter_init(&mem->res, parent ? &parent->res : NULL); | ||
1732 | res_counter_init(&mem->memsw, parent ? &parent->memsw : NULL); | ||
1733 | |||
1728 | 1734 | ||
1729 | return &mem->css; | 1735 | return &mem->css; |
1730 | free_out: | 1736 | free_out: |