From: Hillf Danton <dhillf@gmail.com>
To: Michel Lespinasse <walken@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, riel@redhat.com, peterz@infradead.org,
aarcange@redhat.com, hughd@google.com, daniel.santos@pobox.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/7] mm: interval tree updates
Date: Sat, 8 Sep 2012 12:45:12 +0800 [thread overview]
Message-ID: <CAJd=RBC+AhTpLRqRLLHyZ-fhJahKyi5hFHQU5gimcf3NXfzoaw@mail.gmail.com> (raw)
In-Reply-To: <20120907232617.GA8439@google.com>
Hello Michel
Lets first see snippet in another work.
https://lkml.org/lkml/2012/9/4/75
[PATCH 5/7] mm rmap: remove vma_address check for address inside vma
On Tue, Sep 4, 2012 at 5:20 PM, Michel Lespinasse <walken@google.com> wrote:
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 9c61bf387fd1..28777412de62 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -510,22 +510,26 @@ void page_unlock_anon_vma(struct anon_vma *anon_vma)
>
> /*
> * At what user virtual address is page expected in @vma?
> - * Returns virtual address or -EFAULT if page's index/offset is not
> - * within the range mapped the @vma.
> */
> -inline unsigned long
> -vma_address(struct page *page, struct vm_area_struct *vma)
> +static inline unsigned long
> +__vma_address(struct page *page, struct vm_area_struct *vma)
> {
> pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
> - unsigned long address;
>
> if (unlikely(is_vm_hugetlb_page(vma)))
> pgoff = page->index << huge_page_order(page_hstate(page));
The pgoff computation for huge page remains as it was.
> - address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
> - if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
> - /* page should be within @vma mapping range */
> - return -EFAULT;
> - }
> +
> + return vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
> +}
> +
> +inline unsigned long
> +vma_address(struct page *page, struct vm_area_struct *vma)
> +{
> + unsigned long address = __vma_address(page, vma);
> +
> + /* page should be within @vma mapping range */
> + VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
> +
> return address;
> }
>
Then lets see this work.
On Sat, Sep 8, 2012 at 7:26 AM, Michel Lespinasse <walken@google.com> wrote:
> -----------------------------8<-------------------------------------
> From: Michel Lespinasse <walken@google.com>
> Subject: mm: replace vma prio_tree with an interval tree
>
> Implement an interval tree as a replacement for the VMA prio_tree.
> The algorithms are similar to lib/interval_tree.c; however that code
> can't be directly reused as the interval endpoints are not explicitly
> stored in the VMA. So instead, the common algorithm is moved into
> a template and the details (node type, how to get interval endpoints
> from the node, etc) are filled in using the C preprocessor.
>
> Once the interval tree functions are available, using them as a replacement
> to the VMA prio tree is a relatively simple, mechanical job.
>
> Signed-off-by: Michel Lespinasse <walken@google.com>
> Cc: Rik van Riel <riel@redhat.com>
> Cc: Hillf Danton <dhillf@gmail.com>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
[...]
> --- /dev/null
> +++ b/mm/interval_tree.c
> @@ -0,0 +1,59 @@
> +/*
> + * mm/interval_tree.c - interval tree for mapping->i_mmap
> + *
> + * Copyright (C) 2012, Michel Lespinasse <walken@google.com>
> + *
> + * This file is released under the GPL v2.
> + */
> +
> +#include <linux/mm.h>
> +#include <linux/fs.h>
> +#include <linux/interval_tree_generic.h>
> +
> +static inline unsigned long vma_start_pgoff(struct vm_area_struct *v)
> +{
> + return v->vm_pgoff;
> +}
> +
> +static inline unsigned long vma_last_pgoff(struct vm_area_struct *v)
> +{
> + return v->vm_pgoff + ((v->vm_end - v->vm_start) >> PAGE_SHIFT) - 1;
> +}
> +
The pgoff computations are only for regular page, yes?
> +INTERVAL_TREE_DEFINE(struct vm_area_struct, shared.linear.rb,
> + unsigned long, shared.linear.rb_subtree_last,
> + vma_start_pgoff, vma_last_pgoff,, vma_interval_tree)
> +
[...]
> @@ -1547,7 +1545,6 @@ static int try_to_unmap_file(struct page *page, enum ttu_flags flags)
> struct address_space *mapping = page->mapping;
> pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
What if page is huge?
> struct vm_area_struct *vma;
> - struct prio_tree_iter iter;
> int ret = SWAP_AGAIN;
> unsigned long cursor;
> unsigned long max_nl_cursor = 0;
> @@ -1555,7 +1552,7 @@ static int try_to_unmap_file(struct page *page, enum ttu_flags flags)
> unsigned int mapcount;
>
> mutex_lock(&mapping->i_mmap_mutex);
> - vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
> + vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) {
> unsigned long address = vma_address(page, vma);
> if (address == -EFAULT)
> continue;
--
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:[~2012-09-08 4:45 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-04 9:20 [PATCH 0/7] use interval trees for anon rmap Michel Lespinasse
2012-09-04 9:20 ` [PATCH 1/7] mm: interval tree updates Michel Lespinasse
2012-09-07 22:13 ` Andrew Morton
2012-09-07 22:29 ` Michel Lespinasse
2012-09-07 22:55 ` Andrew Morton
2012-09-07 23:26 ` Michel Lespinasse
2012-09-08 4:45 ` Hillf Danton [this message]
2012-09-07 23:26 ` Michel Lespinasse
2012-09-04 9:20 ` [PATCH 2/7] mm: fix potential anon_vma locking issue in mprotect() Michel Lespinasse
2012-09-04 14:27 ` Andrea Arcangeli
2012-09-04 21:53 ` Michel Lespinasse
2012-09-04 22:16 ` Andrea Arcangeli
2012-09-05 0:45 ` Michel Lespinasse
2012-09-04 9:20 ` [PATCH 3/7] mm anon rmap: remove anon_vma_moveto_tail Michel Lespinasse
2012-09-04 9:20 ` [PATCH 4/7] mm anon rmap: replace same_anon_vma linked list with an interval tree Michel Lespinasse
2012-09-05 0:51 ` Michel Lespinasse
2012-09-04 9:20 ` [PATCH 5/7] mm rmap: remove vma_address check for address inside vma Michel Lespinasse
2012-09-04 9:20 ` [PATCH 6/7] mm: add CONFIG_DEBUG_VM_RB build option Michel Lespinasse
2012-09-14 22:14 ` Sasha Levin
2012-09-14 22:40 ` Sasha Levin
2012-09-14 22:46 ` Michel Lespinasse
2012-09-15 0:00 ` Michel Lespinasse
2012-09-15 7:52 ` Jiri Slaby
2012-09-16 19:07 ` Hugh Dickins
2012-09-22 7:19 ` Jiri Slaby
2012-09-15 9:26 ` Sasha Levin
2012-09-20 21:39 ` Fengguang Wu
2012-09-20 22:27 ` Hugh Dickins
2012-09-20 22:31 ` Fengguang Wu
2012-09-04 9:20 ` [PATCH 7/7] mm: avoid taking rmap locks in move_ptes() Michel Lespinasse
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='CAJd=RBC+AhTpLRqRLLHyZ-fhJahKyi5hFHQU5gimcf3NXfzoaw@mail.gmail.com' \
--to=dhillf@gmail.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=daniel.santos@pobox.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=walken@google.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