From: Jan Kara <jack@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, Al Viro <viro@ZenIV.linux.org.uk>,
mszeredi@suse.cz, Jan Kara <jack@suse.cz>,
Jay <jinshan.xiong@whamcloud.com>,
stable@kernel.org
Subject: [PATCH] mm: Fix assertion mapping->nrpages == 0 in end_writeback()
Date: Mon, 30 May 2011 11:37:38 +0200 [thread overview]
Message-ID: <1306748258-4732-1-git-send-email-jack@suse.cz> (raw)
Under heavy memory and filesystem load, users observe the assertion
mapping->nrpages == 0 in end_writeback() trigger. This can be caused
by page reclaim reclaiming the last page from a mapping in the following
race:
CPU0 CPU1
...
shrink_page_list()
__remove_mapping()
__delete_from_page_cache()
radix_tree_delete()
evict_inode()
truncate_inode_pages()
truncate_inode_pages_range()
pagevec_lookup() - finds nothing
end_writeback()
mapping->nrpages != 0 -> BUG
page->mapping = NULL
mapping->nrpages--
Fix the problem by cycling the mapping->tree_lock at the end of
truncate_inode_pages_range() to synchronize with page reclaim.
Analyzed by Jay <jinshan.xiong@whamcloud.com>, lost in LKML, and dug
out by Miklos Szeredi <mszeredi@suse.de>.
CC: Jay <jinshan.xiong@whamcloud.com>
CC: stable@kernel.org
Acked-by: Miklos Szeredi <mszeredi@suse.de>
Signed-off-by: Jan Kara <jack@suse.cz>
---
mm/truncate.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
Andrew, would you merge this patch please? Thanks.
diff --git a/mm/truncate.c b/mm/truncate.c
index a956675..ec3d292 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -291,6 +291,13 @@ void truncate_inode_pages_range(struct address_space *mapping,
pagevec_release(&pvec);
mem_cgroup_uncharge_end();
}
+ /*
+ * Cycle the tree_lock to make sure all __delete_from_page_cache()
+ * calls run from page reclaim have finished as well (this handles the
+ * case when page reclaim took the last page from our range).
+ */
+ spin_lock_irq(&mapping->tree_lock);
+ spin_unlock_irq(&mapping->tree_lock);
}
EXPORT_SYMBOL(truncate_inode_pages_range);
--
1.7.1
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2011-05-30 9:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-30 9:37 Jan Kara [this message]
2011-06-06 22:16 ` [PATCH] mm: Fix assertion mapping->nrpages == 0 in end_writeback() Andrew Morton
2011-06-07 5:46 ` Miklos Szeredi
2011-06-07 18:22 ` Jinshan Xiong
2011-06-08 16:40 ` Jan Kara
2011-06-08 20:10 ` Jinshan Xiong
2011-06-07 21:33 ` Andrew Morton
2011-06-08 16:36 ` Jan Kara
2011-06-13 22:01 ` Jan Kara
2011-06-13 22:14 ` Andrew Morton
2011-06-13 22:49 ` Jan Kara
2011-06-13 22:58 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1306748258-4732-1-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=jinshan.xiong@whamcloud.com \
--cc=linux-mm@kvack.org \
--cc=mszeredi@suse.cz \
--cc=stable@kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).