From: Nick Piggin <npiggin@suse.de>
To: Rik van Riel <riel@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
lwoodman@redhat.com, Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
aarcange@redhat.com
Subject: Re: [PATCH -mm] remove VM_LOCK_RMAP code
Date: Mon, 1 Feb 2010 17:15:32 +1100 [thread overview]
Message-ID: <20100201061532.GC9085@laptop> (raw)
In-Reply-To: <20100129193410.7ce915d0@annuminas.surriel.com>
On Fri, Jan 29, 2010 at 07:34:10PM -0500, Rik van Riel wrote:
> When a VMA is in an inconsistent state during setup or teardown, the
> worst that can happen is that the rmap code will not be able to find
> the page.
OK, but you missed the interesting thing, which is to explain why
that worst case is not a problem.
rmap of course is not just used for reclaim but also invalidations
from mappings, and those guys definitely need to know that all
page table entries have been handled by the time they return.
>
> It is also impossible for the rmap code to follow a pointer to an
> already freed VMA, because the rmap code holds the anon_vma->lock,
> which the VMA teardown code needs to take before the VMA is removed
> from the anon_vma chain.
>
> Hence, we should not need the VM_LOCK_RMAP locking at all.
>
> Sent as a separate patch because I would appreciate it if others
> could verify my logic :)
>
> Signed-off-by: Rik van Riel <riel@redhat.com>
> ---
> include/linux/mm.h | 4 ----
> mm/mmap.c | 15 ---------------
> mm/rmap.c | 12 ------------
> 3 files changed, 0 insertions(+), 31 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 93bbb70..5866e0c 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -96,11 +96,7 @@ extern unsigned int kobjsize(const void *objp);
> #define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
> #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
> #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
> -#ifdef CONFIG_MMU
> -#define VM_LOCK_RMAP 0x01000000 /* Do not follow this rmap (mmu mmap) */
> -#else
> #define VM_MAPPED_COPY 0x01000000 /* T if mapped copy of data (nommu mmap) */
> -#endif
> #define VM_INSERTPAGE 0x02000000 /* The vma has had "vm_insert_page()" done on it */
> #define VM_ALWAYSDUMP 0x04000000 /* Always include in core dumps */
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 58a3d72..de9e953 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -554,9 +554,7 @@ again: remove_next = 1 + (end > next->vm_end);
> */
> if (importer && !importer->anon_vma) {
> /* Block reverse map lookups until things are set up. */
> - importer->vm_flags |= VM_LOCK_RMAP;
> if (anon_vma_clone(importer, vma)) {
> - importer->vm_flags &= ~VM_LOCK_RMAP;
> return -ENOMEM;
> }
> importer->anon_vma = anon_vma;
> @@ -618,11 +616,6 @@ again: remove_next = 1 + (end > next->vm_end);
> __vma_unlink(mm, next, vma);
> if (file)
> __remove_shared_vm_struct(next, file, mapping);
> - /*
> - * This VMA is now dead, no need for rmap to follow it.
> - * Call anon_vma_merge below, outside of i_mmap_lock.
> - */
> - next->vm_flags |= VM_LOCK_RMAP;
> } else if (insert) {
> /*
> * split_vma has split insert from vma, and needs
> @@ -635,20 +628,12 @@ again: remove_next = 1 + (end > next->vm_end);
> if (mapping)
> spin_unlock(&mapping->i_mmap_lock);
>
> - /*
> - * The current VMA has been set up. It is now safe for the
> - * rmap code to get from the pages to the ptes.
> - */
> - if (anon_vma && importer)
> - importer->vm_flags &= ~VM_LOCK_RMAP;
> -
> if (remove_next) {
> if (file) {
> fput(file);
> if (next->vm_flags & VM_EXECUTABLE)
> removed_exe_file_vma(mm);
> }
> - /* Protected by mmap_sem and VM_LOCK_RMAP. */
> if (next->anon_vma)
> anon_vma_merge(vma, next);
> mm->map_count--;
> diff --git a/mm/rmap.c b/mm/rmap.c
> index aa11f3c..818615a 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -329,18 +329,6 @@ vma_address(struct page *page, struct vm_area_struct *vma)
> /* page should be within @vma mapping range */
> return -EFAULT;
> }
> - if (unlikely(vma->vm_flags & VM_LOCK_RMAP)) {
> - /*
> - * This VMA is being unlinked or is not yet linked into the
> - * VMA tree. Do not try to follow this rmap. This race
> - * condition can result in page_referenced() ignoring a
> - * reference or in try_to_unmap() failing to unmap a page.
> - * The VMA cannot be freed under us because we hold the
> - * anon_vma->lock, which the munmap code takes while
> - * unlinking the anon_vmas from the VMA.
> - */
> - return -EFAULT;
> - }
> return address;
> }
>
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2010-02-01 8:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-28 5:20 [PATCH -mm] change anon_vma linking to fix multi-process server scalability issue Rik van Riel
2010-01-28 6:43 ` [PATCH -mm] rmap: remove obsolete check from __page_check_anon_rmap Rik van Riel
2010-02-01 15:26 ` Minchan Kim
2010-01-28 6:43 ` [PATCH -mm] rmap: move exclusively owned pages to own anon_vma in do_wp_page Rik van Riel
2010-02-01 15:25 ` Minchan Kim
2010-02-01 16:33 ` Rik van Riel
2010-01-28 16:37 ` [PATCH -mm] change anon_vma linking to fix multi-process server scalability issue Minchan Kim
2010-01-28 17:24 ` Rik van Riel
2010-01-29 0:55 ` Minchan Kim
2010-01-29 1:18 ` Rik van Riel
2010-01-29 23:14 ` Andrew Morton
2010-01-29 23:57 ` Rik van Riel
2010-01-30 0:22 ` [PATCH -mm] further cleanups to " Rik van Riel
2010-01-30 0:34 ` [PATCH -mm] remove VM_LOCK_RMAP code Rik van Riel
2010-02-01 6:15 ` Nick Piggin [this message]
2010-02-01 15:55 ` Rik van Riel
2010-02-02 6:44 ` Nick Piggin
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=20100201061532.GC9085@laptop \
--to=npiggin@suse.de \
--cc=Lee.Schermerhorn@hp.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lwoodman@redhat.com \
--cc=riel@redhat.com \
/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).