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 <[email protected]> --- mm/rmap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index 3eda1ed12070..c97b42dbcf25 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)) -- 2.1.4 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
