aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 1e7a715a3866..0579d9069b61 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -471,8 +471,9 @@ out:
471 return NULL; 471 return NULL;
472} 472}
473 473
474static int swap_entry_free(struct swap_info_struct *p, unsigned long offset) 474static int swap_entry_free(struct swap_info_struct *p, swp_entry_t ent)
475{ 475{
476 unsigned long offset = swp_offset(ent);
476 int count = p->swap_map[offset]; 477 int count = p->swap_map[offset];
477 478
478 if (count < SWAP_MAP_MAX) { 479 if (count < SWAP_MAP_MAX) {
@@ -487,6 +488,7 @@ static int swap_entry_free(struct swap_info_struct *p, unsigned long offset)
487 swap_list.next = p - swap_info; 488 swap_list.next = p - swap_info;
488 nr_swap_pages++; 489 nr_swap_pages++;
489 p->inuse_pages--; 490 p->inuse_pages--;
491 mem_cgroup_uncharge_swap(ent);
490 } 492 }
491 } 493 }
492 return count; 494 return count;
@@ -502,7 +504,7 @@ void swap_free(swp_entry_t entry)
502 504
503 p = swap_info_get(entry); 505 p = swap_info_get(entry);
504 if (p) { 506 if (p) {
505 swap_entry_free(p, swp_offset(entry)); 507 swap_entry_free(p, entry);
506 spin_unlock(&swap_lock); 508 spin_unlock(&swap_lock);
507 } 509 }
508} 510}
@@ -582,7 +584,7 @@ int free_swap_and_cache(swp_entry_t entry)
582 584
583 p = swap_info_get(entry); 585 p = swap_info_get(entry);
584 if (p) { 586 if (p) {
585 if (swap_entry_free(p, swp_offset(entry)) == 1) { 587 if (swap_entry_free(p, entry) == 1) {
586 page = find_get_page(&swapper_space, entry.val); 588 page = find_get_page(&swapper_space, entry.val);
587 if (page && !trylock_page(page)) { 589 if (page && !trylock_page(page)) {
588 page_cache_release(page); 590 page_cache_release(page);
@@ -696,7 +698,8 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd,
696 pte_t *pte; 698 pte_t *pte;
697 int ret = 1; 699 int ret = 1;
698 700
699 if (mem_cgroup_try_charge(vma->vm_mm, GFP_HIGHUSER_MOVABLE, &ptr)) 701 if (mem_cgroup_try_charge_swapin(vma->vm_mm, page,
702 GFP_HIGHUSER_MOVABLE, &ptr))
700 ret = -ENOMEM; 703 ret = -ENOMEM;
701 704
702 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 705 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);