From patchwork Thu Jan 5 19:16:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13090345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD757C4708E for ; Thu, 5 Jan 2023 19:17:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8768C94000C; Thu, 5 Jan 2023 14:16:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D87F940016; Thu, 5 Jan 2023 14:16:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47AE394000C; Thu, 5 Jan 2023 14:16:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 23EED940016 for ; Thu, 5 Jan 2023 14:16:54 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E8B601A06E4 for ; Thu, 5 Jan 2023 19:16:53 +0000 (UTC) X-FDA: 80321702706.10.A9C3D02 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf05.hostedemail.com (Postfix) with ESMTP id 7CDA210000D for ; Thu, 5 Jan 2023 19:16:50 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=18kzBsQF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=m3pUCj8D; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672946210; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Lb5D9dYmkvlyu/H9rhqwjZSUxhGiHpFzlJQ5XE2d2T4=; b=k8v5o9cntdlpVT/HeEMLTUOtK/yrjW+1BnFojEUNCVQCkBEdGwoxS0jppx8c+MWN1gVIJN 7JHSBS03juRCwbtZAi/NJvxMTwR227yPk4M9yLvw84t3AVzaQaRwgTxy8btJF5LzcP9MC6 HTNZ2MYDbuo4+xqJ6wB8soPI3x85iLY= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=18kzBsQF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=m3pUCj8D; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1672946210; a=rsa-sha256; cv=pass; b=tKwrxaj8ohBoQ9UvoLjzCufy5zInizgxQ29oAne4FOCkYq3a8aauuZoi6K0zt15Sh+rsCU 9dpvPdB5OUUmOGg+gw1V7/q8/8Mrd7JqivdsIdKRGQKUySSkA0uE8iuMdjVKde6bAflSU/ bV44QTDsFj0AYK3bpyHYyfyiWvbuD9c= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 305ITchi025540; Thu, 5 Jan 2023 19:16:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2022-7-12; bh=Lb5D9dYmkvlyu/H9rhqwjZSUxhGiHpFzlJQ5XE2d2T4=; b=18kzBsQFINdzi/FKWbbU62S6Cgwal3UKM+e0RQkXydHNBjzxnEbMuv/HbQ6IKwkKEClY L5P9BI4PVnumNwqcwaDIMqZGtfM8qkor0VjDN4oFs2heS07VM+S9a78V/MNOGENxQP0l 0HPfxGTP5nzAHrEWPp3M4pNlatN3ImQSjQwXTxm5jTIY0ZGXmkD0NiQ7Zw7hweYHAiRC Lpdm0CfQW7cegsbSs3KWL1NmTGJFMF/XRB3cU5o9+J/kiz7M5TpGLFjio9F+MbbR/B4j Mei3dsGpBjK6XfpS/IimoaEuJzzpZmM00me1bgFgdQXsCD0Vlt0T6jTSIA9pmYnvDj1q Bw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mtdmtskws-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 19:16:49 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 305I9Tnn012151; Thu, 5 Jan 2023 19:16:47 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mwdf0u4xq-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 19:16:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ly1wm34HTV+j+cJfjIoZstZu8F3DUS0JdRl/9H0Vw3CVyLDuW/jPVR0Vlrkzmx9RYGI1SYPu/alOUCQY3mHUcvFUmuAMana1uPBErdIH3E1/51DG8ttxLDpya0h8fLSjxR/7BPawGCWwE0b5pCLT9iUSesTNmPlrS4P+SmzLw2H13h/Yk7NS/p37DvayoRydXceOt/fTkKczBLBqmt4zNUtxgg5kibVWxl1Oc95W3hT8PBQe+AhwFJxWXSjKjXkqiDtushSTHELqCKMldHNCF/+0umBqtoaVR8zUAUxrk10BHU2RbcqXcnKiAGP4M3JW9fj7Oda/ti83FPjM0dnfrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Lb5D9dYmkvlyu/H9rhqwjZSUxhGiHpFzlJQ5XE2d2T4=; b=fZxGdVBcvI0usOzqzJnZgTatjPDlQZfoz9B6Avvt4IXb0z1UxDxjNPViazUEdALAiuQg0gmfwB1k5yNnluO0Ho9MN4GBxyelLUsEcJm+JA/18NIsrZeJhWFB32S1B5Iq5twZRydYjuNmfmxzysXA43BsCxfxJ0V8V0WxPqTBi/yQaUFse1X+SMR7Vye0od6L/t9gRi5xWx2MbVm2PqdlW09JHhxr60jYlED6neKxS1qwdrjIYJxFTBwfVpZLY+XmI7IZgCcFc6P0lAw7wbNuVrAiQZt5f8Rg2kp2kL3KjNQIkS5DsRiyc3ZpMbIjUckOWjoD4sIt3xeT2ypQmII0lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Lb5D9dYmkvlyu/H9rhqwjZSUxhGiHpFzlJQ5XE2d2T4=; b=m3pUCj8DuZofBrw5djqddQXXkzZHwzClMe0xSvBsv9j2H2Z1podQi66BmtJukng8Wu2bDFJkKF905fHQHmVAbaDTb+h8skWPDKgtTshKw7O4VfT+dcUnVrmQxBpEdPa0hfwhj0Mrby26IAdKT7QKMrftlnWYbZ+415DHFyMYPsc= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by PH0PR10MB4791.namprd10.prod.outlook.com (2603:10b6:510:3a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 19:16:41 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::a02:2ac8:ee3e:682]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::a02:2ac8:ee3e:682%4]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 19:16:41 +0000 From: Liam Howlett To: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton CC: Liam Howlett , Liam Howlett Subject: [PATCH v2 41/44] mm/mmap: Introduce dup_vma_anon() helper Thread-Topic: [PATCH v2 41/44] mm/mmap: Introduce dup_vma_anon() helper Thread-Index: AQHZITooigzqF61MskSaz0KIp/6GDQ== Date: Thu, 5 Jan 2023 19:16:05 +0000 Message-ID: <20230105191517.3099082-42-Liam.Howlett@oracle.com> References: <20230105191517.3099082-1-Liam.Howlett@oracle.com> In-Reply-To: <20230105191517.3099082-1-Liam.Howlett@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.35.1 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR10MB3022:EE_|PH0PR10MB4791:EE_ x-ms-office365-filtering-correlation-id: bd052d10-48ef-4b2c-5c5f-08daef51607f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rL2Hk4UIkHYHxOPR1wqtdRYnllMslYymzvpLyu0mAF2dOolfjBmIrefCyG71c+7t0nTwc4eH458S+Wy+E6J0CZQf2+JZdMrfJznI+hag6T0drC8yNg/r4DK49Pwvw6aGmaBIVS0nXJi8GCCpk7G2yLQz2uUAM8NDqwYt+M4LFJ9UmF2ApukvGqaKi++0/qOviXDLv1PMQOdtcox4NZdwqv1LUW5M9VXY76TBq7DIV7DnokpHyvozGIOq/uetzcs1WAHM+77d+4qw+3EZu1aseQ5h2fpx1FFxb4egYwOdwBSAiw8QgtwdD7T6HPPky3nFUe1Rvgbgu2nCr7JZmIu2FjnJPqeHiSE289f06O0pL51SW5HBw+x/YQJZABOvY4xvFkRQ+2g9g42d882LHbk/vIe5cjySwCYIUVS6pdT8R/slEv9leUDkVwhHIZWWWu/D36f3UvwIU5OBJMzWVfDr9edy6QxkAXDkdK36/bpmMx/oaoJ0S72J8w5FSXYLJKgR4CQtb3YpZF5uso7E0cg0h+StCBvzin3Xf4lwergou90TH1W483pJQTLUns+SA7xDDP3GGgN+1+tN2eAWKle3zYSyIlXDxoNep4Si4QQdJWbWXEjJD1uIyPFxRtl66x9pv5QsmjUffkgcWvkthrDIgMzaBLdx2voRGbqQk+JiEdaRhiIvqhda7PfcpMvDkqBBVXxLuz5vYdr/Moefbmz2rw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(39860400002)(136003)(346002)(396003)(366004)(451199015)(83380400001)(8936002)(5660300002)(38070700005)(44832011)(38100700002)(36756003)(122000001)(478600001)(107886003)(6666004)(6486002)(2906002)(54906003)(110136005)(6512007)(186003)(26005)(71200400001)(66476007)(64756008)(8676002)(4326008)(66946007)(66556008)(6506007)(91956017)(76116006)(2616005)(41300700001)(66446008)(316002)(86362001)(1076003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?hk/QqBVGOZC9/Gy2VqtQIld?= =?iso-8859-1?q?Ot9L4j714Ng0Ob08Lysd9Paq3Um8IRzQ7IU4APtB+QBQ7i4Hlc+zPXWQzeBD?= =?iso-8859-1?q?V9JuwQ0zeycSPqcrZJYzehZyCnaF73sE992IGR8t9OhhWLLpunadDn8s3Ekb?= =?iso-8859-1?q?dmHUUrVtE9Qlc7WAFDiJezJfmCQWqZqxUVwbEfnGumsLNCRO5tTUZpnfVhWD?= =?iso-8859-1?q?p6E/2Xh5i3VSxeXhD66+QItBRjgOmRdd09D8ZISJKSp6fGCmdq7HjEZ08ih7?= =?iso-8859-1?q?UmLqSInc9fYpIl3Y4IqbxcWFfYOvdnMzaTiRSH8GTdZuNwXwE3qLVt++2y58?= =?iso-8859-1?q?/GsJdqTJvJ+lcObZJYs+CpgCoZch9KwoG/hOB/fTfwQzP+dZRZf3as6WbngU?= =?iso-8859-1?q?0cV5vCRExuQEoml7hj/XxoVZrKSWms5hfFvcriFuPkfg1jbXS0CD5TsDGFrt?= =?iso-8859-1?q?2pMipMQ/AGA1tj8f26KHv7uFaCiT+DZ+DrgwQILsJ1b9fBINBrRL2v/brPvr?= =?iso-8859-1?q?La17Lt+hGT+acBSwMl0c0EeSYsgoDZyQyyei0iET4MOEcxZPoeSz35CTBK2W?= =?iso-8859-1?q?/BLthKA9qJjewWdeoEDMa51IBtFUQohUbbMY9usAZoPFkjx4hqL1F0l+sMlA?= =?iso-8859-1?q?6/ifmg251ygfKPpHKIRdE0O0b418dEqb65ej2zNiQU7bqwg3/9kXou9nars2?= =?iso-8859-1?q?02KPS0vdbYdFtex3YQa3+gd0u8+ufufhzTKREDjavop9Ueu4hOJQl6ZiTO5K?= =?iso-8859-1?q?0T4pEOu2UfPllze+20IipBiGYu6VYgsyUqKVJUgX6kEbTCBl/7dsyHpICi6J?= =?iso-8859-1?q?lGiW4mimz4zeSQNNXPYpbaSVYV03TYyqsbizfLQfNBSBZEs034+tnnUeAtlM?= =?iso-8859-1?q?Q/j4E+fsnTnlOwVT3HTSb5gq/YGWw5vNohc5w42kuEPfoaFLDfMP3Pznyzsa?= =?iso-8859-1?q?1gmvhKDhQHzW7wAkxAl3z9NJRX2i9YSizi+NGzZwd7NsCKDSYpGy0gNq3t+l?= =?iso-8859-1?q?DbOTzkCAeaAOjRo4yQikK7lxTbwtnhWw2rCd9F9jvQekT4m5x0gR2Uli1FIS?= =?iso-8859-1?q?0nfFib5bPoQ4HMUa9Gfin7QxZ+TLzf+YjhR54a28ELftxJU9+E+dZ87V0xVT?= =?iso-8859-1?q?Pvl0QWQF0vmRkA0Eh4pq0N3pBOirKhUXo0upAKSXl1DRaOLeuROEWhI4NUSv?= =?iso-8859-1?q?nFU9OT08La/Eba0dLOdxKnzZYIVTIWJrvDMR5CZfJ+O1/B9Mr0rs/BcfQmlx?= =?iso-8859-1?q?d9BqcUl5o+hB2BGmA7fU72TJoz02fSRYKCDBppvnDbP/+ivovXbs/qdQLQVL?= =?iso-8859-1?q?6xzENaoIPSdEjsJPiUlpHadZx4yxqzuSHQdHFsvgyYcKvJB432BgRCSdfb2L?= =?iso-8859-1?q?nV2cz3b6R9iJEQjr57XPQkZh6eKvDQ2KLltsMJof0PKj6M+8FjyMsYaf0cHT?= =?iso-8859-1?q?QUOBsd1KaXoPEdLB0SejeA7ojLQoD2s07FU6zux5V5aWp9M9tS8oGZyUNlTV?= =?iso-8859-1?q?PzQ2nzhMPgu10GrhLQxsZ15Bd7i4bDLDPVq+wZ9sFx6YBWm6mNiZD8e1EIxO?= =?iso-8859-1?q?RiT+sY+0ywF/6P8Z4zUecmFQDg2SpLUCGeybNRbOyCF8gH96tNviARBTL4w+?= =?iso-8859-1?q?huOPGPdOLaFEP5R8EGZOM2e2tENI8RT6tY/ntTw=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1xCnvFcvJ5fWz3v/fE8gDhurzhfDgvaibAS84qHZtcgDUA/vQ9Mx/qgTokLf/iIPpVXtnkYUYGPsh7x3vv7Z017iZX5a7QgCntT0wo3q6bKrUQatj7p0xhkGKum32H6neTUzL03Maa1HCYlYb8BPcnGGk/iR1PoctfhyUEPGC8mn8uqdWKecOvfMcn1/yh9WtMjb+LoWwZjxWgYNrM/lJk2JBsqUuo0wbkBata/MLKlosLZMUOEqtoIFXG8e9A66plGgmiPbxgGZw2JmFMJOAG9xMMkWhvEdDjI+uB3/WEhKZIoMF7vKXo4Ru0QGq9+Oaw+fhIhMn+a0iRr16ytqUL1Su9avYAz6/x5XozNQUSCpfZdxnFPku266i/9umOVdz5wY0wAirFf9DoWHRfQhM58N7abIS7ht78iCPC6su+hfs4qodYhFmly8bz9TxGbfWjDCVF6e5W4/PD4x9qG/rStFxWfenn1yVcOK+oNKcPeralhw6xR5NULIIYHTywYz8pLTOMfAH/D1QkZKD9nfhuURYaqbYX9X1qmufNGylVzPe+gxUy/2mU4a7HNuy/yBQuHDI4l6Al5noR+4K9P4D7k++Kck943hs93WkKPGfnmZ9XF26xV0Ke3jssXdpuuc7uH/L06JUWur0pxoOWNqw5g+woS+xxNGyJhQVMX5+uxB76tO2iWrDYuQLGydxQqQz3XEh8vqL69j1fmA5gIRQVaHC5qQlWE8leTR8W1jOlc+rdOBIFRS++SH4R8zxPYim/QEYA+MrY4yNHVIgenpP1SidiO/DGV3u/zvn4u8DktUYmwld0L77mOIQ8Q+I+MQYwUJZuJQMM++CMVpfCig4a6avW933Qa/04LF9e4090cIpXounUcl0PJSuhz+vQP7P1v2vVbYhx7IK1ccQ/YqRQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd052d10-48ef-4b2c-5c5f-08daef51607f X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jan 2023 19:16:05.1563 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: XRH+3Q6gtXTY5zd3YJBL5IAMwwx9ZUClohfORGRI4ZoQfTRypxyLbJBwms3CDMO1Mp+cZyPdweMtRJe6WYhppg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4791 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-05_10,2023-01-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301050152 X-Proofpoint-GUID: INjkCY-trUIadTSNtXuIJ2a8zSpL1GWC X-Proofpoint-ORIG-GUID: INjkCY-trUIadTSNtXuIJ2a8zSpL1GWC X-Rspamd-Queue-Id: 7CDA210000D X-Stat-Signature: xhppmx3siusbh7aqy53hjdrpjwan9175 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1672946210-385301 X-HE-Meta: U2FsdGVkX1+ab7KNOwhk40SgAhzS9hjs0r6qvfTaDoY9ZX6/lURYNF4M7Q463X0pBTvDrim56Frymv75jUNMe/401uHB582QK2i845qD9Mx93pF2DP9tCI9xy4qQZnbfxaJFoDxcvXMvRMM0MlPKvV53hLxOdGIqzgieVpRs7QpYYBdnhq5cvkKbX9nHL/WGoJrMsuq88KbP8E+qmI73lQe44aZcHExWkh/WJG8AQCE1CuX+BFPeZM9HGCbJV9o36kcp9nzfKMWm2nUDzNgwckzPg1DaOZdxkYZVqIwzpjKwBTtYtBg1P3CbvnSj/rw1pS52n7h7gnwE++nE1oQj6D7swrmT+qTejFpcltzbdLOm6vPrlENCsSm6vYbT9tAV0qv3zGZxkT0dmfaKyhjYDk+KhbDgGID1aqchQazIrxApLCIPV/+HQGfXwVmLOAECaPhJded1jCsQCp0+rwFiBDZe1p2QWWLMFRub6rOF8EBy0vSC6NU6ppC7fzGsHlfK+D6hlCUAp+5mmvKdyQ432IHNScdq7gkeH2In3wc3Bcgyx+LS0PoPk+PYgmj3dr9H1TCK2/s114OhDxKKFTbN4B83ByqQiOiAe+Axver+MMaLwXaFZbme1q9yBqXhQ9px2b/S+fQOOdZrZXTonLvGwtBCZ9AL6wGoFjFV//Xh+Va0RkGYDXCux/5/5iGrwL4jfVd/jTpCfUEYbmPCzH3NsalsUwm66TUwSNySCZVJ5sXOblu+XwsM3F8XjXdtqPE0omFuYSMaltFidHuMTolFY6hf5kO3O9QFbuT8K95Xf5bESR7C15/50xLcE4FQvSUMJmU3zGNrIapso9+MXL/6N7/f4z7dF7t5JqP3BPB6bbNaTTJJKz3zUdgCPZM5fng4++k4swYFwo2iwgAZd4SWmTmcJXSdYxHI6bQ3K7Xn2oWhok/izR1lxyd8wSIwBRZv3JWQgFnOY5X39w3cZJT losqdYJ6 HuxV3p14gH929Wdi5Hy8LfPmC0WQn+Jv66BLdobxBu6ag+oGRiUwA1D8o3bkqEFbib1LvmSi933m9p18Lo6LzFRKurNCp+EdHtiF/KEVUkiMzQOgiuTqG4uRTyYTAVQ9RPyjnKhmQcRYGNBi89e92vsACgA== 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: From: "Liam R. Howlett" Create a helper for duplicating the anon vma when adjusting the vma. This simplifies the logic of __vma_adjust(). Signed-off-by: Liam R. Howlett --- mm/mmap.c | 74 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index dad5c0113380..1e9b8eb00d45 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -679,6 +679,29 @@ static inline void vma_complete(struct vma_prepare *vp, uprobe_mmap(vp->insert); } +/* + * dup_anon_vma() - Helper function to duplicate anon_vma + * @dst: The destination VMA + * @src: The source VMA + * + * Returns: 0 on success. + */ +static inline int dup_anon_vma(struct vm_area_struct *dst, + struct vm_area_struct *src) +{ + /* + * Easily overlooked: when mprotect shifts the boundary, make sure the + * expanding vma has anon_vma set if the shrinking vma had, to cover any + * anon pages imported. + */ + if (src->anon_vma && !dst->anon_vma) { + dst->anon_vma = src->anon_vma; + return anon_vma_clone(dst, src); + } + + return 0; +} + /* * vma_expand - Expand an existing VMA * @@ -704,15 +727,12 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, struct vma_prepare vp; if (next && (vma != next) && (end == next->vm_end)) { - remove_next = true; - if (next->anon_vma && !vma->anon_vma) { - int error; + int ret; - vma->anon_vma = next->anon_vma; - error = anon_vma_clone(vma, next); - if (error) - return error; - } + remove_next = true; + ret = dup_anon_vma(vma, next); + if (ret) + return ret; } init_multi_vma_prep(&vp, vma, NULL, remove_next ? next : NULL, NULL); @@ -801,10 +821,11 @@ int __vma_adjust(struct vma_iterator *vmi, struct vm_area_struct *vma, struct file *file = vma->vm_file; bool vma_changed = false; long adjust_next = 0; - struct vm_area_struct *exporter = NULL, *importer = NULL; struct vma_prepare vma_prep; if (next) { + int error = 0; + if (end >= next->vm_end) { /* * vma expands, overlapping all the next, and @@ -839,15 +860,14 @@ int __vma_adjust(struct vma_iterator *vmi, struct vm_area_struct *vma, end != remove2->vm_end); } - exporter = next; - importer = vma; - /* * If next doesn't have anon_vma, import from vma after * next, if the vma overlaps with it. */ - if (remove2 != NULL && !next->anon_vma) - exporter = remove2; + if (remove != NULL && !next->anon_vma) + error = dup_anon_vma(vma, remove2); + else + error = dup_anon_vma(vma, remove); } else if (end > next->vm_start) { /* @@ -855,9 +875,8 @@ int __vma_adjust(struct vma_iterator *vmi, struct vm_area_struct *vma, * mprotect case 5 shifting the boundary up. */ adjust_next = (end - next->vm_start); - exporter = next; - importer = vma; - VM_WARN_ON(expand != importer); + VM_WARN_ON(expand != vma); + error = dup_anon_vma(vma, next); } else if (end < vma->vm_end) { /* * vma shrinks, and !insert tells it's not @@ -865,24 +884,11 @@ int __vma_adjust(struct vma_iterator *vmi, struct vm_area_struct *vma, * mprotect case 4 shifting the boundary down. */ adjust_next = -(vma->vm_end - end); - exporter = vma; - importer = next; - VM_WARN_ON(expand != importer); - } - - /* - * Easily overlooked: when mprotect shifts the boundary, - * make sure the expanding vma has anon_vma set if the - * shrinking vma had, to cover any anon pages imported. - */ - if (exporter && exporter->anon_vma && !importer->anon_vma) { - int error; - - importer->anon_vma = exporter->anon_vma; - error = anon_vma_clone(importer, exporter); - if (error) - return error; + VM_WARN_ON(expand != next); + error = dup_anon_vma(next, vma); } + if (error) + return error; } if (vma_iter_prealloc(vmi, vma))