* [PATCH 1/2] shmem: fix init_page_accessed use to stop !PageLRU bug
@ 2014-06-30 21:08 Hugh Dickins
2014-06-30 21:09 ` [PATCH 2/2] mm: replace init_page_accessed by __SetPageReferenced Hugh Dickins
2014-06-30 22:00 ` [PATCH 1/2] shmem: fix init_page_accessed use to stop !PageLRU bug Mel Gorman
0 siblings, 2 replies; 4+ messages in thread
From: Hugh Dickins @ 2014-06-30 21:08 UTC (permalink / raw)
To: Mel Gorman; +Cc: Andrew Morton, linux-mm, linux-kernel
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>
---
mm/shmem.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
--- 3.16-rc3/mm/shmem.c 2014-06-29 15:22:10.592003936 -0700
+++ linux/mm/shmem.c 2014-06-30 12:15:52.204093217 -0700
@@ -1029,6 +1029,9 @@ repeat:
goto failed;
}
+ if (page && sgp == SGP_WRITE)
+ mark_page_accessed(page);
+
/* fallocated page? */
if (page && !PageUptodate(page)) {
if (sgp != SGP_READ)
@@ -1110,6 +1113,9 @@ repeat:
shmem_recalc_inode(inode);
spin_unlock(&info->lock);
+ if (sgp == SGP_WRITE)
+ mark_page_accessed(page);
+
delete_from_swap_cache(page);
set_page_dirty(page);
swap_free(swap);
@@ -1136,6 +1142,9 @@ repeat:
__SetPageSwapBacked(page);
__set_page_locked(page);
+ if (sgp == SGP_WRITE)
+ init_page_accessed(page);
+
error = mem_cgroup_charge_file(page, current->mm,
gfp & GFP_RECLAIM_MASK);
if (error)
@@ -1412,13 +1421,9 @@ shmem_write_begin(struct file *file, str
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{
- int ret;
struct inode *inode = mapping->host;
pgoff_t index = pos >> PAGE_CACHE_SHIFT;
- ret = shmem_getpage(inode, index, pagep, SGP_WRITE, NULL);
- if (ret == 0 && *pagep)
- init_page_accessed(*pagep);
- return ret;
+ return shmem_getpage(inode, index, pagep, SGP_WRITE, NULL);
}
static int
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] mm: replace init_page_accessed by __SetPageReferenced
2014-06-30 21:08 [PATCH 1/2] shmem: fix init_page_accessed use to stop !PageLRU bug Hugh Dickins
@ 2014-06-30 21:09 ` Hugh Dickins
2014-06-30 21:59 ` Mel Gorman
2014-06-30 22:00 ` [PATCH 1/2] shmem: fix init_page_accessed use to stop !PageLRU bug Mel Gorman
1 sibling, 1 reply; 4+ messages in thread
From: Hugh Dickins @ 2014-06-30 21:09 UTC (permalink / raw)
To: Mel Gorman; +Cc: Andrew Morton, linux-mm, linux-kernel
Do we really need an exported alias for __SetPageReferenced()?
Its callers better know what they're doing, in which case the page
would not be already marked referenced. Kill init_page_accessed(),
just __SetPageReferenced() inline.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
include/linux/swap.h | 1 -
mm/filemap.c | 4 ++--
mm/shmem.c | 2 +-
mm/swap.c | 14 +++-----------
4 files changed, 6 insertions(+), 15 deletions(-)
--- 3.16-rc3+/include/linux/swap.h 2014-06-16 00:28:54.916076526 -0700
+++ linux/include/linux/swap.h 2014-06-30 12:55:35.216149853 -0700
@@ -311,7 +311,6 @@ extern void lru_add_page_tail(struct pag
struct lruvec *lruvec, struct list_head *head);
extern void activate_page(struct page *);
extern void mark_page_accessed(struct page *);
-extern void init_page_accessed(struct page *page);
extern void lru_add_drain(void);
extern void lru_add_drain_cpu(int cpu);
extern void lru_add_drain_all(void);
--- 3.16-rc3+/mm/filemap.c 2014-06-16 00:28:55.100076530 -0700
+++ linux/mm/filemap.c 2014-06-30 12:55:35.216149853 -0700
@@ -1100,9 +1100,9 @@ no_page:
if (WARN_ON_ONCE(!(fgp_flags & FGP_LOCK)))
fgp_flags |= FGP_LOCK;
- /* Init accessed so avoit atomic mark_page_accessed later */
+ /* Init accessed so avoid atomic mark_page_accessed later */
if (fgp_flags & FGP_ACCESSED)
- init_page_accessed(page);
+ __SetPageReferenced(page);
err = add_to_page_cache_lru(page, mapping, offset, radix_gfp_mask);
if (unlikely(err)) {
--- 3.16-rc3+/mm/shmem.c 2014-06-30 12:15:52.204093217 -0700
+++ linux/mm/shmem.c 2014-06-30 12:55:35.216149853 -0700
@@ -1143,7 +1143,7 @@ repeat:
__SetPageSwapBacked(page);
__set_page_locked(page);
if (sgp == SGP_WRITE)
- init_page_accessed(page);
+ __SetPageReferenced(page);
error = mem_cgroup_charge_file(page, current->mm,
gfp & GFP_RECLAIM_MASK);
--- 3.16-rc3+/mm/swap.c 2014-06-16 00:28:55.132076531 -0700
+++ linux/mm/swap.c 2014-06-30 12:55:35.216149853 -0700
@@ -589,6 +589,9 @@ static void __lru_cache_activate_page(st
* inactive,unreferenced -> inactive,referenced
* inactive,referenced -> active,unreferenced
* active,unreferenced -> active,referenced
+ *
+ * When a newly allocated page is not yet visible, so safe for non-atomic ops,
+ * __SetPageReferenced(page) may be substituted for mark_page_accessed(page).
*/
void mark_page_accessed(struct page *page)
{
@@ -614,17 +617,6 @@ void mark_page_accessed(struct page *pag
}
EXPORT_SYMBOL(mark_page_accessed);
-/*
- * Used to mark_page_accessed(page) that is not visible yet and when it is
- * still safe to use non-atomic ops
- */
-void init_page_accessed(struct page *page)
-{
- if (!PageReferenced(page))
- __SetPageReferenced(page);
-}
-EXPORT_SYMBOL(init_page_accessed);
-
static void __lru_cache_add(struct page *page)
{
struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mm: replace init_page_accessed by __SetPageReferenced
2014-06-30 21:09 ` [PATCH 2/2] mm: replace init_page_accessed by __SetPageReferenced Hugh Dickins
@ 2014-06-30 21:59 ` Mel Gorman
0 siblings, 0 replies; 4+ messages in thread
From: Mel Gorman @ 2014-06-30 21:59 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Andrew Morton, linux-mm, linux-kernel
On Mon, Jun 30, 2014 at 02:09:49PM -0700, Hugh Dickins wrote:
> Do we really need an exported alias for __SetPageReferenced()?
> Its callers better know what they're doing, in which case the page
> would not be already marked referenced. Kill init_page_accessed(),
> just __SetPageReferenced() inline.
>
> Signed-off-by: Hugh Dickins <hughd@google.com>
Ok, fair enough. The context it was written in was that callers should not
need to know the internals of what mark_page_accessed does. Initially I
thought there might be filesystem users that really should not know the
internals but that is not necessary obviously. I still feel that
init_page_accessed shows the intent more clearly and you're certainly
right that the checking PageReferenced is redundant. I don't object to
the patch but I don't think it's obviously better either other than it
avoids the temptation of anyone using __SetPageReferenced incorrectly.
Acked-by: Mel Gorman <mgorman@suse.de>
--
Mel Gorman
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] shmem: fix init_page_accessed use to stop !PageLRU bug
2014-06-30 21:08 [PATCH 1/2] shmem: fix init_page_accessed use to stop !PageLRU bug Hugh Dickins
2014-06-30 21:09 ` [PATCH 2/2] mm: replace init_page_accessed by __SetPageReferenced Hugh Dickins
@ 2014-06-30 22:00 ` Mel Gorman
1 sibling, 0 replies; 4+ messages in thread
From: Mel Gorman @ 2014-06-30 22:00 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Andrew Morton, linux-mm, linux-kernel
On Mon, Jun 30, 2014 at 02:08:11PM -0700, Hugh Dickins wrote:
> 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>
--
Mel Gorman
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-30 22:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-30 21:08 [PATCH 1/2] shmem: fix init_page_accessed use to stop !PageLRU bug Hugh Dickins
2014-06-30 21:09 ` [PATCH 2/2] mm: replace init_page_accessed by __SetPageReferenced Hugh Dickins
2014-06-30 21:59 ` Mel Gorman
2014-06-30 22:00 ` [PATCH 1/2] shmem: fix init_page_accessed use to stop !PageLRU bug Mel Gorman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).