diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 7 | ||||
-rw-r--r-- | mm/memory.c | 11 |
2 files changed, 10 insertions, 8 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a7ecf23150c5..0ed61e27d526 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1169,10 +1169,11 @@ void mem_cgroup_commit_charge_swapin(struct page *page, struct mem_cgroup *ptr) | |||
1169 | /* | 1169 | /* |
1170 | * Now swap is on-memory. This means this page may be | 1170 | * Now swap is on-memory. This means this page may be |
1171 | * counted both as mem and swap....double count. | 1171 | * counted both as mem and swap....double count. |
1172 | * Fix it by uncharging from memsw. This SwapCache is stable | 1172 | * Fix it by uncharging from memsw. Basically, this SwapCache is stable |
1173 | * because we're still under lock_page(). | 1173 | * under lock_page(). But in do_swap_page()::memory.c, reuse_swap_page() |
1174 | * may call delete_from_swap_cache() before reach here. | ||
1174 | */ | 1175 | */ |
1175 | if (do_swap_account) { | 1176 | if (do_swap_account && PageSwapCache(page)) { |
1176 | swp_entry_t ent = {.val = page_private(page)}; | 1177 | swp_entry_t ent = {.val = page_private(page)}; |
1177 | struct mem_cgroup *memcg; | 1178 | struct mem_cgroup *memcg; |
1178 | memcg = swap_cgroup_record(ent, NULL); | 1179 | memcg = swap_cgroup_record(ent, NULL); |
diff --git a/mm/memory.c b/mm/memory.c index e5bfbe6b594c..e009ce870859 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -2457,22 +2457,23 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma, | |||
2457 | * while the page is counted on swap but not yet in mapcount i.e. | 2457 | * while the page is counted on swap but not yet in mapcount i.e. |
2458 | * before page_add_anon_rmap() and swap_free(); try_to_free_swap() | 2458 | * before page_add_anon_rmap() and swap_free(); try_to_free_swap() |
2459 | * must be called after the swap_free(), or it will never succeed. | 2459 | * must be called after the swap_free(), or it will never succeed. |
2460 | * And mem_cgroup_commit_charge_swapin(), which uses the swp_entry | 2460 | * Because delete_from_swap_page() may be called by reuse_swap_page(), |
2461 | * in page->private, must be called before reuse_swap_page(), | 2461 | * mem_cgroup_commit_charge_swapin() may not be able to find swp_entry |
2462 | * which may delete_from_swap_cache(). | 2462 | * in page->private. In this case, a record in swap_cgroup is silently |
2463 | * discarded at swap_free(). | ||
2463 | */ | 2464 | */ |
2464 | 2465 | ||
2465 | mem_cgroup_commit_charge_swapin(page, ptr); | ||
2466 | inc_mm_counter(mm, anon_rss); | 2466 | inc_mm_counter(mm, anon_rss); |
2467 | pte = mk_pte(page, vma->vm_page_prot); | 2467 | pte = mk_pte(page, vma->vm_page_prot); |
2468 | if (write_access && reuse_swap_page(page)) { | 2468 | if (write_access && reuse_swap_page(page)) { |
2469 | pte = maybe_mkwrite(pte_mkdirty(pte), vma); | 2469 | pte = maybe_mkwrite(pte_mkdirty(pte), vma); |
2470 | write_access = 0; | 2470 | write_access = 0; |
2471 | } | 2471 | } |
2472 | |||
2473 | flush_icache_page(vma, page); | 2472 | flush_icache_page(vma, page); |
2474 | set_pte_at(mm, address, page_table, pte); | 2473 | set_pte_at(mm, address, page_table, pte); |
2475 | page_add_anon_rmap(page, vma, address); | 2474 | page_add_anon_rmap(page, vma, address); |
2475 | /* It's better to call commit-charge after rmap is established */ | ||
2476 | mem_cgroup_commit_charge_swapin(page, ptr); | ||
2476 | 2477 | ||
2477 | swap_free(entry); | 2478 | swap_free(entry); |
2478 | if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page)) | 2479 | if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page)) |