From patchwork Wed Jul 17 20:06:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13735743 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 391F8C3DA5D for ; Wed, 17 Jul 2024 20:08:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E87856B00A1; Wed, 17 Jul 2024 16:07:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E37746B00A2; Wed, 17 Jul 2024 16:07:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BED086B00A3; Wed, 17 Jul 2024 16:07:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9E9716B00A1 for ; Wed, 17 Jul 2024 16:07:52 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 47B891C3B6F for ; Wed, 17 Jul 2024 20:07:52 +0000 (UTC) X-FDA: 82350330384.26.A90E4C5 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf02.hostedemail.com (Postfix) with ESMTP id DBDCA80024 for ; Wed, 17 Jul 2024 20:07:48 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AlfLpGFu; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=RbNIVLfl; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf02.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246839; a=rsa-sha256; cv=pass; b=5lVDO2WULYXo8+srm0Dr5QPcbfN4teQy8+nQRo7yxb9IDbswsd4yeNYXBahqWzP4RkFAUH dZ0vhejMpuiQdkIwK3dnRjs+wh+viEcN57euUE0c29Kz1md3DukIwLFrH4qqlFYRNCd3DP zw93/1U/86f0SovKpub0ic79u9ceWOg= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AlfLpGFu; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=RbNIVLfl; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf02.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246839; 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=3Bj8KrJIkrFa0UxRm7NqOhO5QapamAHPGNHPLG+zTDo=; b=wjKBl3OkIGA/qVGNph01/PYjCKKRN3c3Cl4u7dcN+WUVIBoFQpAkqZDrww4uPXyCKdkZVM uUCk0+6obkLscjHBildKfwB7CPIS54/6YzL06p2jivJE+y+/yxo3mLhyod1qu+PTsnv/dX bA1n9UWOt7B14VWIMbx0OfXfznev/5Q= Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJuBtC031509; Wed, 17 Jul 2024 20:07:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=3Bj8KrJIkrFa0UxRm7NqOhO5QapamAHPGNHPLG+zTDo=; b= AlfLpGFuj7ftMkzRgbhvi8lL5wS/JOJ5PpPDMm4fKjOvQl7++v3nL9xkmN9vF6wx yvcR13NLAhUMDGwnB0NyahpGuMbbW9cnNXzMGNcCZnQ/OdZ239mB4dtoxQIsKKeS NlwfJ/ziBQeNbKW72MWUamFTUA/M1FzG8EXEN5d8yXJsSZfCJtWOQY3uOoyAUn7q Nf8jJrErkHfStSV5Om21o6obi6uJBGQ98DGLWNGMa0SKOBfNMrZ3fg2JdqSbz9D/ 48643/+RaBKGHHVJmqqbnT490RZQZ4PhOsJyvTyKD7d2ycmMv2VgZyan5MG6hjIv cH1jtL5nSOJ8QzocIN7QMA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emhq80r8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:40 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HIn9iR039514; Wed, 17 Jul 2024 20:07:40 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2177.outbound.protection.outlook.com [104.47.73.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40dwevgj72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UtA++rpKwTYlNQtVQRN6wOWsNGGEIhfWnYAU7DNpmD2ZVLyF4/orZ78ftMzQxoNOnAqlnnUpSFUJCarXbZaMbNZo8inDXzEwm5X62xjzqvxyvU4l6sT88cvD867WIisINoZvQTHZeOMisGOG6MhFCsQHAR0qm4KVH0oWT8asnyYJBCg/Efv4dwIRkpnAAY3bDbTBpFuUEsQ9cZQmTubHlK40ZT5gQJQ4sbDpk1mnvKOtBSGkthPC5p2rSB6VFA/Sk9GkIVwcea+yJNWrwGZvFdQWALK8+nOrLkRuuiHmiKVY3+GuXr8fGQVOtGS+Zd29XEo9ockc8wH/zXevzJVqDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=3Bj8KrJIkrFa0UxRm7NqOhO5QapamAHPGNHPLG+zTDo=; b=Xrvujn+wZSH3jL95JxXKJv9dUBfIeuWlpBgl90woJHGEnf/rVnRHFnVV4F6VrbYBZfPdJe53gjeBqodJMx8G/IfaMCpk9ebuacOAz/gQFstglX2OzG5KPWJYgwI/TQIpNzAmwj5V3FHrMbq3IcIA8h67a9wbLqDl1B04DDqmXggTG/GIQBHaGroom2luV/IjvjhS3hE52Lde5mIzHYu6CDs0QMRG8DusqEBE1B27J6sciJwuyADXPrFzXlPB6PpsT1VJEpEpD8H+meBNOOJlu6lkoA7NYtrhc833vbE2LHrYXsQs9ttRuMrbTZPi4S5XQqpR2RwNKObAQWqW134nvA== 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=3Bj8KrJIkrFa0UxRm7NqOhO5QapamAHPGNHPLG+zTDo=; b=RbNIVLflJo3qWh0SwBNjXcHX1E633/r3cK3YrpB3qsXssN6VYzkXuRlWI0L6BSh9miskgX4nrZWsx154jZSHOwHLQrp/9ChCsP3IeGzlrADtuJn63iGuYEb3G+RjqNzk8vtuEtDzDPBe83WasCTgHLFnIhfBfPaDrBBgyooc6W8= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DM4PR10MB7507.namprd10.prod.outlook.com (2603:10b6:8:187::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Wed, 17 Jul 2024 20:07:37 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7784.016; Wed, 17 Jul 2024 20:07:37 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , Jeff Xu , "Liam R. Howlett" , Lorenzo Stoakes Subject: [PATCH v5 11/21] mm/mmap: Reposition vma iterator in mmap_region() Date: Wed, 17 Jul 2024 16:06:59 -0400 Message-ID: <20240717200709.1552558-12-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240717200709.1552558-1-Liam.Howlett@oracle.com> References: <20240717200709.1552558-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1PR01CA0100.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2c::9) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|DM4PR10MB7507:EE_ X-MS-Office365-Filtering-Correlation-Id: 08b92855-87ee-46d2-6b68-08dca69c1acf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: D5Ab+TmP5AjB0RNJEnE/B4aEE7a/AIsdfNZx2Ci+yirYtHcIrbzpzNRfN5tQJWEH2BmVyXbfi/DUeM0ST2RkpvYFqjao4Nh/z9KWdIGlOxNt1C1So9wMJLG5BuB35xb8wWC4wXL1AbDxdC3u8j56u/M8o5WHCmRzqDtcDK2fLPH/DAFRxrZ3x87WMaxQs9J73eBgB6IP5tJS2+DLDFePhO2x9jfezrrWMKJfh0deR68LQ8y7C2joo49+W7IHvqZNRJjgaKCfAVHfhmq0FxtkK7+AzXctcMftAjMOO9tDgiZBlRBJ0I6CnX5dmhWruPXDWjm95mtQqz0Bzs3SnYTTFMWhHB41vWrqy6MQQAtd2pcDAR6eYk+8+BRsVAJfFQgr7kcWKw41Z/c5Ydep0ME7yZ4Hqka/hVW9Af3Qw8A9H1BYbT+W0ls5srsdRSYEZSvOz3JXmu3i7XKJ1l8mokAxlw5jVpb3ERd2CbLtJoU226acCayJdlOLRZWcKYgkp4WLzjhcn3Nt7x4UmA1Hv24quLR8uToyLudBeSP40rrmGyiHQrudbaElnVMsUl1hGMxO+vzsslOUijEGnD3X+ecJfrPil7XHKPxIZX3oPsaxw2hcvc6BSCg8KBfIOuPo5xqnDVab0Cd2VQBTps6nMUX/USi3vDkCmFRQBIgr95+wm8Y9nWRREpJsxSd0n3aAs2Jsb2Nt3sYCsLP710C5H8pLk6K5mJley/JPF/2jFU0Jg82N0PcDWvxZroaNOBux6GtV1HpAiMTwIIXGIMx/DHHnuYdAdmBKlEkzpJcQ0lkinSxCqYzf0qPvJp7MWMgFZ9b7yTTRegJG9bHQSgXnnyD8muxwGbtijGNmBqORH9HBa5FKkVb4Y57zGAX/x0+/QhxsupYnvUjZKIuEUykfZ9ivgZn4Zd7FmDKxfzOMxkdo5WNor2uEE6mEOgL5xI05ykhmMc5otlH4FbUjFuRmoaSYurJIaTkBr/B4QxEGQ1M/SrVChtyZ/FI0mg+ujXV/7W14fi+L06/dajeWppooWzPrAQRH8V4LzdUNIyfYUCGQSygY5SWB+uf5O/lk9tgfC+dggSUR9J787DNjI5a0BCyJzYhf3JVg5e32pvy8r4fdlERcaS3BGSVa5ok/6o4T/coRmkeJEczasilpPWZ1qcn+jsevxW182hMSwFbXwakQPeAj6G/zvH50oN+Y5CRkez88NpFg9zrUo9Wsrs5I2Ra94rqLlMopz9mZR6Al1wRxA4iRORCWmLtq6ULsHwqkH7t/FiFC+bIh7a3V7xpsjMwckHiC1H7ETj2HqKQgLojRV8M9RV32ik3nZMmuol8zcqvrQi58uTHDdNCJjSn8pjKqOQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j4KMEPnmblXQVNTpBmkw+nm+TK0F42zdB19M2oqaw2Bi5e13eLifRJMRnZBnsVMziuY4KxBTqF8gz48l7BUUKrCsiaK4Zl/EUrlIZBZmk3faOLi5OmRJnLIQeIuDmDgJ9ui2vVJF8nIxu9XuJHQHjJpjYcVONl/pTCC6FErKN+tnlvisGloW+rgLEwvhl3tPfdjq+3ZOvwAtCaX+lKb5cgzkUCQxOv7PijjghkDWenM+D81/8dcE7gk2qWmxBLkr9u0t9m04Ot5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dNI0ckxOhPdUfXB/p3SggK34j9JHbk6jTx6YNQ2TQX2tObnjKlAgvdfZGxS0VlnFbELfq4Jg4dKPb3wcBakr2Ie0GLaNsw1XxEwSOKJMsiXrl9aIftzzss8Tq7/S9XZwJGGVUqz0P1zSsd2VpUdomoBux23pffkrsKWUn6sU5lZXV2sAmxo8X9WdxcBILv7CyhI2qk5ioBDef2UCKJpJkeUjBKW2K0GMQFwc50fVVuqi0uH3j5wqkYZLcE/ZFPUBx9L3yAH71trMvrg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: sQFCqefS3syRGKl+6bXWl6OCD/VuV21RJ0m5/k6JxudReUHKDBwI2Qjfgb6TIwdHBezpN1ERKTDBvD9SdAJSbCAfLQ+ZPllb9IodHgSeqR14lEAQZJ5sDV0UwgHq8e+98XX3KzNmexWDi0aRd/V3iYNZ231a7XVpV+PA+4JVn7P2uqK039ydPl7WrjWZtNgzRg7fdT8/L6D281f2F0gvgbkp1ljLh90idH0DNqsBdrau2WfkRIpigQ3vV5WgfdJFqFoyv6md8EbtHMZULEQVF1lmf3nHcX/eMHlUfsoorDw51EAAHfLLE6EyKsqVSPi9TM/ooFV2336x5bFqCaj4AU2LdRFAJVGUt8I9kSTOd9WL6V02g0CIagqIfskipV0Cpq8KiXjrsfIFwHE3YHmyghDptc+S5/u+2vuz2fen+fMN+qSLe5bJm8BwQ09+fr3IjU6YgH3GgFLBeylnSvEdf3wW9c0xCBLZO6/4rx+hFPysDBeTMx0C1hxOAI8DDW6c29dbTcTHyiDsoE5h/F/p5B2TRCB2mZWeIgw0ooH58S2ivDPwhlBwwV0eUTdLgRwhdkX2pt+DX79bdnhb1d4RL0uln8XVb6tHJLrRyxmroP4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08b92855-87ee-46d2-6b68-08dca69c1acf X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2024 20:07:37.5645 (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: ykEWXC3jiiCmiO7ZOkcCvBBKW0EenzlUZLc/cNt9XNUit25qLDs8KavWyIA/H+wNdJEeUhDkiBO7qhJ30mmbwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB7507 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-17_15,2024-07-17_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: qw8n4dVjJkGOWYA9FfT-AVfppFXzQndA X-Proofpoint-ORIG-GUID: qw8n4dVjJkGOWYA9FfT-AVfppFXzQndA X-Rspamd-Queue-Id: DBDCA80024 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: nkus179fmcmowbh5oxx7xcfht4ujmfok X-HE-Tag: 1721246868-583834 X-HE-Meta: U2FsdGVkX1+TOl7/NrBsf48yIFUe2F2Ssbu5qik2CDyQgPNqRw9GcIw0dMTCAJmDVoODcRPH/k1CYDU5ZLporVcSNy3oCHmIyiTwEk4fKZxqjgNPILIia5uDQY5vd3LIcJr5EqDLNpEG3U1l0gMKRtownSnrp64yx62/jr1GAfYLXgErx47r4rFaS8mGv0oRFBtXYD9VnUjKzcitO1Ylm/fbLXrurrBgRiB+ynPbtni+GoHflo+xn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BnmYd5xhekXH3JBbk3N9FFBSszSRzyhfnaXO+PsYTS209fLIm+8zsg47swCu10r4LWRSrGhH7HPmXpkBlKjEo1rwwBfMD5goo/nHpjJNoj4rqB62TyE100X7THLGXIbU1Ti1iKdKFNPEvspmKy5TGGO/5EsYcDRrjVhFw6atkJwJwGCJ4bej78eWjlLBa3uctDPYYkgGsUvOcAhIaDqMr83pg= 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: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Instead of moving (or leaving) the vma iterator pointing at the previous vma, leave it pointing at the insert location. Pointing the vma iterator at the insert location allows for a cleaner walk of the vma tree for MAP_FIXED and the no expansion cases. The vma_prev() call in the case of merging the previous vma is equivalent to vma_iter_prev_range(), since the vma iterator will be pointing to the location just before the previous vma. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 722bcced0499..b940de8c6df8 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2962,21 +2962,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr, mas_init(&mas_detach, &mt_detach, /* addr = */ 0); /* Prepare to unmap any existing mapping in the area */ if (vms_gather_munmap_vmas(&vms, &mas_detach)) - return -ENOMEM; + goto gather_failed; /* Remove any existing mappings from the vma tree */ if (vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL)) - return -ENOMEM; + goto clear_tree_failed; /* Unmap any existing mapping in the area */ vms_complete_munmap_vmas(&vms, &mas_detach); next = vms.next; prev = vms.prev; - vma_prev(&vmi); vma = NULL; } else { next = vma_next(&vmi); prev = vma_prev(&vmi); + if (prev) + vma_iter_next_range(&vmi); } /* @@ -2989,11 +2990,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_flags |= VM_ACCOUNT; } - if (vm_flags & VM_SPECIAL) { - if (prev) - vma_iter_next_range(&vmi); + if (vm_flags & VM_SPECIAL) goto cannot_expand; - } /* Attempt to expand an old mapping */ /* Check next */ @@ -3014,19 +3012,21 @@ unsigned long mmap_region(struct file *file, unsigned long addr, merge_start = prev->vm_start; vma = prev; vm_pgoff = prev->vm_pgoff; - } else if (prev) { - vma_iter_next_range(&vmi); + vma_prev(&vmi); /* Equivalent to going to the previous range */ } - /* Actually expand, if possible */ - if (vma && - !vma_expand(&vmi, vma, merge_start, merge_end, vm_pgoff, next)) { - khugepaged_enter_vma(vma, vm_flags); - goto expanded; + if (vma) { + /* Actually expand, if possible */ + if (!vma_expand(&vmi, vma, merge_start, merge_end, vm_pgoff, next)) { + khugepaged_enter_vma(vma, vm_flags); + goto expanded; + } + + /* If the expand fails, then reposition the vma iterator */ + if (unlikely(vma == prev)) + vma_iter_set(&vmi, addr); } - if (vma == prev) - vma_iter_set(&vmi, addr); cannot_expand: /* @@ -3187,6 +3187,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_unacct_memory(charged); validate_mm(mm); return error; + +clear_tree_failed: + abort_munmap_vmas(&mas_detach); +gather_failed: + validate_mm(mm); + return -ENOMEM; } static int __vm_munmap(unsigned long start, size_t len, bool unlock)