From: Peter Zijlstra <peterz@infradead.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Maksim Yevmenkin <maksim.yevmenkin@gmail.com>,
Nick Piggin <npiggin@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@suse.de>,
will@crowder-design.com, Rik van Riel <riel@redhat.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [PATCH] Fix OOPS in mmap_region() when merging adjacent VM_LOCKED file segments
Date: Fri, 30 Jan 2009 09:34:10 +0100 [thread overview]
Message-ID: <1233304450.4495.147.camel@laptop> (raw)
In-Reply-To: <alpine.LFD.2.00.0901291245170.3054@localhost.localdomain>
On Thu, 2009-01-29 at 12:48 -0800, Linus Torvalds wrote:
> I still want somebody else to look at and think about it, though.
>
> Linus
>
> ---
> mm/mmap.c | 26 ++++++--------------------
> 1 files changed, 6 insertions(+), 20 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 8d95902..d3fa10a 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1134,16 +1134,11 @@ munmap_back:
> }
>
> /*
> - * Can we just expand an old private anonymous mapping?
> - * The VM_SHARED test is necessary because shmem_zero_setup
> - * will create the file object for a shared anonymous map below.
> + * Can we just expand an old mapping?
> */
> - if (!file && !(vm_flags & VM_SHARED)) {
> - vma = vma_merge(mm, prev, addr, addr + len, vm_flags,
> - NULL, NULL, pgoff, NULL);
> - if (vma)
> - goto out;
> - }
> + vma = vma_merge(mm, prev, addr, addr + len, vm_flags, NULL, file, pgoff, NULL);
> + if (vma)
> + goto out;
You've made checkpatch unhappy ;-)
So we don't bother with anonymous only, always attempt the merge.
> @@ -1206,17 +1201,8 @@ munmap_back:
> if (vma_wants_writenotify(vma))
> vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);
>
> - if (file && vma_merge(mm, prev, addr, vma->vm_end,
> - vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) {
> - mpol_put(vma_policy(vma));
> - kmem_cache_free(vm_area_cachep, vma);
> - fput(file);
> - if (vm_flags & VM_EXECUTABLE)
> - removed_exe_file_vma(mm);
> - } else {
> - vma_link(mm, vma, prev, rb_link, rb_parent);
> - file = vma->vm_file;
> - }
> + vma_link(mm, vma, prev, rb_link, rb_parent);
> + file = vma->vm_file;
And here we don't bother merging because that would have been done
before. Assuming ->mmap() doesn't go wild, in which case it ought to
have set a VM_SPECIAL bit anyway to discourage merging.
[ And even if it didn't, failing to merge shouldn't be a problem, as
minimizing the vmas is an optimization, not a strict requirement
afaik. ]
The obvious glaring difference is the vma_policy() cruft. But staring at
the code a bit I can't see how the new vma can have acquired a vm_policy
here, so it ought to not matter.
Looks ok to my eyes, so I guess:
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
next prev parent reply other threads:[~2009-01-30 8:34 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bb4a86c70901281151w4300605r3882461cd6e9774a@mail.gmail.com>
[not found] ` <alpine.LFD.2.00.0901281316450.3123@localhost.localdomain>
2009-01-29 20:03 ` [PATCH] Fix OOPS in mmap_region() when merging adjacent VM_LOCKED file segments Lee Schermerhorn
2009-01-29 20:33 ` Linus Torvalds
2009-01-29 20:48 ` Linus Torvalds
2009-01-29 22:32 ` Hugh Dickins
2009-01-29 23:02 ` Linus Torvalds
2009-01-30 4:43 ` Lee Schermerhorn
2009-01-30 4:49 ` Linus Torvalds
2009-01-29 22:47 ` Maksim Yevmenkin
2009-01-29 22:48 ` Randy Dunlap
2009-01-29 23:31 ` Maksim Yevmenkin
2009-01-30 2:08 ` Linus Torvalds
2009-01-30 5:56 ` Greg KH
2009-01-30 16:36 ` Linus Torvalds
2009-01-30 17:40 ` Hugh Dickins
2009-01-30 18:14 ` Linus Torvalds
2009-01-30 18:30 ` Hugh Dickins
2009-01-30 19:53 ` Lee Schermerhorn
2009-01-30 20:31 ` Linus Torvalds
2009-01-30 21:12 ` Hugh Dickins
2009-01-30 21:25 ` Linus Torvalds
2009-01-30 21:36 ` Lee Schermerhorn
2009-01-30 22:27 ` Linus Torvalds
2009-01-31 12:35 ` Hugh Dickins
2009-01-31 18:34 ` Linus Torvalds
2009-02-02 11:59 ` KOSAKI Motohiro
2009-02-02 12:54 ` Hugh Dickins
2009-02-02 14:10 ` KOSAKI Motohiro
2009-02-02 18:58 ` Mel Gorman
2009-02-02 19:23 ` Linus Torvalds
2009-02-02 21:50 ` Mel Gorman
2009-02-02 22:12 ` Linus Torvalds
2009-02-02 22:35 ` Mel Gorman
2009-02-02 18:33 ` Mel Gorman
2009-02-03 16:13 ` Lee Schermerhorn
2009-02-03 16:40 ` Linus Torvalds
2009-02-03 17:10 ` Hugh Dickins
2009-02-03 21:50 ` Lee Schermerhorn
2009-01-30 21:37 ` Linus Torvalds
2009-01-31 12:16 ` Hugh Dickins
2009-01-30 20:33 ` Hugh Dickins
2009-01-30 20:53 ` Randy Dunlap
2009-01-30 20:59 ` Lee Schermerhorn
2009-01-30 21:11 ` Will Crowder
2009-01-30 23:44 ` Greg KH
2009-01-30 8:34 ` Peter Zijlstra [this message]
2009-01-30 16:45 ` Linus Torvalds
2009-01-30 16:49 ` Randy Dunlap
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=1233304450.4495.147.camel@laptop \
--to=peterz@infradead.org \
--cc=Lee.Schermerhorn@hp.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@suse.de \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maksim.yevmenkin@gmail.com \
--cc=npiggin@suse.de \
--cc=riel@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=will@crowder-design.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.