free swap space of (re)activated pages
Subsystems (3)
PATCH 1/1 free swap space of (re)activated pages
Hi Andrew,
the attached patch frees the swap space of already resident pages when swap space starts getting tight, instead of only freeing up the swap space taken up by newly swapped in pages.
This should result in the swap space of pages that remain resident in memory being freed, allowing kswapd more chances to actually swap a page out (instead of rotating it back onto the active list).
Signature · 3 lines
Politics is the struggle between those who want to make their country the best in the world, and those who believe it already is. Each group calls the other unpatriotic.
mm/vmscan.c renamed from mm/vmscan.c.swapfree +7 -0
@@ -587,6 +587,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 (page);SetPageActive (page); pgactivate++; keep_locked:
@@ -889,6 +892,8 @@ force_reclaim_mapped:__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); }
@@ -899,6 +904,8 @@ force_reclaim_mapped:__count_vm_events (PGDEACTIVATE , pgdeactivate);spin_unlock_irq (&zone->lru_lock); +if (vm_swap_full ()) +pagevec_swap_free (&pvec);pagevec_release (&pvec); }
mm/swap.c renamed from mm/swap.c.swapfree +20 -0
@@ -420,6 +420,26 @@ void pagevec_strip(struct pagevec *pvec) } } +/* +* Try to free swap space from the pages in a pagevec +*/ +void pagevec_swap_free (struct pagevec *pvec) +{ +int i; + +for (i =0 ; i <pagevec_count (pvec); i++) { +struct page *page = pvec->pages[i]; + +if (PageSwapCache (page) && !TestSetPageLocked (page)) { +if (PageSwapCache (page)) +remove_exclusive_swap_page (page); +unlock_page (page); +if (printk_ratelimit ()) +printk ("kswapd freed a swap space\n" ); + } + } +} +/** * pagevec_lookup - gang pagecache lookup * @pvec: Where the resulting pages are placed
include/linux/pagevec.h renamed from include/linux/pagevec.h.swapfree +1 -0
@@ -26,6 +26,7 @@ void __pagevec_free(struct pagevec *pvecvoid __pagevec_lru_add (struct pagevec *pvec);void __pagevec_lru_add_active (struct pagevec *pvec);void pagevec_strip (struct pagevec *pvec); +void pagevec_swap_free (struct pagevec *pvec);unsigned pagevec_lookup (struct pagevec *pvec,struct address_space *mapping,pgoff_t start,unsigned nr_pages); unsigned pagevec_lookup_tag(struct pagevec *pvec,
Andrew Morton
maintainerQuoted 7 lines · On Fri, 02 Mar 2007 15:31:19 -0500 Rik van Riel <[email protected]> wrote:
the attached patch frees the swap space of already resident pages when swap space starts getting tight, instead of only freeing up the swap space taken up by newly swapped in pages.
This should result in the swap space of pages that remain resident in memory being freed, allowing kswapd more chances to actually swap a page out (instead of rotating it back onto the active list).
Fair enough. How do we work out if this helps things?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Andrew Morton
Quoted 4 lines · On Fri, 02 Mar 2007 15:31:19 -0500 Rik van Riel <[email protected]> wrote:
the attached patch frees the swap space of already resident pages when swap space starts getting tight, instead of only freeing up the swap space taken up by newly swapped in pages.
Quoted 5 lines
Quoted 3 lines
This should result in the swap space of pages that remain resident in memory being freed, allowing kswapd more chances to actually swap a page out (instead of rotating it back onto the active list).
Fair enough. How do we work out if this helps things?
I suspect it should mostly help on desktop systems that slowly fill up (and run out of) swap. I'm not sure how to create that synthetically.
I have seen that swap is kept free much easier in a qsbench test, but that's probably not a very good test since it swaps things in and out all the time...
Signature · 9 lines
Politics is the struggle between those who want to make their country the best in the world, and those who believe it already is. Each group calls the other unpatriotic. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 12 lines · Rik van Riel
Quoted 11 lines · Andrew Morton
On Fri, 02 Mar 2007 15:31:19 -0500
Quoted 7 lines · Rik van Riel
the attached patch frees the swap space of already resident pages when swap space starts getting tight, instead of only freeing up the swap space taken up by newly swapped in pages.
This should result in the swap space of pages that remain resident in memory being freed, allowing kswapd more chances to actually swap a page out (instead of rotating it back onto the active list).
Quoted 5 lines
Quoted 1 line
Fair enough. How do we work out if this helps things?
I suspect it should mostly help on desktop systems that slowly fill up (and run out of) swap. I'm not sure how to create that synthetically.
Ooh you have a vm patch that helps swap on the desktop! I can help you here with my experience from swap prefetch.
1. Get it reviewed and have noone show any evidence it harms
2. Find hundreds of users who can testify it helps
3. Find a way of quantifying it.
4. ...
5. Merge into mainline.
There, that should get you as far as 4.
I haven't figured out what 4 is yet. I believe it may be goto 1;
Signature · 7 lines
-ck -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>