]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - mm/vmscan.c
vmscan: free swap space on swap-in/activation
[net-next-2.6.git] / mm / vmscan.c
index 46fdaa546b8d0493acb74b2b428693d46e0b14b3..e656035d34065d0bb0c857c770940c9acec73b71 100644 (file)
@@ -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);
 }