Commit 5d86cc8b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] tmpfs 4/6: use mark_page_accessed

From: Hugh Dickins <hugh@veritas.com>

tmpfs pages should be surfing the LRUs in the company of their filemap
friends: I was expecting the rules to change, but they've been stable so
long, let's sprinkle mark_page_accessed in the equivalent places here; but
(don't ask me why) SetPageReferenced in shmem_file_write.  Ooh, and
shmem_populate was missing a flush_page_to_ram.
parent f56453c9
...@@ -951,6 +951,7 @@ struct page *shmem_nopage(struct vm_area_struct *vma, unsigned long address, int ...@@ -951,6 +951,7 @@ struct page *shmem_nopage(struct vm_area_struct *vma, unsigned long address, int
if (error) if (error)
return (error == -ENOMEM)? NOPAGE_OOM: NOPAGE_SIGBUS; return (error == -ENOMEM)? NOPAGE_OOM: NOPAGE_SIGBUS;
mark_page_accessed(page);
flush_page_to_ram(page); flush_page_to_ram(page);
return page; return page;
} }
...@@ -978,6 +979,8 @@ static int shmem_populate(struct vm_area_struct *vma, ...@@ -978,6 +979,8 @@ static int shmem_populate(struct vm_area_struct *vma,
if (err) if (err)
return err; return err;
if (page) { if (page) {
mark_page_accessed(page);
flush_page_to_ram(page);
err = install_page(mm, vma, addr, page, prot); err = install_page(mm, vma, addr, page, prot);
if (err) { if (err) {
page_cache_release(page); page_cache_release(page);
...@@ -1192,6 +1195,8 @@ shmem_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos) ...@@ -1192,6 +1195,8 @@ shmem_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
break; break;
} }
if (!PageReferenced(page))
SetPageReferenced(page);
set_page_dirty(page); set_page_dirty(page);
page_cache_release(page); page_cache_release(page);
...@@ -1264,13 +1269,20 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_ ...@@ -1264,13 +1269,20 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_
} }
nr -= offset; nr -= offset;
/* If users can be writing to this page using arbitrary if (page != ZERO_PAGE(0)) {
* virtual addresses, take care about potential aliasing /*
* before reading the page on the kernel side. * If users can be writing to this page using arbitrary
*/ * virtual addresses, take care about potential aliasing
if (!list_empty(&mapping->i_mmap_shared) && * before reading the page on the kernel side.
page != ZERO_PAGE(0)) */
flush_dcache_page(page); if (!list_empty(&mapping->i_mmap_shared))
flush_dcache_page(page);
/*
* Mark the page accessed if we read the beginning.
*/
if (!offset)
mark_page_accessed(page);
}
/* /*
* Ok, we have the page, and it's up-to-date, so * Ok, we have the page, and it's up-to-date, so
...@@ -1523,6 +1535,7 @@ static int shmem_readlink(struct dentry *dentry, char *buffer, int buflen) ...@@ -1523,6 +1535,7 @@ static int shmem_readlink(struct dentry *dentry, char *buffer, int buflen)
return res; return res;
res = vfs_readlink(dentry, buffer, buflen, kmap(page)); res = vfs_readlink(dentry, buffer, buflen, kmap(page));
kunmap(page); kunmap(page);
mark_page_accessed(page);
page_cache_release(page); page_cache_release(page);
return res; return res;
} }
...@@ -1535,6 +1548,7 @@ static int shmem_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -1535,6 +1548,7 @@ static int shmem_follow_link(struct dentry *dentry, struct nameidata *nd)
return res; return res;
res = vfs_follow_link(nd, kmap(page)); res = vfs_follow_link(nd, kmap(page));
kunmap(page); kunmap(page);
mark_page_accessed(page);
page_cache_release(page); page_cache_release(page);
return res; return res;
} }
......
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