[PATCH] 2.4.5-pre2 mm/filemap.c

From: Rik van Riel (riel@conectiva.com.br)
Date: Tue May 15 2001 - 20:33:22 EST


Hi Linus,

here are a filemap.c fix and a slight addition, with the first
fix changed as discussed by email.
 
1) __find_page_nolock should only set the referenced bit
   on an active page, otherwise a number of subsequent
   reads from the same page within one page scan interval
   can SEVERELY mess up page aging to the disadvantage of
   the other pages in the system ...
   just setting the referenced bit on the page makes the
   aging a lot fairer
 
2) in drop_behind() we first increase the page age and
   will then proceed to deactivate the page again; better
   have a simpler help function for this ... note that this
   help function could also be used for eg. ->writepage()
   write clustering code

Rik

--
Virtual memory is like a game you can't win;
However, without VM there's truly nothing to lose...

http://www.surriel.com/ http://distro.conectiva.com/

Send all your spam to aardvark@nl.linux.org (spam digging piggy)

--- linux-2.4.5-pre2/mm/filemap.c.orig Tue May 15 22:00:15 2001 +++ linux-2.4.5-pre2/mm/filemap.c Tue May 15 22:08:04 2001 @@ -284,6 +284,34 @@ spin_unlock(&pagecache_lock); } +/* + * This function is pretty much like __find_page_nolock(), but it only + * requires 2 arguments and doesn't mark the page as touched, making it + * ideal for ->writepage() clustering and other places where you don't + * want to mark the page referenced. + * + * The caller needs to hold the pagecache_lock. + */ +struct page * __find_page_simple(struct address_space *mapping, unsigned long index) +{ + struct page * page = *page_hash(mapping, index); + goto inside; + + for (;;) { + page = page->next_hash; +inside: + if (!page) + goto not_found; + if (page->mapping != mapping) + continue; + if (page->index == index) + break; + } + +not_found: + return page; +} + static inline struct page * __find_page_nolock(struct address_space *mapping, unsigned long offset, struct page *page) { goto inside; @@ -298,14 +326,9 @@ if (page->index == offset) break; } - /* - * Touching the page may move it to the active list. - * If we end up with too few inactive pages, we wake - * up kswapd. - */ - age_page_up(page); - if (inactive_shortage() > inactive_target / 2 && free_shortage()) - wakeup_kswapd(); + /* Mark the page referenced, kswapd will find it later. */ + SetPageReferenced(page); + not_found: return page; } @@ -762,7 +785,6 @@ { struct inode *inode = file->f_dentry->d_inode; struct address_space *mapping = inode->i_mapping; - struct page **hash; struct page *page; unsigned long start; @@ -783,8 +805,7 @@ */ spin_lock(&pagecache_lock); while (--index >= start) { - hash = page_hash(mapping, index); - page = __find_page_nolock(mapping, index, *hash); + page = __find_page_simple(mapping, index); if (!page) break; deactivate_page(page);

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 15 2001 - 21:00:47 EST