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

Chuck Ebbert
2007-03-15T15:57:21Z

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

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@beta.uwaterloo.ca>
>

I like mine better -- it leaves the comment:

[-- Attachment #2: linux-2.6-fix_mark_page_accessed.patch --]
[-- Type: text/plain, Size: 1080 bytes --]

From: Chuck Ebbert <cebbert@redhat.com>

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

Signed-off-by: Chuck Ebbert <cebbert@redhat.com>

--- 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