提交 66d2f4d2 编写于 作者: H Hugh Dickins 提交者: Linus Torvalds

shmem: fix init_page_accessed use to stop !PageLRU bug

Under shmem swapping load, I sometimes hit the VM_BUG_ON_PAGE(!PageLRU)
in isolate_lru_pages() at mm/vmscan.c:1281!

Commit 2457aec6 ("mm: non-atomically mark page accessed during page
cache allocation where possible") looks like interrupted work-in-progress.

mm/filemap.c's call to init_page_accessed() is fine, but not mm/shmem.c's
- shmem_write_begin() is clearly wrong to use it after shmem_getpage(),
when the page is always visible in radix_tree, and often already on LRU.

Revert change to shmem_write_begin(), and use init_page_accessed() or
mark_page_accessed() appropriately for SGP_WRITE in shmem_getpage_gfp().

SGP_WRITE also covers shmem_symlink(), which did not mark_page_accessed()
before; but since many other filesystems use [__]page_symlink(), which did
and does mark the page accessed, consider this as rectifying an oversight.
Signed-off-by: NHugh Dickins <hughd@google.com>
Acked-by: NMel Gorman <mgorman@suse.de>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Prabhakar Lad <prabhakar.csengg@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 d18bbc21
...@@ -1029,6 +1029,9 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, ...@@ -1029,6 +1029,9 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
goto failed; goto failed;
} }
if (page && sgp == SGP_WRITE)
mark_page_accessed(page);
/* fallocated page? */ /* fallocated page? */
if (page && !PageUptodate(page)) { if (page && !PageUptodate(page)) {
if (sgp != SGP_READ) if (sgp != SGP_READ)
...@@ -1110,6 +1113,9 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, ...@@ -1110,6 +1113,9 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
shmem_recalc_inode(inode); shmem_recalc_inode(inode);
spin_unlock(&info->lock); spin_unlock(&info->lock);
if (sgp == SGP_WRITE)
mark_page_accessed(page);
delete_from_swap_cache(page); delete_from_swap_cache(page);
set_page_dirty(page); set_page_dirty(page);
swap_free(swap); swap_free(swap);
...@@ -1136,6 +1142,9 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, ...@@ -1136,6 +1142,9 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
__SetPageSwapBacked(page); __SetPageSwapBacked(page);
__set_page_locked(page); __set_page_locked(page);
if (sgp == SGP_WRITE)
init_page_accessed(page);
error = mem_cgroup_charge_file(page, current->mm, error = mem_cgroup_charge_file(page, current->mm,
gfp & GFP_RECLAIM_MASK); gfp & GFP_RECLAIM_MASK);
if (error) if (error)
...@@ -1412,13 +1421,9 @@ shmem_write_begin(struct file *file, struct address_space *mapping, ...@@ -1412,13 +1421,9 @@ shmem_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags, loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata) struct page **pagep, void **fsdata)
{ {
int ret;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
pgoff_t index = pos >> PAGE_CACHE_SHIFT; pgoff_t index = pos >> PAGE_CACHE_SHIFT;
ret = shmem_getpage(inode, index, pagep, SGP_WRITE, NULL); return shmem_getpage(inode, index, pagep, SGP_WRITE, NULL);
if (ret == 0 && *pagep)
init_page_accessed(*pagep);
return ret;
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册