diff options
author | Hugh Dickins <hughd@google.com> | 2014-07-02 18:22:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-07-03 12:21:54 -0400 |
commit | 66d2f4d28cd030220e7ea2a628993fcabcb956d1 (patch) | |
tree | 5aaf41f53d21b5c15f7f778f0c8735a0dbbf1a81 /mm | |
parent | d18bbc215f81710e1eab7120becafa910554d68d (diff) |
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 2457aec63745 ("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: Hugh Dickins <hughd@google.com>
Acked-by: Mel 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/shmem.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 8f419cff9e34..1140f49b6ded 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -1029,6 +1029,9 @@ repeat: | |||
1029 | goto failed; | 1029 | goto failed; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | if (page && sgp == SGP_WRITE) | ||
1033 | mark_page_accessed(page); | ||
1034 | |||
1032 | /* fallocated page? */ | 1035 | /* fallocated page? */ |
1033 | if (page && !PageUptodate(page)) { | 1036 | if (page && !PageUptodate(page)) { |
1034 | if (sgp != SGP_READ) | 1037 | if (sgp != SGP_READ) |
@@ -1110,6 +1113,9 @@ repeat: | |||
1110 | shmem_recalc_inode(inode); | 1113 | shmem_recalc_inode(inode); |
1111 | spin_unlock(&info->lock); | 1114 | spin_unlock(&info->lock); |
1112 | 1115 | ||
1116 | if (sgp == SGP_WRITE) | ||
1117 | mark_page_accessed(page); | ||
1118 | |||
1113 | delete_from_swap_cache(page); | 1119 | delete_from_swap_cache(page); |
1114 | set_page_dirty(page); | 1120 | set_page_dirty(page); |
1115 | swap_free(swap); | 1121 | swap_free(swap); |
@@ -1136,6 +1142,9 @@ repeat: | |||
1136 | 1142 | ||
1137 | __SetPageSwapBacked(page); | 1143 | __SetPageSwapBacked(page); |
1138 | __set_page_locked(page); | 1144 | __set_page_locked(page); |
1145 | if (sgp == SGP_WRITE) | ||
1146 | init_page_accessed(page); | ||
1147 | |||
1139 | error = mem_cgroup_charge_file(page, current->mm, | 1148 | error = mem_cgroup_charge_file(page, current->mm, |
1140 | gfp & GFP_RECLAIM_MASK); | 1149 | gfp & GFP_RECLAIM_MASK); |
1141 | if (error) | 1150 | if (error) |
@@ -1412,13 +1421,9 @@ shmem_write_begin(struct file *file, struct address_space *mapping, | |||
1412 | loff_t pos, unsigned len, unsigned flags, | 1421 | loff_t pos, unsigned len, unsigned flags, |
1413 | struct page **pagep, void **fsdata) | 1422 | struct page **pagep, void **fsdata) |
1414 | { | 1423 | { |
1415 | int ret; | ||
1416 | struct inode *inode = mapping->host; | 1424 | struct inode *inode = mapping->host; |
1417 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; | 1425 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; |
1418 | ret = shmem_getpage(inode, index, pagep, SGP_WRITE, NULL); | 1426 | return shmem_getpage(inode, index, pagep, SGP_WRITE, NULL); |
1419 | if (ret == 0 && *pagep) | ||
1420 | init_page_accessed(*pagep); | ||
1421 | return ret; | ||
1422 | } | 1427 | } |
1423 | 1428 | ||
1424 | static int | 1429 | static int |