mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch added to -mm tree
@ 2021-01-19 19:32 akpm
  2021-01-27  8:43 ` Li Xinhai
  0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2021-01-19 19:32 UTC (permalink / raw)
  To: aarcange, bgeffon, kirill.shutemov, lixinhai.lxh, lokeshgidra,
	minchan, mm-commits, vbabka


The patch titled
     Subject: mm: mremap: unlink anon_vmas when mremap with MREMAP_DONTUNMAP success
has been added to the -mm tree.  Its filename is
     mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Li Xinhai <lixinhai.lxh@gmail.com>
Subject: mm: mremap: unlink anon_vmas when mremap with MREMAP_DONTUNMAP success

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.

Link: https://lkml.kernel.org/r/20210119075126.3513154-2-lixinhai.lxh@gmail.com
Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
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: Andrew Morton <akpm@linux-foundation.org>
---

 mm/mremap.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/mm/mremap.c~mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success
+++ a/mm/mremap.c
@@ -595,6 +595,13 @@ static unsigned long move_vma(struct vm_
 		/* 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;
 	}
_

Patches currently in -mm which might be from lixinhai.lxh@gmail.com are

mm-rmap-explicitly-reset-vma-anon_vma-in-unlink_anon_vmas.patch
mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch
mm-hugetlbc-fix-unnecessary-address-expansion-of-pmd-sharing.patch


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: + mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch added to -mm tree
  2021-01-19 19:32 + mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch added to -mm tree akpm
@ 2021-01-27  8:43 ` Li Xinhai
  0 siblings, 0 replies; 2+ messages in thread
From: Li Xinhai @ 2021-01-27  8:43 UTC (permalink / raw)
  To: akpm, aarcange, bgeffon, kirill.shutemov, lokeshgidra, minchan,
	mm-commits, vbabka



On 1/20/21 3:32 AM, akpm@linux-foundation.org wrote:
> The patch titled
>       Subject: mm: mremap: unlink anon_vmas when mremap with MREMAP_DONTUNMAP success
> has been added to the -mm tree.  Its filename is
>       mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch
> 
> This patch should soon appear at
>      https://ozlabs.org/~akpm/mmots/broken-out/mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch
> and later at
>      https://ozlabs.org/~akpm/mmotm/broken-out/mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch
> 
> Before you just go and hit "reply", please:
>     a) Consider who else should be cc'ed
>     b) Prefer to cc a suitable mailing list as well
>     c) Ideally: find the original patch on the mailing list and do a
>        reply-to-all to that, adding suitable additional cc's
> 
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
> 
> The -mm tree is included into linux-next and is updated
> there every 3-4 working days
> 

Andrew,
These two patches require updates. I've sent out v2, please consider the new patches. Thanks.

mm-rmap-explicitly-reset-vma-anon_vma-in-unlink_anon_vmas.patch
mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch

> ------------------------------------------------------
> From: Li Xinhai <lixinhai.lxh@gmail.com>
> Subject: mm: mremap: unlink anon_vmas when mremap with MREMAP_DONTUNMAP success
> 
> 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.
> 
> Link: https://lkml.kernel.org/r/20210119075126.3513154-2-lixinhai.lxh@gmail.com
> Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
> 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: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>   mm/mremap.c |    7 +++++++
>   1 file changed, 7 insertions(+)
> 
> --- a/mm/mremap.c~mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success
> +++ a/mm/mremap.c
> @@ -595,6 +595,13 @@ static unsigned long move_vma(struct vm_
>   		/* 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;
>   	}
> _
> 
> Patches currently in -mm which might be from lixinhai.lxh@gmail.com are
> 
> mm-rmap-explicitly-reset-vma-anon_vma-in-unlink_anon_vmas.patch
> mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch
> mm-hugetlbc-fix-unnecessary-address-expansion-of-pmd-sharing.patch
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-27  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19 19:32 + mm-mremap-unlink-anon_vmas-when-mremap-with-mremap_dontunmap-success.patch added to -mm tree akpm
2021-01-27  8:43 ` Li Xinhai

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).