Commit 5019ce29 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[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.
parent a206231b
...@@ -31,6 +31,11 @@ static inline struct page *page_cache_alloc(struct address_space *x) ...@@ -31,6 +31,11 @@ static inline struct page *page_cache_alloc(struct address_space *x)
return alloc_pages(x->gfp_mask, 0); 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 *); typedef int filler_t(void *, struct page *);
extern struct page * find_get_page(struct address_space *mapping, extern struct page * find_get_page(struct address_space *mapping,
......
...@@ -258,7 +258,7 @@ static int page_cache_read(struct file * file, unsigned long offset) ...@@ -258,7 +258,7 @@ static int page_cache_read(struct file * file, unsigned long offset)
struct page *page; struct page *page;
int error; int error;
page = page_cache_alloc(mapping); page = page_cache_alloc_cold(mapping);
if (!page) if (!page)
return -ENOMEM; return -ENOMEM;
...@@ -705,7 +705,7 @@ void do_generic_mapping_read(struct address_space *mapping, ...@@ -705,7 +705,7 @@ void do_generic_mapping_read(struct address_space *mapping,
* page.. * page..
*/ */
if (!cached_page) { if (!cached_page) {
cached_page = page_cache_alloc(mapping); cached_page = page_cache_alloc_cold(mapping);
if (!cached_page) { if (!cached_page) {
desc->error = -ENOMEM; desc->error = -ENOMEM;
break; break;
...@@ -1199,7 +1199,7 @@ static inline struct page *__read_cache_page(struct address_space *mapping, ...@@ -1199,7 +1199,7 @@ static inline struct page *__read_cache_page(struct address_space *mapping,
page = find_get_page(mapping, index); page = find_get_page(mapping, index);
if (!page) { if (!page) {
if (!cached_page) { if (!cached_page) {
cached_page = page_cache_alloc(mapping); cached_page = page_cache_alloc_cold(mapping);
if (!cached_page) if (!cached_page)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
......
...@@ -176,7 +176,7 @@ int do_page_cache_readahead(struct address_space *mapping, ...@@ -176,7 +176,7 @@ int do_page_cache_readahead(struct address_space *mapping,
continue; continue;
read_unlock(&mapping->page_lock); read_unlock(&mapping->page_lock);
page = page_cache_alloc(mapping); page = page_cache_alloc_cold(mapping);
read_lock(&mapping->page_lock); read_lock(&mapping->page_lock);
if (!page) if (!page)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment