LWN.net Logo

hot-n-cold pages: use cold pages for readahead

From:  Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
To:  BK Commits List:;
Subject:  [PATCH] hot-n-cold pages: use cold pages for readahead
Date:  Wed, 30 Oct 2002 23:36:03 +0000

ChangeSet 1.910, 2002/10/30 15:36:03-08:00, akpm@digeo.com

	[PATCH] hot-n-cold pages: use cold pages for readahead
	
	It is usually the case that pagecache reads use busmastering hardware
	to transfer the data into pagecache.  This invalidates the CPU cache of
	the pagecache pages.
	
	So use cache-cold pages for pagecache reads.  To avoid wasting
	cache-hot pages.


# This patch includes the following deltas:
#	           ChangeSet	1.909   -> 1.910  
#	include/linux/pagemap.h	1.28    -> 1.29   
#	      mm/readahead.c	1.18    -> 1.19   
#	        mm/filemap.c	1.151   -> 1.152  
#

 include/linux/pagemap.h |    5 +++++
 mm/filemap.c            |    6 +++---
 mm/readahead.c          |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)


diff -Nru a/include/linux/pagemap.h b/include/linux/pagemap.h
--- a/include/linux/pagemap.h	Wed Oct 30 16:21:58 2002
+++ b/include/linux/pagemap.h	Wed Oct 30 16:21:58 2002
@@ -31,6 +31,11 @@
 	return alloc_pages(x->gfp_mask, 0);
 }
 
+static inline struct page *page_cache_alloc_cold(struct address_space *x)
+{
+	return alloc_pages(x->gfp_mask|__GFP_COLD, 0);
+}
+
 typedef int filler_t(void *, struct page *);
 
 extern struct page * find_get_page(struct address_space *mapping,
diff -Nru a/mm/filemap.c b/mm/filemap.c
--- a/mm/filemap.c	Wed Oct 30 16:21:58 2002
+++ b/mm/filemap.c	Wed Oct 30 16:21:58 2002
@@ -258,7 +258,7 @@
 	struct page *page; 
 	int error;
 
-	page = page_cache_alloc(mapping);
+	page = page_cache_alloc_cold(mapping);
 	if (!page)
 		return -ENOMEM;
 
@@ -705,7 +705,7 @@
 		 * page..
 		 */
 		if (!cached_page) {
-			cached_page = page_cache_alloc(mapping);
+			cached_page = page_cache_alloc_cold(mapping);
 			if (!cached_page) {
 				desc->error = -ENOMEM;
 				break;
@@ -1199,7 +1199,7 @@
 	page = find_get_page(mapping, index);
 	if (!page) {
 		if (!cached_page) {
-			cached_page = page_cache_alloc(mapping);
+			cached_page = page_cache_alloc_cold(mapping);
 			if (!cached_page)
 				return ERR_PTR(-ENOMEM);
 		}
diff -Nru a/mm/readahead.c b/mm/readahead.c
--- a/mm/readahead.c	Wed Oct 30 16:21:58 2002
+++ b/mm/readahead.c	Wed Oct 30 16:21:58 2002
@@ -176,7 +176,7 @@
 			continue;
 
 		read_unlock(&mapping->page_lock);
-		page = page_cache_alloc(mapping);
+		page = page_cache_alloc_cold(mapping);
 		read_lock(&mapping->page_lock);
 		if (!page)
 			break;
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Copyright © 2002, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds