Re: [PATCH] mm/filemap.c: unconditionally call mark_page_accessed

From: Chuck Ebbert
Date: Thu Mar 15 2007 - 11:57:39 EST


Ashif Harji wrote:
>
> This patch unconditionally calls mark_page_accessed to prevent pages,
> especially for small files, from being evicted from the page cache
> despite frequent access.
>
> Signed-off-by: Ashif Harji <asharji@xxxxxxxxxxxxxxxxx>
>

I like mine better -- it leaves the comment:


From: Chuck Ebbert <cebbert@xxxxxxxxxx>

Always mark page as accessed when reading multiple times.
Original idea and patch by Ashif Harji <asharji@xxxxxxxxxxxxxxx>

Signed-off-by: Chuck Ebbert <cebbert@xxxxxxxxxx>

--- 2.6.20.2-t.orig/mm/filemap.c
+++ 2.6.20.2-t/mm/filemap.c
@@ -887,7 +887,6 @@
unsigned long offset;
unsigned long last_index;
unsigned long next_index;
- unsigned long prev_index;
loff_t isize;
struct page *cached_page;
int error;
@@ -896,7 +895,6 @@
cached_page = NULL;
index = *ppos >> PAGE_CACHE_SHIFT;
next_index = index;
- prev_index = ra.prev_page;
last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
offset = *ppos & ~PAGE_CACHE_MASK;

@@ -945,11 +943,9 @@

/*
* When (part of) the same page is read multiple times
- * in succession, only mark it as accessed the first time.
+ * in succession, always mark it accessed.
*/
- if (prev_index != index)
- mark_page_accessed(page);
- prev_index = index;
+ mark_page_accessed(page);

/*
* Ok, we have the page, and it's up-to-date, so