From: Li Xinhai <lixinhai.lxh@gmail.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, Brian Geffon <bgeffon@google.com>,
Lokesh Gidra <lokeshgidra@google.com>,
Minchan Kim <minchan@kernel.org>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Vlastimil Babka <vbabka@suse.cz>,
Andrea Arcangeli <aarcange@redhat.com>
Subject: [PATCH 2/2] mm: mremap: unlink anon_vmas when mremap with MREMAP_DONTUNMAP success
Date: Tue, 19 Jan 2021 15:51:26 +0800 [thread overview]
Message-ID: <20210119075126.3513154-2-lixinhai.lxh@gmail.com> (raw)
In-Reply-To: <20210119075126.3513154-1-lixinhai.lxh@gmail.com>
mremap with MREMAP_DONTUNMAP will move all page table entries to new vma,
which means all pages allocated for the old vma are not relevant to it
anymore, and the relevant anon_vma links needs to be unlinked, in nature
the old vma is much like been freshly created and have no pages been
fault in.
But we should not do unlink, if the new vma has effectively merged with
the old one.
Cc: Brian Geffon <bgeffon@google.com>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
---
mm/mremap.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mm/mremap.c b/mm/mremap.c
index f554320281cc..7745b672e1a6 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -595,6 +595,13 @@ static unsigned long move_vma(struct vm_area_struct *vma,
/* We always clear VM_LOCKED[ONFAULT] on the old vma */
vma->vm_flags &= VM_LOCKED_CLEAR_MASK;
+ /*
+ * anon_vma links of the old vma is no longer needed after its page
+ * table has been moved.
+ */
+ if (new_vma != vma)
+ unlink_anon_vmas(vma);
+
/* Because we won't unmap we don't need to touch locked_vm */
return new_addr;
}
--
2.18.4
prev parent reply other threads:[~2021-01-19 7:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 7:51 [PATCH 1/2] mm: rmap: explicitly reset vma->anon_vma in unlink_anon_vmas() Li Xinhai
2021-01-19 7:51 ` Li Xinhai [this message]
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=20210119075126.3513154-2-lixinhai.lxh@gmail.com \
--to=lixinhai.lxh@gmail.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bgeffon@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=lokeshgidra@google.com \
--cc=minchan@kernel.org \
--cc=vbabka@suse.cz \
/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