X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=mm%2Fswapfile.c;h=d1ade1a48ee7b962852c7645bc08b15c67924050;hb=038cbcf65fd6a30c79e3917690b8c46321a27915;hp=28faa01cf578bd1bc05fa20771015194fd966e4d;hpb=312cec5d094a5d4e68434ace4c5cb55e4f8dfee5;p=mv-sheeva.git diff --git a/mm/swapfile.c b/mm/swapfile.c index 28faa01cf57..d1ade1a48ee 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -583,8 +583,9 @@ static int swap_entry_free(struct swap_info_struct *p, swap_list.next = p - swap_info; nr_swap_pages++; p->inuse_pages--; - mem_cgroup_uncharge_swap(ent); } + if (!swap_count(count)) + mem_cgroup_uncharge_swap(ent); return count; } @@ -609,12 +610,19 @@ void swap_free(swp_entry_t entry) void swapcache_free(swp_entry_t entry, struct page *page) { struct swap_info_struct *p; + int ret; - if (page) - mem_cgroup_uncharge_swapcache(page, entry); p = swap_info_get(entry); if (p) { - swap_entry_free(p, entry, SWAP_CACHE); + ret = swap_entry_free(p, entry, SWAP_CACHE); + if (page) { + bool swapout; + if (ret) + swapout = true; /* the end of swap out */ + else + swapout = false; /* no more swap users! */ + mem_cgroup_uncharge_swapcache(page, entry, swapout); + } spin_unlock(&swap_lock); } return;