]> git.baikalelectronics.ru Git - kernel.git/commit
Allow opportunistic merging of VM_CAN_NONLINEAR areas
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 30 Jan 2009 19:37:22 +0000 (11:37 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 30 Jan 2009 19:37:22 +0000 (11:37 -0800)
commit0b5dfea864c00c2f33b54b92ec3eebdfbe69249f
treed6be0ff97effa23289b2566acf8e56a49aa5657e
parenta9655b3dce588c0526991440b5fbc3b7767da9ce
Allow opportunistic merging of VM_CAN_NONLINEAR areas

Commit e13ba4151031d43ac1316003c321bb759cf18605 ("Fix OOPS in
mmap_region() when merging adjacent VM_LOCKED file segments") unified
the vma merging of anonymous and file maps to just one place, which
simplified the code and fixed a use-after-free bug that could cause an
oops.

But by doing the merge opportunistically before even having called
->mmap() on the file method, it now compares two different 'vm_flags'
values: the pre-mmap() value of the new not-yet-formed vma, and previous
mappings of the same file around it.

And in doing so, it refused to merge the common file case, which adds a
marker to say "I can be made non-linear".

This fixes it by just adding a set of flags that don't have to match,
because we know they are ok to merge.  Currently it's only that single
VM_CAN_NONLINEAR flag, but at least conceptually there could be others
in the future.

Reported-and-acked-by: Hugh Dickins <hugh@veritas.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg KH <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/mmap.c