linmiaohe <linmiaohe@xxxxxxxxxx> wrote: >Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote: > On Tue, 14 Jul 2020 11:07:44 +0800 linmiaohe <linmiaohe@xxxxxxxxxx> wrote: >> >>> The vm_flags may be changed after call_mmap() because drivers may set >>> some flags for their own purpose. As a result, we failed to merge the >>> adjacent vma due to the different vm_flags as userspace can't pass in the same one. >>> Try to merge vma after call_mmap() to fix this issue. >> >>Which drivers do this? > >> I searched the code and I see many drivers change the vm_flags, such as aio_ring_mmap set VM_DONTEXPAND and amdgpu_mmap , binder_mmap also change the vm_flags , and so on... >> >>Thanks. >> I'am sorry. I offered the VM_DONTEXPAND case to you which belongs to VM_SPECIAL. I found some other cases: i810_mmap_buffers: set VM_DONTCOPY dax_mmap: ext4_file_mmap: xfs_file_mmap: set VM_HUGEPAGE These vm_flags don't belong to VM_SPECIAL and should be vma mergeable case. In fact, this problem is found on my own product env. We set VM_DONTCOPY in driver mmap ops, and we got this: 400000000000-400000001000 rw-s 105cee000 00:06 64086 /dev/... 400000001000-400000002000 rw-s 105cef000 00:06 64086 /dev/... 400000002000-400000003000 rw-s 105cf0000 00:06 64086 /dev/... 400000003000-400000004000 rw-s 105cf1000 00:06 64086 /dev/... 400000004000-400000005000 rw-s 105cf2000 00:06 64086 /dev/... 400000005000-400000006000 rw-s 105cf3000 00:06 64086 /dev/... 400000006000-400000007000 rw-s 105cf4000 00:06 64086 /dev/... 400000007000-400000008000 rw-s 105cf5000 00:06 64086 /dev/... 400000008000-400000009000 rw-s 105cf6000 00:06 64086 /dev/... 400000009000-40000000a000 rw-s 105cf7000 00:06 64086 /dev/... 40000000a000-40000000b000 rw-s 105cf8000 00:06 64086 /dev/... 40000000b000-40000000c000 rw-s 105cf9000 00:06 64086 /dev/... 40000000c000-40000000d000 rw-s 105cfa000 00:06 64086 /dev/... 40000000d000-40000000e000 rw-s 105cfb000 00:06 64086 /dev/... 40000000e000-40000000f000 rw-s 105cfc000 00:06 64086 /dev/... 40000000f000-400000010000 rw-s 105cfd000 00:06 64086 /dev/... 400000010000-400000011000 rw-s 105cfe000 00:06 64086 /dev/... 400000011000-400000012000 rw-s 105cff000 00:06 64086 /dev/... 400000012000-400000013000 rw-s 105d00000 00:06 64086 /dev/... 400000013000-400000014000 rw-s 105d01000 00:06 64086 /dev/... 400000014000-400000015000 rw-s 105d02000 00:06 64086 /dev/... 400000015000-400000016000 rw-s 105d03000 00:06 64086 /dev/... 400000016000-400000017000 rw-s 105d04000 00:06 64086 /dev/... 400000017000-400000018000 rw-s 105d05000 00:06 64086 /dev/... 400000018000-400000019000 rw-s 105d06000 00:06 64086 /dev/... 400000019000-40000001a000 rw-s 105d07000 00:06 64086 /dev/... 40000001a000-40000001b000 rw-s 105d08000 00:06 64086 /dev/... 40000001b000-40000001c000 rw-s 105d09000 00:06 64086 /dev/... 40000001c000-40000001d000 rw-s 105d0a000 00:06 64086 /dev/... 40000001d000-40000001e000 rw-s 105d0b000 00:06 64086 /dev/... 40000001e000-40000001f000 rw-s 105d0c000 00:06 64086 /dev/... The vma flags are same, vma address are adjacent, belong to same file and so on... I believe this expose the old uncommon bug. I hope I explain it clearly this time. Many thanks.