vmscan: free swap space on swap-in/activation
If vm_swap_full() (swap space more than 50% full), the system will free swap space at swapin time. With this patch, the system will also free the swap space in the pageout code, when we decide that the page is not a candidate for swapout (and just wasting swap space). Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Lee Schermerhorn <Lee.Schermerhorn@hp.com> Signed-off-by: MinChan Kim <minchan.kim@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
f04e9ebbe4
commit
68a22394c2
@@ -647,6 +647,9 @@ free_it:
|
||||
continue;
|
||||
|
||||
activate_locked:
|
||||
/* Not a candidate for swapping, so reclaim swap space. */
|
||||
if (PageSwapCache(page) && vm_swap_full())
|
||||
remove_exclusive_swap_page_ref(page);
|
||||
SetPageActive(page);
|
||||
pgactivate++;
|
||||
keep_locked:
|
||||
@@ -1228,6 +1231,8 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
|
||||
__mod_zone_page_state(zone, NR_ACTIVE, pgmoved);
|
||||
pgmoved = 0;
|
||||
spin_unlock_irq(&zone->lru_lock);
|
||||
if (vm_swap_full())
|
||||
pagevec_swap_free(&pvec);
|
||||
__pagevec_release(&pvec);
|
||||
spin_lock_irq(&zone->lru_lock);
|
||||
}
|
||||
@@ -1237,6 +1242,8 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
|
||||
__count_zone_vm_events(PGREFILL, zone, pgscanned);
|
||||
__count_vm_events(PGDEACTIVATE, pgdeactivate);
|
||||
spin_unlock_irq(&zone->lru_lock);
|
||||
if (vm_swap_full())
|
||||
pagevec_swap_free(&pvec);
|
||||
|
||||
pagevec_release(&pvec);
|
||||
}
|
||||
|
Reference in New Issue
Block a user