From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 186D8C433E0 for ; Thu, 16 Jul 2020 07:33:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CE636206C1 for ; Thu, 16 Jul 2020 07:33:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE636206C1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 78BFC6B0025; Thu, 16 Jul 2020 03:33:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 73BE66B0026; Thu, 16 Jul 2020 03:33:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 652928D0001; Thu, 16 Jul 2020 03:33:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id 4EE9E6B0025 for ; Thu, 16 Jul 2020 03:33:21 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 192CF180ACEE8 for ; Thu, 16 Jul 2020 07:33:21 +0000 (UTC) X-FDA: 77043123402.30.cart46_0f1157d26f00 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id E53B5180B3C95 for ; Thu, 16 Jul 2020 07:33:20 +0000 (UTC) X-HE-Tag: cart46_0f1157d26f00 X-Filterd-Recvd-Size: 5725 Received: from huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jul 2020 07:33:19 +0000 (UTC) Received: from DGGEMM405-HUB.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id D5162A9454716861D7FB; Thu, 16 Jul 2020 15:33:08 +0800 (CST) Received: from dggeme703-chm.china.huawei.com (10.1.199.99) by DGGEMM405-HUB.china.huawei.com (10.3.20.213) with Microsoft SMTP Server (TLS) id 14.3.487.0; Thu, 16 Jul 2020 15:33:05 +0800 Received: from dggeme753-chm.china.huawei.com (10.3.19.99) by dggeme703-chm.china.huawei.com (10.1.199.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1913.5; Thu, 16 Jul 2020 15:33:05 +0800 Received: from dggeme753-chm.china.huawei.com ([10.7.64.70]) by dggeme753-chm.china.huawei.com ([10.7.64.70]) with mapi id 15.01.1913.007; Thu, 16 Jul 2020 15:33:05 +0800 From: linmiaohe To: Andrew Morton CC: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mm: mmap: Merge vma after call_mmap() if possible Thread-Topic: [PATCH] mm: mmap: Merge vma after call_mmap() if possible Thread-Index: AdZZkbhDr0LDae6gQR+szjsfPzuWPwBqkbJw Date: Thu, 16 Jul 2020 07:33:05 +0000 Message-ID: <3da69bbf7f0d485ca1c8e4a44d5010c6@huawei.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.176.109] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: E53B5180B3C95 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: linmiaohe wrote: >Andrew Morton wrote: > On Tue, 14 Jul 2020 11:07:44 +0800 linmiaohe wrote= : >> >>> The vm_flags may be changed after call_mmap() because drivers may set=20 >>> some flags for their own purpose. As a result, we failed to merge the=20 >>> adjacent vma due to the different vm_flags as userspace can't pass in t= he 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 t= he vm_flags , and so on... >> >>Thanks. >> I'am sorry. I offered the VM_DONTEXPAND case to you which belongs to VM_SPE= CIAL. 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 /d= ev/... 400000001000-400000002000 rw-s 105cef000 00:06 64086 /d= ev/... 400000002000-400000003000 rw-s 105cf0000 00:06 64086 /d= ev/... 400000003000-400000004000 rw-s 105cf1000 00:06 64086 /d= ev/... 400000004000-400000005000 rw-s 105cf2000 00:06 64086 /d= ev/... 400000005000-400000006000 rw-s 105cf3000 00:06 64086 /d= ev/... 400000006000-400000007000 rw-s 105cf4000 00:06 64086 /d= ev/... 400000007000-400000008000 rw-s 105cf5000 00:06 64086 /d= ev/... 400000008000-400000009000 rw-s 105cf6000 00:06 64086 /d= ev/... 400000009000-40000000a000 rw-s 105cf7000 00:06 64086 /d= ev/... 40000000a000-40000000b000 rw-s 105cf8000 00:06 64086 /d= ev/... 40000000b000-40000000c000 rw-s 105cf9000 00:06 64086 /d= ev/... 40000000c000-40000000d000 rw-s 105cfa000 00:06 64086 /d= ev/... 40000000d000-40000000e000 rw-s 105cfb000 00:06 64086 /d= ev/... 40000000e000-40000000f000 rw-s 105cfc000 00:06 64086 /d= ev/... 40000000f000-400000010000 rw-s 105cfd000 00:06 64086 /d= ev/... 400000010000-400000011000 rw-s 105cfe000 00:06 64086 /d= ev/... 400000011000-400000012000 rw-s 105cff000 00:06 64086 /d= ev/... 400000012000-400000013000 rw-s 105d00000 00:06 64086 /d= ev/... 400000013000-400000014000 rw-s 105d01000 00:06 64086 /d= ev/... 400000014000-400000015000 rw-s 105d02000 00:06 64086 /d= ev/... 400000015000-400000016000 rw-s 105d03000 00:06 64086 /d= ev/... 400000016000-400000017000 rw-s 105d04000 00:06 64086 /d= ev/... 400000017000-400000018000 rw-s 105d05000 00:06 64086 /d= ev/... 400000018000-400000019000 rw-s 105d06000 00:06 64086 /d= ev/... 400000019000-40000001a000 rw-s 105d07000 00:06 64086 /d= ev/... 40000001a000-40000001b000 rw-s 105d08000 00:06 64086 /d= ev/... 40000001b000-40000001c000 rw-s 105d09000 00:06 64086 /d= ev/... 40000001c000-40000001d000 rw-s 105d0a000 00:06 64086 /d= ev/... 40000001d000-40000001e000 rw-s 105d0b000 00:06 64086 /d= ev/... 40000001e000-40000001f000 rw-s 105d0c000 00:06 64086 /d= ev/... The vma flags are same, vma address are adjacent, belong to same file and s= o on... I believe this expose the old uncommon bug. I hope I explain it clearly thi= s time. Many thanks.