shrink_mmap scan speedup
PATCH 1/1 shrink_mmap scan speedup
Hi,
This is a patch against 2.4.0test1-ac7
It will speed up list operations in shrink_mmap,
by not deleting and reinserting every page...
It is not enough to get good interactive feel,
but it is a step on the way.
/RogerL
--
Home page:
http://www.norran.net/nra02596/
filemap.c renamed from filemap.c.orig +37 -7
@@ -317,20 +317,24 @@/* we need pagemap_lru_lock for list_del() ... subtle code below */ spin_lock (&pagemap_lru_lock); -while (count >0 && (page_lru = lru_cache.prev) != &lru_cache) { + page_lru = &lru_cache; +while (count >0 ) { + page_lru = page_lru->prev; +if (page_lru == &lru_cache) +continue ;/* one whole run, all could have had age > 0 */ + page = list_entry(page_lru, struct page, lru); -list_del (page_lru);if (PageTestandClearReferenced (page)) { page->age +=PG_AGE_ADV ;if (page->age >PG_AGE_MAX ) page->age =PG_AGE_MAX ; - goto dispose_continue; +continue ; } page->age -=min (PG_AGE_DECL , page->age);if (page->age) - goto dispose_continue; +continue ; count--;/*
@@ -338,17 +342,39 @@* Don't drop page cache entries in vain. */ if (page->zone->free_pages > page->zone->pages_high) - goto dispose_continue; +continue ;/* * Avoid unscalable SMP locking for pages we can * immediate tell are untouchable.. */ if (!page->buffers &&page_count (page) >1 ) - goto dispose_continue; +continue ;if (TryLockPage (page)) - goto dispose_continue; +continue ; + +/* move header before unlock... +* NOTE: the page to scan might move on while having +* pagemap_lru unlocked. Avoid rescanning pages +* by moving head and removing current. +*/ + +/* +* list_del(&lru_cache); +* list_add_tail(&lru_cache, page_lru); +* list_del(page_lru); +*/ +if (lru_cache.prev == page_lru) { +/* Handle case with only one page on lru... +* also optimize if first page checked is suitable. +*/ +list_del (page_lru); + } +else { +list_del (&lru_cache); +__list_add (&lru_cache, page_lru->prev, page_lru->next); + }/* Release the pagemap_lru lock even if the page is not yet queued in any lru queue since we have just locked down
@@ -432,7 +458,11 @@spin_lock (&pagemap_lru_lock);page_cache_release (page); dispose_continue: +/* page_lru was deleted from list. Reinsert it at _new_ +* lru_cache location +*/ list_add (page_lru, &lru_cache); + page_lru = &lru_cache; } goto out;