diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7d698df4a067..31ab9c3f0178 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -2165,7 +2165,7 @@ static int __cpuinit memcg_cpu_hotplug_callback(struct notifier_block *nb, | |||
2165 | if (action == CPU_ONLINE) | 2165 | if (action == CPU_ONLINE) |
2166 | return NOTIFY_OK; | 2166 | return NOTIFY_OK; |
2167 | 2167 | ||
2168 | if ((action != CPU_DEAD) || action != CPU_DEAD_FROZEN) | 2168 | if (action != CPU_DEAD && action != CPU_DEAD_FROZEN) |
2169 | return NOTIFY_OK; | 2169 | return NOTIFY_OK; |
2170 | 2170 | ||
2171 | for_each_mem_cgroup(iter) | 2171 | for_each_mem_cgroup(iter) |
@@ -2476,10 +2476,10 @@ struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page) | |||
2476 | static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg, | 2476 | static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg, |
2477 | struct page *page, | 2477 | struct page *page, |
2478 | unsigned int nr_pages, | 2478 | unsigned int nr_pages, |
2479 | struct page_cgroup *pc, | ||
2480 | enum charge_type ctype, | 2479 | enum charge_type ctype, |
2481 | bool lrucare) | 2480 | bool lrucare) |
2482 | { | 2481 | { |
2482 | struct page_cgroup *pc = lookup_page_cgroup(page); | ||
2483 | struct zone *uninitialized_var(zone); | 2483 | struct zone *uninitialized_var(zone); |
2484 | bool was_on_lru = false; | 2484 | bool was_on_lru = false; |
2485 | bool anon; | 2485 | bool anon; |
@@ -2716,7 +2716,6 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, | |||
2716 | { | 2716 | { |
2717 | struct mem_cgroup *memcg = NULL; | 2717 | struct mem_cgroup *memcg = NULL; |
2718 | unsigned int nr_pages = 1; | 2718 | unsigned int nr_pages = 1; |
2719 | struct page_cgroup *pc; | ||
2720 | bool oom = true; | 2719 | bool oom = true; |
2721 | int ret; | 2720 | int ret; |
2722 | 2721 | ||
@@ -2730,11 +2729,10 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, | |||
2730 | oom = false; | 2729 | oom = false; |
2731 | } | 2730 | } |
2732 | 2731 | ||
2733 | pc = lookup_page_cgroup(page); | ||
2734 | ret = __mem_cgroup_try_charge(mm, gfp_mask, nr_pages, &memcg, oom); | 2732 | ret = __mem_cgroup_try_charge(mm, gfp_mask, nr_pages, &memcg, oom); |
2735 | if (ret == -ENOMEM) | 2733 | if (ret == -ENOMEM) |
2736 | return ret; | 2734 | return ret; |
2737 | __mem_cgroup_commit_charge(memcg, page, nr_pages, pc, ctype, false); | 2735 | __mem_cgroup_commit_charge(memcg, page, nr_pages, ctype, false); |
2738 | return 0; | 2736 | return 0; |
2739 | } | 2737 | } |
2740 | 2738 | ||
@@ -2831,16 +2829,13 @@ static void | |||
2831 | __mem_cgroup_commit_charge_swapin(struct page *page, struct mem_cgroup *memcg, | 2829 | __mem_cgroup_commit_charge_swapin(struct page *page, struct mem_cgroup *memcg, |
2832 | enum charge_type ctype) | 2830 | enum charge_type ctype) |
2833 | { | 2831 | { |
2834 | struct page_cgroup *pc; | ||
2835 | |||
2836 | if (mem_cgroup_disabled()) | 2832 | if (mem_cgroup_disabled()) |
2837 | return; | 2833 | return; |
2838 | if (!memcg) | 2834 | if (!memcg) |
2839 | return; | 2835 | return; |
2840 | cgroup_exclude_rmdir(&memcg->css); | 2836 | cgroup_exclude_rmdir(&memcg->css); |
2841 | 2837 | ||
2842 | pc = lookup_page_cgroup(page); | 2838 | __mem_cgroup_commit_charge(memcg, page, 1, ctype, true); |
2843 | __mem_cgroup_commit_charge(memcg, page, 1, pc, ctype, true); | ||
2844 | /* | 2839 | /* |
2845 | * Now swap is on-memory. This means this page may be | 2840 | * Now swap is on-memory. This means this page may be |
2846 | * counted both as mem and swap....double count. | 2841 | * counted both as mem and swap....double count. |
@@ -3298,14 +3293,13 @@ int mem_cgroup_prepare_migration(struct page *page, | |||
3298 | * page. In the case new page is migrated but not remapped, new page's | 3293 | * page. In the case new page is migrated but not remapped, new page's |
3299 | * mapcount will be finally 0 and we call uncharge in end_migration(). | 3294 | * mapcount will be finally 0 and we call uncharge in end_migration(). |
3300 | */ | 3295 | */ |
3301 | pc = lookup_page_cgroup(newpage); | ||
3302 | if (PageAnon(page)) | 3296 | if (PageAnon(page)) |
3303 | ctype = MEM_CGROUP_CHARGE_TYPE_MAPPED; | 3297 | ctype = MEM_CGROUP_CHARGE_TYPE_MAPPED; |
3304 | else if (page_is_file_cache(page)) | 3298 | else if (page_is_file_cache(page)) |
3305 | ctype = MEM_CGROUP_CHARGE_TYPE_CACHE; | 3299 | ctype = MEM_CGROUP_CHARGE_TYPE_CACHE; |
3306 | else | 3300 | else |
3307 | ctype = MEM_CGROUP_CHARGE_TYPE_SHMEM; | 3301 | ctype = MEM_CGROUP_CHARGE_TYPE_SHMEM; |
3308 | __mem_cgroup_commit_charge(memcg, newpage, 1, pc, ctype, false); | 3302 | __mem_cgroup_commit_charge(memcg, newpage, 1, ctype, false); |
3309 | return ret; | 3303 | return ret; |
3310 | } | 3304 | } |
3311 | 3305 | ||
@@ -3392,7 +3386,7 @@ void mem_cgroup_replace_page_cache(struct page *oldpage, | |||
3392 | * the newpage may be on LRU(or pagevec for LRU) already. We lock | 3386 | * the newpage may be on LRU(or pagevec for LRU) already. We lock |
3393 | * LRU while we overwrite pc->mem_cgroup. | 3387 | * LRU while we overwrite pc->mem_cgroup. |
3394 | */ | 3388 | */ |
3395 | __mem_cgroup_commit_charge(memcg, newpage, 1, pc, type, true); | 3389 | __mem_cgroup_commit_charge(memcg, newpage, 1, type, true); |
3396 | } | 3390 | } |
3397 | 3391 | ||
3398 | #ifdef CONFIG_DEBUG_VM | 3392 | #ifdef CONFIG_DEBUG_VM |
@@ -3763,7 +3757,7 @@ move_account: | |||
3763 | goto try_to_free; | 3757 | goto try_to_free; |
3764 | cond_resched(); | 3758 | cond_resched(); |
3765 | /* "ret" should also be checked to ensure all lists are empty. */ | 3759 | /* "ret" should also be checked to ensure all lists are empty. */ |
3766 | } while (memcg->res.usage > 0 || ret); | 3760 | } while (res_counter_read_u64(&memcg->res, RES_USAGE) > 0 || ret); |
3767 | out: | 3761 | out: |
3768 | css_put(&memcg->css); | 3762 | css_put(&memcg->css); |
3769 | return ret; | 3763 | return ret; |
@@ -3778,7 +3772,7 @@ try_to_free: | |||
3778 | lru_add_drain_all(); | 3772 | lru_add_drain_all(); |
3779 | /* try to free all pages in this cgroup */ | 3773 | /* try to free all pages in this cgroup */ |
3780 | shrink = 1; | 3774 | shrink = 1; |
3781 | while (nr_retries && memcg->res.usage > 0) { | 3775 | while (nr_retries && res_counter_read_u64(&memcg->res, RES_USAGE) > 0) { |
3782 | int progress; | 3776 | int progress; |
3783 | 3777 | ||
3784 | if (signal_pending(current)) { | 3778 | if (signal_pending(current)) { |