[Devel] [PATCH RHEL7 COMMIT] ms/rmap: rmap_walk: move VM_BUG_ON to rmap_walk_file

Konstantin Khorenko khorenko at virtuozzo.com
Sun Dec 13 22:05:07 PST 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.9.16
------>
commit ccf0ec9df7867d02df90be751a8e8cc49721df70
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Mon Dec 14 10:05:01 2015 +0400

    ms/rmap: rmap_walk: move VM_BUG_ON to rmap_walk_file
    
    After the patches generalizing rmap_walk pulled from upstream recently,
    it is safe to call rmap_walk on anonymous pages, but the stale VM_BUG_ON
    is still there. It was moved out to rmap_walk_file in the scope of
    mainstream commit 9f32624be9435 ("mm/rmap: use rmap_walk() in
    page_referenced()"), but I don't want to pull it, because it's quite
    intrusive. Instead, let's just pull the bits needed to fix the issue.
    
    https://jira.sw.ru/browse/PSBM-42214
    
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 mm/rmap.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 3eda1ed..c97b42d 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1810,6 +1810,14 @@ static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc)
 	struct vm_area_struct *vma;
 	int ret = SWAP_AGAIN;
 
+	/*
+	 * The page lock not only makes sure that page->mapping cannot
+	 * suddenly be NULLified by truncation, it makes sure that the
+	 * structure at mapping cannot be freed and reused yet,
+	 * so we can safely take mapping->i_mmap_mutex.
+	 */
+	VM_BUG_ON(!PageLocked(page));
+
 	if (!mapping)
 		return ret;
 	mutex_lock(&mapping->i_mmap_mutex);
@@ -1841,8 +1849,6 @@ done:
 
 int rmap_walk(struct page *page, struct rmap_walk_control *rwc)
 {
-	VM_BUG_ON(!PageLocked(page));
-
 	if (unlikely(PageKsm(page)))
 		return rmap_walk_ksm(page, rwc);
 	else if (PageAnon(page))


More information about the Devel mailing list