From patchwork Tue Jun 25 19:11:45 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: 13711869 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 31717C2BBCA for ; Tue, 25 Jun 2024 19:12:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1D996B00C3; Tue, 25 Jun 2024 15:12:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA4F66B00C4; Tue, 25 Jun 2024 15:12:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5BB06B00C5; Tue, 25 Jun 2024 15:12:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A5F346B00C3 for ; Tue, 25 Jun 2024 15:12:36 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5D9E1805C8 for ; Tue, 25 Jun 2024 19:12:36 +0000 (UTC) X-FDA: 82270357512.05.5619139 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 1C070140011 for ; Tue, 25 Jun 2024 19:12:32 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=DvEmCSX2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=QBTG9ZjO; spf=pass (imf26.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342733; 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=tWeNqUha8Up1eRkUEoS52yWD3cYBN+Ju2CdS1+VKDw8=; b=3ct1c+6KTJ+VHUlKgfwKfDikRe2LhPFtWotPMjGlrDfFClUnhE7T3EtzbL+z4zg4lEGy0H lyLz6toKX+PAtmYFuMXpzDbPSwjBhds0lad9RNZw917S/pNNO3y3gv6yy/EnVpLLNCewVu qlg4ItelxzCEZ5er1tqblHOeonLJSII= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=DvEmCSX2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=QBTG9ZjO; spf=pass (imf26.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342733; a=rsa-sha256; cv=pass; b=yJ/IMsPb2jRmJ4xnvFP/UlYVwqy/P86pAvplxetNKlv8ZV3URrO0fvt3/2fQoTY4lNZIFv 5aMTePg7DUiPdCss437wZa7zi1Ho2HQMBDVbqWUGpFCIbWzirdRIe2P64wr8aQSPa0FL43 397cuxy4n89D8TGJwo5twDZ3DPLYnEE= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45PIfXVb007432; Tue, 25 Jun 2024 19:12:25 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=tWeNqUha8Up1eRkUEoS52yWD3cYBN+Ju2CdS1+VKDw8=; b= DvEmCSX24jkVGARy83WJTc7JA9ZcLb8J/LeMuXpC3jwBolKzsSzcNADlXICDVdXa E/PL3gTSmizEVXPGHTULtwnpLGkUppWyOVemLJbGQm+o3SqT7YCztUWnhcZKR67W Rq3kQX6q2jy0fRDfDqKP0lTa6vbAZasIctgpg7Y1zrZ1cf2FO3axdBULSThbf5HS UBgE28Zt8FjS2DN2ZM+mXv9lKnQOl/f6q43mIkkbVy/v5yV0jTwJyvZNA0Itnzya B5nTYsDXfOMMnfyFtrWMAuZmuwd9/XTGNoT+VfJ8n2xHiNH8FoEhtABHXIXh/F4r HSuz8Yg+TgNVPY1umadwPw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywn1d1dns-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:25 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PHqkok037140; Tue, 25 Jun 2024 19:12:24 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn28fjkn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wc0lJZN/7AFEqZf22cYf4g95io0rEdUr/Glfy+1j0BFOIyieEDfXIVnJqcUCJJeT+5Q+58cHgXPEv0Ni+lKwHWloF31UjDCttSwXIpVFbf0Eu9c1H2mP8YAJeE2XecS60Ku+SivFE0z0rsPd9U139p0SQbBx8mgeS6pi3SWQd/Utgbai+Z2xCZsB8KY2/VQDf2i83/oRp2igoJ1Zfog9MIqBGk0rUfJAuly1EOr/YGsj3kiz+ub3PGKLlk3qnFs0TbSkI4JowOuzj8GQ1lq2mbuhLGK+VCQzXKpopuwuLyiFY8aHqgYr4eG1ivXI442pllfkw/b5a+vYZXfdjNqVmQ== 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=tWeNqUha8Up1eRkUEoS52yWD3cYBN+Ju2CdS1+VKDw8=; b=ns+PI7k7E/4P7d7B2STABjDWdLUOLM3OVfs/o4KDcg8vfXpY90nPoPDKDTB77esdXc9iFX8PLvBn93zs3TnYDImMdeRBWsrYb2pV7mOjemrpKuq4Qan9Kv9222V4GEWh4Vl7gzVYn4zUl6C5+rmDstBRBRFMUkiBgHj/Kbfu1X6k/fa7uAcuw6HVn8sJ2DdtVARvpYnOiAgmGCKWhjHlkjsJqplGXMwgjUPKk3JniePXiD1Ipg7Gx+CvssvncL0nzWXOqCt+3l3pxYqDqQaOHsLJe9qXctRRLZSbGXC/KJDh6TB+++3MhwrXF0PErzLvfGLenc9raAgZGD0ygUPmvg== 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=tWeNqUha8Up1eRkUEoS52yWD3cYBN+Ju2CdS1+VKDw8=; b=QBTG9ZjOdby1WbkPHMGP9oZ2C1IZWd/TvjRyDWjhFjvyrEilEjQSH4d/npWMo2KaJmdBc8VZXjG8xNttg5BojHwOsk7dimh+YxgAh4z3hcdS5m5633NIQGbcXRqDSh92GjEmVAzL0FxrrTsQ64qjkPk/mTf3S1ECpAfFqV5dVP4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DS0PR10MB7066.namprd10.prod.outlook.com (2603:10b6:8:140::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Tue, 25 Jun 2024 19:12:22 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:22 +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 , "Liam R. Howlett" Subject: [PATCH v2 15/15] mm/mmap: Move may_expand_vm() check in mmap_region() Date: Tue, 25 Jun 2024 15:11:45 -0400 Message-ID: <20240625191145.3382793-16-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YTBP288CA0026.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:14::39) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|DS0PR10MB7066:EE_ X-MS-Office365-Filtering-Correlation-Id: a91fc411-bbc1-4898-dc5b-08dc954abdbe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: VLVtHGEQgkKPvHDM/8+NyPH8klJ4AtcPZbwKPn4qFlAszdhakyqBcEmCV9eGlKph+vDjNAR3tu44kIBzy41WSgzaI2erEWJjt2T3dlfOuQ0TTNVZ0dZL3cffpkar3eaU5V3Z8YRhEhBtNpc1E+d+IDwQpkmmz3P9EJ3wVdkV0kvSUrk3PFbwpRbCf3SK8l7sKG/wiExs3DBx9JvdlfigdacBiqzVg34U/p8gKrNeJ/cWY3VVhqMGc1h45vp9PiyYbJnr/M0qgtjfDUs7nrijLX0JmzCnyEja3EDVHI7lXUmlWw7q4Dwb3hL4ZOkXKeshfVZogK+ihlmD/RGFVxPJMijl3u/uTZDmxB78NxtsQ4Knr8zRRGhBFF+Nivgef5Jo5lUP5RMbqUGSF1Y+UN2y+tstYWtVjOnOqRq+FU08jY+xyf9n3nQagz22ZymPlVwH6WdJ5noWi9U9wMrhLDgcaSEEQPuqXvDtkjErd2EAoizs6JaEEgtlEn7ALfhQ9bdkMv9CsSpkaGEYzhLLpYzHiDNffBzeyr1SzLpqKClkpuliN6YTVzVgfZuc5Kurax5aamkeIo2qYK+uvDnXzvJm1bCOPR4wrHnrGddNUx0gTu2LvlfU+2am8gk+gugXtiJNvmUlj3YxYRg8Kr8vcLTo92D/cPQJ9pWpmr6zIe1XBanyoKseAGU4K8LWgrgPAAUQUgn3ImPLkPsWdj+x2yCqUyWnstXFheUwk8n03IBIv9gOxDyrXXnFUzWkOTJSm6W9loY3JoKt+SKcd8gmxbcjCzsgaPdruNKE8JmjM/n8PuLnLwVMJcGng3rZ+pIinUjoLNIsaP4Uh9NfsibWfZu4pnZDD8YbKwdq3e1P3joPNNP1GbpgMSlvlIOHQBeed3ZyFPiCmbZa0FepZHLa9m8p5hFlim02hMF2XuDW8QaPTX/uSwkj3bMQG3SKJEhdtW/R7i27/POgtHp6/FbKAH+ecp0Y9otGMZb6CRAtnkQfkeuQ0bk0u0j0GbzDP3FWnUgH1FCjYWNF5oNnD5bUldbuFKgIiYzTqaMUpzKroQlLFjzT8wxx3JOPqBg1BWCdr4rlx+hIuwTzKdwlNJH1RAGxB36F+GUaUh2eziNaEK+C8cebsa5HJ4SvACAEVgErsxQYYKiawijqbuwDsLNo9Za5vKXldRFWQaI6AlBwJ4Us0ue0uzOIZw8LgiyA8uXCRGBUAYeCSe6Lht4w29QVf3j4gJaqy9UaW057blvCqgV9pCexi6dh5yA+OxLsg8mMsQ27MH/SzwGLgVM8dMhusxkeEDYoD/I9k3MvoWKSgPTFWTo+3zzkSgGjRE/a4yY8rZqZH7ORtrkq19GvZo6UUpAYcw== 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8MM9aeZru+X7LJlmxesPTnfgT0eXIjal6ewRTRk6it44ErAaySARE/momXbw9Zu6KUPLoA4uV4/LnonIiONhrsCQOXFdU9FJNVJSyiwZPTG4/YuXUuC262HKgqrLPwWr8bp33jDsEJ5KVoUsIzZ/H606TX/m5aO0pLn1gic6qdy7+kXo0cotk/32qGHpQrdQnKPD700o1EoiED94Nti3wm5Jf1RBgbhT4H9d1SWKyJLsuWTcMerFsvLExekzFQ5RaK9bdn88W28a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VQSY86LRENSayOJdi06uHleMt1859r9XfPMYvhfKmsZayz2glB83TdbmQoJbPYmVevgdEpdHmOiO1qafMggu3r9V7FdgUWCsD8ZJ8IXeyvYlWe8u7l0USAgbNrNGnM5RQD0b0LSHuwsfgWsyxr79xEnjY1XsOV6DFuOLQOG1LqU4iAYLncjbpDcIHPSZHTLY+rBhbB90Af8WgfDmXl85B797szXk/ccCpqf6KPDNwRx5jtkvWCmAgQhzoiV4pUQrrwITfy4bxqKwW/Oe8u325VjLGDURLnd4FuXw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Qc41SRMMATOJYthAJauWQZD+t1Lx/9kv8OmEbHadYd1SvDQ7cpGFQEv5XnJmucA3CGT5Z5WJrNSzrMJ4pcECiQNP6+rNvsD9uE2OoEZxU3oHI3ByJrJ1ZfLMtiaZwELPbdH3fTn2UiZ3Wg39pLhC9lfsKmtXwjeIDV5s3mzPSenIDDGQgvPnKb/DE70eHCdYmV+WBKGXt9RJRNurOECIy+GXwgAUDs+IkzYvyWn/0/x/hKrd9BkKkdMwUSTiPBRFjTbBYN625TvUx8jcsuniMICEZI4LCqSW7bd80qpaM3je2RwCSLo4eBlPM70dbCfbxRIUaCRxJauFMGQCQ2O6sumg0rSlXazxq3DJIYM/39DT67TK8Mj36nk0B3qO8huqDpG15aQH+rGar2nV+cZ6bVQq0oR5LEtyFS0op1iV4zEP4n8LwAVZEXzFooDI0/E46PmlIuijZ9s71I4ebCO9f3LSdpAOOo+mbw2Tfah56t6PPw7lm743letgmZR8v5PRUesXXbf/QPtjNtZpU+FlmiVCvDX/985leP2Tvwf6K7JBQwY1XNkriF3VSd0CG/2ltFSqBBMH+cEqFbkPRrb9XBb4A/zspzBkK+vImpuyA2I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a91fc411-bbc1-4898-dc5b-08dc954abdbe X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:22.4219 (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: 10/Ru7xxAP+NFp3SpwHoYAjTWI37cvxhKrczjU4HAQCHVgHYxrJoU2yxqr8ns4X6KzhilkIGOPK8BpOBLnQAhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7066 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: YkfakiUomWIeKsJ98R73bpq7pu2zfHLO X-Proofpoint-ORIG-GUID: YkfakiUomWIeKsJ98R73bpq7pu2zfHLO X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1C070140011 X-Stat-Signature: abo5nxnshpbob6hywy8gim4q7nthx4gw X-Rspam-User: X-HE-Tag: 1719342752-524252 X-HE-Meta: U2FsdGVkX18m+Gbtz6PM6vglHp6T8q70HbCV2pX3BTA0HxJ6h1dZIpGRktb1Yj+T2kpWvQVSde0P6sEtngejOBOACfp0n7NAhMahbToluVdud6Iotkyu5/vm/Ip3i2ReCdXG2Qh4lMLsbwPhzpXlPrHme9uupq1+0o0+HntQPL8xsyT2jN1OJHClTDFewZqu0QnGxq2/iYZjhdA9EPukkOXxhcgW8o5qf/LTEwUpy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aA7KVZHRL5Bnrw0e8jB+pGFxQFa64ov0dqnmnITZ6rdMu1o6pgYvJTfJg0vw8rgsm7Clz7mRv4kcW2XoxWkXDoByOqjZOZmaskpw5HekJXz2BsNYYWa92mW2LWch1T9UR4fYGNDWo+h1A== 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" The MAP_FIXED page count is available after the vms_gather_munmap_vmas() call, so use it instead of looping over the vmas twice. Signed-off-by: Liam R. Howlett --- mm/mmap.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index adb0bb5ea344..a310b05a01c2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -405,27 +405,6 @@ anon_vma_interval_tree_post_update_vma(struct vm_area_struct *vma) anon_vma_interval_tree_insert(avc, &avc->anon_vma->rb_root); } -static unsigned long count_vma_pages_range(struct mm_struct *mm, - unsigned long addr, unsigned long end, - unsigned long *nr_accounted) -{ - VMA_ITERATOR(vmi, mm, addr); - struct vm_area_struct *vma; - unsigned long nr_pages = 0; - - *nr_accounted = 0; - for_each_vma_range(vmi, vma, end) { - unsigned long vm_start = max(addr, vma->vm_start); - unsigned long vm_end = min(end, vma->vm_end); - - nr_pages += PHYS_PFN(vm_end - vm_start); - if (vma->vm_flags & VM_ACCOUNT) - *nr_accounted += PHYS_PFN(vm_end - vm_start); - } - - return nr_pages; -} - static void __vma_link_file(struct vm_area_struct *vma, struct address_space *mapping) { @@ -2936,17 +2915,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, pgoff_t vm_pgoff; int error = -ENOMEM; VMA_ITERATOR(vmi, mm, addr); - unsigned long nr_pages, nr_accounted; - - nr_pages = count_vma_pages_range(mm, addr, end, &nr_accounted); - - /* Check against address space limit. */ - /* - * MAP_FIXED may remove pages of mappings that intersects with requested - * mapping. Account for the pages it would unmap. - */ - if (!may_expand_vm(mm, vm_flags, pglen - nr_pages)) - return -ENOMEM; if (unlikely(!can_modify_mm(mm, addr, end))) return -EPERM; @@ -2977,6 +2945,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vma_iter_next_range(&vmi); } + /* Check against address space limit. */ + if (!may_expand_vm(mm, vm_flags, pglen - vms.nr_pages)) + goto abort_munmap; + /* * Private writable mapping: check memory availability */