From patchwork Thu Jul 4 18:27:15 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: 13724178 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 0C6E7C30653 for ; Thu, 4 Jul 2024 18:28:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 925D96B00A7; Thu, 4 Jul 2024 14:28:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D7746B00A8; Thu, 4 Jul 2024 14:28:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B2E16B00A9; Thu, 4 Jul 2024 14:28:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 45C696B00A7 for ; Thu, 4 Jul 2024 14:28:04 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 030581A08AA for ; Thu, 4 Jul 2024 18:28:03 +0000 (UTC) X-FDA: 82302904488.13.C51A917 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf08.hostedemail.com (Postfix) with ESMTP id B37DE160018 for ; Thu, 4 Jul 2024 18:28:00 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OtyaXuK4; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C2m1VjA5; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf08.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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720117655; 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=cbmWb7Ca9QhbidioktTVL2ube+NqVVmgF2/QsnRM2Ls=; b=VSFJAqlo0931pC7z2sj+2ZvdsVSZOcFjpKsg/79Fl4GItfJAxQ7XxtEybb4wAZ7FuHEmtE Tmf3f1LR/HSc9DaAUkp2Ot3qvTX9zxAx+R8jr6BNZCRMziQfxtfXGRnHRTXR2fQlWyS5gT eKlqDJ3ZAOGKwMovXUOdy4uyizg77rM= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1720117655; a=rsa-sha256; cv=pass; b=BsBQTrdCA3latHCzNfZ44lRjYvFZdqOfB8xxEIPq4q8txYahjKDeDpYpwydKcuf9JBaVl5 rbDT7FSmOgE7tjPPpzCbdnIRiSg5DU0IpjKN758P+6TlToqLuGKKOtVP9QMqQGB1xDuKqy sbrxrDf1cEu1I/7SLtLpAijg9wnfh+s= ARC-Authentication-Results: i=2; imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OtyaXuK4; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C2m1VjA5; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf08.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 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 464DLweW031054; Thu, 4 Jul 2024 18:27:53 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=cbmWb7Ca9QhbidioktTVL2ube+NqVVmgF2/QsnRM2Ls=; b= OtyaXuK4A4k1yfwLCxOrsHN1quLSTws/Hqay6NuBYctF0kfm9L1q9Jt+eyTN0QCz QyDRXCc15uvO51A686VwBGnPjyqvqAKD8bVIVYdahQcVFVSUITZAo3O73I/VmGFw /ahZdF5ClHobJW5gVtKtk3wwRgjCMJUALo/W3f3URXpKhYhmYfG5EzXY1Lih3/MI LGVeHKjo16BiNsZ8aj/oGM3uhIqfKhnRx7CqxguanFOEhdRMNMy3q83ELgJMRBFD UFYledDSKbvVKZWlSm8n62W1mUIfskXRmtQAlmxo9We6TPZpPuHvXwbWp95pypm4 cpunknoDuRoFwQjvO4SVtg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 402aacjt0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Jul 2024 18:27:52 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 464FoemP023607; Thu, 4 Jul 2024 18:27:52 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 404n11kmr2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Jul 2024 18:27:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W753l3eLhyGIokJabDDZPLn0BIeXWziPqzf4UcLjRfjAn1dTRSeDUPiNODJrCMh3jfA83AIPU6ESACNmZHW0qmoi1OVSZ1Wn3Nu5fLjT2VbDXWomcVQ7F4nq+f/uTcCbjq+6CFg5lkcAW914pQI3r4/bfp5VNxjrcuSKBbaSAWMoWYgKKaftxZOrt+nOtvDOz9Rsv5yEKRnGVgfU/1alVdw4cKY+gKtomBXPJJQIe4t5rDpDUbn2x2x0Kl2dZMJIwSHPsTFvPwHOiy5Q7Q22qbKb59SVPBtbl+ffB7Na6vJPYWs8YAe6t2otcJyZCAHgN+570rNIy7xnMNTtU2wAaA== 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=cbmWb7Ca9QhbidioktTVL2ube+NqVVmgF2/QsnRM2Ls=; b=m16VBkerahljIur+G3PqqUmbQbELObgMpnc5xX8vvrE0svLog5bhBcCSmGA/amJQ+tdc2XI1I2uhXW7U4IBYVUKmQfzWwF+LFbX25+j9i2t49+iyQAL2yFqFL6t3GeOulb3FDInZGOG2WNDkxwozzy/sB41DnmR8SyTmD6vkdLh0TZC84+EOG4/MeuvnCbcWvtaNsek9itcpOSDTDwTXlMvykWrAMkJCgiVeSnA2d39LIRJKxBX8JtIwvVxsDpcoWMXnF7t3qGBuC0kgxej5b9dEjEYgd5jRF4ST7OHpf936poZ1IsqyjEAEO4RA3LRUBZOwcjVYw+wTc+0XqZ8wQg== 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=cbmWb7Ca9QhbidioktTVL2ube+NqVVmgF2/QsnRM2Ls=; b=C2m1VjA5IC6p93a6IjVLjN4B6YjcO96Cl6lOVKVhWWF2Nv8XMVLEMMqWSzWeqdBXz5BqZw/bcA+U5OsTeT0zu88ILza0gMuWQROlaDqmCTF2UAPsFJznzNHXixqNQugs3ikZeo3KFnXMDoKZoC3d4/qv6JscXA5uEZcvV29QQys= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by BY5PR10MB4242.namprd10.prod.outlook.com (2603:10b6:a03:20d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.29; Thu, 4 Jul 2024 18:27:49 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%5]) with mapi id 15.20.7741.027; Thu, 4 Jul 2024 18:27:49 +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 v3 13/16] mm/mmap: Avoid zeroing vma tree in mmap_region() Date: Thu, 4 Jul 2024 14:27:15 -0400 Message-ID: <20240704182718.2653918-14-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240704182718.2653918-1-Liam.Howlett@oracle.com> References: <20240704182718.2653918-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0023.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d4::24) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|BY5PR10MB4242:EE_ X-MS-Office365-Filtering-Correlation-Id: 6344b4e9-d6c1-4798-b1ee-08dc9c57027a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: sGbxOS4zDIz/P8l3ep74Cjg6csCXlJx5LQwkeezHYE4Pwg4kOnXF0emarQw7/HowM94K8e+SCJFD0Fi/pGdryWddKaPMdi9Ou21pwp6rCQMjMnEPDC2ytfVekLQDiRpk7TjnSRIbubgmU/sPEOUeyVFCU1d9WY4cE1NxzRxq0ZWuB6Iy/zuwvnkuFqT8GH+elt180YAz7DwSu7rDKv4y7AW/fnvDgwOt8gvRgcWWyJLRDWfL2d4TD6RsjSlhKoU4FHIVyJCH2oBy/6G86zXvlHq+l/KhBq6+qadwzbxzHYEqNq9fCy+3ZzFLWLeie4R/P0luwEI2woNB3EM3KAQujvWJTk4VKMvntk6/Kz0gkd3XzbtWB4LJvter1Qn4QKVl4jzxEHS3cp36v/llqDDXAVMUxJXDxDVH5drvrQBmmorr3oVy/JJ+iddIIp6Kybq5k37insW1YzjBfZr4KbyJLCm3xYfSY68emMNwYckPpaaj7Y1iuV8aY0YVpqWj8dtWxZVoW2+xN9+fD+L9vfndqkOOAk6/ruacHqIRCgYaTgS7BjdjtSKjeqvIgV9xHDBqfoNUj+Ic6s8h//xfL8g7rzYUDRLrpv65OOnJGhQodJtVLXOktDoYR//SXCosj9hVQeNmhbh/qLu93vQ5qXfomT1NkQn/u8VCh90ZDiulgZZjdYGesiychl6vps7QLEujy3FJF3H+mSNuGaeLsocxWZJszOQD659o+2KmhSoxOw8/gepUgORN00R3D1NkX9e3db6NwLwWgIHaGtscN5QHZbl532yZt+W1RY7SznRLtdvCanNldKoYr8seQPT4kihx1/uZIXUhwUxqE9XudWif8+T/X5wJUsfUHm4q5XDgUh0Fdl4T7XUi7WbnyEfVnXbjA6r5DW1iWol6SFJK0fHeIuUgbBvWDDaccH1yScHTZVPoGZ3MSM2Q3kptmj8FAexm5E9ZPlP6zZgX/mDY1Hsy8xFrT9922ebvZcgkcSwBmncV/pDmfJx6WHAdA+fVN2geA14lYiYL6ZDKQ0dFLl9l+JvyuqPeGgXaM1IYtdURv16dvxV2Us16RcOFsETtLB4Ju0lRZ10sFWhW2ZemUidyLF2HryR0if6e1yc36J8E1lUA3MP6EpOvJGRbAsfSMIZygTE4lKP3zwlzWgL5ou7SIDQCsbIF6E8eGf/gpo77x9iZTI2uOvBSxt+c6j0ocWR3PIxOGfe9hijI7YmNPJIYx4wwmeAN+Jbb+nItqAk7Ud+t4sPm7Seas+EjhzR5c+2pxkSbPI2WP1LZXLcRsmaEN78/55A8oAzzMMQa+WzWmY6XNE0LyKKQbEBchHbBaSruORGSkhS3QqPImqdTb2tndg== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q6SocswB4fkIIFzMcXroW9ZsrGD1ClLP7AbdNeCf/I3OGHMm9Z67inGW8KfEftNP/mO+jBx/IcK0C/sAblbCXPqxSjNisdiBIeaqsCey7rjkpJKjVDLg8KhJ5zmIMUH+pX8z+ncUpaYrasn/gSQQSXocDqH19HmOP2tIU09Au9Z0Yh7vZXMJHXFLlRdeDis84wep3UFzz51CN3cJRLJwUek61oW3Wo41NvvZXGGEzdsHflE4PC4CfbkdUEw1r/EgYSF4rl6opbEd+pBEUnQ2M8cDXD6wpMN0DyFyuVhsZ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X43c6YNSDztFLjgzZrZCPQxTWewhybB6knZ/XKl1Nie9MTs7+FrhxKlD/BMWrvcjUKE7OyjTko4DRGAC/MXIxedBpa0Cs3/hrRzdt8IuXCfxUliZ03LECgU1OQ50IIsLe0ctgj0xaD7o+zymmS1GoQk3PSCqiSELPhUYET5aeTxF9Hfw7Pk4yjzDJQiLAf+FYIW4bGV5fnPsP3W2cGinq+1eOj9FieMUZPUdyGjrWZHFdw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6l0In6VKbF6m07eVf+xEqjhD3VSA7HwM1ZRre+kX6PDzO8TfAigI0kf+pc8tDNgy4V1PIfx25+pLZtf5PHVqk6SoL661Vx5lTOn1PWM0tjefE8pw9C6mRdtN/98vUGYLG/ba9ARY2lws0bEQSORIpG2kAh7cqoikJp/j3UVe2nP4R0luaYdeS1N3Tk7pC+j43+8Lv9n9bAda1reTB3s+PPYb3vka4zmXJJnI9c79jNiDO8ILSBOKrNLxG79c9mXUZqtkeqY8QKmD6CePlZ0/e6Z63M9aAplFh2PTVjcdtfQtYfBpajkc1SoBScGVBpS0Cd1jKIXXs/TcP8RQvEtF7ZCHDvSpHJ3p7UC2Vk2Pr9ghE/9VOm6sM2uBEfs6ykGrYTxwHFEtodPp40YFYV1psweWoqOX1syXryOvDb3ywpY+7pU6vbOdlbzeGC9dqZjqfbuRr6TrC1Chm5M18e2zj7nm0r6YUC3GPZLgJbvbvZNU0p1/N7LFAxCDWPaHCSU39SbY8z+0ohY5wViV6ovVziNhS/DJi7FKWf/glAxZdzBPsvlBJPjyx4l/qY5Q1m09eOnHN8/dhAUK9XjzxUC/UMhIccSe4ckjDfJh4a1EMBw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6344b4e9-d6c1-4798-b1ee-08dc9c57027a X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2024 18:27:49.8147 (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: WOfMaTlvOnxEkasW2Cpcic7YRz7v1SRoUPI713b4OO2mUm4iwB+pvmWSnGUTiqmAhdXaD7CUEcS0oq8YO3XvVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4242 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-04_14,2024-07-03_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407040134 X-Proofpoint-GUID: qpCWcEOB7OZ3GNrF1LOKsvGRj35glK6O X-Proofpoint-ORIG-GUID: qpCWcEOB7OZ3GNrF1LOKsvGRj35glK6O X-Stat-Signature: 46jtnxw4ib957g3dhfkftufi3to8r97u X-Rspamd-Queue-Id: B37DE160018 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1720117680-406899 X-HE-Meta: U2FsdGVkX1+JcmJHUR2LOpzGogY08iFkkorxAkfQ8sOVw/CDjvqGyt6EK6VGFRspURuypZUJHYL1CDTlTSwiCiqD7BY9NeMiIh8ucgCso11XlonIrxACCR6kIIjaGF2JwJIBKhValwJN4bsRuvdkabvYsA1izt/V+1ZEu9dpJXq9e1lXhl8ekVCttNIZnfpIddGIgMQKiDWZfx8Hi2E8VR3RdEz3m4KK0GprLFS01DhpdigHdZ5wAM9xOSDLqLK3IU8TkJyxG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DEaPhbOSyekkUdSSuQ8CbYG45zjVSjtUPlof7VtseZDtHQlMvB69fiHXVLOJK6xrHB+Ui+9sDIHGkBber3+GbB6Qd8JTGMKnUE43lifFWMo1tWCkQ1+oFENnghRfDPAg== 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 zeroing the vma tree and then overwriting the area, let the area be overwritten and then clean up the gathered vmas using vms_complete_munmap_vmas(). In the case of a driver mapping over existing vmas, the PTEs are cleared using the helper vms_complete_pte_clear(). Temporarily keep track of the number of pages that will be removed and reduce the charged amount. This also drops the validate_mm() call in the vma_expand() function. It is necessary to drop the validate as it would fail since the mm map_count would be incorrect during a vma expansion, prior to the cleanup from vms_complete_munmap_vmas(). Signed-off-by: Liam R. Howlett --- mm/internal.h | 1 + mm/mmap.c | 61 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 4c9f06669cc4..fae4a1bba732 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1503,6 +1503,7 @@ struct vma_munmap_struct { unsigned long stack_vm; unsigned long data_vm; bool unlock; /* Unlock after the munmap */ + bool cleared_ptes; /* If the PTE are cleared already */ }; void __meminit __init_single_page(struct page *page, unsigned long pfn, diff --git a/mm/mmap.c b/mm/mmap.c index 5d458c5f080e..0c334eeae8cd 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -401,17 +401,21 @@ anon_vma_interval_tree_post_update_vma(struct vm_area_struct *vma) } static unsigned long count_vma_pages_range(struct mm_struct *mm, - unsigned long addr, unsigned long end) + 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; @@ -522,6 +526,7 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, vms->exec_vm = vms->stack_vm = vms->data_vm = 0; vms->unmap_start = FIRST_USER_ADDRESS; vms->unmap_end = USER_PGTABLES_CEILING; + vms->cleared_ptes = false; } /* @@ -730,7 +735,6 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_iter_store(vmi, vma); vma_complete(&vp, vmi, vma->vm_mm); - validate_mm(vma->vm_mm); return 0; nomem: @@ -2612,6 +2616,9 @@ static void vms_complete_pte_clear(struct vma_munmap_struct *vms, { struct mmu_gather tlb; + if (vms->cleared_ptes) + return; + /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. @@ -2624,6 +2631,7 @@ static void vms_complete_pte_clear(struct vma_munmap_struct *vms, mas_set(mas_detach, 1); free_pgtables(&tlb, mas_detach, vms->vma, vms->unmap_start, vms->unmap_end, mm_wr_locked); tlb_finish_mmu(&tlb); + vms->cleared_ptes = true; } /* @@ -2936,24 +2944,19 @@ unsigned long mmap_region(struct file *file, unsigned long addr, unsigned long merge_start = addr, merge_end = end; bool writable_file_mapping = false; pgoff_t vm_pgoff; - int error; + int error = -ENOMEM; VMA_ITERATOR(vmi, mm, addr); + unsigned long nr_pages, nr_accounted; - /* Check against address space limit. */ - if (!may_expand_vm(mm, vm_flags, len >> PAGE_SHIFT)) { - unsigned long nr_pages; - - /* - * MAP_FIXED may remove pages of mappings that intersects with - * requested mapping. Account for the pages it would unmap. - */ - nr_pages = count_vma_pages_range(mm, addr, end); - - if (!may_expand_vm(mm, vm_flags, - (len >> PAGE_SHIFT) - nr_pages)) - return -ENOMEM; - } + 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, (len >> PAGE_SHIFT) - nr_pages)) + return -ENOMEM; if (unlikely(!can_modify_mm(mm, addr, end))) return -EPERM; @@ -2971,14 +2974,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (vms_gather_munmap_vmas(&vms, &mas_detach)) return -ENOMEM; - if (vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL)) - return -ENOMEM; - - vms_complete_munmap_vmas(&vms, &mas_detach); next = vms.next; prev = vms.prev; vma = NULL; } else { + /* Minimal setup of vms */ + vms.nr_pages = 0; next = vma_next(&vmi); prev = vma_prev(&vmi); if (prev) @@ -2990,8 +2991,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, */ if (accountable_mapping(file, vm_flags)) { charged = len >> PAGE_SHIFT; + charged -= nr_accounted; if (security_vm_enough_memory_mm(mm, charged)) - return -ENOMEM; + goto abort_munmap; + vms.nr_accounted = 0; vm_flags |= VM_ACCOUNT; } @@ -3040,10 +3043,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr, * not unmapped, but the maps are removed from the list. */ vma = vm_area_alloc(mm); - if (!vma) { - error = -ENOMEM; + if (!vma) goto unacct_error; - } vma_iter_config(&vmi, addr, end); vma_set_range(vma, addr, end, pgoff); @@ -3052,6 +3053,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (file) { vma->vm_file = get_file(file); + /* call_mmap() map PTE, so ensure there are no existing PTEs */ + if (vms.nr_pages) + vms_complete_pte_clear(&vms, &mas_detach, true); error = call_mmap(file, vma); if (error) goto unmap_and_free_vma; @@ -3142,6 +3146,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr, expanded: perf_event_mmap(vma); + if (vms.nr_pages) + vms_complete_munmap_vmas(&vms, &mas_detach); + vm_stat_account(mm, vm_flags, len >> PAGE_SHIFT); if (vm_flags & VM_LOCKED) { if ((vm_flags & VM_SPECIAL) || vma_is_dax(vma) || @@ -3189,6 +3196,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, unacct_error: if (charged) vm_unacct_memory(charged); + +abort_munmap: + if (vms.nr_pages) + abort_munmap_vmas(&mas_detach); validate_mm(mm); return error; }