aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a7165a60d0a7..b659260c56ad 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2476,10 +2476,10 @@ struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page)
2476static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg, 2476static 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
@@ -4513,6 +4507,12 @@ static void mem_cgroup_usage_unregister_event(struct cgroup *cgrp,
4513swap_buffers: 4507swap_buffers:
4514 /* Swap primary and spare array */ 4508 /* Swap primary and spare array */
4515 thresholds->spare = thresholds->primary; 4509 thresholds->spare = thresholds->primary;
4510 /* If all events are unregistered, free the spare array */
4511 if (!new) {
4512 kfree(thresholds->spare);
4513 thresholds->spare = NULL;
4514 }
4515
4516 rcu_assign_pointer(thresholds->primary, new); 4516 rcu_assign_pointer(thresholds->primary, new);
4517 4517
4518 /* To be sure that nobody uses thresholds */ 4518 /* To be sure that nobody uses thresholds */