diff options
author | Rik van Riel <riel@redhat.com> | 2008-10-18 23:26:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 11:50:25 -0400 |
commit | 68a22394c286a2daf06ee8d65d8835f738faefa5 (patch) | |
tree | 1fb91d5bf57a1f6d1cabaac0a6f5d86060ebecb5 /mm/swap.c | |
parent | f04e9ebbe4909f9a41efd55149bc353299f4e83b (diff) |
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>
Diffstat (limited to 'mm/swap.c')
-rw-r--r-- | mm/swap.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -428,6 +428,30 @@ void pagevec_strip(struct pagevec *pvec) | |||
428 | } | 428 | } |
429 | 429 | ||
430 | /** | 430 | /** |
431 | * pagevec_swap_free - try to free swap space from the pages in a pagevec | ||
432 | * @pvec: pagevec with swapcache pages to free the swap space of | ||
433 | * | ||
434 | * The caller needs to hold an extra reference to each page and | ||
435 | * not hold the page lock on the pages. This function uses a | ||
436 | * trylock on the page lock so it may not always free the swap | ||
437 | * space associated with a page. | ||
438 | */ | ||
439 | void pagevec_swap_free(struct pagevec *pvec) | ||
440 | { | ||
441 | int i; | ||
442 | |||
443 | for (i = 0; i < pagevec_count(pvec); i++) { | ||
444 | struct page *page = pvec->pages[i]; | ||
445 | |||
446 | if (PageSwapCache(page) && trylock_page(page)) { | ||
447 | if (PageSwapCache(page)) | ||
448 | remove_exclusive_swap_page_ref(page); | ||
449 | unlock_page(page); | ||
450 | } | ||
451 | } | ||
452 | } | ||
453 | |||
454 | /** | ||
431 | * pagevec_lookup - gang pagecache lookup | 455 | * pagevec_lookup - gang pagecache lookup |
432 | * @pvec: Where the resulting pages are placed | 456 | * @pvec: Where the resulting pages are placed |
433 | * @mapping: The address_space to search | 457 | * @mapping: The address_space to search |