aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 28faa01cf578..d1ade1a48ee7 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -583,8 +583,9 @@ static int swap_entry_free(struct swap_info_struct *p,
583 swap_list.next = p - swap_info; 583 swap_list.next = p - swap_info;
584 nr_swap_pages++; 584 nr_swap_pages++;
585 p->inuse_pages--; 585 p->inuse_pages--;
586 mem_cgroup_uncharge_swap(ent);
587 } 586 }
587 if (!swap_count(count))
588 mem_cgroup_uncharge_swap(ent);
588 return count; 589 return count;
589} 590}
590 591
@@ -609,12 +610,19 @@ void swap_free(swp_entry_t entry)
609void swapcache_free(swp_entry_t entry, struct page *page) 610void swapcache_free(swp_entry_t entry, struct page *page)
610{ 611{
611 struct swap_info_struct *p; 612 struct swap_info_struct *p;
613 int ret;
612 614
613 if (page)
614 mem_cgroup_uncharge_swapcache(page, entry);
615 p = swap_info_get(entry); 615 p = swap_info_get(entry);
616 if (p) { 616 if (p) {
617 swap_entry_free(p, entry, SWAP_CACHE); 617 ret = swap_entry_free(p, entry, SWAP_CACHE);
618 if (page) {
619 bool swapout;
620 if (ret)
621 swapout = true; /* the end of swap out */
622 else
623 swapout = false; /* no more swap users! */
624 mem_cgroup_uncharge_swapcache(page, entry, swapout);
625 }
618 spin_unlock(&swap_lock); 626 spin_unlock(&swap_lock);
619 } 627 }
620 return; 628 return;