From patchwork Wed Jul 17 20:06:49 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: 13735733 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 D34EEC3DA60 for ; Wed, 17 Jul 2024 20:07:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55E646B008C; Wed, 17 Jul 2024 16:07:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50E446B0092; Wed, 17 Jul 2024 16:07:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 313A86B0093; Wed, 17 Jul 2024 16:07:33 -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 0EA926B008C for ; Wed, 17 Jul 2024 16:07:33 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B5982C0C7A for ; Wed, 17 Jul 2024 20:07:32 +0000 (UTC) X-FDA: 82350329544.22.33BA2F1 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf14.hostedemail.com (Postfix) with ESMTP id 567C9100012 for ; Wed, 17 Jul 2024 20:07:28 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=PXMg6VvV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VOsEjgRS; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf14.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.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=1721246808; 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=vBrw4cpyDlw0oCxrS1NpsHrvh6il04b/OpjjP2KEzV4=; b=pZpvp9i0tC1wloM2B4+bOiX5KipCy3H6NSD2pGNgaQnHnOfHpQXjxgq5Xs3PB5SizGYPC1 zzEITYgfMz1+ZVPGXsvQNtpJ1dXQaiIRbyWg8sNznymGpI21uUnG/2Ul7qcxcTG3QWHAzh T6sdRhbGbmYR5HxtA1oKVtTiPFL99OQ= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246808; a=rsa-sha256; cv=pass; b=fBQzuaIJziTgqRPil4gNSpe7fSskwmVEfr4SIGXWptukMs2pZ/YILz5mZMRaLZ2tYmxtQx tbSsu3fjB/bXfTptk+g8yeDmvU8aZiyxbjx3pkfRQcQJxf9aURTJsH0JRDZ/X3BxvkKHWF uubVqOO+bHDks12OnlKpudHqos4bUDU= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=PXMg6VvV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VOsEjgRS; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf14.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJu5hB000339; Wed, 17 Jul 2024 20:07:20 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=vBrw4cpyDlw0oCxrS1NpsHrvh6il04b/OpjjP2KEzV4=; b= PXMg6VvVChm6zPaY5LxlXGuDAk23rLTAEuihIW339N2dcu4knnjE7D4uhSnD6aBY Q3BjC5RuYHrWlTgtd7wwdFBEmKD6eCvbcz0EMDP4OD1oXlxDUkok7EMJ8f9ua6VM DSQdnco0RO3v4klG9W76IPAKvCSIitzkIKqfiDdBkjGMuyzqfdVR7KHTE/HrVJk1 Ot5Lig3trbcwbfCOnbCbVF9HckP6BFYPd+zyCLjnih1KkdoBgYVnBh/t4c3X3RhY U9cFnS2fBVM7QpJCO1bI78EG+vbh8fyGZRNGLgX5dkGJoI9iHrz0rc1rdmiC24OJ Qgw6MLVWh/cnvvnR4cSysQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emhpr0q4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:20 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HJ01Pu006829; Wed, 17 Jul 2024 20:07:18 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dwey1f7t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J+8Zpl685VyB6GnOoPaYwgeIVSTMWN9pHHLGHFm/F8+31mK6kZj5rQBPW8iKPvdnWNbMEtTIjhVw9YE/R3Qx4JVAZuQCNHJ4YPWTSdgKQncF4r2stoMlNw3uGUrocs8+PiUAfLbC6+WWpoLSyG93PyI01XwavgoRG4q2CBM3jmyts3J1yOL4DlxTvwf0WdQ0QQ6tmq7CllfzQI7L+83J/O9zhMkC6kjsSS7gfk438EW3FT2lQuH4lpN3nidng07QVlG4V/eEv7avL/Y0RF0rFz8jolgFWAyZ05SKbMM3j5D+1tSIxusRm8Onwkfr/589sNpeLNhJ53a70loaIP3vwg== 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=vBrw4cpyDlw0oCxrS1NpsHrvh6il04b/OpjjP2KEzV4=; b=YnZzkqnsVdpKq0YIYgdiSLBVr0nCXBZ6KHbnlm3OM6ki7K6+RphKkns/B4lfchsqGf8w6NGv92v/PdjODATxSKAFzfZG8bvMVr20kkFH60rPNY1W1yYF1xGJeQp7WdrYfXa5zdygaSbcHBXv1jV2ftKVT6pAT3S09QMLIJLNwZ9SkXTKa8mufhiykJDNH5hsAyjRZbrquqB43WAkeLanTjGl4j1ToVC5XYL7HXCYnci95xkUMUJXHixVGEUhLOxISqCn4/m5hT9xf+sDS3rCocnYhCdcEgnhyaXxfgem1da08MYw1qf1aHf1Y+JaBQ9ZZGrkOzIzAUROC6zPkyzIqg== 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=vBrw4cpyDlw0oCxrS1NpsHrvh6il04b/OpjjP2KEzV4=; b=VOsEjgRSUUQGs3auk+9Zi3ip/V6p43uGOMGR+sUQWJmQv9E0UedlN7DulpJxLzb7bsiEfRSfDLoFzeyb5Ekfycc5y325ykXSwleTMo+Ptb0yo/gN7hAi4GXKEoKtQ8awoVOTCL9NVrmojB7OebO+yhcSg0MMcXnvHiOR4kKJecY= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:15 +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:15 +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" Subject: [PATCH v5 01/21] mm/mmap: Correctly position vma_iterator in __split_vma() Date: Wed, 17 Jul 2024 16:06:49 -0400 Message-ID: <20240717200709.1552558-2-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: YT4PR01CA0242.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10f::21) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: 601ed92f-7f4b-4ad4-5dd7-08dca69c0d93 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: Lye1SotZqYbu9AKIX/iRjbsoSp764YIJuWJ8w16eR2Q8I2cWCG6BwcU2CmqeottneQQN/iFU/kOdJIIfeRig65vqtFo7kINJqDC9nmZK5o46DLods/KFrDnHQ8+ah1gokKLm4fAaDHjKfOGjW6FuC9M6i9o4GIFOE5VnI+MIyA1ujV++vkRFtf9oNIiVyxzqM1LcB69AnXVu9TjsfxnksVI8xJDglNRboauzA+Dhbm9R7KroQuHxJc6chXsp57z8ba2RlE+SC+VcLv82Bwrj083MOPGbkGY7H9GIdCy7NVV6QAJDsGsrmWPFFaybh0BrvIsYHDKj+iFhFNBJhn2uxE4C+73djtjkFDH1ivxtOLsE7tQuxouGTEFUytAIJGO/atO4xtY4OFhottxD2dncT84yNYJGZL+y0E8Uw79CxYHhRoQfGUB3Bp7ZODQ+kb6Q90NTQe7mhi8yIixFQDXnVjH66O8R+JlE8RdsGkjK6lzIlxAoijTfxuzUp+IvB2PTK0FSrjJE0ABgX6tywagHMlQrnMVzCLDHWcILZY3b+VYpzcRsjLxnvUps/hwj9jxJXH6mQBgBq5zdp7qWWqeFYgfuX1gS2C0udbNWqU00xlE5S7mGjcGFoxx3+9+mWUGw/xLghOIOWivRd61DsI1jMi/efUjSxEigMZNc4z9ucGF1vnatd0sjtxs/eWKXyFN/zEQyiG0XnYjvDngRJbgwqxPSlRXs4kb3TeOgxZWxgj6gntdg6YFmLitfDtGOotbgDqk9CxIOOSQ+Zb1WBmddUaJg7S2q5yItpQKH0rKquSXqHYnzdAB3QZ1WUT748qTidN53gkyvvyfvHjJYaU6Oh4GRkT8ssvZ5FwfNNQqECEPAyUXkECGI6VJoClnbQP6P+2TxU74n0Hllus/2GAkwRaAqfGt5Z8rQv+5aGEFIl06RxxkopWArXIfgATpkovwKcKntxwLnMchtnBjcXXxhN9H2S8ZG+6T5RnviDkU28EeWY1L40DlFMlC5ZPxyzHJ9ba/i0xsxuXZVVLqDkiaO0wwKFGUVVS6bkSY4aeGFw4zhOHwVABhC6TzKpwbOWAtfgc8guwOCm1OSwlodbbTFjUHxjFkjpueI6eu/C91Kkodt3+ktFaaH6IB43jGXGHvM2gmqGIGPtcNIfq97nvMQJ+U6yQEMhTFQNGumTjpIxQx45/juEgT4mt6hM28fyK6OqWzQt4sW7bEcvf5gm/EDX9GIt1UIIsmC28GL1YP2As6NOT45rTapPy+DxJeWXOaMsJZqGat2gRWjLQcGmbRDrOrkFiZTckMJCaFJ/DarWIKyvVvvSd2hfuO0h0STaH7/zQy4Tmppbr6k3mERpKd2Dw== 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: RehTt9hjQSgvOhQHWS0DSfsUzlgd5nVWV87librkiTso+nqo3JpRod6ppw17fS9nD0oKsx5OSziBuzYrMFG4Ptm4228OMWNd/t/NpslupTua00nQNUA1MDmpzn4/obveLwHZGtq/MOM0/Lv9HTtJ5J4JdRxm9AGZ8jZa64oy9Aad7/E7mnY5CsrAfnKexUMRkkPTwXyofJKmONlnR2Hm5hwPjjyzAV1iDVldxtoS57Rnn+8YEdKf0uKwq+jOiqQS8okh3a+s0VrZoYCkI6jGhh5z3Ns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85yUiWMadL+ql+PDODWk82AS7i7q0dGatGJ35CpO4KbTLNRPQdA0KsjSv3lTYOfB+RZJPqsmhzIiX5EIUum6dKQdL5tq++7XS6Hk41CpYPIDzrZVJWfeN1TcZp2y/oKlyzOjKvtwPZwAavLkXwNskJJ4Zt9O4LCkFlzVZaJ/A3qSLjZsF2fTtYOynW4AEbB6Ikh9OuzJxW5RM7xA9JvKOqMcK7wJvyYGUg42OlpWEAQhtzlV0hAjv3HPxSj4ZBJ3divE29V8EcIA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Vt7qNiN7clzQPgCUlr1B142FzDrMIQodC3KehzzdPbxzh0H31S4takTPTjDbLUeQaQ3H8Ll13aDIUkI8WKq2KYYy/08FFLyYlpQTmFJfaCa2gvnXH459zkiMuE3od/0LIE6J3wisvbT+45UWrKYTkfYREYmaQcxgeChVB8lE7ZyiP6IVxYl5z757kFZ0suuLdlYzw4cUiDbdf0af1xsdPAxQfW3HpnZIY/pst7S/1tuULuBBAiaA+dBqZkBe2Hx0NtfSG16HLntefRnKCr+UKMTp5o6PArIRt2Jf99vOqUJuyKQTDIbLVZsCJM7eW+Nf77pqZI+pxhzv2qtRzeXhumPteOy7J7yhQzNq7JsT3fXTUjMOwkNt02XodU6PwPjwtLgCuWru+kFz3b6PVZecxUBmzDvRz4qfquTlSOnFCZwa+W2FkHbFGa9ev2A4G0Et1c1hGUdvsyw36FdTkcUpaAlnUkT5GzwU0NHWkPQJbEiinvptoLTeiGt46PDXuCOM69l3s3LDBuA6L2YgMb/ZuDifYWyLF3zFCH1ug4q5gBs5Be+KYU2LAe2w0rw60yyIT99B/gdqMH8A/tlLb4tuXz2is89DE5RH/tIIFy9eEOo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 601ed92f-7f4b-4ad4-5dd7-08dca69c0d93 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:15.3726 (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: NgtYF8bXCuReoB1TnYjaq900+/AgT9zy1vODnUpRdhgd16IMI73yjxGvM7/Gg0smATC1HFH/8G1xufE2hkmmiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: 8OI3qzsgwM6PVv8UAj1fSiyPCHzfEas2 X-Proofpoint-ORIG-GUID: 8OI3qzsgwM6PVv8UAj1fSiyPCHzfEas2 X-Stat-Signature: afwfzqpzzxx9de7sfm3dgcdh7b87tyzh X-Rspamd-Queue-Id: 567C9100012 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721246848-8251 X-HE-Meta: U2FsdGVkX19a1WEQY6uWzVJTcjtsPwnhWEKDDRwa/R4BAd7aGUTPDMJwi6x7nHIYUVPyGv+h5018TKj28uu5rSxvnoESwH6yjhEanLoq7k/2NKo5cD5N46jMqjl1CZ0DSER0aLuouWnBZgWIlBnSNewjO0bQa7uK7eg+du4Rw1HB2nMqV4ec9abNe2wVgpus2gpeU+7rFx6nWLMSwlkME/LOvHIJlVaoSzje3HqPU4vYSw9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rzQDt5dAZSE+AYxmSvQpxUKtyewaNlOh1ECjD+EJCEtEkX5HHM02dHP0EpIMVuXYfaFQpWjf1r5Vk/u4bjbSuixl5U3/63myRqnl0pPtylzTYY/Az6ZFOOYSdhIYJ2ezA6a2dcdrocYMPa90iRHMGqRACNofX3L9lZj9CuAxS7pb7zSUjX7/DCV6/l+Qc7JW0X/Thx85nS2bx5Fs7zAbAibrpQn+mowk5nIxVRjDVhXBu0brSOQP6YerSkf0Mj 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: The vma iterator may be left pointing to the newly created vma. This happens when inserting the new vma at the end of the old vma (!new_below). The incorrect position in the vma iterator is not exposed currently since the vma iterator is repositioned in the munmap path and is not reused in any of the other paths. This has limited impact in the current code, but is required for future changes. Fixes: b2b3b886738f ("mm: don't use __vma_adjust() in __split_vma()") Signed-off-by: Liam R. Howlett Reviewed-by: Suren Baghdasaryan Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index e42d89f98071..28a46d9ddde0 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2414,7 +2414,7 @@ static void unmap_region(struct mm_struct *mm, struct ma_state *mas, /* * __split_vma() bypasses sysctl_max_map_count checking. We use this where it * has already been checked or doesn't make sense to fail. - * VMA Iterator will point to the end VMA. + * VMA Iterator will point to the original vma. */ static int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, unsigned long addr, int new_below) @@ -2483,6 +2483,9 @@ static int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, /* Success. */ if (new_below) vma_next(vmi); + else + vma_prev(vmi); + return 0; out_free_mpol: From patchwork Wed Jul 17 20:06:50 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: 13735734 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 88E5EC3DA60 for ; Wed, 17 Jul 2024 20:07:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DF836B0093; Wed, 17 Jul 2024 16:07:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 164D66B0095; Wed, 17 Jul 2024 16:07:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAC506B0096; Wed, 17 Jul 2024 16:07:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CA4E46B0093 for ; Wed, 17 Jul 2024 16:07:38 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 87674140C74 for ; Wed, 17 Jul 2024 20:07:38 +0000 (UTC) X-FDA: 82350329796.14.F0634F1 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf23.hostedemail.com (Postfix) with ESMTP id 22D90140023 for ; Wed, 17 Jul 2024 20:07:34 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="ZIA1iP/G"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=i4pW+gnO; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf23.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=1721246825; a=rsa-sha256; cv=pass; b=d5u8mznMeF3v3Ynq1OoPNn+GEh6Dj5M6N5u5A29cstBRBT+oR4jHaMkcFufkwlLyhh0uU8 nhSAvqCVcWNQkIIV9/FiEjWGtM0CFwB2Mp1ovbT/n0hYHDqCAy426dqbItx71wSPw5BFX0 u8l0JdY59Ol7QfF1yhTS2lG3t3BkeAQ= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="ZIA1iP/G"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=i4pW+gnO; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf23.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=1721246825; 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=wem2AJBoTGHtBckyqvpen9uiSUKgs9mhKNjHQHA0o5E=; b=lYuNBDGTJ084/3ck/3LZIkqmw29s0ODubLqFF1k62B3Jir9aOknGd74QkvBgxnCRzfDeK/ HvX2Ko1Hprgc6hGTA+JelyEmsxpbAxRpVZhPFYlMvVTAl8YaKKugjyfxUSnHWXLBB6uged ikgh1mW6wRCoxln/folGPbu1xk3Z5mo= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJtlDm031584; Wed, 17 Jul 2024 20:07:28 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=wem2AJBoTGHtBckyqvpen9uiSUKgs9mhKNjHQHA0o5E=; b= ZIA1iP/GGVdIiWFx7zHprxM6H79jnoNvqLFAdnXXJwcNikN47hdhnizNe3mEm/0o dCyYmfSSy1SqjAxqG5DL4TFcoqEE/UwfJ2Z0AtnoVNCXPI/dfcSljl4w0P2mbeer VYWJiaxTXStGpAcymAe0cbbkl3JIlRq3fKrXShghKndt/rnG8pVf2XJKffHrvyYN J4g8QONGr0vNoggT5U0JDJRg+TzpMWtbtKowUd++c59EOC/z6S0uuEgy9UoCPOlr i3aCJWS/Uv8yVJN4j/XcMuNE1K7ee6xRKpaZwVUIqdkoP9Ux4t0mOZpzSRY6LjCU USotMqNbNdgLiNtQwIl3oQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emhpr0qf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:28 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HIrJXk006940; Wed, 17 Jul 2024 20:07:26 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dwey1fcb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W8nJvMHJBbDc4gPv0yTVQSd1pgBxNo2fvb0Mj1JOa34/PCKMIsgjYijjAveYEddgNc9WT21QzeAmZYWmwjr7q0rKcDn8MS/oscC5aiJUmDZSkHkEfcap/rkSfDXpxCHvg7eOA2t3ccSCXTBcaATGQmTRxIZZfok8q31Tyu7fWUbpa7voB5u8TqJV8EvmDjcl+XZSWabw0gSTphC5XCB+GId7c1j5lp84J7FLU8KLQyQLQvJ+IkNag8OZylxEseUhzxt/215f0NVS2Zxqvg7XIMHtdLbYvcFBOGeLXg/Ixxe88Q6iCvUmyCBfDjT/kkGerzohrFEdtgjRG/mVnxk0bg== 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=wem2AJBoTGHtBckyqvpen9uiSUKgs9mhKNjHQHA0o5E=; b=Bd98euYxD7WOZZaqpN29GWFXFKHDO0iDWWBXnc60ERQQ37/EE02cp/xI7+ljiPdbNhBwILuoHnwKf7wUWmaU1TJPjECqT2edyUpEAZ//PVEg5Zo/DMNYkv4aIPoPiixfT82180P4kaI1sgzo+W//VjCVajQKXG6SLtoC8k5WFhiOcqivuFvBrEpSmWU9PL1Ne0oN5/CVZoUtBtN4z3RCerXQPlgFr83V/NuSkSHgLawwZBvI/PFUQl0kTxHIvJJo//eL2fN9eaSNwl9Q3Avxwdryf1v9mqd3aBbCmjUmvyep5IeqAN+TCJF/yDGyLjcCQkGjmarM8WXqglKGcsoZzg== 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=wem2AJBoTGHtBckyqvpen9uiSUKgs9mhKNjHQHA0o5E=; b=i4pW+gnOSVnA3s7/ntzREOViaBZMNHjlfQNnO29A4x52ADTrbHbMKUxi6u9yvPmPuYIRlO4QcvchTjTxZ/x1gcCi/QZjwbAVK9o+Ln0x+U49VwDJ+5hZCVtSjGnccZSlUmRM9cQSk04duA4dPoiublgUGnIWYFb6m0Hu7Hiw6jc= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:23 +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:18 +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 02/21] mm/mmap: Introduce abort_munmap_vmas() Date: Wed, 17 Jul 2024 16:06:50 -0400 Message-ID: <20240717200709.1552558-3-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: YT4PR01CA0459.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d6::18) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: f7f43bfb-d2fb-4ba5-16b8-08dca69c0f2a 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: x3mJTI5lRr8oOddF8b9f6nxCpq2Eh1YDmnQe0rVsLtv3mTUuGysIQHZPfnc9z5GgoWUog4j93aBdb71fXOZIyZz3rRe7JWLaOHmVA5qQF1jDyiyhaPy0VI0LC3XnIh03BYZpvMfD2NVPP/nUFs/JvPuMqWu5LwIl496bDHexzcuOkuUAenmEXlIbAIRFvUFqL6ozEpxHMOMbhrOXmhcEb8UFfknlY+I2QLOBX6mkNa7BYZwRjLKCijP7jQuXfrXatEznBx7mUPbVwuy/MZxzYLauldfPNCJjlw0aUTpIpxrFXEgvuOC66NfTiQMJBNr2+KtpdFAA/ogKNU2MBsQVBaGXBJ+XXVWlxAgXPE/QFzizUQBRs6lWsuSt0rckZysqHKoZIrcVqFoJqY48742VjU6P84fDd8xiEJNtIk3MccAAnu6cG2mEu4BuCM0Ta8t4ihiQQsLRgTB5O250pTtlysUnoJxCLPiJUN4qVFcWe3bYJ1hUB0gmN2UGKRTx30R/9YkjbN+F7BiylpTYBl9EkQPKf4gEps43Tvhnz0Ro0jpMf8JL/vKwV0xXPWKgUsXgf33DvC3Es+3M/5h0KWalmHLmLyRmGEYZxM6nloGWxgVBuwE/t59nJG7t/V11BP8JaTB7z/alY5jiUwzbf0XsWYpeRmbfWRMtqh6BQpkMfH0EM4FJAtivbat3PtdakxAIFtfn+w5gYMoAgYfJGYNG+QOYnC7PEQTmGav+ds5IKEy+iDBOgasZX83y2YotHcYIw6nL0cp2mrSMv8iW6lHFJifbJSk9s10O33vQbITvRYv8PS9I29FpAQFm0/lFik2PtyB/kgz0peIfx76bCQ/shIdRHrXh00Mn47iF7+z1uTqncjCLEj6St+rswc2lbcDGrhwgV3A/MlpZsNeADoo8RcqXbccCfv3GBY94rzH7pq6Ndiw4GmIw59RGevXFOrtf65d0W77E6sI3jhzunK/JcUU41pqYbYt2f9extmqfnumELiiTG2M4XXj2SEO5flTGcP6mLT7ICkRXIXwdx+/3+iR6Pgfycr9SEK75Sl3xpGztrgjP4nBjj2cHlGvQACrcSO76MvdDNFqcrHRO9NioW0c8K29+CvRGZ9uUUSzLb65v4ZSv8Tly2WId2BECvxRrDRQWstv3/uYxH1Pydy+xf8VSyJFeZTIsFLo1f5+fN/KWrGBjyvGgteOXzH7LbdeoeKwMXfw8e8Y1QAq0uHus8F7LYay8CIhxRq1FolCymSOaXhqF8Tp6u6nnexdJSp1XAmN7JLBcdWDklBn+LhmDNOK05PuYvtdaOF5MJh8ZAdiw8n3u8hggrKDrgkAjGPL2dHO1rG3H53xHIkXqcRdiRQ== 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: SOX94kEo2GhU2l52u6K2vsmOnJQ/Zamm8yn1LD0xrwoQ4IdqgrnJzMGqb38IRU/8Xce5gwd/Z4dQrn9Byd01+JIPvLBYnq/WI2Qlju5F93tlpkCMI9knAtCz+nX3iIjZmb/4J5sG/MKLKmcE84t7aOQc93ZXb0qSV0qKuyp2eByjKhBHCnZnF9mjsdkuzoHuzzdsY9qKZjhF1QnQft+dyciIum7PwW655rhGvG6XI6/UJwaYVG20Rojz5WAGcuN8351+A0pAXnNi2xHVqA2eUTxK6l+6cNB7Epx0JZdu7AvwKYc1rKUZTZo4tSadxnInU/YI74nntvTF1f6CQdYuBZ87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TSysW6igiacojplCOdiuaqRraiop0DlovD516BLEBhmfG3/evrTk5Y0NPHYJvbuk3qk0spfLv7Yoecamn70MtEQ624qha29GNK40ulEws5kLudWjH1B1kaHSi4p4eYT/t/EDdoxOZaR1orpxYWh/cP743cWW7vw23mbLVnwDeQFR1pjO X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: cMuIu1Z7h9LrSz3cEydnUdk1zofbu0MPZZJ9Xguy//0aCLXqyUPxL+VZYnykhVy/FmtdxtEmkRGC/IsTBx3DY+xc2KBqRuc7aoPVZCU17fL5r5T9f27Kr3h16B+CfXVAkiOzdStskcgfUt53n9lWSyHSM6nBae3CTtUjs32uHhQm99m5T/YiN5q3aZtpdt9kS5/b9A8KY+Gwls7wqHgFyl5bfspvYoCi190/NnURTEAVoZ7dmkOOYXm1AcwROY79f+gBfIcfQFGIsWE/LdcS/fu2b5OGIBQFY+DuoEFuNb3bvF3z23Kpiruqrxnv9/LP/Fq1ACegWkQXzq+T//J2rl4WypDsqLSbz9xl1EYBq6C4lsdixFjLhuXuG8P86RqLndYtZxNn8H96vXDQRwIYf4Q0y16xGr5nqSj4fLIkWWFYyTHBMohbVCBwyvIbxeIImsn807ql2Ca9/O7U+HekCfDlqD55pnmlWftx+jpqzv/m+4WLyB0wMgeeex2LvQaacCERV4BC2/4BSiaNRbADQgyqak9lgr6VqMzJ24ErSToROQgaap41Sr55jX9e0aJQh72lQRvQNY3omU7rdeNongtmdh2mhY2cY3zdf/rwbeY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7f43bfb-d2fb-4ba5-16b8-08dca69c0f2a 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:18.0283 (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: EjUkB1chtJUogZV/hlklPwq2AXKFvgRhO3qQUuQPLhhzf0sxqHGoCjR0C/+hHegkX1649nLga6tyteBXUeWsRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: 659WKp4VXWsHkCKUMiFhSCsM0zMKIQwV X-Proofpoint-ORIG-GUID: 659WKp4VXWsHkCKUMiFhSCsM0zMKIQwV X-Rspamd-Queue-Id: 22D90140023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fxtmzfngahieez6attyfr1cdw5684ada X-HE-Tag: 1721246854-811736 X-HE-Meta: U2FsdGVkX18wTU1+8bNkvnTuopy6JMm4ZEhlM9yDX4FVUrg/hmF3DSqRA7vcyqwOjSlKILz6y7g/ND38V7L5nAscIYqVTkg05hEaezM5bICKKYZMS6rnfoJrd3mVI+lA9SFyT077hyadD1rhNucRuJL2QZ+UAwGUjyOqT46b3KEckGFXSeFsBeevTwTHBGiSqMivz8crMVG0sKAKtMgDQ7UdFZaasBnObUDw4+M8DKNZV85xYK/cztcM2Jhh8hyYrGETL53ZkaMC/Jwhohe7S15hm+P1xiYSQk3M4TeCSQCF5Ij+Cqv1cC+VeY+w1v5EeRDvFNu6eLzyUxfMRxGzBBBFhOW+jJnxgCV7UdWKrjIU/e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dQCpYWT+SlOvU+huuc4C5hPuoc+JKBgUhvT96meV1uUcpiIYGCsm967MlBkDXMV48jJp5QrZXhjlSqjdqr+tgbYHjsxzlnusYLyRVjV4WnxTqaSogtAzJI= 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: Extract clean up of failed munmap() operations from do_vmi_align_munmap(). This simplifies later patches in the series. It is worth noting that the mas_for_each() loop now has a different upper limit. This should not change the number of vmas visited for reattaching to the main vma tree (mm_mt), as all vmas are reattached in both scenarios. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan --- mm/mmap.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 28a46d9ddde0..babfa50f1411 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2586,6 +2586,22 @@ struct vm_area_struct *vma_merge_extend(struct vma_iterator *vmi, vma->vm_userfaultfd_ctx, anon_vma_name(vma)); } +/* + * abort_munmap_vmas - Undo any munmap work and free resources + * + * Reattach any detached vmas and free up the maple tree used to track the vmas. + */ +static inline void abort_munmap_vmas(struct ma_state *mas_detach) +{ + struct vm_area_struct *vma; + + mas_set(mas_detach, 0); + mas_for_each(mas_detach, vma, ULONG_MAX) + vma_mark_detached(vma, false); + + __mt_destroy(mas_detach->tree); +} + /* * do_vmi_align_munmap() - munmap the aligned region from @start to @end. * @vmi: The vma iterator @@ -2740,11 +2756,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, userfaultfd_error: munmap_gather_failed: end_split_failed: - mas_set(&mas_detach, 0); - mas_for_each(&mas_detach, next, end) - vma_mark_detached(next, false); - - __mt_destroy(&mt_detach); + abort_munmap_vmas(&mas_detach); start_split_failed: map_count_exceeded: validate_mm(mm); From patchwork Wed Jul 17 20:06:51 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: 13735736 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 1A216C3DA62 for ; Wed, 17 Jul 2024 20:07:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5600C6B0096; Wed, 17 Jul 2024 16:07:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5103A6B009A; Wed, 17 Jul 2024 16:07:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C8026B0096; Wed, 17 Jul 2024 16:07:42 -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 D36826B0098 for ; Wed, 17 Jul 2024 16:07:41 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 644F2140C57 for ; Wed, 17 Jul 2024 20:07:41 +0000 (UTC) X-FDA: 82350329922.09.52EAAAA Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf29.hostedemail.com (Postfix) with ESMTP id 3845A120007 for ; Wed, 17 Jul 2024 20:07:37 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=L8Qn6u6u; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="kIz/lBPa"; spf=pass (imf29.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=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246826; 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=dpHEzn80OIyOxWiBfc/i9nreyp81gPbsuptSnKpNCXI=; b=vjBeFFifXmIffR/H4GK5hZIjwIdGROdn0RHM1lLFewAGc8IGuyJXTBuqSuy+Y0PXR9at16 IVz9G3Wv66pabbaLDtIAeCPxs2i9hn4YQxL22V3GBDRdcaP9wKZCzT9H3yu7N0G61wxe0R qkxsgZuRuNgx9CU2u1sF2SS0AN6FX2Q= ARC-Authentication-Results: i=2; imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=L8Qn6u6u; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="kIz/lBPa"; spf=pass (imf29.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=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246826; a=rsa-sha256; cv=pass; b=0AkB94FMkAfWmlW5FLSoU6/ZBAUkrfn7whSPjrrrzQAWArop94NBRxf1VHYDZoi+UcWNl9 OmEumga8RfHlFFy3+YlG+lx5TxJNUJxemGbaybTV2FCBu1BBdJUukiDXmf7AEqHLyiCJY3 8PYAdZAUCTziQmHfRaubHvw7FegjE40= Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HK02JU028040; Wed, 17 Jul 2024 20:07:28 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=dpHEzn80OIyOxWiBfc/i9nreyp81gPbsuptSnKpNCXI=; b= L8Qn6u6uI0rigaSQ56VHmhUlWrMua93Sqy8GV8Slqr1He+Ft0X9tCEG3z1LVceuZ JJffKVIFsP7nxRK/Z0RClQtrkXlvFL/3iM1F3zUgjtd9BuAFJr5VTp90t433vbBq 7P2JR5Xvq3y/wRm8MqFIYdDX57wHnYkgjIYPmfq87eUmUww/PVqkrv3+moimZTH2 AIKkUzNFW2GRGv6zNRsNU8yxfzwCAejkaHD8YP9wejT/pOusfNMn8ahywZ1P3npf NQ9UOB/33ijfTU97vqbcyvKRaQCK0/nqAUseX+oodXCexz6MQpzVwbIwyJhjS3Re YGhHRnhj1cF2MAJnrIbJDQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emkyg19k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:28 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HIrJXl006940; Wed, 17 Jul 2024 20:07:27 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dwey1fcb-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cUSht0IDkIuSCu+OnoiRYek3cOumGDq22liHknB1nzXWtmW8sRCz8VRmAd0GDNRrAB8jqcOYOcj+1yee7a3HY/kozLOQ4j7zpZgGCcD48fbHOCjU1talcGGAr/+r9W5xFqS90sbwbtWuIxuKZppny0tKmJQ3tVpOEYTgFFBqgic65ZfSUwTghRJ+DzYjSmKiVXrSXDrdwhNg2crCPaEAffsPhowSRgRjslMfJxNjaaSIwxE1buCLuxvcO5RjfYd0kRa0t2wEuZ46L6Y2s4n2xkNrkzCUJRY7oX6FSb0gNXKIiVrzjAU7W3OIJI7AS56wpj9rm/MlcU1C2pIhjyEooA== 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=dpHEzn80OIyOxWiBfc/i9nreyp81gPbsuptSnKpNCXI=; b=EwqowUH+XnKKwYt6rwqqfcqhgp9Sbnx200vhKzyALnRQ8THjL5vROTZ8fK/AneIPRpZtlWxhUkl7rHjedEodcwNeLd2zzaGZIi1M+KnkXuvA56Y4MbOftDSRa+FAJM40ariKE44/Fg7iIGnavFRPrdGtYHyJCYOuHTIITNIMTDyQxf3ueMd3WQJF6ZQD4KU6OGtoxPgVFuDDdz4DeTjBnqoOz8qb4J4nDDQsg3nk00rwBb61XzHNQoErKRObmvRYdCz1GaTNuq7Ohjo+OkWtZ53XYO1hSaIw7Mq1gMOPDQqcaoxD0hkovPQGJ9P109Kz0LzGTmQdKyxv13wzu5KRfg== 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=dpHEzn80OIyOxWiBfc/i9nreyp81gPbsuptSnKpNCXI=; b=kIz/lBPaRN6SI/ITe+XB0lwkWvfhFUMHZRM5San4l04X3XGX4H1/RoLiAnQxldWTOMTm3KzIyvoH83dhMtKaoqlCUkY1lr7CHXFDu8OHvSkEq9c02jWDHXIqTPtgX5AizbYlTufLjBmlHJqrCuWn1DIhZvRYE9NeMzVaGFvm+sU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:24 +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:24 +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 03/21] mm/mmap: Introduce vmi_complete_munmap_vmas() Date: Wed, 17 Jul 2024 16:06:51 -0400 Message-ID: <20240717200709.1552558-4-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: YT3PR01CA0083.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:84::11) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: b85c3025-21dd-441b-d1b0-08dca69c104b 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: e62a/9dA5J44bLZYKBqIKnzoJJ6Zi/nbGUX9DI5NjKkqdCIb1DoVARYe/95loYqQJnztszPGlwudsPbLQPRsDlX9FLlvrVhf/yL5MK6Y3XJxIG9ult17+QRbW65k83nOr9oBQ+lnrGPHBjIJd49fEMSWEtJSncx/kXWQ+zWmmWKPmpTBDQKQ5gN3dO6m8/Ind5Ug/Yiamulw9SW2P4N1QgWTA3yCygZF51yXehdiaS8f0OIqNaaXaKeFV8Wf4mAIXvBTzFsJgE5gm3WG+94MpH9zu232ebpSFufP6b4lCCCvKgYiV1oEdtovKrt0CeSWGHP0LTlcJqeYG1ZIgAaoysLQVELxeEPO8w06Vjx/PvC222aD7sOK1UGbucn4NYiVIWqHi6bgxje6vbeHiE5pjHKBg6HXiNuv5CEl5TyIf+mTHQpxC8ioPubVDQvkgfxAxdA4OzeI9ujHWit8ow8xrCF0MU6XM8rrqWZjk6PoKJ9LGdF+Uwr4gqPXPKjTKIyxueCukKg7/O3Uqsk6nP7rnpol5KGdLQCtHzDIHc10iUNj5JOOVfOa85Gjntof2zcV3Aefa0And0F2bHdvhScHi6LeRK4tMq7G/VWmAJUeHTXipcAGKUDlp0jHxoCR4l8BFhfGl4QAFSRvJ/YYKU7VfapuHqB6jfog88nHYmNTUzUzmTG0oqflI+yuZHyxe6WZ36gNXpBayKt4ilKhpU+aWrk7kQ9JcRdU0tI65S8MZRtx923+A7fRyj/d9DYqheWroO1sO1DrFspZNdG/dO8eWHR32+2ldL0yEjbUnY2REh52myd8eKEZYfZp5CIDxDbQyinAKA5FZeS85lRkWuXob8I0X9fHXdLxqpeKDsZ4z3KL8gSOsPwkga7rJYgvJZ6HgU5izmgUG6DRg96PjiNttZWeDJtMy6RCvt2xLTDv2tKYaSvI9nYlup+5IL7k88hzShR1RMGrxB+icw0zPv5uCx99qpY8VT61G9LYacamTM04bzv9YMixozEc08klhCgGrqIncZp+OQKhMv1ou2/XSgfesLreN6inXGMmnny0A3Fsvbf7CQaRwv7AicyqPnnT8s+9+YLtXBSLgufBIQ0jbh8/WSPVfNq2FBDOBjmle4miCmFZXa+xAc5X9Y0Bb9ekPHQsfkBkGnJ3TSA3n8+59dpS5A0vlvDYYWSmEneryLdX1m59epuL5zpAuiUjxpSGTQ7XoOK8AYZs2dzcZzdnxSNBWxO7z7L1N1MRNHSYm/0GISqbF6vbi/kIynqzXSFAJFBj4FyxF0Rmt3VjNHNI4etPU17kss6XksI0dIMqqod1Q33bWXmRkdv3mWty51HJP7ze1TRlF1ueotMQ3fKBkw== 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: gE5StXQyyZXM9PxttijVvsn5BqKp/q/f5nUgGnKBxmeMEvXguXiHrIuL1nECkb2Sqts2gDU/gV1WeSJpWbpVs1t7RwYIoaxTKT92IEVExkmakLqvbGXHwy36wJi51E3WQdcSq1S5QFvpLzloATUJDaPGrb6ptoUvb4WQ7YlQJqyRMKMKX98sE2A9iGvbZnYClYVVV9FwJ4boGH6q9/ZYmHcf+v8nMU/BwjHsuYui5FOkhlyw/Xn+wEfNI+1HlOTqKrTO2Fa/Vzg3tuC1nbAqqslbxG6eOsEP9A9UU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eAscZQE8zMQ+Ux077fA+JaW0AiMBVzoSDgmCaG1um5qglKzALrmkQZChFlneqa/EFztfBbQlx0xkh5LAIKZJnzrjVf15O2bOhC0yCX3fyiVIumaeDumhG7yqZ9/96/3AtR4JV10hmLFnbYGdrVlSxNEjRxm890qZC4X5BwiSYGn+DRXlQ8ILqKDHl4SvHBJIVq9F+yfZP7SZIWNRlON5Omo/D4ImrNlqTH8r9+MJdFm15 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: sfZMqnuArvtftoEvrJ/D1Q8W1ic2laaU1Y8v/8+U64Q7zS58ffa1GR3n1omsvrL0dpqzldeWifJw46X6AAxQ9XVXk61HfG1qUqQV4yera+BrIcN8RtCgxo2vPJ1ConXsWKfEPA/+IzkOon+l9Vwe/r3TRbdDd5/4OhkLpYHECw169bFg+dQWp89ihKJI52oap5uQqCG3VDkQvjqDdtdQKLeq3Srzm0UmHtVrFctuaPqBLiFt5sUjzn9EbSPUs9Xc9MDaThH3NWTyw+Jmu734b5ksmDYw1rGyVkrbyE8gMgLShz3raXaYW2cddePGbC1s2UZXu1lofoyI25tYijtsXm15dNJD1hGIG/qJ+UORreMOnGNZCl9SzB6S07mrCIxhYHMfwT/lb5y+c/qPl8Ejk18sZupTJDmYZCCNsFZ8Vsg4D2Wnj6Eo3uqkplBzkcXf15+JwNUyVnO2MAKoR4qNKCs/jwxAjM7IixPUFQ+Vol+IVuw9CTTp2wmDShK+ghTymbREOE7bMJJpjRJRsjJIGn85SwaKUXZQNNsYMGpxmORBMbH4qfXR8ldd68j1SLjdJNgnEr7SN1t2T3H8dkfnsJgR4Re+2Yll5tZCvPtGOqk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b85c3025-21dd-441b-d1b0-08dca69c104b 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:19.9280 (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: 7U5l9aqes1KCB4reRwC4OxJjzBddKEafZibhuXhfLdVbwPfnHGirI/2BtUMnPt/fGf8VOAy6bCAcmqol3Ii4ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: qKmkn7AXKb2v2bJP3Hj8a8xZ3O6BRXsf X-Proofpoint-ORIG-GUID: qKmkn7AXKb2v2bJP3Hj8a8xZ3O6BRXsf X-Stat-Signature: cb6f8jpecybsn3yjndue47unbugbzg4a X-Rspam-User: X-Rspamd-Queue-Id: 3845A120007 X-Rspamd-Server: rspam02 X-HE-Tag: 1721246857-686149 X-HE-Meta: U2FsdGVkX1+oGZRZxFPtD2lzotTeN1LgPgjL4pcf2j5FQV2SO6pdIy3CwczPggHZekrKQ9nJHbJ3k3KJtdsCVVbeur9aEckcd9HOlFxsJvy12jsz05Aq0oFIlgL29yh50gsJ+W4rdAv7dww/xnBuAqOwUTFNi2nzkPP+BO8ZAMP+RHuBN+xDp0Xqbo66oeTvQHraJpoAENrnJGLR69aBYr0l+g48mm9xN2z6vcdYk4IA6SWWZGJ4orkuaMy22Lj2UkY/M+yJHMgVbwmp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hQsQE9/DYot5DD0HMilaBVDcuO5i6rlWqMsHCIUe56yBTOEejVEX6LxuzIwhP1IlqBsuYQ5jYPqMWDJ8uNuAzWQOvyqk9u1UtDmrnApIappXW26k1BRW4dgEsXhCOnyhkfefVmg0lSZ3I5XPg2yufSMzEqqmNUNxtJNTZ+nhZre0Hq1+x3U8Tw= 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: Extract all necessary operations that need to be completed after the vma maple tree is updated from a munmap() operation. Extracting this makes the later patch in the series easier to understand. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan --- mm/mmap.c | 81 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index babfa50f1411..bd3378935c70 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2602,6 +2602,58 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) __mt_destroy(mas_detach->tree); } +/* + * vmi_complete_munmap_vmas() - Finish the munmap() operation + * @vmi: The vma iterator + * @vma: The first vma to be munmapped + * @mm: The mm struct + * @start: The start address + * @end: The end address + * @unlock: Unlock the mm or not + * @mas_detach: them maple state of the detached vma maple tree + * @locked_vm: The locked_vm count in the detached vmas + * + * This function updates the mm_struct, unmaps the region, frees the resources + * used for the munmap() and may downgrade the lock - if requested. Everything + * needed to be done once the vma maple tree is updated. + */ +static void +vmi_complete_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, + struct mm_struct *mm, unsigned long start, + unsigned long end, bool unlock, struct ma_state *mas_detach, + unsigned long locked_vm) +{ + struct vm_area_struct *prev, *next; + int count; + + count = mas_detach->index + 1; + mm->map_count -= count; + mm->locked_vm -= locked_vm; + if (unlock) + mmap_write_downgrade(mm); + + prev = vma_iter_prev_range(vmi); + next = vma_next(vmi); + if (next) + vma_iter_prev_range(vmi); + + /* + * We can free page tables without write-locking mmap_lock because VMAs + * were isolated before we downgraded mmap_lock. + */ + mas_set(mas_detach, 1); + unmap_region(mm, mas_detach, vma, prev, next, start, end, count, + !unlock); + /* Statistics and freeing VMAs */ + mas_set(mas_detach, 0); + remove_mt(mm, mas_detach); + validate_mm(mm); + if (unlock) + mmap_read_unlock(mm); + + __mt_destroy(mas_detach->tree); +} + /* * do_vmi_align_munmap() - munmap the aligned region from @start to @end. * @vmi: The vma iterator @@ -2621,7 +2673,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start, unsigned long end, struct list_head *uf, bool unlock) { - struct vm_area_struct *prev, *next = NULL; + struct vm_area_struct *next = NULL; struct maple_tree mt_detach; int count = 0; int error = -ENOMEM; @@ -2725,31 +2777,8 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, goto clear_tree_failed; /* Point of no return */ - mm->locked_vm -= locked_vm; - mm->map_count -= count; - if (unlock) - mmap_write_downgrade(mm); - - prev = vma_iter_prev_range(vmi); - next = vma_next(vmi); - if (next) - vma_iter_prev_range(vmi); - - /* - * We can free page tables without write-locking mmap_lock because VMAs - * were isolated before we downgraded mmap_lock. - */ - mas_set(&mas_detach, 1); - unmap_region(mm, &mas_detach, vma, prev, next, start, end, count, - !unlock); - /* Statistics and freeing VMAs */ - mas_set(&mas_detach, 0); - remove_mt(mm, &mas_detach); - validate_mm(mm); - if (unlock) - mmap_read_unlock(mm); - - __mt_destroy(&mt_detach); + vmi_complete_munmap_vmas(vmi, vma, mm, start, end, unlock, &mas_detach, + locked_vm); return 0; clear_tree_failed: From patchwork Wed Jul 17 20:06:52 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: 13735735 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 7E068C3DA5D for ; Wed, 17 Jul 2024 20:07:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CBDD6B0098; Wed, 17 Jul 2024 16:07:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 07ABD6B009B; Wed, 17 Jul 2024 16:07:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAFF26B0096; Wed, 17 Jul 2024 16:07:41 -0400 (EDT) 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 B40D56B0096 for ; Wed, 17 Jul 2024 16:07:41 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5A2DCC0CE0 for ; Wed, 17 Jul 2024 20:07:41 +0000 (UTC) X-FDA: 82350329922.11.52D4823 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf25.hostedemail.com (Postfix) with ESMTP id 10823A0027 for ; Wed, 17 Jul 2024 20:07:37 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=K+C4GbOi; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Jo7y10DN; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf25.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.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=1721246817; 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=W8ePtixmHK858Jxwt740eyTinrn/Sv9QWh8NJ5u4sOE=; b=PWJbjp67cvoIpi0Vsb8LuXZ7wfg6oDPqihUwbfpSq40jybpdBAsC4XQU589PzyJVGklqT7 1QlnGZgp9qqEZnCGs0EEvdVHPGXkaLnWY+6af8fnCqLT2ePJMsRr92+XAXKEjoig4CTgvz BUS3SZ0IC9rO0hAy26w8oEnJGOScOFs= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246817; a=rsa-sha256; cv=pass; b=OVlt0b9QNnR1b+Yr57VPFFDA9Ed07Ff4ozwundei7WrrRZJ2eB4XmaY47N8YQDhIrtzq74 ioKYIRXgrlWv3gPr839eMc61C/Vp9b+IQuBc/8enf60zcUDrgwHlE7Y2Nw7Ejp+tYmhjbi ACngvyG8MpTbQce7kxr/paqKuZgWUqI= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=K+C4GbOi; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Jo7y10DN; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf25.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJsS4o002470; Wed, 17 Jul 2024 20:07:30 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=W8ePtixmHK858Jxwt740eyTinrn/Sv9QWh8NJ5u4sOE=; b= K+C4GbOiFPwZABIXe6mNL4Jj2ProPb7If/OMOLVqRm4iK37LL7AWbqmB/BkEtdsx nnr++EJG7g+X5jajgiAU59pKcXQ4Xl1gd/H0ZwAPw7ih0sO0amK66AU38YF4b20O mRITla0mPjiffuAyGvNaTBnJ1SgeT5a1KgYRFpYh2rwFkxeNMHW0RALDAlvjxMGK eKNZKKpNOlvFv+HSrF1VRhfdxlgmQ76NwAXtt7b85BbhKdmH79Rnl9/4VWHqsNEF A+oL8+NrwBCHJqM6TRLrDzO1gZlWjvDUAA9m7PKgLAuNGs7UCyM11JyWUPUTvTZd OPeGodJ87CjsgnGwSuhaKw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40ekxy84ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:29 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HIrJXm006940; Wed, 17 Jul 2024 20:07:28 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dwey1fcb-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OxTaIv5bbHkEP+QPEjkwA89YUI3b462E4bkQB3AXq/EG/wL38L4QxO/aYXi+Cm6bm6iwPAIDyOJT4QS1eDuWEa/Nt+7ugOUftNK1IrxiWAgTtCXAD74bfPHNKIl48gXk1tdZ6ZS3KymAJzRpfAc0wFIV5zq4mjMh5UIsNJXUSRrJp2Cx9o0Ctssej+D3FkEckFqrD8+p3OxLctZwcM9kHF3AESnF1VZUGAXILXrp8oMnS6tXCvvmAacxNwCZahrAL++Y12LDWld/93yb7VUEJdZ8nOn8qgKcp47rFFBbKYcnj9cHlL2KrT9+UmbVEDbTMRhR/kHw1j0fymmGVuMJxQ== 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=W8ePtixmHK858Jxwt740eyTinrn/Sv9QWh8NJ5u4sOE=; b=fUqcePQA699PLBbstItIrApibdNVUJw8xQywwPCJ9HmJkMHaCvK6yfPkwJoFUIQFmk5xLVfRbddm9/KuIneCAfwYHIoINThzqFy8tRTD6+S4dwFjNlpzG2X0ZyZ4hBzAlnlwm+2Pjub2ab6tbqATjtdvREPYGGpal+RGdbIml03CMbKSFFIrcHJ+bigFdqyltywfwgEhNvDrv+uhtnpbh2XvJemb8GPAu3B/yXe5ikxqDzF3g/o5ha1HQzRnRS5XMBqNHlCSoJQz4rD+PP5WaI7Y7KnjBgrZxE2Mch85urLa8CzFV33v46peoZD7aCh/Dlb5VejBz5E1ebqSmwCSTw== 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=W8ePtixmHK858Jxwt740eyTinrn/Sv9QWh8NJ5u4sOE=; b=Jo7y10DNg/DAcytYUYDwEf2KJe3Oj68yPxN7I3X2sResQYdR/AI+QeLgNnKc6ImhmAoQrwpMg7WjrNYlAVJce2J4VtIn9cggUYrygLUAKK8aflszRmkDqzGfPtMacsLCYuglcqsF32pntpc5BMRGgyp0i0FiSMMuVxAQ0TvTkCk= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:24 +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:24 +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 04/21] mm/mmap: Extract the gathering of vmas from do_vmi_align_munmap() Date: Wed, 17 Jul 2024 16:06:52 -0400 Message-ID: <20240717200709.1552558-5-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: YT3PR01CA0071.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:84::12) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: ae453853-f68b-43fc-9335-08dca69c11bf 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: nPIxEncZ3rO7iGQcBmwGgwhcCQWPslMTUDfRb9zuOJY58FEsJbWlq8DO5XvnBvVqSI3chw8LjfF8+jSWn9enUJdAQIchlpmku0Nqo6+t7dUUBSQrg0oHsWWUGEENx/LqqxxmxyA42i2KLEQrF/Cg8b05YCjs62cc4Cwz9MsFy87eBWfhezWuV59RFp/PvEWV7oG1O2LRpHzmCxkkgNZQf98dd2w99xdqMSZwpCz6D5mfXxW4mUAfK34E7w8Rs0Hz6XlDrf8CB4hRbRKetCp4wnTyItDB4IlvGoJSEuG9+B3o9EOmv1Dk4GDYJiWPcoxFUQUlSvyMr6R7gbk8tQFQuzKpnvbq6yEhPcV36vaewOj1bCXPddKh3R6XrIX/Y/pVoRB7Xo7c445waePayZTvo+JY8ykZ+HzEpSF97T3C452rpjwoSjnVCnG3iLOfC6/DDfyCpopTQLbDyBg2JmFOyq0nSlnzrKkSGC4qmzFzJ3EfW4gB0wnPXksGxCn0M5z+XE0nmatiigtTlZu+hSKrRSc2OuCKPpiAkbLRF114p6dZq8pFaDezFqWBdFswtYPoBPhmJhE3iuKL59zqRxc8qkNMNpAV4kjYf1CH0xY5T8QdXRGz7E8WGbviPzmIVb2bEiuy0TR55FLabu436qct2VcRETOpxQfoAi4afEmAAJ6rG6pV6301i0ALS8p4phxyo+Bn42S9nNTgvyP2c4TBzhCYKJ2rEgA3uMnhXHAjT4pazcZeFNWlXsIBum0CeJEES8aUkvCoFtnt+A6N10S9PjqMWtRIXUrSJVOTHF5nG3evZyDnbYq7TRBEWG4w4diD6jDfz6oiDnfCR8D3WXppNmtLAvl1xNUVejxkmsUZduGWV63qGkkn0CxVM39MQ5z+95lDDfxPzT72xJe1K4fVsoxDRvN+3bvGWOIloUjsdhEf6pkhNwkJS2XzS8xivv4+3Jf++aJmpyXWVfnHNHePbAms8Su2QruHT5MamTwrZ7lOWBw+TDCvA8Hu74F0cFhKsiR3+G741Tk8DyI7lGT40uFYsoZlgicdEAodsBLx1dYpTEAy+D6fH9nUjOwmLC4BLpxnTKdSYR5XfoEXjQUJK2ldFhjMo7kHrDNScz7zP9mE1DD74448JsxYCeDXy3NsFHhPyq3HJt1Owz6CyOBfjkU7AmiNpBtDw1jfvimOMtO+2hpyXPFE1/Tmk4B1jIgIRh/feOSimmTHJpzgz6Hgd2X15UwE7GeOvEo3hxW6rCjtZOy8wp+YAi2iBMGKC/14/MYU5/fUo6WDHs/+vmWz9zPWW7dB6pSoHzsW+E8P9uZURj5I4X8uBoMi0nY/xcqhAkjGMWJhItym4LmDpxB2aw== 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: a0tHpNWWlTOjyAIsiF+b5cwOWaMNq6tJ1HAych1wkNhTR7ZcpfjJj2876ui63QCCfcJBEXhEIhJ0D016t5hEfeibGKYVMEHeO0MzdiLbazbtzBqOaTBnWDuBVBZYFpGlcjkgSdz7oicC/u7mYMqBommIpgPClGgZKtWVQ/9taGAvPwrzXY/4bAt+DejJGfqN6dnBsZ01q2ytPtgtd7fLlilJceyFfLypIvDsfx8YpZi5OT0S3F27RH8tvYxwMPxHNlZz78jC9XhzYykznuu29rlVlqbD7BI7Co8NRhF+XhnnqwROAtTr4D6AvfeH1D37t+26Wb48JA2ktSbru5FUtN9mJQagtIdeeq7McjfYGfyIin38+TMwGLx8dxuKNS7TR4kBoWnQ2vwiGoCk1Wc6fNm4mY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r5rgKermdyu5CP8cyusdN1A0J8gZOpUtuWqCPQC9hKCJWnD16hDX39mlJA4zY+4UMdD9jZNB9G/r5EXiE6i+lE9AZlMBcYSVG/D5i6VSa6d2X1NazByy+px X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: NS4Nzs6qgGRGmZse7D9tTRmDyzSW7LZXx4yZiey/MB4BRWm4aHqOwOSJRB+8UigIZTdrlxNzkjxRFgcecjzeaao7f7qHrYXnEjgtvQk6p6/sFsSDheZXG56sk9wKWIZqvVfQBWFIMq3CAQ01CGLJs8jo8fC7GoNZOnbPS3bbK9C+nIL5OYckA0cshb1Yd/gl9FkPnA0DS4y2CGWocq2CzU7WZUfVNwIblK5BBFK3PpTXxbMpeyEv2pd1vPTr4D0RRoBp/qDI34F+0YXb7Kr3OsK7mQA4zSdlDjqFDQeF9UNtcVRhTvkZrrVxO9fk/og5eHwbi/V2cocNUyRkQSIgUbkJEaYElG3g+gBg+p9gPJChjcKntPoGJoBXKdtcriFWt6Xv9PJVsqALrQ59dK783ylTZmz+NmcjYyLejqebXODG6x/wjZxMSOO4Y2HrDAObx41ktKbigc33TmPaYS3s8ijFRJDPk9+BS8AJsrblU1/io810VFG5C0OBKDs35eYE8YX/qpFNbL0j+83N+TqKn3QSM+HoZsdcrtgiTXQ9eXhSxbHNxRq5njG/raD+7RsX1L1K6Sp48gtIOqmjdqaudVV9ke24rRFR2HCM8mXRtm8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae453853-f68b-43fc-9335-08dca69c11bf 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:22.3466 (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: WHZKY2WALSEfZx0O+LxA5AU6WMqqr/ts1p7oHrsLQNzcA/M0rB8i2QCoKRA1v8UJUwMZBhJPuVHBbAwf8C2tHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-ORIG-GUID: pRLOhoYPNISsJEM7B4jIiACYZXIpw5QH X-Proofpoint-GUID: pRLOhoYPNISsJEM7B4jIiACYZXIpw5QH X-Stat-Signature: u36ew1m5i9rg39bmadfremjr1b5o6fop X-Rspamd-Queue-Id: 10823A0027 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721246857-65348 X-HE-Meta: U2FsdGVkX1/Yv51dyvzl/4X5yor/3yemlcefr77aoB3ZhmWQQ1lFOQB0Kr35wxmw8FK3xT7Ip8qBjfLlPzINkRs6ASEH4ERV1aVU6zyxfLhZh/JQJ1lGQdv52t1MJey0SkBtQ/weHQtn6+7XYKJ9U0xvVmqXzfg/45TSgOG67tDpXAEIon7uDgKAB2WgSddoCYxsrCcKWXpo0FZUyew/iXBpNVtFK/MQLPlphbyboqEoi4eLOsks85gZrNqwwJM1seIkMbJXt8YU1Aefg2KFnuD3Hvt0XVWxjvW+rJ/vVOQWohxhK8fmPwG7JwWBMfvz2i3z0/zpv2worbmIuz9Rc8bJMbZn36rAqohG2iMCxwtyQCAXy90uHeqc6vsZJevUeaL2tV0qK6sWEl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QZ4zNjcaQEab9jwVyvj9lIUJLszry1kPAD4K8HytAZazc34Z5fMw== 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: Create vmi_gather_munmap_vmas() to handle the gathering of vmas into a detached maple tree for removal later. Part of the gathering is the splitting of vmas that span the boundary. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 80 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 22 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index bd3378935c70..0d03fcf2ac0b 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2655,32 +2655,30 @@ vmi_complete_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, } /* - * do_vmi_align_munmap() - munmap the aligned region from @start to @end. + * vmi_gather_munmap_vmas() - Put all VMAs within a range into a maple tree + * for removal at a later date. Handles splitting first and last if necessary + * and marking the vmas as isolated. + * * @vmi: The vma iterator * @vma: The starting vm_area_struct * @mm: The mm_struct * @start: The aligned start address to munmap. * @end: The aligned end address to munmap. * @uf: The userfaultfd list_head - * @unlock: Set to true to drop the mmap_lock. unlocking only happens on - * success. + * @mas_detach: The maple state tracking the detached tree + * @locked_vm: a pointer to store the VM_LOCKED pages count. * - * Return: 0 on success and drops the lock if so directed, error and leaves the - * lock held otherwise. + * Return: 0 on success */ static int -do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, +vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start, - unsigned long end, struct list_head *uf, bool unlock) + unsigned long end, struct list_head *uf, + struct ma_state *mas_detach, unsigned long *locked_vm) { struct vm_area_struct *next = NULL; - struct maple_tree mt_detach; int count = 0; int error = -ENOMEM; - unsigned long locked_vm = 0; - MA_STATE(mas_detach, &mt_detach, 0, 0); - mt_init_flags(&mt_detach, vmi->mas.tree->ma_flags & MT_FLAGS_LOCK_MASK); - mt_on_stack(mt_detach); /* * If we need to split any vma, do it now to save pain later. @@ -2719,15 +2717,15 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, goto end_split_failed; } vma_start_write(next); - mas_set(&mas_detach, count); - error = mas_store_gfp(&mas_detach, next, GFP_KERNEL); + mas_set(mas_detach, count++); + error = mas_store_gfp(mas_detach, next, GFP_KERNEL); if (error) goto munmap_gather_failed; + vma_mark_detached(next, true); if (next->vm_flags & VM_LOCKED) - locked_vm += vma_pages(next); + *locked_vm += vma_pages(next); - count++; if (unlikely(uf)) { /* * If userfaultfd_unmap_prep returns an error the vmas @@ -2752,7 +2750,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, #if defined(CONFIG_DEBUG_VM_MAPLE_TREE) /* Make sure no VMAs are about to be lost. */ { - MA_STATE(test, &mt_detach, 0, 0); + MA_STATE(test, mas_detach->tree, 0, 0); struct vm_area_struct *vma_mas, *vma_test; int test_count = 0; @@ -2772,6 +2770,48 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, while (vma_iter_addr(vmi) > start) vma_iter_prev_range(vmi); + return 0; + +userfaultfd_error: +munmap_gather_failed: +end_split_failed: + abort_munmap_vmas(mas_detach); +start_split_failed: +map_count_exceeded: + return error; +} + +/* + * do_vmi_align_munmap() - munmap the aligned region from @start to @end. + * @vmi: The vma iterator + * @vma: The starting vm_area_struct + * @mm: The mm_struct + * @start: The aligned start address to munmap. + * @end: The aligned end address to munmap. + * @uf: The userfaultfd list_head + * @unlock: Set to true to drop the mmap_lock. unlocking only happens on + * success. + * + * Return: 0 on success and drops the lock if so directed, error and leaves the + * lock held otherwise. + */ +static int +do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, + struct mm_struct *mm, unsigned long start, + unsigned long end, struct list_head *uf, bool unlock) +{ + struct maple_tree mt_detach; + MA_STATE(mas_detach, &mt_detach, 0, 0); + mt_init_flags(&mt_detach, vmi->mas.tree->ma_flags & MT_FLAGS_LOCK_MASK); + mt_on_stack(mt_detach); + int error; + unsigned long locked_vm = 0; + + error = vmi_gather_munmap_vmas(vmi, vma, mm, start, end, uf, + &mas_detach, &locked_vm); + if (error) + goto gather_failed; + error = vma_iter_clear_gfp(vmi, start, end, GFP_KERNEL); if (error) goto clear_tree_failed; @@ -2782,12 +2822,8 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, return 0; clear_tree_failed: -userfaultfd_error: -munmap_gather_failed: -end_split_failed: abort_munmap_vmas(&mas_detach); -start_split_failed: -map_count_exceeded: +gather_failed: validate_mm(mm); return error; } From patchwork Wed Jul 17 20:06:53 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: 13735737 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 ED98DC3DA62 for ; Wed, 17 Jul 2024 20:07:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B52806B0099; Wed, 17 Jul 2024 16:07:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B03BE6B009A; Wed, 17 Jul 2024 16:07:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B9E56B009B; Wed, 17 Jul 2024 16:07:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 577976B0099 for ; Wed, 17 Jul 2024 16:07:42 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EE3C11C1D9E for ; Wed, 17 Jul 2024 20:07:41 +0000 (UTC) X-FDA: 82350329922.23.31DCB6E Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf03.hostedemail.com (Postfix) with ESMTP id 87F2D2001F for ; Wed, 17 Jul 2024 20:07:38 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=gJMb6BQo; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=voiaFBI4; spf=pass (imf03.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246827; 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=uZF6pfcItsFziTEqk2v7DiOKJeCOiZuix0/xFXNniOo=; b=oSCe6xqnWbbUv5tEMHaHTRo1PG20qEhQ+NBJ0l4NYPe3/GjmPp+1kBcaabOw95X29aegUv 8XczPgDKSxDCSmBg4+fKuRAySOOjLmoDACN43jdJUCC0Tm66DU202CvFodpNwuxhDLPCL2 vfoPi5ab2TE106L1wF7sLjZ36mDGulo= ARC-Authentication-Results: i=2; imf03.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=gJMb6BQo; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=voiaFBI4; spf=pass (imf03.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246827; a=rsa-sha256; cv=pass; b=uAIf+Q5S4p9otwsWN2AwbvP8Ve7vPCTbsIxIrZOHg1zJD210rU2fuDX6uCUaRWl8xHaF4T L4/1JcuLRu2kcp4e9Dokny0JFNN/bJEIMybmeKHx55BzLFm79hPbe+In5wSNRoI9CNrJxs QPgkqcYamDRyZv+18WwnhMMAFmQ6YGs= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJsQ5j016975; Wed, 17 Jul 2024 20:07:30 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=uZF6pfcItsFziTEqk2v7DiOKJeCOiZuix0/xFXNniOo=; b= gJMb6BQoVbVc+JPaQCTfcqCoeSkvW1mMMHOVtJARBkz4d2eAhQX8EZxKGb3iOXRY JXNmjOaTh79AZfj8G1G7FTdtgPz0hUB5d3TuT7tle5zmoyrpuOHlf7Nw2dYP511G Xpx+UuvcJ39pFuL3+JOKpg8X8DnRoMV+OYPK0SMAmU/nOXhOACVmV+RO0PFMkIaP CMU3HnrutPrk4ozPkLhBQgMemWSvEieUoBvHfEWUFMtx3nmbonjJYpAjLFnmEGa8 b2IqMhIbZxzJRw16IWfqft7dYkdX9gyAvD+1aZlzG9oIDmQu20+dV2Bsgvu8ULVe vewvJ4VZ+h0hqlUT9QxXgA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40em3m033e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:30 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HIrJXn006940; Wed, 17 Jul 2024 20:07:29 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dwey1fcb-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QhRR4fCZ5aiLfxiXPvzhCSD9hLd38GqTlHpzfqW4Kt3SaojloB9nREGELs/Nbf1fyt2dh3Zg7hUw1LEVAyTMETrNc1Qdhpp54ii252p5tx4M27tvLqeiabxb2rZ9syb+IUKhm3eat1+jsXLe+84xW7DrSa252X6Vx24bsQRFYrK+bQKdrrBxvQOJh58ClUq9NnaXOTi7G34Tn1NzEt6ELVyUV158Xm7lvWxMIclY2OtrDgVa0ni5enZBdFJIFL52F5PG7Y+JIxev1tApUMmpCWqp0EXFXfMrRzF1xCdd+zN/rv81TprPTjk2DmLosO1VStbMQ4mKMrdWfsdFPkj0gw== 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=uZF6pfcItsFziTEqk2v7DiOKJeCOiZuix0/xFXNniOo=; b=CSWMKBgDJ+rQCUcR51s31PMI49ibdBHMdUBDs0mpoQPz+EggFwl1I+tGUZDHEZfsMgwyeEL8K8pJ1xyjRzxdb04vF/UaTlclj2qKaTcTeZ5AhYsRCH+2CMwXPWGn0JQQSh3B0gKuCmbovT3fl3t2RfYqC9bowTcBxdi8wQqNWdp4ydSLaxEK9SlL4lkzrCuScYQ6lwwyivEupwTA2pM3Ems+9it4N8PZhPISal+k27bI7QWXcHZjpfQBpCG730ANp1FIqx1o8UnyZYvt+luIQS6y4oeVwL8g2Y8WGGgRcCifOEr39y/PHq1NJZC/FL1PDkjuddG8sLcfv7DpLK7uJg== 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=uZF6pfcItsFziTEqk2v7DiOKJeCOiZuix0/xFXNniOo=; b=voiaFBI4WpMUrVSqlTHz6tXWrM1SmW6cjkhEC2BZyB96DVIiTU0t6QPdVFPAU1eR87HYKs8QmBv4sGeqs+e7hsaDEjuH/6azBuxJyAPkoq8aHjoCg85oOW00rv697OF0b80zUNeOPiZTakjE1WjZ4KgGE8BwyXNbJHKurPHCluY= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:25 +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:25 +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 05/21] mm/mmap: Introduce vma_munmap_struct for use in munmap operations Date: Wed, 17 Jul 2024 16:06:53 -0400 Message-ID: <20240717200709.1552558-6-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: YT4PR01CA0157.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ac::29) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: a27bc2e4-c53d-41a1-eb90-08dca69c12f1 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: Bxb8YUMllyaObAwzYDXTHQNyI8wmnCRUCx66bQ/dP2YLNazlv4UyRL+OoZ5nRQrMmjLoBbtkzfGf8/r6p/6N0ISV9ETQ7IUciWNDJBj1P+735BD71dh/XDxzOGQV7lroW++EVMu9O4RM0uC0y5vSDeeJkeX8jTq/i4hh8D992/YgKwHfjGYCkSx3kaUUH+jUuwmxiavgbbPbbynxKfigelegQjMvlc5xeCTxYpkV4XhOdeejgafFZtVb1tq2Mh3R6FByRdHfaEiS8dRiEdWQUgwGe5rHEfdCHXV2evcRlP2zSsnJKByHmZjMUpZZqWRD1kAqKQM9zNpSLS0pJZrgmLuDko3ximjHvshrf+HaA6wPX3tsVWz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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: Cd7pERAF4HhhZ4isPqapwnb/RNKrToyx26Vp9n4HOJs42HMR9v3AxrQwtRnEH0ZkwnKvGs/5wco2ZsFppBbK1oVit3ikZTUcJGxDL4rNSdEZWcQHMYL1wv8dAliRzYJpPWMuaWVTnFcNTO35+oRCxkbjp94v97ZVcDaq7FO71KMg2JQPmQe9+RcnyUSYRIHkK9Y7T8cReeo0+MF1kr8ClFaAV0kBkJ3hAjSTRymisrtBPGRxBzBKZGyNx3ZIwysf/vmtHcFFYo1ycqI193JjLcBhjCTikaVeyjP3r+3YTWIiuC+x+ieWpTchrTYpuEezBUDO5nWu4LJLvc5z4zC714hpHQv/S3F+pilNWcaZipowi6aeZv6UdAMztaQxZLXKEc0G3GevMpWhAwUFBYGcKIG+8B91hgn3BDL42j1AensabwEAxPQoGkVgtjInB/Uq/BozD7FxVCw7d5QvsZiAzLE0rI4j6MKvOjAp/n0MzP3rjhbTse8VqvH654eqp/34iZGg0389tL+oibS/Otc6WOqK1jISza2DphbyqX8aYq0ic4DP6aZicjX/1Vs45wN2uGIj+Y/2P1lj3B6ZQzjdFw+NaG73dLofFEq2GxPOOmvBAOL2DLL11tOaLZ6nEzU+8OSHER++MHfYM3nK9x64/Zlm0/EVFpbJwJ0qNC7nLIksxLeJVANPY1sc/9NHJXBcRsO22g5fIn7i/0ZhCcnUKgk1Qnh9SxvYUstQ50bnYyreXBCK/PQgkAdGahbg46WM1HYjc0Js7aPzKr/QfTw6Jz4riAbaCI/9QXX8+YXD2VCf+jtd+GeZvgodsJvzriEVvAQQKuS2UAyS4cAm7/CmxZcVxMJQKRUydKjl7Q791lqb4DTt0ISqrz8SG5MDBGX/qHHwUAG3bIHdan4Rx4mrJvDUo/8RhvqNn7NCTuVFzfsMhSh0hJ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aMa6D/+zNsLuCphQV9PXEn+gI2cuYyGbAEqgEYkiipeT8qzBWK4cRAGDIvqk/hLND7lknwK52eyUBPUXyu3++mqRn5t1Ua0KfR6o+KHDXo65KTeO3fww2IuXjEvySZBPxWYFZeGY/EiauBKJTE4XFZOWIKHE9HxER8HNAE1J9TUClfcphYkpsPMh1PfPKlVicmum0kxpfqotubY4oAKaF0vQ70PR+3fasL1bekWPDUglJRRp3kT0jdL/8+DRBMNOQ1dE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a27bc2e4-c53d-41a1-eb90-08dca69c12f1 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:24.4742 (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: DTyE1rSR2WX2ugtLGbkscImFa+GoWakwaJ+2eqDlwZHGNps68iGfR8B6KVDc/Jr0vX/5X8thCuB/sF4fWdzjNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-ORIG-GUID: xuuZ5_ra5CKDlYTId5vGajqy8BfQ9eIO X-Proofpoint-GUID: xuuZ5_ra5CKDlYTId5vGajqy8BfQ9eIO X-Stat-Signature: ahzc9rpwjj5aw9k55xbgs9sa8wbxo35e X-Rspam-User: X-Rspamd-Queue-Id: 87F2D2001F X-Rspamd-Server: rspam02 X-HE-Tag: 1721246858-933567 X-HE-Meta: U2FsdGVkX1+bloMo1bB1qDmDldAB5YFMz/juBPLdVMNk9g8ASbjNIHTAvI5ifrFVVbI+7u8jlc40pA+nrzqW+MHZUrdvdlmzKGAzMduUK/v9B9s06iwheK9bWICjkzogRbwu/6xy0JOunL03hyrtuALNrfr6jiXPhHcROLIVGOpkyYZczq8Iymwm0bdWpooqtKYITD2a/SUs/RgJ+pcTi1fKz338pCgdKd2377imu9GiIZ1CseVwzo40iCgYLIeUT/3ISmunILNjJgBY/zWquzdagB5AIuh9iJsyKg599KRltmlam0GQaASfd5tt+avNzcCl5zkFhHerhl8+QYzvNJd+Q3OtWdy6wIIJFQVLQMLxSBxktbE1E5yTQo8Y7GdOLIYZGBoYAU/BGTh1k+Dr5wVwwqEe6fNX8gjqOTD9HvH9gm21hupA0tVcALSlzYPnaEmQFZaDAPmtbiW1PZLgSTSPl/2sSounJLpv1qGGT8bPGxWEew75n3vZ0PuZjJkOB0FPwuLRwSMGRfqJmQ3MQ3tFQm9CZPzXQSptZtdeC1NNWFDgG6Y8lLUR0nGCBBr+URrBIVaYOaJ6g243fTrBbM2YR6b6BAuAMZV/WciYfjmzbUVOQKXFuT/gT7Tcu+6Z0w5sQfB3fgeLalrPkwulpej/66Hj1gLf9Y97D5uxPSsrYSIVQ9jGZMtRejCdQcOKoBJrZ9mWgsCwivTp3PlPmktzC15P8+UBcdmtYpJm4h6/kmgMe2dPMeHA4VShs+wFYw6Au6WUKmV508Ns5EfdOPByIkemex4IfcsS/0k855/G7EC316x/5zRxoF7aLpSA4FN5AXZFQVuhmogIcZoORXopp/1YhS6D8R36djDjsuoUIMg/1h8XxsCv1K6SBAyZob0YFvu80wUeOoVYX9KOpTyllA9hZ0v7DPt8fO6VQzQijmrllXBCtkqNuB3fjQub1u8GZaypzaKBqwjF3oR oJ9VP4u7 BkGXIU2KTnSuPrgwkWBmKyQjaFBgwXe9U/Xm7WSCUywKcZbntQN/PlFulX4D3D5MW5Qle38JG0gKunA0o1TXkAL5+OUO7xD8yAzxGEAIPx40o90m8FV7j4KuzXni5F8iMJg/yyQygyMlgobetorqOmPkpq4kqhsDFtdKG9VRvSpQLd9KYgtyf81urFXpeD5igcP+h4aaY7hma38PX2JVYdp5/PUb9qI6pvuo2pfsnqKbEEEwlwi0zif7EB0tm8WEMtBfQs81tSh008Ij/nDe9Sz9UJzkZzLpzfJvYX//avKV3mi3X+QKZ1+Z7TQhKHYhJOWeYBQkcqcYUTDKt5SRMpp/h1IojrgkCcsZOGAapSIHR6E2lYTmhoXGT1w49QDWaec1Hhlam7RLU1Bf6WQRh4HtbYdaSLwiF+dPm3EbyugLq5KbUic+Ki//lwl0rp+sthDYF1z1p/HzGmCgJYnqXZfA/TfNAE31/SVw7R+eL9n20ypngniSf2Ys9u0Iozg/Cx9w5cob0xBYWksvJQoDvf80Y6KrB3SuElyPK1uy+WG9ApXc= 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: Use a structure to pass along all the necessary information and counters involved in removing vmas from the mm_struct. Update vmi_ function names to vms_ to indicate the first argument type change. Signed-off-by: Liam R. Howlett Reviewed-by: Suren Baghdasaryan Reviewed-by: Lorenzo Stoakes --- mm/internal.h | 16 ++++++ mm/mmap.c | 138 ++++++++++++++++++++++++++------------------------ 2 files changed, 89 insertions(+), 65 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index b4d86436565b..9d0f4d1bebba 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1481,6 +1481,22 @@ struct vma_prepare { struct vm_area_struct *remove2; }; +/* + * vma munmap operation + */ +struct vma_munmap_struct { + struct vma_iterator *vmi; + struct mm_struct *mm; + struct vm_area_struct *vma; /* The first vma to munmap */ + struct list_head *uf; /* Userfaultfd list_head */ + unsigned long start; /* Aligned start addr (inclusive) */ + unsigned long end; /* Aligned end addr (exclusive) */ + int vma_count; /* Number of vmas that will be removed */ + unsigned long nr_pages; /* Number of pages being removed */ + unsigned long locked_vm; /* Number of locked pages */ + bool unlock; /* Unlock after the munmap */ +}; + void __meminit __init_single_page(struct page *page, unsigned long pfn, unsigned long zone, int nid); diff --git a/mm/mmap.c b/mm/mmap.c index 0d03fcf2ac0b..1ed0720c38c5 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -500,6 +500,31 @@ static inline void init_vma_prep(struct vma_prepare *vp, init_multi_vma_prep(vp, vma, NULL, NULL, NULL); } +/* + * init_vma_munmap() - Initializer wrapper for vma_munmap_struct + * @vms: The vma munmap struct + * @vmi: The vma iterator + * @vma: The first vm_area_struct to munmap + * @start: The aligned start address to munmap + * @end: The aligned end address to munmap + * @uf: The userfaultfd list_head + * @unlock: Unlock after the operation. Only unlocked on success + */ +static inline void init_vma_munmap(struct vma_munmap_struct *vms, + struct vma_iterator *vmi, struct vm_area_struct *vma, + unsigned long start, unsigned long end, struct list_head *uf, + bool unlock) +{ + vms->vmi = vmi; + vms->vma = vma; + vms->mm = vma->vm_mm; + vms->start = start; + vms->end = end; + vms->unlock = unlock; + vms->uf = uf; + vms->vma_count = 0; + vms->nr_pages = vms->locked_vm = 0; +} /* * vma_prepare() - Helper function for handling locking VMAs prior to altering @@ -2603,81 +2628,63 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) } /* - * vmi_complete_munmap_vmas() - Finish the munmap() operation - * @vmi: The vma iterator - * @vma: The first vma to be munmapped - * @mm: The mm struct - * @start: The start address - * @end: The end address - * @unlock: Unlock the mm or not - * @mas_detach: them maple state of the detached vma maple tree - * @locked_vm: The locked_vm count in the detached vmas + * vms_complete_munmap_vmas() - Finish the munmap() operation + * @vms: The vma munmap struct + * @mas_detach: The maple state of the detached vmas * - * This function updates the mm_struct, unmaps the region, frees the resources + * This updates the mm_struct, unmaps the region, frees the resources * used for the munmap() and may downgrade the lock - if requested. Everything * needed to be done once the vma maple tree is updated. */ -static void -vmi_complete_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, - struct mm_struct *mm, unsigned long start, - unsigned long end, bool unlock, struct ma_state *mas_detach, - unsigned long locked_vm) + +static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, + struct ma_state *mas_detach) { struct vm_area_struct *prev, *next; - int count; + struct mm_struct *mm; - count = mas_detach->index + 1; - mm->map_count -= count; - mm->locked_vm -= locked_vm; - if (unlock) + mm = vms->mm; + mm->map_count -= vms->vma_count; + mm->locked_vm -= vms->locked_vm; + if (vms->unlock) mmap_write_downgrade(mm); - prev = vma_iter_prev_range(vmi); - next = vma_next(vmi); + prev = vma_iter_prev_range(vms->vmi); + next = vma_next(vms->vmi); if (next) - vma_iter_prev_range(vmi); + vma_iter_prev_range(vms->vmi); /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. */ mas_set(mas_detach, 1); - unmap_region(mm, mas_detach, vma, prev, next, start, end, count, - !unlock); + unmap_region(mm, mas_detach, vms->vma, prev, next, vms->start, vms->end, + vms->vma_count, !vms->unlock); /* Statistics and freeing VMAs */ mas_set(mas_detach, 0); remove_mt(mm, mas_detach); validate_mm(mm); - if (unlock) + if (vms->unlock) mmap_read_unlock(mm); __mt_destroy(mas_detach->tree); } /* - * vmi_gather_munmap_vmas() - Put all VMAs within a range into a maple tree + * vms_gather_munmap_vmas() - Put all VMAs within a range into a maple tree * for removal at a later date. Handles splitting first and last if necessary * and marking the vmas as isolated. * - * @vmi: The vma iterator - * @vma: The starting vm_area_struct - * @mm: The mm_struct - * @start: The aligned start address to munmap. - * @end: The aligned end address to munmap. - * @uf: The userfaultfd list_head + * @vms: The vma munmap struct * @mas_detach: The maple state tracking the detached tree - * @locked_vm: a pointer to store the VM_LOCKED pages count. * * Return: 0 on success */ -static int -vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, - struct mm_struct *mm, unsigned long start, - unsigned long end, struct list_head *uf, - struct ma_state *mas_detach, unsigned long *locked_vm) +static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, + struct ma_state *mas_detach) { struct vm_area_struct *next = NULL; - int count = 0; int error = -ENOMEM; /* @@ -2689,17 +2696,18 @@ vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, */ /* Does it split the first one? */ - if (start > vma->vm_start) { + if (vms->start > vms->vma->vm_start) { /* * Make sure that map_count on return from munmap() will * not exceed its limit; but let map_count go just above * its limit temporarily, to help free resources as expected. */ - if (end < vma->vm_end && mm->map_count >= sysctl_max_map_count) + if (vms->end < vms->vma->vm_end && + vms->mm->map_count >= sysctl_max_map_count) goto map_count_exceeded; - error = __split_vma(vmi, vma, start, 1); + error = __split_vma(vms->vmi, vms->vma, vms->start, 1); if (error) goto start_split_failed; } @@ -2708,25 +2716,25 @@ vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, * Detach a range of VMAs from the mm. Using next as a temp variable as * it is always overwritten. */ - next = vma; + next = vms->vma; do { /* Does it split the end? */ - if (next->vm_end > end) { - error = __split_vma(vmi, next, end, 0); + if (next->vm_end > vms->end) { + error = __split_vma(vms->vmi, next, vms->end, 0); if (error) goto end_split_failed; } vma_start_write(next); - mas_set(mas_detach, count++); + mas_set(mas_detach, vms->vma_count++); error = mas_store_gfp(mas_detach, next, GFP_KERNEL); if (error) goto munmap_gather_failed; vma_mark_detached(next, true); if (next->vm_flags & VM_LOCKED) - *locked_vm += vma_pages(next); + vms->locked_vm += vma_pages(next); - if (unlikely(uf)) { + if (unlikely(vms->uf)) { /* * If userfaultfd_unmap_prep returns an error the vmas * will remain split, but userland will get a @@ -2736,16 +2744,17 @@ vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, * split, despite we could. This is unlikely enough * failure that it's not worth optimizing it for. */ - error = userfaultfd_unmap_prep(next, start, end, uf); + error = userfaultfd_unmap_prep(next, vms->start, + vms->end, vms->uf); if (error) goto userfaultfd_error; } #ifdef CONFIG_DEBUG_VM_MAPLE_TREE - BUG_ON(next->vm_start < start); - BUG_ON(next->vm_start > end); + BUG_ON(next->vm_start < vms->start); + BUG_ON(next->vm_start > vms->end); #endif - } for_each_vma_range(*vmi, next, end); + } for_each_vma_range(*(vms->vmi), next, vms->end); #if defined(CONFIG_DEBUG_VM_MAPLE_TREE) /* Make sure no VMAs are about to be lost. */ @@ -2754,21 +2763,21 @@ vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, struct vm_area_struct *vma_mas, *vma_test; int test_count = 0; - vma_iter_set(vmi, start); + vma_iter_set(vms->vmi, vms->start); rcu_read_lock(); - vma_test = mas_find(&test, count - 1); - for_each_vma_range(*vmi, vma_mas, end) { + vma_test = mas_find(&test, vms->vma_count - 1); + for_each_vma_range(*(vms->vmi), vma_mas, vms->end) { BUG_ON(vma_mas != vma_test); test_count++; - vma_test = mas_next(&test, count - 1); + vma_test = mas_next(&test, vms->vma_count - 1); } rcu_read_unlock(); - BUG_ON(count != test_count); + BUG_ON(vms->vma_count != test_count); } #endif - while (vma_iter_addr(vmi) > start) - vma_iter_prev_range(vmi); + while (vma_iter_addr(vms->vmi) > vms->start) + vma_iter_prev_range(vms->vmi); return 0; @@ -2804,11 +2813,11 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, MA_STATE(mas_detach, &mt_detach, 0, 0); mt_init_flags(&mt_detach, vmi->mas.tree->ma_flags & MT_FLAGS_LOCK_MASK); mt_on_stack(mt_detach); + struct vma_munmap_struct vms; int error; - unsigned long locked_vm = 0; - error = vmi_gather_munmap_vmas(vmi, vma, mm, start, end, uf, - &mas_detach, &locked_vm); + init_vma_munmap(&vms, vmi, vma, start, end, uf, unlock); + error = vms_gather_munmap_vmas(&vms, &mas_detach); if (error) goto gather_failed; @@ -2817,8 +2826,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, goto clear_tree_failed; /* Point of no return */ - vmi_complete_munmap_vmas(vmi, vma, mm, start, end, unlock, &mas_detach, - locked_vm); + vms_complete_munmap_vmas(&vms, &mas_detach); return 0; clear_tree_failed: From patchwork Wed Jul 17 20:06:54 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: 13735739 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 EF322C3DA60 for ; Wed, 17 Jul 2024 20:07:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC8726B009B; Wed, 17 Jul 2024 16:07:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B785D6B009D; Wed, 17 Jul 2024 16:07:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 694866B009C; Wed, 17 Jul 2024 16:07:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3D71C6B009B for ; Wed, 17 Jul 2024 16:07:45 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A77BD8180B for ; Wed, 17 Jul 2024 20:07:44 +0000 (UTC) X-FDA: 82350330048.22.BBBFE5E Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf10.hostedemail.com (Postfix) with ESMTP id 3BE4EC0028 for ; Wed, 17 Jul 2024 20:07:41 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UEOHCqPv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=o2RCFJsz; spf=pass (imf10.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246841; 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=tD/0zTBFlIy2X0qEJP0lFciqbADB3HhcYy8G490XlQE=; b=eYWM728kVZjBdrouSsJBYhcB+WguajlDYusZyPiCidmAkL1mD5w3z3qkn09PzsP6XnjTky m0Dauv7O1jyMJjtNRL+3kJHqbQxuBgPJd0wqmwX2oz67HNPHrEmly8WWySpp10vhYXIV2B rIAI4ZoB+vPUcEqptjsSxbSm88ciG5g= ARC-Authentication-Results: i=2; imf10.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UEOHCqPv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=o2RCFJsz; spf=pass (imf10.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246841; a=rsa-sha256; cv=pass; b=fBeM/iyNNY/dz0m850lWMsvcUWgEJmCIGcKI9xW91P9UFWlvtaFAohNzwAXrUIQmaaMCU1 Lu9Um0V2S0aFK9e9Q4rL4euw6A2SB1wP0EVh5y1CEZ/PX7W9gyttURFoxqt9zOWO80dO6E mWs9dfQUUlWpYC5WCWd45AWTiwr8Qks= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJtlDn031584; Wed, 17 Jul 2024 20:07:33 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=tD/0zTBFlIy2X0qEJP0lFciqbADB3HhcYy8G490XlQE=; b= UEOHCqPvhcJhliieKdzkhIxyN9qMci3eK5c/N/MaZJE3xNzVrIzA920wNZDCNCLt J32mDh3DNeAj6Do5/096814Vx2/2UEsdbhrKOWpjoomOivICj/iQwmluszgfSOyC zwxlFamfyOJXke9MUyRPUIrS2d6MB7QOBkhFUgOL6djdH7pdWHx3kdl+nPmDh73F lSSdNj18Bmq2vpkEz6Ngy4cPvav3Xv40G99Oj/QQYXy4Ot5Tk78jw4zVRlgsoJnS wgormYVg5sLKSdSiznhp/6CP8s8S5FG1FW7qqLwk1ELqXMpkX5YCVbB3goAuN4Ix z1vSaW80HcGurqgFOuyw5A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emhpr0qj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:33 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HIrJXp006940; Wed, 17 Jul 2024 20:07:31 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dwey1fcb-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZRElpd9xBDE8mhBPJl1G/HQ++kucTHhRj7G3Sr+QGFRvUWc2NtQZxoRY0mj+YgZWowaKseEg/yrulpyrLKc0S/Nq0jWy+rWOSR+VmckNFkGm94yf5+5lbYQL4MMKoQbo0annDkxdFiqlIdWbGKgavoTI5KbazWLJixEb1tHNCQblZKP6lBHSqrpvy+4/qouAu7NE13jKiZMhm1ZhQRKjnFHTLdoxKd/W2wLGTibq+3slBltMBfo461P3f7fb7QkI1SOvebaEcwK5nYXRJElQqQjMShLFOqxHq4k/c81yF4IbXr47iT3Byht8/+rvPm8xGCrFWNbe4p+S7VIZwodAGg== 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=tD/0zTBFlIy2X0qEJP0lFciqbADB3HhcYy8G490XlQE=; b=K7KX4eHUZivoYjWJRGFcJUi4vDNg/yisvkcOp8VoNxSqdOHPIiH9KSjoPJZULyh+HMYFOwRIH8VyIpV9C3rCSdRwfiCKXWc4pmfLsUht7xFHlu3jL18xErLJeXjBfFLzYikZzoWb7gNtNI9KOgSkCCwwejh+TeAqau597wHajYkmTbvHRQLPDu+RQoPCcYv34EDZcT3T3s/yuTlz22My0TV7myEhAGLAIl9H0jMrNre27gFapbplsOGwKXB0oRUk+AjtfWisAB4c8klZihTsFfRbuGgST/2s1FkzOtWSgn7O7Qi+65zkD8APLhZEBYRYnL0OsQJHAPEEUFIo8QGy5w== 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=tD/0zTBFlIy2X0qEJP0lFciqbADB3HhcYy8G490XlQE=; b=o2RCFJsz33b5sRj08lELKRjgC9J5K6flbTgv2rjTZjhmx6pEK8vcV0m4gb8USE0y/6mpoYMBYxz93nFO2nqexzX6E4j3ylz4fckz2tXj/QzlWirGnVmjavwar8CCtDWhxjK29XCh/d8RAb5TTPeok9hX7+SidftH1lbJtUn7aWs= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:26 +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:26 +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 06/21] mm/mmap: Change munmap to use vma_munmap_struct() for accounting and surrounding vmas Date: Wed, 17 Jul 2024 16:06:54 -0400 Message-ID: <20240717200709.1552558-7-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: YT2PR01CA0026.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:38::31) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: ef419b56-51d9-4931-2f7a-08dca69c1461 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: 9nGc5X9E1SbyP5TrkU9tpJEb8sfFGDYF08E1Q0Ec+V1yj8IQTLTLlN+h/VZntcdjcMwB3uOSIckbB6l0o2AaW1DiK6KJ6Iyw5Ko+cxRrySKN54SMiO957zrjlvS+42fdJIWj9ct4mofnDMIMpwGTp9MBax5leCFwgAx59wq4MnbekqNGcUIeHu4FDWkaB0nv/VqThNe2ZDnYjbaLYMDNBxKQ0aDwBH4+EsW7D0XyCFtfHB/BLhBUmnHEdBkYYMMc65sSNuMxbBkBtsAYYPer6tlliT1DKoKbAADdTkiE0FGaew4ovZZb0fKqu8uNXz3SQg+Hh+KMQgthzhCIQ+6XtRaWFbSY4d7Q2di37Z4Swa7gquc/IZ5WVHklYCwFq0WkmhPn4TjWv75W/n2CGI5CM+EGaempzdhAxci2mJxipaa75I/E34MFDJ53Mt8tD9cWpLvF5uhqS8TtAN13GSrNTKZXuTkP4Xx5p3Y7W4dpd6aLcswhA8K3oOHRs02dJp13H8wDzEqx092XUQmE6pa6RtKnIkqPua/b2yZ/VucNdKkAB6i3CLDMweepHCtAa5kZwA59hIKEZzPdV4HsnZ5L1Ncp+3Cry7Eg4SJ6NSfjYuV2jl2Lw8HIN0HcUnPsJdDYNxkwNQtPprzP79K817ARgNTOb3QSrHAJxr+OXqfyt00FVRaFyWLchtlomNIyQblTdPZE1bNVraXwgrhqOzcEtCIOZszPXlIusf6Rq0gEu3VfrdUwXVmGLNE+hnBdQXEhHPewoGfwXp34Tx72eHUVPdSDJmwUtmhZVTlfeuO5HKObG9/vIxA8ajxADc0QdqQTRw0fhXLPi3aIGV4a671Cv7InJPvl1qpwC4PxUSsUNoVe7JAxszl13xahcIkXlqY0ydnTIRoop+72oGVBVwBJTJUGoGH/KftL+mqUgpnMn4SFC84CBSFz2ZpgUwnHVKtMf7JOyPW7I5yqI3NArldpUVM2bBhK3CrtU8A09X/f2qhsRPf8ms0mzStBhGrfetlwYhbii/KbpQ1vgElvy8WcHkI94hicggThfig6Pd4CqyRbWE1df4Ux/8dq35OGFnITS60xMt6IBF1q4yRpcViLxdoopK1K57dXW/ikYtAn2tEUqh7RNRyEXOtkg9y+oCKBo6xjU+aVvp4mV/Z0rrNc9Zc2VVwN9lb23+3t5uh5GW0od/S0m0N97ITipsmDex9Mm6WSYiBUjPjnyC6HCQImmZTk8oBF3MxFFPHMqH0VyqkTIaFV/0qWCPJ1nzerJqIq04IbdTOJrKuoEVzu4tnanXBXR70joMtStrjH3ZafxR/C5szA93DF38KIQ1GshZVamNT+kUzQ8NEAtxFh+2YCtg== 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: Rfuvp8+mtjwSu+I9A56ykuX/qrwl5DhTOBFHrFi6JSi2p9VjmqBJUygF/wS+Wp/5QNxnrx1b0tLjp/OgDdEJTVGbkov9Z4h3Ftr4e6/wEg4djvHOJXxg8KoX39YMrITdIhh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+pmykAuuXte6Yw9WZdTIc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef419b56-51d9-4931-2f7a-08dca69c1461 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:26.7693 (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: xDhIvbNrNjGt/VOKHOCSmMAgTf5L7QJ/Kx38jeuPqa5wFuNjgF68xAOeAhpIzpZ6gX9PW1lfkoApkarE5mTg4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: 1lp5xNXu4R5qAyxKqzPfYsmeLJd5spJy X-Proofpoint-ORIG-GUID: 1lp5xNXu4R5qAyxKqzPfYsmeLJd5spJy X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 3BE4EC0028 X-Stat-Signature: xtpgfmx6uicfd4rwmf1dwnxeqoqeyq5s X-HE-Tag: 1721246861-435676 X-HE-Meta: U2FsdGVkX19NxH8e71Vlt7/+ummtK99OB1fbGNUni2eDFF+mjhLiPnIccauxVeKx2lQv1g55yDZR9cSB/EBRgYl3P4EQ/xHjZ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MCFExMkEAcaYdoT/B4KwNYlPih0QDzUX9fdAyrH5TP3oFZIB4X5hAmd4eHBxvy9CquScra2nWMmnY3/KDni0KtikMcpg6tVNOvd2DqtLEeytJENuxGxcoOoY6YzS7Gi2dM8PHPwascPKF9Q8ATE3D7LKJ/J6KYwpX5/kR60vmz+UfyYdYrjWkUWInRNt5ZY2pYLtXd7KDiP8M9JXozf4tu2pZGbHUo7L8OhFAggpteMglj2dzFgpzXIUoUHtVXRTmTiFh/8zNoQGyd3EodXgJ/FISj6b92OERvvhJJ3APG3d6DGUzqk= 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: Clean up the code by changing the munmap operation to use a structure for the accounting and munmap variables. Since remove_mt() is only called in one location and the contents will be reduced to almost nothing. The remains of the function can be added to vms_complete_munmap_vmas(). Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan --- mm/internal.h | 6 ++++ mm/mmap.c | 80 +++++++++++++++++++++++++-------------------------- 2 files changed, 46 insertions(+), 40 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 9d0f4d1bebba..02627e269d6b 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1488,12 +1488,18 @@ struct vma_munmap_struct { struct vma_iterator *vmi; struct mm_struct *mm; struct vm_area_struct *vma; /* The first vma to munmap */ + struct vm_area_struct *prev; /* vma before the munmap area */ + struct vm_area_struct *next; /* vma after the munmap area */ struct list_head *uf; /* Userfaultfd list_head */ unsigned long start; /* Aligned start addr (inclusive) */ unsigned long end; /* Aligned end addr (exclusive) */ int vma_count; /* Number of vmas that will be removed */ unsigned long nr_pages; /* Number of pages being removed */ unsigned long locked_vm; /* Number of locked pages */ + unsigned long nr_accounted; /* Number of VM_ACCOUNT pages */ + unsigned long exec_vm; + unsigned long stack_vm; + unsigned long data_vm; bool unlock; /* Unlock after the munmap */ }; diff --git a/mm/mmap.c b/mm/mmap.c index 1ed0720c38c5..62ff7aa10004 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -523,7 +523,8 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, vms->unlock = unlock; vms->uf = uf; vms->vma_count = 0; - vms->nr_pages = vms->locked_vm = 0; + vms->nr_pages = vms->locked_vm = vms->nr_accounted = 0; + vms->exec_vm = vms->stack_vm = vms->data_vm = 0; } /* @@ -2388,30 +2389,6 @@ struct vm_area_struct *expand_stack(struct mm_struct *mm, unsigned long addr) return vma; } -/* - * Ok - we have the memory areas we should free on a maple tree so release them, - * and do the vma updates. - * - * Called with the mm semaphore held. - */ -static inline void remove_mt(struct mm_struct *mm, struct ma_state *mas) -{ - unsigned long nr_accounted = 0; - struct vm_area_struct *vma; - - /* Update high watermark before we lower total_vm */ - update_hiwater_vm(mm); - mas_for_each(mas, vma, ULONG_MAX) { - long nrpages = vma_pages(vma); - - if (vma->vm_flags & VM_ACCOUNT) - nr_accounted += nrpages; - vm_stat_account(mm, vma->vm_flags, -nrpages); - remove_vma(vma, false); - } - vm_unacct_memory(nr_accounted); -} - /* * Get rid of page table information in the indicated region. * @@ -2632,15 +2609,14 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) * @vms: The vma munmap struct * @mas_detach: The maple state of the detached vmas * - * This updates the mm_struct, unmaps the region, frees the resources + * This function updates the mm_struct, unmaps the region, frees the resources * used for the munmap() and may downgrade the lock - if requested. Everything * needed to be done once the vma maple tree is updated. */ - static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach) { - struct vm_area_struct *prev, *next; + struct vm_area_struct *vma; struct mm_struct *mm; mm = vms->mm; @@ -2649,21 +2625,26 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, if (vms->unlock) mmap_write_downgrade(mm); - prev = vma_iter_prev_range(vms->vmi); - next = vma_next(vms->vmi); - if (next) - vma_iter_prev_range(vms->vmi); - /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. */ mas_set(mas_detach, 1); - unmap_region(mm, mas_detach, vms->vma, prev, next, vms->start, vms->end, - vms->vma_count, !vms->unlock); - /* Statistics and freeing VMAs */ + unmap_region(mm, mas_detach, vms->vma, vms->prev, vms->next, + vms->start, vms->end, vms->vma_count, !vms->unlock); + /* Update high watermark before we lower total_vm */ + update_hiwater_vm(mm); + /* Stat accounting */ + WRITE_ONCE(mm->total_vm, READ_ONCE(mm->total_vm) - vms->nr_pages); + mm->exec_vm -= vms->exec_vm; + mm->stack_vm -= vms->stack_vm; + mm->data_vm -= vms->data_vm; + /* Remove and clean up vmas */ mas_set(mas_detach, 0); - remove_mt(mm, mas_detach); + mas_for_each(mas_detach, vma, ULONG_MAX) + remove_vma(vma, false); + + vm_unacct_memory(vms->nr_accounted); validate_mm(mm); if (vms->unlock) mmap_read_unlock(mm); @@ -2711,13 +2692,14 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, if (error) goto start_split_failed; } + vms->prev = vma_prev(vms->vmi); /* * Detach a range of VMAs from the mm. Using next as a temp variable as * it is always overwritten. */ - next = vms->vma; - do { + for_each_vma_range(*(vms->vmi), next, vms->end) { + long nrpages; /* Does it split the end? */ if (next->vm_end > vms->end) { error = __split_vma(vms->vmi, next, vms->end, 0); @@ -2731,6 +2713,22 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, goto munmap_gather_failed; vma_mark_detached(next, true); + nrpages = vma_pages(next); + + vms->nr_pages += nrpages; + if (next->vm_flags & VM_LOCKED) + vms->locked_vm += nrpages; + + if (next->vm_flags & VM_ACCOUNT) + vms->nr_accounted += nrpages; + + if (is_exec_mapping(next->vm_flags)) + vms->exec_vm += nrpages; + else if (is_stack_mapping(next->vm_flags)) + vms->stack_vm += nrpages; + else if (is_data_mapping(next->vm_flags)) + vms->data_vm += nrpages; + if (next->vm_flags & VM_LOCKED) vms->locked_vm += vma_pages(next); @@ -2754,7 +2752,9 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, BUG_ON(next->vm_start < vms->start); BUG_ON(next->vm_start > vms->end); #endif - } for_each_vma_range(*(vms->vmi), next, vms->end); + } + + vms->next = vma_next(vms->vmi); #if defined(CONFIG_DEBUG_VM_MAPLE_TREE) /* Make sure no VMAs are about to be lost. */ From patchwork Wed Jul 17 20:06:55 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: 13735738 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 EE4F0C3DA60 for ; Wed, 17 Jul 2024 20:07:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86D406B009A; Wed, 17 Jul 2024 16:07:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81BD96B009B; Wed, 17 Jul 2024 16:07:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61FD46B009D; Wed, 17 Jul 2024 16:07:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3D4DE6B009A for ; Wed, 17 Jul 2024 16:07:45 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CE9B5160CA3 for ; Wed, 17 Jul 2024 20:07:44 +0000 (UTC) X-FDA: 82350330048.03.6CBA7EE Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf11.hostedemail.com (Postfix) with ESMTP id 92AF240030 for ; Wed, 17 Jul 2024 20:07:41 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YnCg+waC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=0N3mKt37; spf=pass (imf11.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=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246808; 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=R72J2Rq+pSM7hD2A/i8y70d9fRxZSFkCgc//56gCKE0=; b=Fib0a7gjsoeYYT09MBiQ1tsLrpbbgfJpGlSqDKGNltCxW0C2cVEkZmruVHtCKepa2l0vM1 ikcMVUhos0AjRuqByMueCrUYgZovNdDEUntEfzSqg/bPpBuxzz020Dn+V+tojBp8nbM41q S2ZbohtneSAOBBo2HaJn2FrZvEzqUoo= ARC-Authentication-Results: i=2; imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YnCg+waC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=0N3mKt37; spf=pass (imf11.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=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246808; a=rsa-sha256; cv=pass; b=PMXUxRTr6Be0sOxPAtr9+DbImpGo0kdZOu1yFQYfVAJKE14jW71ZL9odgqhJTz9I5HZliP N1SADVPJhyaXZwGPCJ7h1+6lBZ283DPUMaXnVg+pkkXYVw7aVry3Wt6cCBJPaxgof7XOXJ GqRvLBtRbsX+r5GGGtSIN1WiP5rVqZ8= 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 46HK4ww9001760; Wed, 17 Jul 2024 20:07:33 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=R72J2Rq+pSM7hD2A/i8y70d9fRxZSFkCgc//56gCKE0=; b= YnCg+waCSG6RuuK/GLj84Mntb5/ucduftPtXPkwlmsMp+LPXW9o4Qd+ZPoFaLVRW PYDfmD+sJL0dwpEzFoZWTAfSmtYQfmvobDaLSIXxFu2y/g2yJZJszb73kFk9MmSP XombzOSC4bzOz6chZ/r8psvwbZ9tT+BHNgGH76Hkng9pmtYV0NWihp840WZr5VJc n5QU7DYmkslW1Tvba7ShztRIGDfEW/WtKtBjoHRYEp+EAayjWUv7uBpJ7C8Hbt5q XlwiStWuLqASrEVq+u9Rjb7Tzf7k9cBppqAhWG5eqVwFoQpz7bVF4Ue+VbWgE91f 0PppHHV5klbkIysRI0X/hA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emp5r07e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:33 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HIrJXq006940; Wed, 17 Jul 2024 20:07:32 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dwey1fcb-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=afWhwIemtrElLX4i+QbK4Vl8ERhZCye+kLI/KNx6FJYXGIq3y5E+3OHpFmCXksZ5iujdv7ycFqLSjXs4N7GpK9cD6Mi0c64u/iyi8F55I+NxNwCpk8zldtkBJs13fQXWjQ3YRnwoRIQEO3OKX80r5efSwiGHgmVxyXFYKotNDS7fDP7UJBxxQO2xgP73/ZwAbnZyaCvw5EXmneRtnorFUMy2T4hHKp39O9nxWNZS/7oFIrMZZgMlsNhxqjPQcyMZQZPYsntqhCKH0W2SrsusKN2kxtvQxUOm93o7qhuVAj/fVGtvStntHUU1mJ7FBcmKx8Tk4+nxPPBXPeh+I2z3Mg== 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=R72J2Rq+pSM7hD2A/i8y70d9fRxZSFkCgc//56gCKE0=; b=EDQhMJ3FMwPIi6FJ9DWaEl8L/ZzZvfQjHiS2wfaXG9ps/lrOrplbiDYcm4S0WlSIofEXzDBtWfSUKfDaPlCk/rXX2pSolquWPCOStVxP2udOtG9NCnfDJ3utfaTKB3bW7MZisCLs5PvE2CJt7y9CqwdK4NJQGYwATMJS8JK9YYJXD0ftMu1pIUhU4AiRggDzxEQOpG1O02WMSoSybncDrz8w9NN+sLtefs6sS6nuWFb2iBvrfa+JRSyXFNMbmkrIH+qHiNH3O1CLlaETyA75CdCiK3O6DoRd1uDbWks8n8r7rG4eSB+0F2oCqQhIKOtLEn1DMvUaqD5LlTSvHOqdhA== 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=R72J2Rq+pSM7hD2A/i8y70d9fRxZSFkCgc//56gCKE0=; b=0N3mKt37eX7BEO86r16/p8a1fYT5MykxS5W4SnGB88SIG8ejAqHX5XbLhukJ6bUHaMfejVyumhFwabi2wMWxtqR1vSKamnoh8bHgP/8UblK5PDjgRDf0yo0f1R2Cs+rxHQsNSC9s7hU6eiVWGaJM8Ek7Ltov67ez8+USnKacs9s= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:28 +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:28 +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 07/21] mm/mmap: Extract validate_mm() from vma_complete() Date: Wed, 17 Jul 2024 16:06:55 -0400 Message-ID: <20240717200709.1552558-8-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: YT2PR01CA0002.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:38::7) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: 96490cb5-e445-4164-255e-08dca69c1552 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: 3cuBf45e3BBp8JbBVJAh3WLSLtq+OjPRc/qlSsPhQwTcjkOg+Lnib4ul3r2jCyRLK86B+chKUeaC2KfhCA1RyrQ1AVz228DCjf3QCxhDwmzJa3cJ2/Tw7JvQIHBUSQ4t2/iPUKpx74NfXq2sRakN9l0vCyLyIgXJOa1vn2n+nf3m8inH1Hh7DwW0T9qHfnmLNrtgg4R82CHsn5OFa9n73+SROOlTQLQWtv/C8jTD1OmufSoIpPPkZWnzfD9UbD+ikOli6QL51ASfZ73adr1lHYaLOLaLyBX+uSKu4LxHK0CDb1KwXNh8TmWPz2EPCHI7avPZ0oRVayFjteYExX037w12eRsABKaC+CsMQdaYJXh4bVd1TODO8mvvzd8r0Zws4TKt2opo2aH+LZV5lix8W3JZq0xk/VBS7F1Rcpcs6gMjSTjl7FGMP3AuIGhuwQ1HUjwLtS82iv+DNNzAvjaZ6flzdaPfegA2J7pH6QN7Ij1r+dFa3Bi32oq+oyJ1CSeDUMZGktPfgXkUjhR/3m+0suGjBEEGj+BQWGvz+rOZIUUJpYkpNCCwznZ0kF64qr98jcAMxO1OcitAkUbuRYhbE9Wn+hjBcz9ovERWotYwpnTX0f6iWy9T9DzgS6LfRVgsCvW8PE2gtdMhD1acZMtH0zGkY9HGkT0OUVIG5iidJy6Z3J1c7DJk+Xlr+GADqzVlnNk97riWdrVqJ7wtg5G8U4ssof6L+3b+MGj1bwfTLHKYzZ4XmxfrZvQwa2S3QHfL3OQzNtgt4W3zorMu7wZbtwkdxfVDfux+4SsZ4yHiPKwEVw5GRI018LGWGhqel2SqSS9j2AVB1/w47pAXZ9nVFsZ0GACj8GqZGfJxA2DKA7uv5XcDMiapdz4JrdshH7Y4PCS2Uk3q4/FjxOzm5GlLn8fgh7fvSxyEyritaYPLCFMTwcP2vsx5p9SYS98eHkfJBjS5H09+MfyRHzZ6BV0xuqqh5+o0fspIcnxNaF7dY24EGktONh5f+BNfdjnxyl0QmElux8VkGF3vmigN5sJoEFFMiBOgr9Rl8mqGejNDu3/cjGG/4clG5hkSJ6sx7d54OeWZfVTuSuqto+wvzs8GCVvEqT1fjTcEGGZj5XCKTa8fnIl136bV/Zj/xx22irdNuNzArhpxbIr2P0bzCFRXWuKqpxwrXFEbn2T16VfI5fkoRlkS1IBHlSRBfhKrQLFyDDQytPYKFdHrSVS1PduQuKPaezhhmy3CFsbgzDLNrfiYhd1j3Mt40sKtzydqs/5pKp2xNjlM5JkxapXPzXtKSzRP1EGX+L7aMHi3aqEF4WRYkO+zU/tNtAkx2s15StDbvL4GkBYzbeNdIhL6W2hQNw== 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: WE15ZjdNkp4V7zVaf6V3gbWBbaOYjLr5PuQtouOOTRHk5lBbz+mXnyLOPyEW7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k+N0A2GsFU6xOeniy8BTp8bSTwmACvokW8u5b5XMq7SpBScc086hrJg+Cx7uvIaDh46FZlkVYMi10Owi+HuwqxuhFWKOGso= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96490cb5-e445-4164-255e-08dca69c1552 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:28.3994 (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: fvfhnHAjnSjwMxY/pZriZ9KQrL7ZHHL4EX1fRArRb5lp6a7lH6tzjLmWtbJoQzLdjPYiPP4huU1D+y8/cs28jg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: Cp1m-mtI6d2amT0j3kFnT_RNDrFgb7RV X-Proofpoint-ORIG-GUID: Cp1m-mtI6d2amT0j3kFnT_RNDrFgb7RV X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 92AF240030 X-Stat-Signature: d98xjzeuwikdw9ftbquwtfexa8rhy6ky X-Rspam-User: X-HE-Tag: 1721246861-820916 X-HE-Meta: U2FsdGVkX1//7+WDAA7yEfkLwMZ4K8Yl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L/n4v4ymN//W4/XuoLbgkfV1LpWr2IciUFthZ94vhOOG3QL5IDpXoKDrPz0cDkCDsNl4xRLg/l01QAz7bikCx+hhdjbM1pwLFLE5RU2AB+9Pt0yhf32FcUlq2rt6dWDk1Lz+6bZdfe1gmRfn+/rCvyQmk8K4aH2tWpYQVFPJBLJcneDfQDN7/R6zvmtoUhDM8aGzHkaNe8mb0Fb+1o9HcDesvHwO9igB1ZrOnT7v7L9KULYLn8Bcwrw/KqPIP7iCST+63a6q3wEvYKitiVdYzt4SQbHdOhrDrDu//z9H+e2B7rLJWNkiDarHioY6kngtW6+FgrGV8SQKXCHkdZ1imFG2CW/NBGtDF+/iQPGNjmGswaw5keTEYeMDinnzgqLGHAPSxvO7pDWdmwRc= 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: vma_complete() will need to be called during an unsafe time to call validate_mm(). Extract the call in all places now so that only one location can be modified in the next change. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 62ff7aa10004..1c9016fb6b5c 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -646,7 +646,6 @@ static inline void vma_complete(struct vma_prepare *vp, } if (vp->insert && vp->file) uprobe_mmap(vp->insert); - validate_mm(mm); } /* @@ -734,6 +733,7 @@ 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: @@ -775,6 +775,7 @@ int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_iter_clear(vmi); vma_set_range(vma, start, end, pgoff); vma_complete(&vp, vmi, vma->vm_mm); + validate_mm(vma->vm_mm); return 0; } @@ -1103,6 +1104,7 @@ static struct vm_area_struct } vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(res, vm_flags); return res; @@ -2481,6 +2483,7 @@ static int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, /* vma_complete stores the new vma */ vma_complete(&vp, vmi, vma->vm_mm); + validate_mm(vma->vm_mm); /* Success. */ if (new_below) @@ -3354,6 +3357,7 @@ static int do_brk_flags(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_iter_store(vmi, vma); vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(vma, flags); goto out; } From patchwork Wed Jul 17 20:06:56 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: 13735740 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 F008BC3DA5D for ; Wed, 17 Jul 2024 20:08:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07F006B009D; Wed, 17 Jul 2024 16:07:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02C656B009E; Wed, 17 Jul 2024 16:07:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D27B46B009F; Wed, 17 Jul 2024 16:07:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A9E486B009D for ; Wed, 17 Jul 2024 16:07:47 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5E21E120C86 for ; Wed, 17 Jul 2024 20:07:47 +0000 (UTC) X-FDA: 82350330174.23.18DCB7B Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf20.hostedemail.com (Postfix) with ESMTP id 2CBC11C000F for ; Wed, 17 Jul 2024 20:07:44 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=WoP01W6O; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gRdLmOrs; spf=pass (imf20.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=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246833; 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=LArHVtRPmTnLL4Ka/8b8U968Rn79AaiiLYmA/o/M1Rk=; b=lI9jl5mHDBwUEf6AupezENkbodTsDHHLnzIjYtX1NHZQrl1vW65O3uFxa3GJgxHBWACqXs gCAVx5q6jMJlR5ctn1QNu8ordMGamPYGvigg0XKoYCO71aO0YlsENMswsivh+EscIEO9kk jhb70NU0jTaiqzD3sckZRNw7Sek/nb4= ARC-Authentication-Results: i=2; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=WoP01W6O; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gRdLmOrs; spf=pass (imf20.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=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246833; a=rsa-sha256; cv=pass; b=BUOjE+W7q/nLSUeF0zt7ByHlOAk/on3P7VCdYldKGNV4TVprZN/Jlo/K4Uz+qs2z8YHco/ qwGz+EjDImoHqBPaMW+59LGymJO6X8aRC1U1Ov7PxC5iw9pxrcQizicftkm1XKcXqxrXnC 0LuivSd5EehMbF7hFUbHW/xB1PlYqbE= 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 46HK5ARp002719; Wed, 17 Jul 2024 20:07:36 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=LArHVtRPmTnLL4Ka/8b8U968Rn79AaiiLYmA/o/M1Rk=; b= WoP01W6O2dx5J7hrolTh2BTrFkXgiRJxWftRVO31nsM3ejb7sWpyblYNhq9FINFy qVKK9mkd3VOsvh0kgA3NI29r647dUcjOGcsr4f5pG0mgydkOuvSCN3qREgEfjjV4 sBqL6pDZwKaWiy5ryxnxOKbLIHnuSpzKkY92RLhkcxhFU38wC9dVqh0CcDxQe/94 VzflUDHYMPUMAn5PDcBHO1cTVx/e11aGTxc1oVcI+z8bJ+1v/yXXcJcYmJLzb4Y0 x9Q1GnXOJta5Dvh9S7TgnhBP070GXMXkF+sBpIZuVDivfr0fFOxpuL+QA8y8FnD/ pu39rxOJqzqkNkTrqf2UpA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emp5r07h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:35 +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 46HJbBG1031594; Wed, 17 Jul 2024 20:07:35 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40dwexugm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=obBGr4I8KZ960gCY2GseLrSq8ExxoDbiAMMGnRFUltnFB6bOfbiAoSxwUO/FC/nev5QO6kXhqc5h4GquHALFVprCI1ZSZTfJBDjQCa9tKthojmmIpvCtG8YiUllyqCwvs5xS54TpVlFAUgYHxTE4PiesnQyMN3uV07NyRAlNCqpLLoP8Xdh/P8q8gHBNvlb2F3m9a8v2zLl+L+LlrBBjumNWdR45/z/454UhP8keYSgayVkGpEzO1ThMyqvQEZwKTuUQit+hr2K/nLGMub/QFNLxN7RJe1CI/CfNKPCcdUQU15i/sCwF0UT20QCg9UhxBth49ydxe1ceQ7T1lllZKA== 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=LArHVtRPmTnLL4Ka/8b8U968Rn79AaiiLYmA/o/M1Rk=; b=BeFR2QXhKkiBecpgHGQVdRusWjdyYdCBNVh6g5Snm+JIRVfF+likh8Opp1Yk6r7uensTSAkoa9qUKs/iwbBVItWF8hoD2U2put/Ihi5er7u1KmpeZyQ3RHEuPSU923GZi0HuO1LuDLmtTkP+lc0UaessujRVUR7rS5tEzWOwF/Zox2o0VBK0IzVGr612OlYpSJkWp22AiCJGPgT7p00YN3itnmCu6U7ua8/3H9rccK9R6hfhpiUi48qt5i6BXePNKw0yUfUOpXQXjW2L+yigyYN4QDvDIn4JgMe0ZVblonpMrorJQ8X6PmNLX/2eia3P0shmg5k+r7OeMS+ECdfH1A== 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=LArHVtRPmTnLL4Ka/8b8U968Rn79AaiiLYmA/o/M1Rk=; b=gRdLmOrsmYgbKwkN2IRTRnzii38TAxpQu0jytbhkXO+OmES4ROSQchMdT9iIQfHjb9kA4JSckGzrfaVtfk08EsVRkEKmdiTGl5Af2MJZtNXaY2J++XCJlkkwh60LlWky9ByYNZNTT6oNEj+KA50L16KKkJXy5f3kSLJKW8R2XfQ= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:31 +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:31 +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 08/21] mm/mmap: Inline munmap operation in mmap_region() Date: Wed, 17 Jul 2024 16:06:56 -0400 Message-ID: <20240717200709.1552558-9-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: YT4PR01CA0108.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d7::7) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: 79b33095-407f-4e47-bd6b-08dca69c16f5 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: VtiqM40uxJX7F0NidoNF0nGx7Ppm2TEWN2JAkHwGa3B8PhvOiB10Hwyh1JvJGXwQCDTDtPuZYwBHT9g5RhaSDh5svtYbo8isASJIDzVtJhkxiT3VFL792SKs4CXtQy0wghJhO/4i4tvWU42hN/UXceKm3Sjyu3iUTEmm9PatoWHV0eVKa37x8yXrE0Y4I1QLH8MW2UVD5M53mdEKklJc5iunaqjBYWkbVwp0j1JeUlxwLlk6mF7SjAI1ZuTi92PYnpZlDMtAanKWNHSMy/OtzhrUmXE58rJep/H8tUZdi10T28JywznEYH5HH+8XkqUFfePmW+OjL83DRD6rtLPMhd3GSV8ylDB6Lt03XiTptpDd7ADKukmb8x7770WQpHmD0D7aY+lKxrn4QRJa6oeXO088Yj1KVVE3hAmZQl41Nj+H4oYPFTM/B3ogrb1wOjLc0Rpw2NM8YuschadxBZ5dEPU0eXAZm46RL+aZhiFMDhjhszWzA++QCoSQxkmjIjhDtngrP4UIBn4Mdz5+n8VpnKdDlMXJGKEEfQbjYGaT27XO3d9ODD9D6K++4bqWo2gWsTZWFlJ8FOLGr/hX7DB6/Eqj5f2iAn1+uZPpg53REWQ4G2oI2Io6Mio4esqU5GjtF//15D7IOy2Jpx/AMhq6gWxfD5yFn5P5rsMykqhcXoAJdalqgFYvm/wrxaZ13AwpwvtIj5ej/JSDMuwAo3Lc//ych3o+oxdPTwuoy3OGXvwFwav8vjA3msaSWXcKFmvxqfHNtIgNbgaMFCMAshg6GwCgzgkAYyZeXqILW6kTD8lVpPu96Fyi5s7AVl4F4VWQ/i2NPJQpZ+Ax165h7GWmF+b0OJPryjgU0QztbplR/5gntCr0sN4UaFaw4MfB0MrZtxX0VtaCd4P8tgJgvWLj7HMZpmSGeIgGPJ1h1GW1lFSGE2fNMq2N87NeghzsgNjI/pqoZuYnodZXVLRdATCeXuOB6lGoCXPDP82ZrWgfgBxVv+moCTCKG/6uy2HlVIc+hJ2GnFyUd4BgDfCeIceoUY/x+1wNcpVK6FL7l83TOCn662P5hD8E9FO7e6oaaRMo1jZ+30+QEkGyjeC3WopXGnj790iXK/D6YMhaime4sBC/iHzzY05bTkjR/T/m2vnM3b3ObMQoHNQiTjp3OjkDLOouPJpaHoYeXNQfGJpmw0E5MxNnCckFcNla8lkNus765/xUS6BgvthzBIVVDWUdRExcfSJxflLk5bREkkKg4EcdbK4JupPiNX1YPPCX2zdQGLLBff9S1wIUaxgYzs6Anj7pqLsXrSWNqemX1xUxhouOMDl2b5N6QR42Qn7Q4BpcERobCRIBuQm8qtNmweDbdA== 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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EXHBMUdoJdLQMw4hHCei7bpio7neR6SV3UsAU+eqrYu8ONbPjyLWfs14txTBhtVDGq6eOZxlR66m1s2bk7ADeCKcf10zMzvXTa2FOomJz0bMVDEbqKmvFX7rblPmPuddAjSyUZcdTj34KE2hY2XylhS5GZ85krwnv8hRsUxFBrFvbP+nFnHnDHxM1m0ZdiLWnxaq5w+ah8d3xLleHlTQ/D2yPWRH/VqDlbTtK4mkVIkWl1KyW2Ae0hwcv80pnN8nLPvj+jJFwvC2QTnIZUXvqCNXIvx5V02dqoNfW3YPIhafQBaZ5toSV/6JsOierPf+uKGPICD4VYkQ4GkufwE08FAnVNfsfNdsPMX9RGJklR1FVRLHWcll0rGS7gFiEwl0RrtL/QqUsVMwca7ceVllcAp65kSNAoMCH5yMaJctjq0XABJ06QkCvlKAVewDbLnIQZ80CiS3LI0qDkRFBwqqvnXCqLLA8JeqacxQpEVUC+xxdjew7REaUNRvKip1iHN35zbX0VtWwO7itiSVaD4SNdDQbD2jckZy44yE/YO7iQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: hg04Y/uoTAYKoHdE23ks33lRiMzFCV8JFUb1SCHZub7a2/CGvDFZ2/0GZI3jPC1o+fN6dtru6qvH7/Xxew9gMI9KjyosM5yyV3tjBlItWaRdnm0XgCx28P6L1B9Ff3bPs9arvc/kfUSa9adNRNXpqayybwtc9QUhSFF4GsqQMUetkUoute7l8wTdsTkdQzKc6Hb8D+3ot2bgC205A0inQPzjxahXFMfcdHeNFSctKKKbmueI9TQtw5nDKKRWQmohE+wvfPW7bpmBTtvE4rJIQC2DN+yyTgQnUerNB5MHyUbDhy2vO5zcKo72Lvr4hPueh/eXZqan0i5C38QfTXd9Co19vJUVHDWaguaH7wEGde3akALf0TjoeAPeRQHclgTNPvXSOGY/wRst7cmfQ59h288SC5iPP7GPWsHdu4ixxdHrwQ3CJ7ertvI4pBJZq6bIh7335zWKRO/HA3AjazH9C1GtLMrE38ORXHFYx42xd6Mqki3xDmhQa1LYY3V7AvuzDO0aBedE/QJU2B1uEKbmHLeRRAcr8uHAzZxRgBxIijHlxaNbVWv/4eXkoiT+nU27JnQs346jXQKg3K1LNfYeeZuNTGYr7vgBD4vhDOEjZhc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79b33095-407f-4e47-bd6b-08dca69c16f5 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:31.0914 (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: tFaQsn6pQtmetdFzbtlWdRTaTAlTWXHEwr8nyGoNxtoG4FNNpIJ58AAcfsale5Nuric7ooHTbT2rQcDBmTcCrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 malwarescore=0 mlxlogscore=993 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: IseVej541CAnO5fNrz3YmBtFU580LOpk X-Proofpoint-ORIG-GUID: IseVej541CAnO5fNrz3YmBtFU580LOpk X-Stat-Signature: nfco5ufwpkxa4tpq6sd4r3d6ki6987x8 X-Rspam-User: X-Rspamd-Queue-Id: 2CBC11C000F X-Rspamd-Server: rspam02 X-HE-T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3tjqMzplZUYg9dd2pJ2xwNAZqCB+ftTVvJctQ/Olu9JyKN0mzj0e5RGyor//PjoVDxNZ20ZbOINbeYhoukvf6S5Eq5EJJVhmrkn8Vw3yafsJL5xBMHSWOzDCQ+vxrg4Tlep05mYJh/CU1KWqOo8yrmjlN6F9x1vDqmL2V9IgjChuoN3JxrnwNwyHvasfVMPQt11qNRM7CEXLFy5ugr/JLUAf2bqKpGKF+JRy8Y39hihPBzH5XKlCZmr7iEgQa3utnXpyl8r0OP/NkVp4FNRMjOSeIaJcjuWfkef7DnBZzT22ufkuJILE+EqAgb6taI2DxCp7rUfTxNWvt09356SV2u0Ex0zQWfI++D/s5G+6NSfo8wgo2fK+Ulu0y6Hh4GGpYeX7CMCtGeJtye9aQwTp+r1LvigK26pqKvEG/mIgaebdW9gtG7s1lU+VM 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" mmap_region is already passed sanitized addr and len, so change the call to do_vmi_munmap() to do_vmi_align_munmap() and inline the other checks. The inlining of the function and checks is an intermediate step in the series so future patches are easier to follow. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 1c9016fb6b5c..49b3ab406353 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2938,12 +2938,21 @@ unsigned long mmap_region(struct file *file, unsigned long addr, return -ENOMEM; } - /* Unmap any existing mapping in the area */ - error = do_vmi_munmap(&vmi, mm, addr, len, uf, false); - if (error == -EPERM) - return error; - else if (error) - return -ENOMEM; + + if (unlikely(!can_modify_mm(mm, addr, end))) + return -EPERM; + + /* arch_unmap() might do unmaps itself. */ + arch_unmap(mm, addr, end); + + /* Find the first overlapping VMA */ + vma = vma_find(&vmi, end); + if (vma) { + /* Unmap any existing mapping in the area */ + if (do_vmi_align_munmap(&vmi, vma, mm, addr, end, uf, false)) + return -ENOMEM; + vma = NULL; + } /* * Private writable mapping: check memory availability From patchwork Wed Jul 17 20:06:57 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: 13735741 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 2D388C3DA5D for ; Wed, 17 Jul 2024 20:08:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29FEE6B009E; Wed, 17 Jul 2024 16:07:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 229596B009F; Wed, 17 Jul 2024 16:07:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED5976B00A0; Wed, 17 Jul 2024 16:07:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CE4856B009E for ; Wed, 17 Jul 2024 16:07:48 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8B37B160CBD for ; Wed, 17 Jul 2024 20:07:48 +0000 (UTC) X-FDA: 82350330216.05.67F797D Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf08.hostedemail.com (Postfix) with ESMTP id 54FE0160017 for ; Wed, 17 Jul 2024 20:07:45 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=RFNTDkub; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="0J7QU0v/"; 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=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246846; 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=X3v/lo9AxRmsHNZlKpTsm76kEoN8cW2y2gHVgYbRbTg=; b=dH7zVCiWPOIAKwn6zhdWxYzELsZUtI4cBe2FjA2nVsqZYj6EfR+Ljwko2kfrrTd+WfJKdG YFzeO4T2vuCmbTBk772mx6uwiCVG/0ODrIVaEAuRSSAw87bsYXguAbTLZvNpnM6+fqvAQ5 bRtx+oKJirysPrtv40ZQbL0dxWvnOgQ= ARC-Authentication-Results: i=2; imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=RFNTDkub; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="0J7QU0v/"; 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=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246846; a=rsa-sha256; cv=pass; b=4QB/LCy9PrIkGSNrJxdLkhM2B4IGHjD9BJp+ufE0iiWTZQb8OlbUE/NirKz82HziUYy6Rw Z+ZpEXTAJVr4o0Wzgqql8S0eV9cDqCzUG7DGbgwVk+dO/qcLFoWmlwUWJuN09hQdm+M92/ lD+ShiiPnR1uE33RS97QeHywqMU0bl8= Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HK03GU028095; Wed, 17 Jul 2024 20:07:37 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=X3v/lo9AxRmsHNZlKpTsm76kEoN8cW2y2gHVgYbRbTg=; b= RFNTDkubyajNzrJwx6ZDN/vhGbvEDpeqiNNi5Mnf8b7JNjeHq/cJsTq/rKcWCctw nYSlz6c8fwzJg/pq6UZ/8gzdkqbrwWN2PE+OizSrk26/ZBInbJSh/yjzubP+OR7k nZGy/5HO/FpYvk5E8VFQZlg6yFgXPi7O39X2RET+q03xuTKGxY7Dr9cIc1ixFCra lbEDuIhZ+Go2el8crt6pPT1G9AJ9oBbt3pHRz6YYe069lZzUnbCnRl+3PSHnBOqO SPtaHgtZpVkQfrUCgp7UVOdWcPukSXUOaUJrI8hzEOy7jWUmT3D10QSgEgUAMnNN yLGtYrkbBKyBuLxihvJVnw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emkyg19v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:36 +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 46HJbBG2031594; Wed, 17 Jul 2024 20:07:35 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40dwexugm1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hQvRXb8zmbUCmIFsbBkZQxh56Wpz0vk+MYZRGfCuMMBH2s74Nd9ArCzCU0sVvff+H4iusG/zy9YFQVLOotAmhu53CnqxANZ92x5dIKzGPEk+t48JhO2i4TcsIdEt+js4zY6R4yVKsiLGXqhgg7TTlji7ugb22IeVbvpLUuXw92h/XRUUtzju0WkvNIJSBJ/lBfb6ndLlA9UVZ4AmhLh1gcFto2qWvXWLBzIc1CACOtuSnX4BIyzhODTr49XflsHSL7IJv0Kmf7FJuLq6IoltYrA5l4N2wCnQajt2bYFF/kRH3Hn+7vWEv5K3dDVcdYgQiU3t6H+GZZml3yDiD6/TYA== 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=X3v/lo9AxRmsHNZlKpTsm76kEoN8cW2y2gHVgYbRbTg=; b=U7lcyOBhem7ok97IUqR60TLgCUE41U8s/2WYUDdRFkq+KGnrsJH7XupLlGf/b2p/RaIb2K1KZGXmCTt8LveHNJZBch4SKpj3oqjo9rUeHtZtgGoO2cDdy4Kk59Jyum5goq3D5ryDtZadkImBdXXySW0W/t3zitxNZ1AfB4F3Wl06wxzQvmexuGg6LY6QdacQ5GndYtxTUeThct7a5zjo9xng8ICiMm5i3xqMLeVPJhidULRcyjDLz6CzQmHi95rbIfLIKaPLivebrCKIyDRIKCOp5lRHa32jR/JydNfQ+//vXRmNY1mrnxCnnhonubVZkRYmFiHK5bt90QqURSzliQ== 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=X3v/lo9AxRmsHNZlKpTsm76kEoN8cW2y2gHVgYbRbTg=; b=0J7QU0v/k2GR2ZevAnfIOJl8WdKqeRIo8UBdWowgkkioJX8GKFVJnFnkX4Kf14laPxlahfF3gL6DbDYBm6glmw4Wt/giZw4IxSaU14AHi6orPWmoSTCng/sDHqjxwJP2+e700tUQFWyAGuZWTFVMFXcaGpfFUyjP8uGE7tL+YR4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:33 +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:33 +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 09/21] mm/mmap: Expand mmap_region() munmap call Date: Wed, 17 Jul 2024 16:06:57 -0400 Message-ID: <20240717200709.1552558-10-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: YT4PR01CA0143.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d5::18) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: e8a147d9-c97c-4eca-7d80-08dca69c1832 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: 41206tqtRPNEeQ9WhAN39w7Pq4AoKu76S1UzR+/ebq19EOvcNBqnzLhBbgh6ccRyCfiASN1N8Jf5oe5qO73kP1pRHyKIufnSb9bxC82R5c7/rwl7f1sFjcATeu8cdQoFmJMiGNyE7k3BvglPxB8lx2bcWkN4y7YUWOYGbCi93RQeaWSgWTtU4h0/vLGkC3d/SzM9BbHLqRZxyRTrCtckfnSwdeMVf9kFXd4pwIZ6HKqCtTBK6UQ4Qj0q5p/AYoS6vV5HRjPS1Ko70oKjQ9IwLr783DlqVR2OM0xHrAp091MCjUrUFmVX1u01S3D4TB8EkCWZdtAg8ndUcPlZwetzSzyECcvCSbbgBiZwSKvdRtG0+pDi5X5I9bpqd/zW4t4qWBJ38qzB6+RLz7k75ZXLHREn/nZZUACIu6TR2+3c5e6hjO/eEiZnbv6/9d5mYdSeHmEcEAIW75tLUqtQ2zdnYmP4cP61ypcopefEIHBB8MsH9giHqhJRSdtWB3txFbEIFhga5rB5E3fqs9bw+CaN7bwXS9XyfEvDadac/pVkC98AQIhcOJdrKM9Vx5l01fFFWT2NFOSD8VtIAdSvOw813D8sYWBTZDyQeyhUI86IZ9MYCv5VzaXvtqL/NkfR0MxS0cRsNCk3pgDdXmscCc0q3/QoLUL8kF+VojrtNDVfDBs2zjm/SodXoOW7AAS7MUfeMnYWbsnZ5xPVdp11G4+9p8IvuqOOYbyaAUikSbx1l1bwAQ87RaNtUvgdZEwj1cVUFhSpGNFh1ZziLtmh7ewrTKG674N/mRZjGIDlZyjzY9RH/PbfWFo7X31UW/PHDjJ4xGNu9IsA1Kbf5q6E/IaoD7TlF2qyJdrKW/zZbApMi0yIYmvF7OgVgbUwxgZcetiowoXDMT0/nO3b/Jkz0fuwkwjgvJe3mHhsvLUaY5O/R+g7kqRAy4Jm6eFP91vP69E+7eyWXsIcwbMnOelT3EzWJI83gVkJfuGLZZBwhjoMOkuV0ysAYCuLsv3g9SAF0+VDiSXzCLZ1s0UJB+m7yGhhf9s1+B4xuj2oc0wdtVIsImM+x65jhpa9q02AW6PXEtFwxOCaXiJr7mXS95gV+MHqXCWE/Aos7rOH11carGteE+s+UtLyeAhelbBSPlgK0iLU5MVJAxdlAC8+PdKJcpkxdGwwFJa88Ye8CssRUCKezGTFrBN7sVzHFfZ53tiifaeN3fz6HTLql+WGGv1jQKOZXhumDNdxRpgfF8jSRK6Rr5PkbRtRt7oUW5YiYLGMd0aAsO2L8FnbKAZWQzEJ39AYx3aPXTpcAS96bS4MpZa57Ou2zWqAvXnMdlN6wqpPiu1JRPzUQZdrEg0PdyXbRgGUig== 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: WnmxuffSVt9xLy+ocvHFaNjXDLyLnpxzY52MfnZimpsVahBBI12NW9rdbRyxnjnz1T+tkmoKhlGY8kDXzvY0/FENqZM2iOLUIagGz9dQevMUwCFnTfJhsFtQr8ynFPLR/77P5CpYC9mXlLS8KA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d0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8a147d9-c97c-4eca-7d80-08dca69c1832 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:33.1850 (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: 8hOQI+OhNe6qrhjsDcmGKz/njdzYbLpzB7Ar8GgvlH5FCXg5VLHwqQBw8K90sRKmdlyWE9DrrfY3Me1ENGPV4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 malwarescore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: xWU0oLElLrmHOswr_d-TEfm3l9tGAdl0 X-Proofpoint-ORIG-GUID: xWU0oLElLrmHOswr_d-TEfm3l9tGAdl0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 54FE0160017 X-Stat-Signature: gjswwjpa8hsg8h3ce1kup498f8jrrehj X-HE-Tag: 1721246865-560540 X-HE-Meta: U2FsdGVkX1/NQ2WkoPw3ARKzQkW4KFjWYo/B1S7ge/nS4U26UXhczo+RZYM/F88bXJc01N2FiKQ7DDKDvo4OI3CD4GdSwt3gSFizQTrVS48t3yJRyk5X0Pp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ZRG50hahL8u6l7fwqVKaH1zZWXdzQuYCWhXVy2kWsjvE1M9vIdckgpcA+2foh6WG1xCln17U19Id3w6rGtVZm7pSsafBpAXdlQjGAq7TKd2d9p00Tk3vkiCIe1NaWfuwXfgvrhlE6Ou3GtJXfkvyfByJ1ssKHPV3kgMnItR9LIPbckAXEzz3MeJOtxBm3H5fL/30omFSsQYfjbe8ooEew3BnnAGjfZMysc0IptYKtdInUyH/ux5yi09V/5WxscXlvFZ5B0bQkboqIrBzEhivOJGVL3rPhLNxXWjThxIHAUEUtJDYJh95SOQlojh2J53A6CMIPHl+2rIWISJeqyf1Iihdg= 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" Open code the do_vmi_align_munmap() call so that it can be broken up later in the series. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 49b3ab406353..a1544a68558e 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2916,6 +2916,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr, struct vm_area_struct *next, *prev, *merge; pgoff_t pglen = len >> PAGE_SHIFT; unsigned long charged = 0; + struct vma_munmap_struct vms; + struct ma_state mas_detach; + struct maple_tree mt_detach; unsigned long end = addr + len; unsigned long merge_start = addr, merge_end = end; bool writable_file_mapping = false; @@ -2948,10 +2951,27 @@ unsigned long mmap_region(struct file *file, unsigned long addr, /* Find the first overlapping VMA */ vma = vma_find(&vmi, end); if (vma) { - /* Unmap any existing mapping in the area */ - if (do_vmi_align_munmap(&vmi, vma, mm, addr, end, uf, false)) + mt_init_flags(&mt_detach, vmi.mas.tree->ma_flags & MT_FLAGS_LOCK_MASK); + mt_on_stack(mt_detach); + mas_init(&mas_detach, &mt_detach, /* addr = */ 0); + init_vma_munmap(&vms, &vmi, vma, addr, end, uf, /* unlock = */ false); + /* Prepare to unmap any existing mapping in the area */ + if (vms_gather_munmap_vmas(&vms, &mas_detach)) + return -ENOMEM; + + /* Remove any existing mappings from the vma tree */ + if (vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL)) return -ENOMEM; + + /* 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); } /* @@ -2964,8 +2984,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_flags |= VM_ACCOUNT; } - next = vma_next(&vmi); - prev = vma_prev(&vmi); if (vm_flags & VM_SPECIAL) { if (prev) vma_iter_next_range(&vmi); From patchwork Wed Jul 17 20:06:58 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: 13735742 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 AA00DC3DA5D for ; Wed, 17 Jul 2024 20:08:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 908696B00A0; Wed, 17 Jul 2024 16:07:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 892AA6B00A1; Wed, 17 Jul 2024 16:07:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C0076B00A2; Wed, 17 Jul 2024 16:07:51 -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 4C32A6B00A0 for ; Wed, 17 Jul 2024 16:07:51 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0582C160CC1 for ; Wed, 17 Jul 2024 20:07:51 +0000 (UTC) X-FDA: 82350330342.03.E699F85 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id B9EEA14001B for ; Wed, 17 Jul 2024 20:07:47 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=LfS6mrRI; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=fQcGhEC9; 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=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246836; 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=S37ZWrf+uGjTlHx8kEYsOJHDQEEph06qnirTptSS0/U=; b=IYwtbA5krez7q2mEKu8TemBhIrIemscmvm5p5dsvPuYxC+q8c1QVpxNnaffD9ZUB/xlIcT 50E8CKquUY7hPM5skReY6EiNbw2bWHppNN/bPi2mbjjrZ8fagX43U6NnofODKyNoHNAMq8 k0lUp/WaUmUyxg+OhnrLm0kkBf4MACw= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=LfS6mrRI; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=fQcGhEC9; 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=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246836; a=rsa-sha256; cv=pass; b=Q+ukn4gCb47trP8k5nczcrHVrRaBSYoYNnskyTQvJpf/tOnMldrpXWpabwkwpvqwr+lqLb 6706nJYx23SCyL+b9GptgQ1RF+WyhdINcP1k9gp2YbYVuRd5SIaNCZEF3TmRoS0lZ7hmQy /0tVQcKQcC+nKgbdd2dHCxDa4WbEAGI= Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HK0js6029063; Wed, 17 Jul 2024 20:07:40 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=S37ZWrf+uGjTlHx8kEYsOJHDQEEph06qnirTptSS0/U=; b= LfS6mrRIfemTMAlMIdrimYUoynbGPKJ+l9SGCvjRCSjk06gmaZikCIhBcisw964/ M2tuld2XJE2afpY9ItpNykqXn9lV4lWXuECpNLlCQTlkw7Nc+g0zLP7xyMK3Bzkh Gi7qnibnuDcvS+BBVhx4pCGYuyuw+EG2CuNFjCeQenA3SE//6XdW1E49G9JR+mnd mjcDxKlRI8J3t3acQfMbnybgylEnTVCsFLaLp0C7+6SkgqdsvsEY/QWCne6ukiM9 oUxEwF20IG3f6OgQI7UL3K5MEvCQ3blUGlH8VSXHqFMkCt4hhCRWLLTfZ6+/Ev38 ZI2P3q1RcZKNpgdnwJyd7Q== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emkyg19x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:39 +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 46HJmtKI031693; Wed, 17 Jul 2024 20:07:38 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40dwexugp1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BZ/ZwiecW9/6oMuncH6VVKvKsY0NvK+CfK3CvzQoVLz4tytgWumvjMw85uzmz5EPDt1gxP8vHVZqhRjztZSFkfAk3y1izFGPFMUsZVYEl7zUj2GwnuFq2bc/TQmMsSrOtv8YnEnxGQ1a2mMTZCCrrCrryb4zqE9mxRa6awcSndHPEGRfo4nxhz0XzB7VGqHrfLs8KutQZmtzBgUZB6y1PBaYRVN2sqkyGbHQmP6abBPtlD2XeQ19GuYmAhdP/R2BIjSZfnJ/HjcSPxqidAmS9ve+Mvplo8bhBcTJ7NMYAf8QrLqLlKVJPoP0E9Su1TPAy6Q3lgRGuAA4tcOo+0Ho6Q== 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=S37ZWrf+uGjTlHx8kEYsOJHDQEEph06qnirTptSS0/U=; b=p0oe4vs89fd6UGGhEroClw7ydAdzakJiPjh6p72oY4EqgIr3RToNvgoySakZRIjPyuJpKYK4OyxHOZ9hdvOHjGRHFEuKxfOhqFK+cHkGqiOB5vp0GfMoZRqP+BDG29RnMZC2wPNFk+13lyt8QhdvxByGVTRq2mxjttbPyyO4hvr9Ij4DjLFGHewStPM9ztxX3aq9FIwMJS8rd/yZDAjQ9bjoAR+ake5I0D4jyuehKXrdKntBRJmOb6oPKZ2vjuT2wgYp4911NlyMSbSQShdo57+ZbPWJXkgsaM0LTIBnZNzVxJRGoOU50CMhN9sTPMnqxHOew6EaxNBY+SLNHHvY1A== 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=S37ZWrf+uGjTlHx8kEYsOJHDQEEph06qnirTptSS0/U=; b=fQcGhEC9os9r923QtdTBa5LlRjykSpYFHuDM9k2OsPtB5gy7CAs5ZOkY8NDcybIuoBvvy3Jr31LdWKCJRxd7gQrqpOYabHf2oZvobUKeEWvs/XsnBlF5eipeVkpISD96oC3EQ7wjEA6W/ppTPT+0kX+JlegKuva/8mReIGppe50= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA0PR10MB7303.namprd10.prod.outlook.com (2603:10b6:208:40d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Wed, 17 Jul 2024 20:07:35 +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:35 +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" Subject: [PATCH v5 10/21] mm/mmap: Support vma == NULL in init_vma_munmap() Date: Wed, 17 Jul 2024 16:06:58 -0400 Message-ID: <20240717200709.1552558-11-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: YT4PR01CA0136.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d5::20) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA0PR10MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: e3993f67-2566-42ad-0cab-08dca69c1994 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: 7PN68O8py4iovjHTdV4p2GzTeG8afpWCx49mHftk2xFhZteOhQJokObg/kg6IacHaxRzJVyXgh6lq8UA0QoUf3xrZ5SXi3U8DYWhqp2SsnjAi3oAikLnzKe6yOPM7yn9erFlJ2b5H9jRl5BISAC0JOV45ZUoG9j1AZ0y+RSoSnJuzxAqyxBoFgxP6b+HadhKGj7ksyjxNtnTDZhVdpbpD91qQuXaCf+NEUB5FPbs+CnKceEEOSRjrZrreGxz76HbR0dFI4r5L3iAMKQVAPGubuPfNoGADdwDcXAevhRBKtY+AUiPqRK8wyONOcRBm9Cexd9lVg50w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RY:;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: Z0NV3fsPhkqRQIfXskgBEphkl2zMJCosDKGBghYwvz7s+Rh6/eAc2K0eo4VfCRrdZlbeOj3k0y7xMpLwX9R0sRASHuSeH5xLy4URMPdCKFtNJ2cxUiDNvgB+Xg8Jg/fYPPg7gH0WmQKo2H/1/8vO+SQE83hfrqnOAUsnBzjb3Wzun+3Phb2APz34G26NRWXWpFq0FTTVxvc37jWggQzFI2CS0h2NdRcsGjJZIQ6kHC7uQFIz7eDmZ8IFwG+3qivcdtXZThx9ov78jLN7bE7kNSuKTnEw0AHog4xJWr2Xbpdi69VgMqHHYUC3vPl9klso8Tp4CHuMsMqRkd/FgodYplpu+GO1CyX3OcfbujWbo1T2IcDwdCYTb5sAbzfD0l0VDvHHOVlZMxtSFes8PZzzubl/oORI6Ojej6fuZ0kQCo5JEIytsaqAcSFPQquU7ZgdK/vAzTjq60yJ8HM3s5+vJR5Hh6/Pc1BAanMdySUR6lr8oF4FZpjEMed7P2Q8Y3C5YOzpikhl9i7NDfXOaTxaJaEzmEvcNyRPghj+JQUu1aHl/1QkHJ25i7WyT7/tE3x8Sn+V8qD+p4iKmVZ3HGgMzl+4vXHJJPPTwDwyNtfHCkOedgWYxynKPaumK09j5zfoXNKFjwHkJOUsvCDqTSpcMDTyQEUDi7qct0n/QZ/hEF5QTxMaSWk+kBHqkotLmt8PMJx9YpDZin/cvHOmlr3uUndZR5ZwO9n7yMC0KqVQ8linmLhDfP43m3WoznZJH7/jRCqhnaVnfbPfaWrwocUVJp0bu13KDJbYMhHA+Nyys1IZ30aDEek6KrSCfxcA8p94V4EW0nNlMkeC0SXD4cIasILcGDcemnfUFY7BBnlwUeoPHN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X/wcPLmW+8cjioeOqevikEf+qTTZ9vHIh0IK6fiq4vUHpIaUJJIb/ISARKkSPiyb6b3I3sMOxBvKA8D1uPM4B2d9pbA7GBrcjFGvzq1/HQ7WNmXFYv423QSsLFs8cVTOwYCgUK3sapOR95PIUeVmDDUkAY1E+Grrqu0Q5wZPwBk+SN0hlcRh9UtCzQGN6SUOV3lGefZJuDiGQf52ZUiDdV1cettkporl+KO6y0mHiuRPqXuk5F4rhuAY4Vkt73hIbK/pl4Qj6+eRlvQMv27mWOEVuZhRSNetZmJINJiAXsxbCPEVgdWuhASC0v1xjOoO6VA9o7U6Gp+YlOQ2sntA/mWkFQfnsonIdX9AAg0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3993f67-2566-42ad-0cab-08dca69c1994 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:35.4887 (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: 57YsfsvxnY3Xcr44LgGMAFFFpDH9pazZ9hO9yK+dPJlChGbik0wwh6zK2DGDNX6FWyJxvAC07Cw8wZdjW7gzUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7303 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 malwarescore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: wwNEHToBeP4Sd4mr0IdCfKDHLKEjCElI X-Proofpoint-ORIG-GUID: wwNEHToBeP4Sd4mr0IdCfKDHLKEjCElI X-Stat-Signature: 6n74wruoxirq5znfm7bj93oyuwb7mnjq X-Rspam-User: X-Rspamd-Queue-Id: B9EEA14001B X-Rspamd-Server: rspam02 X-HE-Tag: 1721246867-585920 X-HE-Meta: U2FsdGVkX1+snjlvLoedvle6jBap3kKdwNcwU2kxrzg8Sq6uOy7Yz6mZ4aNoU9euMKd158gXyNoQWb7EbpcKBGGMRW2MiKoLLRPOhUDHMtcKtm2qL1bjcMx7tY71+5dzZ19QATCg3ONSGKmN3Nffak5d4o7K4TV/3NceWJ8k3BGLnintIcdleToMmmpc0A7KhPO7ehNwnCLcUMWEm2fSkspLbprw0ePRrZD7ZQf2BkJdCVZENSoeKkEJZ2OgPjABMrpRH4PRTEzONDGgdxKVk/ZzjRziJGbH2zBC6MiO+3CQAjQgN7cI9O2hrb4dNP3K6G94FYqc4g+cwZvBYyFu9ZaknyMGbGdQ31oL6/ckjISGSSS7vbKbhCyAI98+kHK00cmrG2y8QrW77r4eiON8ilg+713v66ZrJmckvIjHe8u8rI394tZKDOhBdpZU71Qete37GQr7Sd9xj+WT0R6GIXeddhgh6X/CqljtgkrmZOALYpwluxZr7YzAlHaVm91qKSI4sAm7nI5T/iIyOHQHxqwql6gzFOKxjNXvFSUnkrAG6yd6iWQviJVicf6c8ExYsgDLw5BgoQItjK7p2p2Voy0HY6x5wSpHbKyv8841uLV0uc9yK/v2U/HV3ZQzlq9GNQOd7XeDYMDRv51VbcXVGtcxxK/+X5IssoM5jnIgAgrZYJzue43iGotMjyWrxGSyF+UgiZOtNEqdaHw4dUbn2e1W1UnmsfNbbsqKIOpaoWSw+Bg0s8clE/mwMxBxAblQDkChMZqH/BVOLMKH8tz5WOpJZ3+eWQJ8Bsw4vkG6mH1oLX3zpsquXdmtl0LJW4paAVBPvbmZ2dMIrbCOSlIemktSPja4mauvXYeX/ZbjFHRHVr8vX/7D128YDbbWn1aLAIsOderh+C9bznArNf9DKxW8vuLH/DMV7wDn98sHyVZ50IZNmQ/jrkiVlfHVRzWCbEsHsgG08BDfewodCS1 K557V35z kzR2DjD54LVf3I6S5huORwkwLhYz6OKFqPfL8sLmLtdshxsamT3Zj3TwFsBb7mr/gPj+kcZCI9pnROoFRDPid9bLfz2Ks5VkB7e8gOIhMTrhZV5cp7exTlKh2CB04rEacIyWBDNvi8E0K0Q4DedXyg+QNLBv+w4fHkKRT4ktvSQ99lIuJf2Lp6qdI01wzyja1XpZd07z6hluGeAsrF7s2DhTnc6jdAn7FPAVxcaHkMnpumjGoLTYcndJrp6HoLdpesPTAOyNb1OQnI1HJpsghr0Ts5H+zTYBHvnKknvoWTF9M8g6PUCfqurBUwTI9V5iYRJDX4APMSoUnlWEjBagd5HJc4Tjaled06gXZ3B3vfj2Qce3AxxoWi2pA+sp2l9K7y8MWGBA64PG5OOi/kfQFvPdP1VCh8kWTREGrUY3GnWZxYHzwhE190Ky0+y+7lTOu5I/LoIuqGpqgz3TzcGFPc3N2c3BepS/k52CSGdJWMxhAAn+yU6k2lkNWc048gRpg3pP5P4+aQp5Hhz8= 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" Adding support for a NULL vma means the init_vma_munmap() can be initialized for a less error-prone process when calling vms_complete_munmap_vmas() later on. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index a1544a68558e..722bcced0499 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -517,9 +517,14 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, { vms->vmi = vmi; vms->vma = vma; - vms->mm = vma->vm_mm; - vms->start = start; - vms->end = end; + if (vma) { + vms->mm = vma->vm_mm; + vms->start = start; + vms->end = end; + } else { + vms->mm = NULL; + vms->start = vms->end = 0; + } vms->unlock = unlock; vms->uf = uf; vms->vma_count = 0; @@ -2950,11 +2955,11 @@ unsigned long mmap_region(struct file *file, unsigned long addr, /* Find the first overlapping VMA */ vma = vma_find(&vmi, end); + init_vma_munmap(&vms, &vmi, vma, addr, end, uf, /* unlock = */ false); if (vma) { mt_init_flags(&mt_detach, vmi.mas.tree->ma_flags & MT_FLAGS_LOCK_MASK); mt_on_stack(mt_detach); mas_init(&mas_detach, &mt_detach, /* addr = */ 0); - init_vma_munmap(&vms, &vmi, vma, addr, end, uf, /* unlock = */ false); /* Prepare to unmap any existing mapping in the area */ if (vms_gather_munmap_vmas(&vms, &mas_detach)) return -ENOMEM; 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+AzXctcMftAjMOO9tDgiZBlRBJ0I6C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IP: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/8dcE7gk2qWmxBLkr9u0t9m04Ot5m4LrWY0ytpUrUBMVsPhn8k4VmRynt/ACOITFdFy8cjhao9wbDRUBWYDPiw9jSFjqzsguL/ZLYU+a6WV9wBzQ5qFel4t11h9oYrTfovADCBDgZyIGL72vsUs+t0ur9icdJ/YjZAQfl6BCyeGinnIeryFreznw9VxWWxXgN+gp+2I6JHKpunBk52O+yqaChge6KeqXFx73rKhHvRJg0Y4S9yd8to8DfMV3tXddm91gM6x2Ime9WDlQS7ToYYIIEBY+C/govjeyzcSuKRc9mWuf/2jlxj3HSV3+mLo2kGxi/ZSbgI2+RhGMKQ+eUkA+CtyKwB3s5JPJmV7Yn5rDtdx1sEGZMhj7vhnx6D8IH0Qsx8RqqJ17i5ZsmkHoyFi1FmEXGAVPCpqOd9G5RYhrhdyy99WqDWarq4AB8i+xSsuRkC2CSm0gkOkq3LFCjVfoYArB/uy66G6YGECVtviuFjT3z1dibHlWy0lmFBZqPrbpI9a3JcMUVvn3D2RGU1Q223HP9feaSp6zWVWeJLCbp8zHVsNxIoE89vD/3zJ+yA2xHL4rqQP/FPLYuozh/GkbHH5cO5SWyzxW1iIDlrA7YOYm/zKUDpMuNpofGf+Chn5OQ6UqFP1m0iFLNaxygOKTDaFCmYnsta2aGQcI96ph0XxShcEYwpKtcuG2xyCFbvAdRLR6gRplFv3nZPKfCkyNDKMqKduXSsrZa8DohVv8wVXd/ONDguewGZmSARBakHlOXZCaq7SAvxAA8mvD86fWAUakCcoB5FBM23wrlbsG8YDBWZFlsgIKoNNlSEDgZAEOcuKWpTuOxoMcMV8dE25KXY1FjexlSZkTWZ9pSx2/eZTMaxI9oFF8d95On9gTrX5csothxcxYFrYYhY69YA4owENLk5En8doVi/kJJZ2epWWJt/SRsJGKJhQHTkNeMugLLSs5uKPGgJqnjAlOTdoWmULC6aH0VuLg9FMXyaGZ4woCs7nycoyO93U2pLCiJOdVtV0TTZ06e/3NORixor0/mnBB3cV80dsbFi5A2W/ch7jPSAk5+VXFrjPIdn90Fg5To4222WlO9OMRKAWn1Hr0dNI0ckxOhPdUfXB/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+xnVW9iKXfjsOlpXA50aIKpwHYEYpJAKf5oH39BG8HC/eyHbt3gPP5n0fH9iw47jj/x9K78hEGi87DThGaXWJP/ubzRE1LqpEWVTWefS11kPZr+LlyE0ngJFf19KvkY0atgsUg4pnl13kdocMPYprESMoIQOptU1hyVhIEeyvMtb1kuME12rt09Hpm6KltHsrZTFUFwtYFC7+AfoQ+gjbtFWPVcCTZ1XBXJ5H9X8u92wwq3mel093DsMW1iKpkIv9b4OpKsds+PW6Y85A46aVgs5XdR45Gmp6ML/lOF/oDxkyt3LuE2YlyxjVy+hOfeprKHbbZ9TX7uZEGcrdoK7BB6sE8Y4lPWwjdaHvhTn0VJJJgzL5rzkt80E0YqYrVNa4A2dI0kg4hmBCn3QEHcGhy+hpaWE9IR6qFiB85jaRHrle18ZGfVaA5Jfn4a8UNuQSeisKU45GDN91Ocp54HK+W6/sTT5he1rOcBcuZ1x6bw6rNZDVZ8nMCsVvKobOqk/ri5LnHnKjHLAvhqsqgHIlC3fuQwu736hXSumR4skycIifLkMvjn1rXYJb5a4vARS9kh8rc215QwmDRAfEqvKqTUoCgIQTVYL4q8M8A5hCwDV+yGN6QqZwawRoHoA/zxtJrZSbB7FTe9Erm38Z9ldyBCvFsI4N42yeHSJQhJF8UZb+gUC8PdWGR6FfjtNpXl1gHw8iOEPT8TqwjCdMn7rHo6qbQvZ6yI7u DUcgNyFV K8lUpssD5HVZjDUIcvi9RutiRTJvg3Ko4UYUWj55fL5frRPUlDSawT+1NnYUT6WoabdNE4W4w2jLDKaaLBHD9ROidTeien06UwbGSlTqMYDwjq/nEvSfS/5bRYAEizUtdXTuPPkqQzxp7TQvqkai/gYVvkDPx3q/ki6gTAQtXMYDydGRrAeP0RuTOwNVKMCymbtNfQ+uSiVixvo8EI/nDa/HbVcCG88++oFZ6npulOoPpih3NgEmFoRy19aKflUGBBIHItHmpkdr1/bThSjlTuBGMXN9zuy3BwKD94MTX4dqCytHYg2607cnwkSKqzDo+qZ8qLozE7yZprrJGRSNsn3BnmYd5xhekXH3JBbk3N9FFBSszSRzyhfnaXO+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) From patchwork Wed Jul 17 20:07:00 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: 13735744 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 D098CC3DA5D for ; Wed, 17 Jul 2024 20:08:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 844AE6B00A3; Wed, 17 Jul 2024 16:07:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F5A56B00A4; Wed, 17 Jul 2024 16:07:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 620646B00A5; Wed, 17 Jul 2024 16:07:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 31BA56B00A3 for ; Wed, 17 Jul 2024 16:07:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D9FA48181F for ; Wed, 17 Jul 2024 20:07:54 +0000 (UTC) X-FDA: 82350330468.21.28B7694 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf22.hostedemail.com (Postfix) with ESMTP id 7C23BC001D for ; Wed, 17 Jul 2024 20:07:51 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OSGj4Mwa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=fdUqpcad; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf22.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=jc5RsYxr/ntqX1pvmeZoP9TRa17VibluTFoo5T1hSkDpWHbrO/Fr0uFRk4XiR3fkB1At4W YaWg/yJT4GE7wATIYGTlhJ2lWDhCisDzvQjxU49pqhEq3fgH4MjFzaXI1IKPb5Fgulp1t9 0/cYejhQ2Q5483JYjiL/U3F7wrENTbs= ARC-Authentication-Results: i=2; imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OSGj4Mwa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=fdUqpcad; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf22.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=1TtzgtfAgfJoN12sNHXK3gwWMxm7+yNqFvSCP2hWL+g=; b=mOXilodieeCbE0NSSxSudc5/oUX5YIo4OeWL4U+68DM7ur2QZFdBN6fhodL+5183j4PiP+ Slf7w2v+fCkgqp97p1KuohQJGsJAeHYzK2VAGkUZ9qkv5ABLWPavroWrEv4ggsfLWVrOyb Psc8M+sGejc1ynF4Wsc7O956Gqx3LsU= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJtuGd032011; Wed, 17 Jul 2024 20:07:43 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=1TtzgtfAgfJoN12sNHXK3gwWMxm7+yNqFvSCP2hWL+g=; b= OSGj4Mwa1q80GcM+cf44hAuyqlkPlz1Om4ioa9G7BRP0I0/OMdMOufli/Q11npva ym+nSBmySs0LJ4LTlLT8MYccsZfrUIfnTwnKPVN95iq3NiwvKTV7tJQ2PHvJBxAZ mbkPxtJQO6FSfEQqPkZoA3DRUorQtYG045nXjQfa/lWB+flfgHQs2YHqtlgfclqM OFTJ8u4iCwLoaaWfpVtxj4Y8t3lXkuYg++mLORNgQx8q5Jd893NNelJvZye+M16u eiKPy41iww/m1/sm83em1sJcgV/+eZdD/jfsOtbaVSYO+3DEPTEvwZ/huGE7vLC9 xgSRe3JHHS+r6VjouZzt+w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emhpr0qs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:43 +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 46HJ4sq7003630; Wed, 17 Jul 2024 20:07:42 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dweyhkja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cgpkYaPVZntqAuUBzs/v08bb//fKwmyODrJa7wVsVnXNC10gSnJeYacakgCX13S+WuwZ8yHxnPG+lGIiZWCNKtahRaN6H6zTz2fehG3BGz3W5Lk8y2z6t9sdqHhG5OfYPaxDpJqC0nRvePcRC9bGOChYlkA2GqXt7AQSJqjCTXqlKE1CWqiReXeq0lXG6wp2D//Uc/SXEWReAUZsBjchwrxg1A2m5jUyWqMJaD/hKkjC/PRnbeonvhiNjM2umxnaUEveOzS9v9lk3s62qHTVhN7w9zn78xlsgX6SL1YdTPLW1u6QJu7SeOmyxYcMJP3opxB8xSuoigKKhgOjENY3tA== 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=1TtzgtfAgfJoN12sNHXK3gwWMxm7+yNqFvSCP2hWL+g=; b=sKA+Ilgl+KapwzyXeJzC+bckBGNM2bDOrKJDbQp41v30wdGuKIconvU4Yewv+ZY6n4Do3tXj5lCVRjs+hDur4GNAsxJ4R6hRetKdNJE4J6TSiCeKAyi8FG7/uj4QE89qGaI4F05fGRKbDB6d8FkTkrrNErTwixVmS4+9dulTcewgKMlIyb69FqRPHPQVNyDE90rJezjc3WYnF//PoP0tyY3wE/wnZ01g0aJs8eJDrJdmmvJeyHuw4OjGiJ2COIpL2hbE0dTd7hshZ51suuMCtlKtjoCHTLzWFN2+YFfyp0OyNNEHdxo7oEIgPgN/8RzLHXUwicBcCpgxJfWw459Nmg== 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=1TtzgtfAgfJoN12sNHXK3gwWMxm7+yNqFvSCP2hWL+g=; b=fdUqpcadriZAmrLMjmdvgl9+aqRzWlqs173uGR7Pm4TZq/en9uJXBY2zoe/XDIwZ3i0LHhvzbR2bzgZWvwHETI6qFREwv5z2ySPN14ZvTUJKdF71L3/cPorMTY9rm4mGRDVIZmkVCiINpn6ZuUwNcKH7P4ZVVMU4ntTUSO6T5mM= 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:40 +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:40 +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 12/21] mm/mmap: Track start and end of munmap in vma_munmap_struct Date: Wed, 17 Jul 2024 16:07:00 -0400 Message-ID: <20240717200709.1552558-13-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: YT1PR01CA0101.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2c::10) 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: 8f2497ce-a893-453e-879d-08dca69c1c5c 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: LSd0jL+q0u2kUs6RAOByPRGWWSeP0S8mnk9INejQ0SXIj1xrmQF+Lsh+ZtyqabRkKb4iGuZi18SKqgp1C3xS7/uc4Z2lT4CWZd775n0k99ODvLw0APuOpPZnAGpvJJK2V569SepWQTVMuo7nCDpgr/i3xFCrZS8HqkE07hKtgIeq7hg9BauELBq2c6qr28zGn6rF6zvSQmRFJ+Myj7A7sc9eFea8yAykI7ivnoyiQZIFLhnzQ82r93viLvplM4yclT46KXT4Z2wCfwVD7mVhiJi+keYK6O2YsipSjuoyUol4ZkuIvV50QlZ2mkSCTGDmSNBJJ3pkJgVkbfsDvjrQ8q4QIM/tWgu9re8zy8jhCB8eBoZldnFdRwbOBX2VjorAZfuv0hAgdRLr5s86Vw+76UHC/dg+JZCgtRzUID13yeLCcvis1JsnGzxVhfZOWQQnT43Lpmg8JdPOIKBSM2QRJdJeyU9fg2PKusWWc5lORRmCc/2MboqeHkT91qUSE9UxnPbGw9hDrIlzrKfpjZHLYn9ybD1mGbvxA/346D4ZiYZaydERsr4U9aZjDqwdaf1OG8nObAB9Nm1dAI6D3QP933sYhblTTlEVzGzZb+0Hj3z825mZbQ3OM/v4oObo4YuUHvKdepLpy9TrqqUIjgrHUU551nWd2u3QGkoR5wt5aQy8NgSw9Z1sktXdA4BMBS9uxv/OQPZB7H6cGN6mFqjUblFdraNwkvrMIfHIefDbPYEKXP9vxKzVhKnG41sizCsdYX3w74yYPvA/1YQRM1PN7JsAigl9uOLb0h5tGjR1ZJqUYQBZwB0RnOruKg/1H0TNCWlk8A8dxgUc1kCftPk9vnm5jyXNwnIfz0wak/8081ZAoeOwZW+0Lia6odTPFYtreBQBqwShp3qSXQtJNZ+j+0jCYU1Hsay462gRH3ZDoQiplEHVu/PgRFH/G5dMVXs+apdqywsHIDor4H0gct1Q1o/V4zGKkzd1/ZUdG6+nBVZCo2eSgr/qb31RJ6NAa+QJxBNzHeIuxyEDYu+QYvuEA7O34JacFQMzTWVIF16hbrRo97UZ0a1zcUBDKEOkicJGIGtPOlD0Zk0KGIyXqgS1wDZY7n88qVn/qC46kBkOwH9Qu+C3qVJwetYBeMWgh1DCR+OXGn49rG9g38ZRTM76LwuMZ/otdYV+gQ3gRoDhJk84jIyFIgNn4SZZach4wS2STPD9FqJK0lcQwhYQsJPuqgLxC5T61vVDGpcnWMNXxtz4DgAqDKbjQvt2GJndEgoPo3MQRwZ7IQokgWADr2xb5u+rnQWNKBYQImmQb9xZBrDskkl8JV8aN7H9PlmHGph8fO3ZooM17RsIvUy9ueWBLA== 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: 3X8GE6puGwoEYmhJQk2OdM0P5mWK4EhjGWlxnNodHk3hVTscJnGkDQvqPWlNapl0W+3OyTeIe/VjB16Wra5q2s8WK5W1EYPHG80mk+KpD5Mn4yW5r64Vuimn0creO/SX/gRFl2Q5buBQr/wcWp9Lf2F5nPvS2C581f0Iv2Lj01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aRnWx/61c7dFdIqmkTOym+QXi2yDGgrHTjz3OUJRnjNb3aVY7Int4tIzihxEUz8k+sKaI5wUEo/0M69zqcsrCMB2nbPqxi/1yqJvh9CHAFJZX4tWvlvV8dVDcQcLNyVAfbLWTXWAvjOYW6oaOANtrjm3wwIWNyv3vKSIHbO9jXRxn4bHJCwiwurImQeq4OvQQvPeKZPgz18HRRFBrh9tA9UI1htXyQh7Sstr9XOEsS9esDyuKlhtANP232CNs9h6ycANyC9twQkeNb/pPyjq1ekGoC8jMS5E2oer5gBK5t0s7SsLHpZ+/rB1t5VIF9wny7FqpFE8dJNIgdi1r9whyfwRCGyBfCnavO/GBMM6STGqulcCtoPA7vfR3WFADcPoxKw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: UZyXF+2HwiIG2cbnKvil0FqC2tBYlSNg0gVqf6HG/g+WbWTlxSqh9LA+aJFiU5AWcKvXiiRBoVPhiz9tCETQEaoP0VErcFpQt7SL0zP+iTZTKENJJYRET1eGq49EDa1c5noRHM8MJp6NYaj7itXYxA1y6iQEKjwSNHelLiL2dSZjCg9VeeWsFYS/91YdUSnt2H2UH/iVbBdspdnImsWHUMzjnN2izDJy5QUPddS+Ob7uz1fNOAy7d48yE4tLwVhZjNMzv3VNR55bWSdfnYoNmpMR6LTHcIwevXeob11v3hzdvlICYZtzF1iSjRhk1cwUcEeT2rkdw6UHk8JlIKuEFVxNc3r9ooK7x9MfFUuIxpROA53zjr4JucMDVmPmCNHHhOtuRtfLlW3TBDp0Yzvpv0qDplEQVGOInotaJgrrwhZKb4yg/5kUxhmZCbLeNPjA5klfGkjPecojJNO668GW3bXXSwHtG70PhBRrmUR+E7WoGrsysxTaLhZTgbJp4n8v6dYODee2glurJprBZTUvKUadlf5JwipMCwUbn7h+0U+rPRIzxpvTLTE23cTwJMen5mDRdr23NhmMSyIn3jQcfJTodgefdOfayYbdBNS1+J8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f2497ce-a893-453e-879d-08dca69c1c5c 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:40.1834 (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: pbUt0/S0Ri2UMXBjMQ0xqcUQP6XjR8Pwu6uXOYTxaYYgwKWwP0l/TiYXWoz2ggJ7N+DDd+FFqd0I2PkkK1k8LQ== 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 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: I_zVh1YjHHwW-IVez-UO1U83I_cf5lFO X-Proofpoint-ORIG-GUID: I_zVh1YjHHwW-IVez-UO1U83I_cf5lFO X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7C23BC001D X-Stat-Signature: xezwckzz9cgg5psn8uyb455um8mhgh55 X-Rspam-User: X-HE-Tag: 1721246871-875770 X-HE-Meta: U2FsdGVkX192bK4kx2KBqaJxU8Vt3zvWFo3+McEPeVdVxcOqldByJQRjhkw2Fn/pfZdzfq6MHT6t4ihIt3iWMOkXaVXu1YFFOvKzEB1sjefDAVtc+mw19rpIciSEA1LCDVoVgDk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kqIKqRLiszPyeknZA5jAQxYCDJFJPjWeLa7AJFi4m7K/p3lkEWBu7n+h9s/rg/WZFbjM5mbcBEE9xznq+em6OY2+CYjxqGFBHLdbR3ta8SkuHRyZYjpcFShL6fklhsPcBC7VRU2J4d/fLiycs0AEurgUiHs3WGkIwc3Yo28qrKxEon3PoD+GfJRzHMfZmCCuyAP0WsrLXIhW3m73SSG6iRWofFZqJfIlRgybWVWvQeDqMVEjZ5RTXdeA7h4uqTIclKPf72Xkl4YfP/r+omp7/yfyKFQDcZcWIrcWVjbWmFzosXLjhbrrSIkBgxcRQ== 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" Set the start and end address for munmap when the prev and next are gathered. This is needed to avoid incorrect addresses being used during the vms_complete_munmap_vmas() function if the prev/next vma are expanded. Add a new helper vms_complete_pte_clear(), which is needed later and will avoid growing the argument list to unmap_region() beyond the 9 it already has. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/internal.h | 2 ++ mm/mmap.c | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 02627e269d6b..ec8441362c28 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1493,6 +1493,8 @@ struct vma_munmap_struct { struct list_head *uf; /* Userfaultfd list_head */ unsigned long start; /* Aligned start addr (inclusive) */ unsigned long end; /* Aligned end addr (exclusive) */ + unsigned long unmap_start; /* Unmap PTE start */ + unsigned long unmap_end; /* Unmap PTE end */ int vma_count; /* Number of vmas that will be removed */ unsigned long nr_pages; /* Number of pages being removed */ unsigned long locked_vm; /* Number of locked pages */ diff --git a/mm/mmap.c b/mm/mmap.c index b940de8c6df8..7cc1f47122f6 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -530,6 +530,8 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, vms->vma_count = 0; vms->nr_pages = vms->locked_vm = vms->nr_accounted = 0; vms->exec_vm = vms->stack_vm = vms->data_vm = 0; + vms->unmap_start = FIRST_USER_ADDRESS; + vms->unmap_end = USER_PGTABLES_CEILING; } /* @@ -2612,6 +2614,29 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) __mt_destroy(mas_detach->tree); } + +static void vms_complete_pte_clear(struct vma_munmap_struct *vms, + struct ma_state *mas_detach, bool mm_wr_locked) +{ + struct mmu_gather tlb; + + /* + * We can free page tables without write-locking mmap_lock because VMAs + * were isolated before we downgraded mmap_lock. + */ + mas_set(mas_detach, 1); + lru_add_drain(); + tlb_gather_mmu(&tlb, vms->mm); + update_hiwater_rss(vms->mm); + unmap_vmas(&tlb, mas_detach, vms->vma, vms->start, vms->end, + vms->vma_count, mm_wr_locked); + mas_set(mas_detach, 1); + /* start and end may be different if there is no prev or next vma. */ + free_pgtables(&tlb, mas_detach, vms->vma, vms->unmap_start, + vms->unmap_end, mm_wr_locked); + tlb_finish_mmu(&tlb); +} + /* * vms_complete_munmap_vmas() - Finish the munmap() operation * @vms: The vma munmap struct @@ -2633,13 +2658,7 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, if (vms->unlock) mmap_write_downgrade(mm); - /* - * We can free page tables without write-locking mmap_lock because VMAs - * were isolated before we downgraded mmap_lock. - */ - mas_set(mas_detach, 1); - unmap_region(mm, mas_detach, vms->vma, vms->prev, vms->next, - vms->start, vms->end, vms->vma_count, !vms->unlock); + vms_complete_pte_clear(vms, mas_detach, !vms->unlock); /* Update high watermark before we lower total_vm */ update_hiwater_vm(mm); /* Stat accounting */ @@ -2701,6 +2720,8 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, goto start_split_failed; } vms->prev = vma_prev(vms->vmi); + if (vms->prev) + vms->unmap_start = vms->prev->vm_end; /* * Detach a range of VMAs from the mm. Using next as a temp variable as @@ -2763,6 +2784,8 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, } vms->next = vma_next(vms->vmi); + if (vms->next) + vms->unmap_end = vms->next->vm_start; #if defined(CONFIG_DEBUG_VM_MAPLE_TREE) /* Make sure no VMAs are about to be lost. */ From patchwork Wed Jul 17 20:07:01 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: 13735745 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 571B8C3DA5D for ; Wed, 17 Jul 2024 20:08:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C2966B00A4; Wed, 17 Jul 2024 16:07:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 472636B00A5; Wed, 17 Jul 2024 16:07:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 251976B00A6; Wed, 17 Jul 2024 16:07:56 -0400 (EDT) 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 05C096B00A4 for ; Wed, 17 Jul 2024 16:07:55 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B1C891C1FAA for ; Wed, 17 Jul 2024 20:07:55 +0000 (UTC) X-FDA: 82350330510.09.8A7E0D6 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf17.hostedemail.com (Postfix) with ESMTP id 6624E40012 for ; Wed, 17 Jul 2024 20:07:52 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AE29rS9d; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=mefy1aLO; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf17.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.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=1721246833; 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=/B8O90wsTqrG8aGCnP35NaLGvZW5iIPaZPRpBTO3Ycw=; b=SKZNMfhH8EG6XMaZfXPGfXkP4n1y6Vo+Wqn9C90nFpPyzPhnd92Rd1kSzphj6MHKu+d4T/ AkM21VZa6ypGKODDmwgyX6nbQlq8JkQQk8URgvIr3BOSPc8Z1QRRGMCJV2nBkHKZad0yfv XPtcCcAM9I94qGrjIRvDHeJHhLEpWvI= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246833; a=rsa-sha256; cv=pass; b=1jYZ3EuR3QYLnHy96aTHtx//8fVWZxqWMupbKLvKIlSyNDSOeV9RfuOghgrKd1TSug9L98 ZnrEwJL86W6yeuRcigOiOrKFh/VBfWwpX4Be2QYUf295RKlG58AguLzOEpSgmteb2zB72t 1pElvRGojRPPwhV9AQBDW1YOn75ests= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AE29rS9d; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=mefy1aLO; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf17.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJu8A4000345; Wed, 17 Jul 2024 20:07:45 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=/B8O90wsTqrG8aGCnP35NaLGvZW5iIPaZPRpBTO3Ycw=; b= AE29rS9dWRNMzwIHxueRmLCZ+Yo9Z5rzITMthaioavtn2a3hWIZANYKgKwZSBHcu iOxsg5yZGcC4n+ai68b+zpOdaACTp6wZrpSZEEv4jFn0rw5/j7Eqk2OAvNPwaoRd LXbPBbUiEdJxwYs9fdf/d4SdLpb2hGdBajGHF7y6eoGd5diCP5IR7AokMeO5/5Ry CAjODzFpI5O34u3UkDFitNeebEUxgr4L2EN37V3cgoEtgfb/rTECNQaHmoGwLl7g /5rykrZfowawV+HVHJO/9f33BaB1UD+QSRQ6WlivrNHebt3d507JdEo+mCh+3PfV W80pFUYIOfhCkjMWYDtshw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emhpr0qw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:45 +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 46HIoUnx003734; Wed, 17 Jul 2024 20:07:43 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2041.outbound.protection.outlook.com [104.47.56.41]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dweyhkk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A8MfxNUMD12fP+cXcq29wIdNu+VxasFyhg35DGf4/vGcrbCTlNOCMvyAPkQl3fi8mCUS/zJ9tAp/zFy+WXWPWwZQCJeJBHcc3Pm+qMWb9j1E78PUuZL3hRMgyGbZUoh/q3cJGWejdwhUqFkLKiD5QidHAN1wS0GVcSOI2H6gPtv8NnPj9pFdsiQzXyMYTGoOYQGZu3xp4+lsl2CgcSKBgIn6/7k/64UKpFPSaZMcKQNkc1sws20yXWOFB0eJNt/5Q+EN66IG/HUtONlctMmHedSaXnASXVeoqXEZEpAB6WNIJLk+PuX8KbYKZeunwXw/VNq3F8TxGn83b51UN2xeHA== 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=/B8O90wsTqrG8aGCnP35NaLGvZW5iIPaZPRpBTO3Ycw=; b=KRKMiNmeRvS2x8brdxuw5gNHDXyMtgflY1plQrjFtfbtbBN1/386rQLK9gyTutW6OXD12mEHCLfg05DpECLS7TKVwH/GLMlznnjqO5kJrObyTYlRr9JUBe4EYetqhaRhBl179ZatSA33TxW/ULVg/gnx0Rt/6hcIfsdCvW4JxtH1QI2luJxIwjkyzSxfRiGOYG0+QHiDjnYoV9lSZuXE4ijzlFVFjXJ8ILZvSwU4zNB4zsekzkynxIHXNNn/4Gr0UgpXePnmoVm7CLfrbQKRxrKVVoovv5W5w99pV3XD4Cy0m40pd4iUv4b55Gmt16BZmdbDSX+QinIzi7dogl6LQA== 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=/B8O90wsTqrG8aGCnP35NaLGvZW5iIPaZPRpBTO3Ycw=; b=mefy1aLOQDbw6FEsfMVG2YZ8VI36CITvKjgSJM9wKdPM0WFrHZQPdZ9UuSLbrvzBQry5U+J+F4y8MkvPWGTsyR7X5pJwYLeTKgIi9TgSBBLVKw46qCTNWDopK0/Gr3lWSxHIgXXP7la4sLIrrD8CYHQEHX5+pW3Wl2iuuAKDmbk= 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:41 +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:41 +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 13/21] mm/mmap: Clean up unmap_region() argument list Date: Wed, 17 Jul 2024 16:07:01 -0400 Message-ID: <20240717200709.1552558-14-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: YT3PR01CA0083.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:84::11) 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: 8a597975-915e-4510-be67-08dca69c1d1a 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: J5ev+TkQCRJWM6Wm2bxTsIJJ0guU7rq4uKLiU8zIz3lo+rYLk+S0Vqp1LcditGmvxmM3QTTYoPFKF7CDizys+Iq4/Fdvw8sfyZYQ3I0W9KUlHrkWMoGFvNNjStzbJUlt92VqjKHlROJ67pN0wNdry2z5wD36apBpyChQFYjXebTGyoG1fV+a6U+OdvvfQQRvFHfkwLkfNMQzeZ3dphDZrw9zhZSROsunC9NRz5BL6uhq2HpWbvKwTk6zs1G8Lcj8oc0kGGQiC94qEYSRUkA02jjsE/r1E26Djv4kJSR7rkBKAAl4YE7f7Spm31EAUoJmWpaNyvTXGHIuQ7uaCKAnzclnam7ee9eyqK4/cckkrm+rjapyc+/k6ZQXQQXhSFH5oQTr+qwpCXSkbMVBMmWw6MiypPEUAFoQeIrHRRCJEgN4uLqPPNOa4AVjxHc5vrhncPtvOXC/VbUsGZhwrQ5OICNGnzCynEs5+SStZ11yHnkt7WRvNQ9c4xvtH2doGikwp80FbJmk6Sgy106ZZMkba7DeypzuVxTA1vOJKFZzQ7qMloVostt2l7x1c08rg2eVH5VPZwsRQUq04adl7QK2ika43wp0zJ4mbv8R3CIv0v5ZaUErdINMmO5yrxg2ctgPrKPfCNAnMqJpoNy49Xn+E/Cf/JR9me0WT1vkmZIFYFo94sOLnEjiiSluMQtTWc5HFYs/Nr69blnFwoGdtJXJVigrBjE1cx6Ys4SUHdLdBAe35SsKb2r26hTwUsjp3JqN68rEiae1Ummngo4QSSBMiiyP8xDHze6UqiKkRs7ZhT+8AwGjXauqSVimPZNjXWgXs6Em/NqNpBUwqefkk0sC1cVVIvGw1iPC+2b6y+jQXx8a2S2XoU/sAh4TH1ZiG2SOnSjsqDFfTPn+tDe+CowSv0xNs01EPz8y2RWgK3uYDGQeUfSNqet4sRfTKRgMHSauJjJqjTI/y/KStpyPIWku2WpfRAfwnQHMrk1YMXyi8tZsAbkz4ISSrjtsnX6hJYmO8S4XwrBXPIr6rpycEt0Bt7z9IhggKXi8a6qIFUm2MyBim5LUKtCZ1IUySyn88s/337qpZeUC1DwM1Cn2bUT2qNvSevHRQIAW3jYvQaPV6GMy8tp3h6TRrr8F1PtXlcfxmR05/lbcyydf8bJkfHt/CNEpWruMM2G47mMLYoAHK+IhTh8AnzfACPJrC8GRmKrl5TEviizVlJojKWsAn0sqdZMbb5J79qK6yHrg8INVdpbYvgWUXRgFsX2ezzYb4vBMnMjaZ83rl2yIdvGazazMQpwAbHfQrm3pv1dobMK3cyh5aUTKMHGT2QSPQK2OLy48rXrXR5xJCDLSwsA3G+EchQ== 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: 5A/uqbb/VQ7nuVWmspHKeWB6AbBAPqldn9dNHrGRwH/V7q2Km8vRtBHYUEi4HDlbVRWrtXfwqinGaIL1z4tWa6UXIbX3MQaqW17kY/UxNx/Y6vneyueJ2ciIXZYUBCnQT20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bsPE0CurNdU8LF4ssr27GlyV7kjBSBRc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a597975-915e-4510-be67-08dca69c1d1a 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:41.4018 (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: XNP4b9aR35T+oNFYzieizH3+uPQqRlrlcgjFhtkzhbBKfK//4XtYk6V7AEiCIK9xt8vcbX2QC5tI+qL0Ye0w/g== 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 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: hpCF9MCQ_rf2aE0WeE9MRVdzOzeNlq8O X-Proofpoint-ORIG-GUID: hpCF9MCQ_rf2aE0WeE9MRVdzOzeNlq8O X-Rspamd-Queue-Id: 6624E40012 X-Stat-Signature: 3q9m8nqyitadxjbbzcb9fkfmddswps4u X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721246872-991982 X-HE-Meta: U2FsdGVkX1/VJiktWH8esXTWLJ62dhB0hg7tCW7p9v/lCqd0vPXhNk6alodt06naH0yFFpmjSykTTKsBl9oR/d87q4GoMrmfY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NK19gaVPMx8HAIPZj7qnMG904heSsBh7m0b/FcdOxpqEZF1VfVlrqe/TN+wnh56hhuUCaLh6MMbNJkCywIC30aOTLpiJHh5DtY0R0sdop/JR/an7byarlGjaiCB8ZZhiLVu9X/MNCpu/zBxSwV5xaeiXnFTCqXxT+pcyuYD6S2SJyoBOrrxkwiR1vFG8XFDefFT55s9vmuShSZiQv2bK8iug9mZOaRUrDa5bQ30NGiKqhb5OhSYqvIHhvSI/YuvI247A0FOmfrqQMQdy1sXFOag4zVd+2Q7ubRhd6o+4+aXBiG7zvlPR8TNn09uvtryAiPvvZObd6ojtoXXOXr436QSLmrAtFQ5YSj+aPAkI7BLJ6zvPIOTX3cQ== 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" With the only caller to unmap_region() being the error path of mmap_region(), the argument list can be significantly reduced. There is also no need to forward declare the static function any longer. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 7cc1f47122f6..20da0d039c95 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -76,11 +76,6 @@ int mmap_rnd_compat_bits __read_mostly = CONFIG_ARCH_MMAP_RND_COMPAT_BITS; static bool ignore_rlimit_data; core_param(ignore_rlimit_data, ignore_rlimit_data, bool, 0644); -static void unmap_region(struct mm_struct *mm, struct ma_state *mas, - struct vm_area_struct *vma, struct vm_area_struct *prev, - struct vm_area_struct *next, unsigned long start, - unsigned long end, unsigned long tree_end, bool mm_wr_locked); - static pgprot_t vm_pgprot_modify(pgprot_t oldprot, unsigned long vm_flags) { return pgprot_modify(oldprot, vm_get_page_prot(vm_flags)); @@ -2403,22 +2398,21 @@ struct vm_area_struct *expand_stack(struct mm_struct *mm, unsigned long addr) * * Called with the mm semaphore held. */ -static void unmap_region(struct mm_struct *mm, struct ma_state *mas, - struct vm_area_struct *vma, struct vm_area_struct *prev, - struct vm_area_struct *next, unsigned long start, - unsigned long end, unsigned long tree_end, bool mm_wr_locked) +static void unmap_region(struct ma_state *mas, struct vm_area_struct *vma, + struct vm_area_struct *prev, struct vm_area_struct *next) { + struct mm_struct *mm = vma->vm_mm; struct mmu_gather tlb; - unsigned long mt_start = mas->index; lru_add_drain(); tlb_gather_mmu(&tlb, mm); update_hiwater_rss(mm); - unmap_vmas(&tlb, mas, vma, start, end, tree_end, mm_wr_locked); - mas_set(mas, mt_start); + unmap_vmas(&tlb, mas, vma, vma->vm_start, vma->vm_end, vma->vm_end, + /* mm_wr_locked = */ true); + mas_set(mas, vma->vm_end); free_pgtables(&tlb, mas, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS, - next ? next->vm_start : USER_PGTABLES_CEILING, - mm_wr_locked); + next ? next->vm_start : USER_PGTABLES_CEILING, + /* mm_wr_locked = */ true); tlb_finish_mmu(&tlb); } @@ -3198,8 +3192,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vma_iter_set(&vmi, vma->vm_end); /* Undo any partial mapping done by a device driver. */ - unmap_region(mm, &vmi.mas, vma, prev, next, vma->vm_start, - vma->vm_end, vma->vm_end, true); + unmap_region(&vmi.mas, vma, prev, next); } if (writable_file_mapping) mapping_unmap_writable(file->f_mapping); From patchwork Wed Jul 17 20:07:02 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: 13735747 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 36BFDC3DA5D for ; Wed, 17 Jul 2024 20:08:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2794D6B00A7; Wed, 17 Jul 2024 16:08:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 250DE6B00A8; Wed, 17 Jul 2024 16:08:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 054406B00A9; Wed, 17 Jul 2024 16:08:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CE32C6B00A8 for ; Wed, 17 Jul 2024 16:08:00 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7CD72120BFB for ; Wed, 17 Jul 2024 20:08:00 +0000 (UTC) X-FDA: 82350330720.11.B8160EC Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf23.hostedemail.com (Postfix) with ESMTP id 2CBAE14001B for ; Wed, 17 Jul 2024 20:07:56 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=F99lLj2D; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=G5Vz3w8W; spf=pass (imf23.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246824; 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=9BtKiGUugGEEWslw8NJfElcvJlWGE3OYXj7kTlHZwJw=; b=K0c+SPkyI2j7GvtIFVL5R7gqs2h2ocaZDRMR1Z+h/k4CLBpBhWu7tE7nRaRKcVfiNBSf0o gZPfUdKODkLr6I3DMJLfwgChEVTW/b7P8q5dxzAFjVsrXboZLormZp1jjX0FpWm2w9Fsel WhiETz6X3CDLnVpIsVSqma+MTVyw6iQ= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=F99lLj2D; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=G5Vz3w8W; spf=pass (imf23.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246824; a=rsa-sha256; cv=pass; b=q41GwhAJdFxHE8lObtprO0orW7Cbt2quRTyswflegaI7Lc/TQ0cHmxFIVVBw3fwoMOBLlX 9zeax73sOVNrSKvOJJqg99fFS1GIMnucj45/NpymT1aRSXy5CrmzOqHV6QWu07LhFShRZn ARHvIQbp/Ad8lRDTGloh12Dn2uWmnCI= Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJsRWw002443; Wed, 17 Jul 2024 20:07:49 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=9BtKiGUugGEEWslw8NJfElcvJlWGE3OYXj7kTlHZwJw=; b= F99lLj2D0pPc2p9qzDcSqqZsqT8Tg1ZS7Y1NYvrs6lejysEY3jEiW+X39fNDgWR2 FN0UcxQmVQ62Kp5So0faA1W6mhPJ352cAdJ4cqO2E742CGDsfk93iE8eU6iZL8EC UWdZUa1Eepn1kjIZGEw19NEHjkrjt7Te70ZBa9d8yZwHL2HcEl2LjggUuzlL7wnf YkXmJ2TACG4jxjyLdTxzbQIrpp6lbmZJlxH/QMFylmd6gHt2JKBX56sosDcLcCQE qoy6AlGuBUNDZTnOQTMdC1vsSuqrE6RQh7gGtcyXZ5EI+xR/UaByLHZ5/zXARymO EohV7nqMiEMrmCcL+Vejpw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40ekxy84at-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:49 +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 46HJIY6I003738; Wed, 17 Jul 2024 20:07:48 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2174.outbound.protection.outlook.com [104.47.73.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dweyhkpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PAKIgtkD+w3hmex/YZer243bNB4CarquBBfU6cyalT9ymOZ9vKsT3CfWuEl60fv8ahVNFCmhzMmgxvZJV+9JEAVElLi04XS3abqWnzf0Kvh/oy1KvRnR8mh5DQ/1seF4nUaEmhxXwSlIqGFxZtTCmWXG9MW+j6cdtYzE/8S879NANQfiSxOdBiUiBqyivh41LIpVg5jKJjHQg4Hg4CO31x9AbwgGwN2IwRrUAk2GyZCI4pvvNGz/2S+2H+bnohEAMWFl+foMXlm3iy2+PI1JhLXzKVgqJO05EbJkpklsSAcZllXh8FIEAc6IiiNOnCcqBlAoY06/41u8tZ79hn0Z0A== 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=9BtKiGUugGEEWslw8NJfElcvJlWGE3OYXj7kTlHZwJw=; b=kRYeWNylGwmLKxUbOT2yTDfZlu8ItHUXaXEvbz6mtJIASYt/6RoYqhdHeIcbU3opCbImtjR7CieIbt9MSLsnTAW67pm5L8tKVuISrRBKSrY6BhzI+w9hd3ouC0ltvuyxY93yDWCxatPXwd0pSgdCPlxShJn8/IDD6A3rRcikQHep1NeuQABoJxRQRCxXXDjPAPy9Km5y5icuNwubU9zpBOzM0kZV7dEsLVN96FmmAQMcjDzNlxqyGM4vGLXI2jI9Xz5LBqbrmrf9RcAH7I7ChXcdlhzcFfLh2eS0px7Bym/+T904ctdvXonlDLs3VxThC+RWhDNDyZrSJjlU4wWPjg== 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=9BtKiGUugGEEWslw8NJfElcvJlWGE3OYXj7kTlHZwJw=; b=G5Vz3w8WbkVxrt4i5HAVfajiveBCZ3W+bG1V1S6snjbbhvwf9gLupvAEK7xCl6eYUoAPhJAYuCmlS/3yiU5WoBjdg/JnBkpkJw6EIxw1GmFIfybEwfwaoMsjfxNlAMIKp3IduWyYVcuIYJ1CCgB0I1QqvZadA3O9am+6UoE3l7Y= 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:43 +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:43 +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" Subject: [PATCH v5 14/21] mm/mmap: Avoid zeroing vma tree in mmap_region() Date: Wed, 17 Jul 2024 16:07:02 -0400 Message-ID: <20240717200709.1552558-15-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: YT4PR01CA0050.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:111::10) 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: 0a15224a-d056-46fe-394d-08dca69c1e24 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: LHf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YgqjGBThTEfvTMkHKNYLEN9id2ytyretSazrWPcZK4eI7zs0T175aTbj7WEPiGZa5TBMuSFKeMSvfGG4R9fE8aUZwMNTqV6ofKnTqDZffK1OmyxqBcb72YeFJmwT6li0uExSPOoY2DiSXiRPkG1rv1pCetCMlPB3R4cIDr965v5JsvWEwXaz4x8r7/8bP8/kq4fYXj7Q1XTPblHyP2IK5pyLPrClGySZQuaDD2/1IsQ1FMdVwixPMFOBuGg97eauhBpR9j7dlzTbIxw/kdJI031x6XVUElRzjdfUmxOMgsLg== 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: 9Jnmiif3feMX6wIxaPvv38Eq/S8UwFz5x7aVLwW1AH524lZVDqcLgXe9cFMPMYWUXxAfOB0QlfD26B1QKvjS5X8l61zxjgKQaZdlJ8+NLQqC7mDJJpFhiD93qTM5GTCBwXq5RRqJmLH0bv1ODDXak1uphwM7uVJyGU8wMpdKoXBq+iMQ06IF3vwOveGyQ9TCv0/8O7ZDexsWGV0j4KOWb4YJZL/oYYVC6yVFl2dCNcCbXBBqyIdPWvzLrplaJlW8KPLRr2LZ9WZtwk7kpmzsi3peXW81HbcTPaaKtzJhTgfB1jQtcdUqItdE3ZGr4h4CSG2OACUtesp1zj18nvsPcXTI51I5wLuvn/9BEg7qQYDJjwXC6fC7mKOmC7vB4w5mhl0Q1RNIy2aAiD7OnLwLsc+/lwmS95t/FHyyGIIvRo3ro89h14jRhptMIYCZtIRXOzkYIKr1p/4aedU0rC+PDoZLlfnckNj+rjWKFR6/sLKH1shj1Lu6HA2paBUWUjHxY6ziS2I+We3FPySwLEWeaCY6kMGvbbvPKldYDIsvV4pyW4e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Data-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mC1P1SEDK2ZsACtWdFu6WEKwncbMM8f8sViK+dnAqLaQc7+N7n3gm9UkHTWJ08zwvgJY8vrgQK+jKx9sBUDMqV1NuSZGffb+u2ijL9EBIWlDySTiTRUXMlvNXz17HsGlIZfqOEfDbo+4erqbVoOauqUD9YqXBuMdwRuCxxA0EL7A2tJFEznmGy+nnQM8gGgTAyMt3LtuibE69xLeCICIUoTFzxffBl2JdqhPTSxt5a3cb41hA2diLq/3551K80m9MLgPJXNyFX7GWqKYyOo0OcOMEvtmhWWZNrfFxtkAm98KzjNjePFvhA7Qc3POsq6N53SBeK0cO3tCk5sMx28rEEfs0bunS7wkpf7qA+yaguVEkBKQbip49FLBwzPgqauiiZs9FltAoNHsG0LT4PQnStDqpZroBgWr/UE4Wrp0QDkle6e2QGRJt8wwb4nZpM439XX0FYHUYvWWR7wKjarqzaxvVnizjx5P20HjX9nB+btwlunIQgBPc2lntu3E3uQbgJO1wESuoYjqGTnVOlRJkj2mdk0+WJRc9vE+t9MxpoOY+IjoVHTtki1lI0JGirXpXc8/7XWjZtYaDp8O1ctQDbSuYATzVhXzVpcumk+eMo8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a15224a-d056-46fe-394d-08dca69c1e24 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:43.1842 (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: T8pJMxzRvvaujBu9QWKuJdr84/+XZDyRlvL5k37GkaAxdDjbFtEHHKLC0NFRHiVdKpB7ohePI0KsefAj6Mbkxw== 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 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-ORIG-GUID: 8pxu8IA42-a4_-5pWZhOhMGtHFSc9l3C X-Proofpoint-GUID: 8pxu8IA42-a4_-5pWZhOhMGtHFSc9l3C X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2CBAE14001B X-Stat-Signature: hiektzyyk5h5oxgfeouaoszdc7zb7cc8 X-Rspam-User: X-HE-Tag: 1721246876-712208 X-HE-Meta: U2FsdGVkX18NTJ1692OGcBe2M2KQkJhlp0wW67p5vdLf6ss/7iphU7wIjycy3F4KieBPTpMuP3oyIX6WdY6ljmP0UQZoVXb2cpPZK7rsYJlcq2aoOpVohsIigRKyDuMPYc3RVB4Pnt+vMH+ZyJFvlZapRZttibUGtuBLSmysj3Eb6OSjOsabb1vHRSc19KLcTcjSr3KJ+HpgtqVbZDxUBB9polpKywKpQIxBJJ1paBk0cTiGZTfZAG8fheIO2oRFBf2dc8E8au9e+2yaWxXagouJqVNA8LvIu5rjn49pdUC1vw+DpGW+U5rWBETWtjPCx4o5PbHy0RS+pMxP/fywVGhcCJwyLGN9w2GEMgRINwgEWOodM3CpYG3FgeBLrH1iMd5/MEO54TrOT9mI6lmXCLcD6gxB+qHyV2wAQCui5+Ea/h1Ar450tkPNmA1nw3zHNVI1DozomHLq7q3zT+iUmn5xASld06SUgwGZBMYoaUT35Vqw8AlYHgskU/1YI5ZGDB04O8dbs5ic20ErvmZubDG8Z82RPLe0ASxF03deLhP0y9RFaKrYw8BIiDG530yI+Y08KfKxgcWLCnhi86yPZ9TzfUsVr2eSO3igQbwN8Nn3WfWThMUhCdsAbaT3VsJKYaFthK8U7/GdMg0V/dA3H+CsG80H4xeRYoJnN9OVgXh6aw9HMR8LkxO2aVN4nfoX4KBRPWB6zbX/+pQ+yau0w+XVFjgg46Zk6iBXml6k/FPzfKCpirSQ6V31hT7mMhsGDVfIq0p5ti9ZaR/tTYH14VAWoKqlhQfv7jOVqAyU9Z5JbUK8cThntK3XK4oO/3iDWpGVS2/rUhVRaBXek/Ua/9u21rvWRt/hU0Jv7lwVc4mk+Ej6Ad/kqC3x4+NhmXOcEk0RABbjLelwpGOZtSqjsrUuHKBrP9PnR93c1qmC+ZFHFTCHUxXCANbi+pUCQYRLh273PNY+ZqXsZRiTJ0W 4ZO4mET5 JPrAlnMkUWM/BiXl/fpZ+ow0aCP6jV8S8WSGwgYxasMAfSM6kXNJXrHZhH/0D0mddoFyWVu5pKXp4wyV0N03Qw3sR8x8Olm2fU94WRWtVmPoa9kvsA9e8/SlU9nRKEzvZgl2EkBNcTNUpt+STcH1WP6ahM82n89ElBBZ/WHIhtGNnQ79/KLjA+ezICMJF2eet/OB4LQTmKr+JZpDo0XjedH1AWHpA/0ZIr2bmQtifOEJAvPVaCt0CZ+Tc7CPCeVeglQdiGnIaeM9yR68fAHi98LDmZS159mLEVSpYepfmx/mgzNR/VmOlwlriLq6kTenfH6WIzqKBHHAFa9GuK7o1Hyj6YJHd345/kB9cD41pDYfVABtsFxeVX6gdEFVgemdbGUh8YPiZAMEdmw3NP35FGeZ4h/40DxgVSog4SS6e/hFHwI2HrkvXPv2AIVK4Ns3VIJjy21cezc10bCuW+w9UBysdXQ== 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(). If a driver is mapping over an existing vma, then clear the ptes before the call_mmap() invocation. If the vma has a vm_ops->close(), then call the close() function. This is done using the vms_clear_ptes() and vms_close_vmas() helpers. This has the side effect of needing to call open() on the vmas if the mmap_region() fails later on. Temporarily keep track of the number of pages that will be removed and reduce the charged amount. This commit 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(). Clean up the error handing of the vms_gather_munmap_vmas() by calling the verification within the function. Note that before this change, a MAP_FIXED could fail and leave a gap in the vma tree. With this change, a MAP_FIXED failure will fail without creating a gap and leave *a* vma in the area (may have been split) and attept to restore them to an operational state (re-attached and vm_ops->open()'ed if they were vm_ops->close()'d). Signed-off-by: Liam R. Howlett --- mm/internal.h | 2 + mm/mmap.c | 119 +++++++++++++++++++++++++++++++------------------- 2 files changed, 76 insertions(+), 45 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index ec8441362c28..5bd60cb9fcbb 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1503,6 +1503,8 @@ struct vma_munmap_struct { unsigned long stack_vm; unsigned long data_vm; bool unlock; /* Unlock after the munmap */ + bool clear_ptes; /* If there are outstanding PTE to be cleared */ + bool closed; /* vma->vm_ops->close() called already */ }; void __meminit __init_single_page(struct page *page, unsigned long pfn, diff --git a/mm/mmap.c b/mm/mmap.c index 20da0d039c95..0b7aa2c46cec 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -170,10 +170,11 @@ void unlink_file_vma_batch_final(struct unlink_vma_file_batch *vb) /* * Close a vm structure and free it. */ -static void remove_vma(struct vm_area_struct *vma, bool unreachable) +static +void remove_vma(struct vm_area_struct *vma, bool unreachable, bool closed) { might_sleep(); - if (vma->vm_ops && vma->vm_ops->close) + if (!closed && vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); if (vma->vm_file) fput(vma->vm_file); @@ -401,17 +402,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; @@ -527,6 +532,8 @@ 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->clear_ptes = false; /* No PTEs to clear yet */ + vms->closed = false; } /* @@ -735,7 +742,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: @@ -2597,23 +2603,31 @@ struct vm_area_struct *vma_merge_extend(struct vma_iterator *vmi, * * Reattach any detached vmas and free up the maple tree used to track the vmas. */ -static inline void abort_munmap_vmas(struct ma_state *mas_detach) +static inline void abort_munmap_vmas(struct ma_state *mas_detach, bool closed) { struct vm_area_struct *vma; mas_set(mas_detach, 0); - mas_for_each(mas_detach, vma, ULONG_MAX) + mas_for_each(mas_detach, vma, ULONG_MAX) { + if (closed && vma->vm_ops && vma->vm_ops->close && + vma->vm_ops->open) + vma->vm_ops->open(vma); + vma_mark_detached(vma, false); + } __mt_destroy(mas_detach->tree); } -static void vms_complete_pte_clear(struct vma_munmap_struct *vms, +static inline void vms_clear_ptes(struct vma_munmap_struct *vms, struct ma_state *mas_detach, bool mm_wr_locked) { struct mmu_gather tlb; + if (!vms->clear_ptes) + return; + /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. @@ -2629,6 +2643,23 @@ static void vms_complete_pte_clear(struct vma_munmap_struct *vms, free_pgtables(&tlb, mas_detach, vms->vma, vms->unmap_start, vms->unmap_end, mm_wr_locked); tlb_finish_mmu(&tlb); + vms->clear_ptes = false; +} + +static inline void +vms_close_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach) +{ + struct vm_area_struct *vma; + + if (!vms->vma_count) + return; + + mas_set(mas_detach, 0); + mas_for_each(mas_detach, vma, ULONG_MAX) + if (vma->vm_ops && vma->vm_ops->close) + vma->vm_ops->close(vma); + + vms->closed = true; } /* @@ -2652,7 +2683,7 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, if (vms->unlock) mmap_write_downgrade(mm); - vms_complete_pte_clear(vms, mas_detach, !vms->unlock); + vms_clear_ptes(vms, mas_detach, !vms->unlock); /* Update high watermark before we lower total_vm */ update_hiwater_vm(mm); /* Stat accounting */ @@ -2663,7 +2694,7 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, /* Remove and clean up vmas */ mas_set(mas_detach, 0); mas_for_each(mas_detach, vma, ULONG_MAX) - remove_vma(vma, false); + remove_vma(vma, /* unreachable = */ false, vms->closed); vm_unacct_memory(vms->nr_accounted); validate_mm(mm); @@ -2804,14 +2835,18 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, while (vma_iter_addr(vms->vmi) > vms->start) vma_iter_prev_range(vms->vmi); + /* There are now PTEs that need to be cleared */ + vms->clear_ptes = true; + return 0; userfaultfd_error: munmap_gather_failed: end_split_failed: - abort_munmap_vmas(mas_detach); + abort_munmap_vmas(mas_detach, /* closed = */ false); start_split_failed: map_count_exceeded: + validate_mm(vms->mm); return error; } @@ -2855,9 +2890,9 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, return 0; clear_tree_failed: - abort_munmap_vmas(&mas_detach); -gather_failed: + abort_munmap_vmas(&mas_detach, /* closed = */ false); validate_mm(mm); +gather_failed: return error; } @@ -2945,24 +2980,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; @@ -2979,14 +3009,8 @@ 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)) - goto gather_failed; - - /* Remove any existing mappings from the vma tree */ - if (vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL)) - goto clear_tree_failed; + return -ENOMEM; - /* Unmap any existing mapping in the area */ - vms_complete_munmap_vmas(&vms, &mas_detach); next = vms.next; prev = vms.prev; vma = NULL; @@ -3002,8 +3026,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; } @@ -3052,10 +3078,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); @@ -3064,6 +3088,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (file) { vma->vm_file = get_file(file); + /* call_mmap() may map PTE, so ensure there are no existing PTEs */ + vms_clear_ptes(&vms, &mas_detach, /* mm_wr_locked = */ true); + vms_close_vmas(&vms, &mas_detach); error = call_mmap(file, vma); if (error) goto unmap_and_free_vma; @@ -3154,6 +3181,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, expanded: perf_event_mmap(vma); + /* Unmap any existing mapping in the area */ + 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) || @@ -3201,14 +3232,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr, unacct_error: if (charged) vm_unacct_memory(charged); - validate_mm(mm); - return error; -clear_tree_failed: - abort_munmap_vmas(&mas_detach); -gather_failed: +abort_munmap: + if (vms.nr_pages) + abort_munmap_vmas(&mas_detach, vms.closed); validate_mm(mm); - return -ENOMEM; + return error; } static int __vm_munmap(unsigned long start, size_t len, bool unlock) @@ -3549,7 +3578,7 @@ void exit_mmap(struct mm_struct *mm) do { if (vma->vm_flags & VM_ACCOUNT) nr_accounted += vma_pages(vma); - remove_vma(vma, true); + remove_vma(vma, /* unreachable = */ true, /* closed = */ false); count++; cond_resched(); vma = vma_next(&vmi); From patchwork Wed Jul 17 20:07:03 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: 13735746 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 51A0BC3DA5D for ; Wed, 17 Jul 2024 20:08:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C17836B00A6; Wed, 17 Jul 2024 16:08:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9FAC6B00A7; Wed, 17 Jul 2024 16:08:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 97BBA6B00A8; Wed, 17 Jul 2024 16:08:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 77BCA6B00A6 for ; Wed, 17 Jul 2024 16:08:00 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 30CCA140C7E for ; Wed, 17 Jul 2024 20:08:00 +0000 (UTC) X-FDA: 82350330720.08.F174F5D Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf22.hostedemail.com (Postfix) with ESMTP id D1A3CC0014 for ; Wed, 17 Jul 2024 20:07:56 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YJtJR1aJ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Rk12HtaU; spf=pass (imf22.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246856; a=rsa-sha256; cv=pass; b=Xlp4vWQU5XwMkNg1Xvk+TlL+cT0y0PYy0v+c+Nrb5kStQGicnsBJvS2ppLxAgZPxiclH3d YQAo3cYMR90OH7NPszYEttrj1c3lU7cMIT+g2wprBGbgQZ8WAhA2ZSF83Ry9NNE0aqtCyL uYaxCA/81KFlVxgisnI4wMDfzA3xqZ0= ARC-Authentication-Results: i=2; imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YJtJR1aJ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Rk12HtaU; spf=pass (imf22.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246856; 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=0BaWiKTmL5k+MzajqRbdkupIu6HCcw1ZcSuzW844wgw=; b=gpVE8p/Afk671jRHEb4dmyja2RA6bmtzDLmyqBNoqVjdf81HCgxHAmVeIOesc5vifrVWoB /BmJavMnxxvVUNJtUqu85sIRjiQVs3bVP+kFyDMxo9htPjSLbXNSknGdnP3su6LxeZKkbn ZczUbyVJAn6Thb8hXPwNs7IJaoRrtRs= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJsRp6016980; Wed, 17 Jul 2024 20:07:50 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=0BaWiKTmL5k+MzajqRbdkupIu6HCcw1ZcSuzW844wgw=; b= YJtJR1aJw2jVohMrMmS0IF8HW7gRhl8vuiFra21mX0eLONTEIVAutIYDhc3Y1e9C +B5fgP+gpsEH55dgufX/YEd3erNP+lzDqIAKQbZnwA+Y8o0v1eLCgTlRsu1evczu 9C42ua3S+6PXBjkTOFDp/P9O0CPYr320C8eMDosT4WMKWPfLMha0/4YunULAUpi4 9+b+9hGzq7db6lUY14cCUqEN6P2E59r9vAC3sqkCUEvgzFzo9Fkd8yxrIMMYpGVK G5skKKI28bzO4bHQsUsfRWPC2sMvC6srI8imd0DLSogU00BJ7jW8LN1927neP24e 23OK6vO0b4lGERJH1A0djA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40em3m033t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:49 +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 46HJIY6J003738; Wed, 17 Jul 2024 20:07:48 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2174.outbound.protection.outlook.com [104.47.73.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dweyhkpk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P1Ld24LK8hRV3kTR7gZvwP4mXjXjiFimV4j+4IVYeeT+PfGh+FyKXERZGkOSr78wpX05WfzporEG48lUHt7oOJfAQHrvfe8NeRkUnrXWvkQwAYv6B48c54GCCP9ZlXjgshcLe9SR/JNzuM3Eo8aFp9a/w5RIazz2xs1dl3tefErvn6stFc08y4OF0aLdVpiZuKbr7LeJkAXblwER+nGyYvrC0P5Cgiyc6cYrTqzFQv7/bIChG/GO6QV4qRNLDT59DG6DR/6xBHeWDXNfp6CKd9cLx/NdA5/zOIthEgQP2aepdHGGPYoGrwjRa8lCvHERgydzevoWJ++faJOhHK8Ngw== 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=0BaWiKTmL5k+MzajqRbdkupIu6HCcw1ZcSuzW844wgw=; b=cR7+T6CYQqOh8gXYPnSns/Kr5C3Z2KZVN1avTxW/GFtfW6ppYzyB/xhhTbxtlrP+IF+4e+JbdVSmUr8vD4Xp8gAtOjaepQMb5U1aTM07mlvdK9U764KYJrFjaVxT5+vVXRIr02qyiBoqgx5pezDZJONiEuGXYb6jGalKvrlq3GI0H9wwf2rzPAWDK6WyEkKbWUBcTbIY/XEZazVtsYBGTtSBlqhQN2ROz2Ojb2oL4hhzmiG/r9ikpTdjHegqX6vfg9zGZd+1by+8ox6TH3aNmcuOWI1D53o91XaG1GgVpHJOy/9Fbg3fdSycWKk0yyCg/ZA0lyaWb1btYBHflC8YCQ== 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=0BaWiKTmL5k+MzajqRbdkupIu6HCcw1ZcSuzW844wgw=; b=Rk12HtaUqHvgf9THmGZWRndZAQ6BfD9gERU1HkDDW1wvcTr8sRX6EpU/e94b8WlUFkfYoIKYHPIrolX2+1wldo1iEWC/mGCwnAUCAstjLkzJ9qxZG1eoUTXtWjDT1o5/iRPHMrGC6qGw3uiDQSd+Gm4PjHS67IoJaRjmMUFZt4A= 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:45 +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:45 +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 15/21] mm/mmap: Use PHYS_PFN in mmap_region() Date: Wed, 17 Jul 2024 16:07:03 -0400 Message-ID: <20240717200709.1552558-16-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: YT4PR01CA0034.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fe::16) 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: 5dc7fadd-b0b8-4e12-a5c4-08dca69c1f61 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: V+wEtXyUyFDe/Quihil2olE7jxBr6Ir2knpvIlIz3cYwIFbTwStJ5YyF9Uh4UNi9G0Ffr4m38Vr7Sb1UssyZo/61PzrVkbWrPhKEdKUx9ubi9kalSqJYPhQ6pJshj9uQB/OV2PybBR4wgAapvnZ/ojLq/+x40anwoPhFG2v73ISkoT+KawqhRfaijejCrL7+rEoUL8VpMhx3gSBBIs24EqVi4TunxP9pdaN95a1LUf251ipAlqessfvqdJx7CIfjaSGI1iw9DajbHjpj549KguMpEi+Az4hfVJdHgWmAYi9F+Th+6vSuSExURiKEnQ+V1bUSpGS4pKP9yzhObbf1n1g5HTUBXiZJtPE2WfZG+mIAWwio+HFsTOZ+xGV48G5eh38RuzSlWoZB6WDpW+1LgBc2zG3UNu1fuhjRGLs5DnCRxS6GLaPOfz0HtgTQNUqEep9oOyW5KwOhG7L/c/d1NgLkiEcqACh9jSmn/zMrK76aDGisYzogrWiQ4L8RpCY7axJmJcohgYjBabGIrIKadLtpwhmmAfDQgJGMf+nN4rk/cLB88E8svOLZkmKwe+1MuyRdMHJIZcZI6DY5Jjo0iZuY5H5RUnncQpxBycbE3lmFfaA/4+0ahxtgejoXsxmLixcl4e5RCrz0QfEziFxxmF+Pla3nTstgjlCtHQyD5AYubqO2kJMD64U9cc11rlbZIDGyzDv5jlTvfX25+ALp9u+nk/qUM3PXjuj9eQ/6tux1GR8bAwSS07SHciGO4+8Xt67sxJg2xVvADH9IAtujGA11xYWSOGMNiZePKzi4r6j/zUC/c9H9loPrrEGLsF/FX/hRul61voEXT4xoX1aHKwvmOh1dp9FLj9jx5U3BFjyFNdWRRBavp8k+qoGu4pmC9iMdEVnK5WXqTHVwCtM0FuFpuUs6/N2TFpGtAYkEhUW6JlWtJXJPBB7A4X3lacmE04MlUiqjpva5DJXU9GxSDKtN9+JeP0fZhOiswoO5gIJHFFcEAO0i2qnpl+tFRLdzM7eEEymQy0FGXuWFQL0gaU3Mx5jcY8JuysWFHFNRyvJPBPO0FJ/2e6+WC9u/gDCmbVXpS3YzcETZryxW79LezUF2SAQQGjpLYG2IzrQUXx2XRU6cFhGI1eGbsXVFKyntFI55IGqVVRgEcpnWAp6Kq8iSBCv5cuhdwl9u7Kv3vxbEKJe/qxLJwfhEPrLfT8rdCHYSs2eVn9ih3GKGw4achP1srQWGg/mrixgQsVU7vpAZZhSsMwcQXotFOmaN8zQcyovp1oPkXXI0k1bqDqI4bCHVfAdeJMaKLg/Efembj6n9JPO+Kme8eFHBCS+se2P2YUVvs1dehduYhPtI0+f+jw== 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: Bc/OnrVn+Hzg2nyFYy+aXmqOjw7rqNp2rq0rbQMYcfmS/tMiixig/wEq7ACmFWVx8fSEPL2u0BHfgXJeM0P1+XcmlOh3xoJG6LLl1sH2YmKjD0ZQlhnfdm3VSFLnLxGGqZv7YS70HDnuEa0H5VP6N2HYepD+aUxpRRIXB8WIei8S/vcKSmBVFWtaf45p7/jiJb+dmVwdeuSMS6/AHdV720BTuZ8tvUawvk2f86VLVgMdu3rkyuQO/0WKXgXXcc0UJ8ASY+N9UJ/15OdTQmov9HSgMz6anG8cEMd69GR1So5vZ4GruEY8jEIHMtrUw+scRylLjoo/MN6WbCoGoV1WcSNLhv8GK9lftGkwzDTnhDEPFQ+33Ffw+1rrx38eN0/F+It8nRqxTSRVx2AWQJCRziU0GqUhPqJ5PbzVGaJp+nLGLu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eHrA2DipEyAlhPQD+mg7Oc6GHE3mA6ZBmU1s93Ih03bxLfXMMfpmtSHWBE9jZnlFdoMTIR1Df554kTAB4dtMVP9GokPKlWHcuqK2ZymeuUbEXFd2Iq7vvQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: GOOj/1HjxAgxkUosa4U3StxeFtLt/WpgJjqO49Se2g3ZjBz/evLeWxcXZOCm4CDanGEvNc/rDjF7/JvWZJljcyoK0mUssPdKNNfSYKoLoMg/Rldh3ppg30UwGLkDDPc5jwNAX01TP58ndyVcHRmF6GxTYaG80PxsghwylocmtzTkKx59z64irnIWBh9tlcoGsbVxHuZco8NJOCPj4wdmc8BXgT8zO3N54uQS/R79K8n6tKOvQuTWN35Zn5qsJ1cNHq3ui/RqvRibQxhaQabZbvU2d0Jq/p+Iiekmd/XJq4jlIx5ZDGtUsP+fCdiOQoyvkVPZypJoUxM2+qSjLx6HQXJ/VpbkXShuKlW+QfG3PSmG4MqKNhHXgxUA6Dy3WFI37b3SKR6KUzlburxR6KgnO6FPmP17b3ua84uZI6riJQ3NNaBQfNO0DVItAZAXV5IeoFNo6z2C5F/STGNuBeIzTOYJ/f4AmVYsGmpryMMVWMMrDurrP7f/QnsQ78jbpfaef4kfoLxGGI/1m7FHzcH6AkbzfrG+dBxJk7OO5Wvxp8HRP7bWkcn6w4cS5Ti6BrBaROwFvCn7XysHZbhLvzVhMk3Tk8FtRnUhpQNKLFtxTXM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5dc7fadd-b0b8-4e12-a5c4-08dca69c1f61 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:45.2592 (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: T67CdT9UamGa5FNdKMa2fU6v4z75wr++3s32tmTvqVbr6N5HzH0FrGyCnq/7FLs/3VMZeg5AIevREB10++ejcA== 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 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-ORIG-GUID: i15cWQNC84QuNNyqJ0Bp1gfmyk4gk1gx X-Proofpoint-GUID: i15cWQNC84QuNNyqJ0Bp1gfmyk4gk1gx X-Stat-Signature: ot8m5tcrpcq1todjjxj5pb1spqx9u1pg X-Rspamd-Queue-Id: D1A3CC0014 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1721246876-825514 X-HE-Meta: U2FsdGVkX1/ywo0eF+Cr9smfvgRNI4LGjDsn+9vRXtbY7Kpc1DgFRZHwZZCkNRjz7Lg+inFwxU6JPYsIYfAIyS0w7SiBf6j9bsbwlZ3LWEcmsHxjpV9Dn6eWv+O3AeZQrGHdqNiwMqWqeK1zhKDdQ1o+rA47LQ5ARYEMFztzAgRcqc8yP2nrdV0hlWPD+PT+a9etc+hVDytVzWhwPQ4e5N40ZQ7UZYHzgbnMH93zE9Oy0b3VtrV9H5RIKpAffEJ7H3Om0EQ5cpgHiq5bDtO7y4tgBNfc+KZaxI1Fr4l4QeUsCkaWj4SonOUnbtYxB66gO/HmuHuaiKlEwKn3XPOgcP6ouCqSZbkNZh5h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evo9rNbhRM7YVT4Io+28Yqq1OjwD3UPa5d52k4T0tL3lg3Eee1isIWO6q4tlI+FL3C353DcP0eLQMMsdJX6QVMUuMOH7X/9x0RjmnW8A= 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 shifting the length by PAGE_SIZE, use PHYS_PFN. Also use the existing local variable everywhere instead of some of the time. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan --- mm/mmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 0b7aa2c46cec..45fb8725a6c5 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2971,7 +2971,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, struct mm_struct *mm = current->mm; struct vm_area_struct *vma = NULL; struct vm_area_struct *next, *prev, *merge; - pgoff_t pglen = len >> PAGE_SHIFT; + pgoff_t pglen = PHYS_PFN(len); unsigned long charged = 0; struct vma_munmap_struct vms; struct ma_state mas_detach; @@ -2991,7 +2991,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, * 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)) + if (!may_expand_vm(mm, vm_flags, pglen - nr_pages)) return -ENOMEM; if (unlikely(!can_modify_mm(mm, addr, end))) @@ -3025,7 +3025,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, * Private writable mapping: check memory availability */ if (accountable_mapping(file, vm_flags)) { - charged = len >> PAGE_SHIFT; + charged = pglen; charged -= nr_accounted; if (security_vm_enough_memory_mm(mm, charged)) goto abort_munmap; @@ -3185,14 +3185,14 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (vms.nr_pages) vms_complete_munmap_vmas(&vms, &mas_detach); - vm_stat_account(mm, vm_flags, len >> PAGE_SHIFT); + vm_stat_account(mm, vm_flags, pglen); if (vm_flags & VM_LOCKED) { if ((vm_flags & VM_SPECIAL) || vma_is_dax(vma) || is_vm_hugetlb_page(vma) || vma == get_gate_vma(current->mm)) vm_flags_clear(vma, VM_LOCKED_MASK); else - mm->locked_vm += (len >> PAGE_SHIFT); + mm->locked_vm += pglen; } if (file) From patchwork Wed Jul 17 20:07:04 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: 13735748 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 022A1C3DA60 for ; Wed, 17 Jul 2024 20:08:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EAF0C6B00A9; Wed, 17 Jul 2024 16:08:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E37186B00AA; Wed, 17 Jul 2024 16:08:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3C1B6B00AB; Wed, 17 Jul 2024 16:08:05 -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 A077E6B00A9 for ; Wed, 17 Jul 2024 16:08:05 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5C5BE817D8 for ; Wed, 17 Jul 2024 20:08:05 +0000 (UTC) X-FDA: 82350330930.30.2210262 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf01.hostedemail.com (Postfix) with ESMTP id 1C0D640026 for ; Wed, 17 Jul 2024 20:08:01 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=fbcbr5Pg; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="iV0/F2gR"; spf=pass (imf01.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=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246861; a=rsa-sha256; cv=pass; b=eq6lIT42X0QMWU92M9faceGYChyScRcw1KOZyVU++Ri7v9cgNQz/rXFfsq/4PNbdS8S6Nb ykE5T490klchI4hawtF0Q/rzT5CYyb0HZ/zpit1BiQkILUZEBzgAVHUNviWAX3hyFCUUCC sDcVwO+Y2UJeJ+OABPb/3ZMK9BxRhr8= ARC-Authentication-Results: i=2; imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=fbcbr5Pg; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="iV0/F2gR"; spf=pass (imf01.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=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246861; 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=MCbfSOiY26c0tug8tqf4PmH91ko+wJF0zouXoNIkQsY=; b=qO1cvpkymHjHkQuivmhaFqs29uMnwTQYDsI4MAfwQjO5CeRPL+dw/frqByDfC0xi9psNxQ kbNhfyMbEqRFOFqZXU/cRF58Nsp38HpWfSEAk0/qeldaKbu9ZtErrUlhUH31mSiO0XS+ad o3img0sbvKxVC1oR9++R7el2q9M0sGA= 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 46HK506K001775; Wed, 17 Jul 2024 20:07:54 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=MCbfSOiY26c0tug8tqf4PmH91ko+wJF0zouXoNIkQsY=; b= fbcbr5PgkKibnorf25EFp7YP1VgRx2+IcisNa1tOhzkpGfdp3g2qB5oN9IYljiNt /xXevkti+GUGbig9fNxm605fo1v57uryEIlw8pnGNxdVvNvw5P8vIy/GgDNcz49b xevGR5C3foGAplAT8jTFnBCi7g4vXrKIduGhhnfLFZ5u3ODfqOcTyX3ZKHv8aYGs K70QFk9F6rUl+s7n2Zn6j/y41qM9Os+F/xEjjMa2wEvlLEPEJq4YfMegNKlEsETi ZFzZRY36B9um4IQOlmP575cfFej2bUqMTEq3aYfSvQG68J9t+gqpKJ9W2ObVuzJG mMs6dDGKPomOAs0546tUng== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emp5r08d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:54 +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 46HJ4sqC003630; Wed, 17 Jul 2024 20:07:53 GMT Received: from outbound.mail.protection.outlook.com (mail-mw2nam10lp2049.outbound.protection.outlook.com [104.47.55.49]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dweyhkte-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=isvng2+bqIeHvnXEkQjGv6omCKsHzE0pwv8YMikhufc27wzT8Bs5MttC1e56YQ56fAWzTgCCxJemYzorMWaO0aDIpEQ7cJY2cCXOGWSdR6vCjUkeQaEYXq6YBzibZxiS7G/FhmRtYzDnUx1duRESG+xoHVRKV2r1VBIZrMltC2M1bmqtaNebbw4wAuKoZFa+9iFR7C1h7VGr3bCO1220Jd1uOm1Bmo0HYPU32kezGwG6iX6hMnyYPLzqRGC0vI/2t1uUsbZRR9Gvt8kzfM/7Uu5X3p6/w+TgDuvbBhzdPomQjInppwLN6bQALMEsCDwXfJGGKTixxi1RXAeBhVarWQ== 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=MCbfSOiY26c0tug8tqf4PmH91ko+wJF0zouXoNIkQsY=; b=tiGj2uaxoL+JVuF3YBwvED8hYABrcR8ZeJQo3F4SdcIVNCWhCbGx2oAQfIfwzx0s9789Zz3mWmyVv2L+RtLDNGJFCJcCFBaqZ8tDxvP9dXSc1J6YeEciIhL57PzZEQOSUgbaaMYvYrsVjbFlHF3iSxcT21UxNNLZOlKXlj9neGAtsSdvSRobW1Ro/EHR3OSMlJCwhTwitJj/dHY21zRlmfo2F0XxuJ5AvJea4hq3I98m+cLiLupjZ2bTjzBPAHiTbZjLt12oY4Oc41EeA35bWPAlh8z4h5CCtCvjHzpXc56Mo7PRKUw4+O4/+Ys5QlLKJ1w7rtIFahqIa+YAUJLlMQ== 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=MCbfSOiY26c0tug8tqf4PmH91ko+wJF0zouXoNIkQsY=; b=iV0/F2gRQRAVbH66OCrIl1dJy98XxjJHGQbD1Ow2xptRKwvHW5S3g2lUOXHIOm0M/ZIhaxdt9cTpLTVs2YnzL6QzHT0t3MJRdHAIQ8MPnXMtrGn+WXoTrSIVrmneCTgusS3UGC3QkpGHl53EA/kbm41Z4s4mbQWMNkiv0/Wb2ro= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH7PR10MB7694.namprd10.prod.outlook.com (2603:10b6:510:2e5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.15; Wed, 17 Jul 2024 20:07: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%3]) with mapi id 15.20.7784.016; Wed, 17 Jul 2024 20:07:48 +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" , linux-security-module@vger.kernel.org, Lorenzo Stoakes Subject: [PATCH v5 16/21] mm/mmap: Use vms accounted pages in mmap_region() Date: Wed, 17 Jul 2024 16:07:04 -0400 Message-ID: <20240717200709.1552558-17-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: YT1P288CA0003.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01::16) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH7PR10MB7694:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cc32298-6e7c-4f7a-3ad0-08dca69c213f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: TAyRJDSWQDWgGC+3RxkdDK5lS91gdClMsni/yUfZ0V/BsUGi25uwLYhAQNTr0Wor/4Abj33AoNFdoHEpvoHCsoXQZSybJ5Ry4UnKSFKiK43wmKTAAJtlu/8epX15b6wxTLUmf+s1EjZM1TES0bKb7jFLRUK7YYv4f7pBxvqY50HnrV3CGO26WAm6GTuxgVl4/vTh94n5jnURFfPzmzt1K3Ce2nlCfRGtbgC1LZoaYu28u6uZafVHMEM+RoDxJiCbhid/sx7cE7bETvMHZFc5NHmpD6xXvIv+A9v0VMqct11g5TR+zNUdnwUACzMONpcigp3860bUIxtn6nsgsLADqA7Q1HvmCNCBSGHW9ipD5rtPtImPS6CNPm22u6zP857cIPFdXXR2nuzllnZdS/9cHVjLBM3HUR/RCiDUmTEsaI3RhykfKzguYXt0ErD4zhOnCxNNHjnYJjbfL/aUQRHaZubUsn5GkEZxWXL2j9mbGSsc7nlhyqRncC3KbyZ54LVdIWy0t702ZZkuxZAHUptRQM1ndxlJWX1Kce6Dov7LwfInndgSrcbH9DnWmieTQOfFgZZvhBMx11dYdkpuo5T4uBMWcTXzClUwcGBezzcXdMDE5iIvCCFvRFKhk1nfaC4HUZQIaX3brABIiHBCvFakDL2fiq9mI4ZW9MGlR7UclnkbI7GLdec0y4Gk0C9RqHJCZnSHJ+RCp5rKEwau5ZwwcuIzpqfWukQyslgeURxXPJVaVy2ia8c4k58M8rtqtG+ynA/Yd1ftOXUkEzq7blJaYK3IEasMefsLyFPsucvWemfn/wGUZHk37moyyYxpYPV9qgsJ5SOEvdYAJvFnizvp+u7kcNvwiLKNIqdS42ZpRWxhKRM4LAs6DTtgNnrdESO6wYOQB1qfzf3pJqqZRoiZaZTcvjYlGbKodW67Mvc3rDECDH3r4tPqOfPXLx15QBwCopXmqQHLM2IXTrGEI9Vo9Wm4X/8st/WEGeU774kieJJWqhPZAVrJabdya6gOeeDWIf1ydG4ZBvwJh6ECCDluwAqPIbk+cA9QdC6dbhFN/X00m0BgcuOZbQBijc3C+b/NE5aI0XOjVOolLbZjk46/HHXmqv/14awV/lbtkfWdrvt6CVcEgduiciMoURi2IDmiV75QiODChZOogAwBqLkao3M1YOsXpMmyNlZJI7WoWosNTwQaiCh4dFHOyP/KROuf38LsA3U4N9IZefpn2EbBOvPDOUgJYrlyOlxbF4N5gusPjRfIH1JuBpo9+edzoHSg6P68FQvOokstyJAfPdnHwdYr+T0YHiRLbzgeAw6aY88dYm/6VAZtVfOJDPYIyTAwFLAoj8hNpB+ZJGn8mRRMIw== 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)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RsHnykufyRporE+RyPOFAcvrQl9fDrnoSfcd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PzIuQ1b3AcJowbcdAjAnn4mbkFVnCjlAwJk0YvoJRkG9V0LZknoIadwfW4/EAvYmawykMXW5sD45e292Fuy6TOxnpKvUx7Ym6uHx8bIgNOR80o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cc32298-6e7c-4f7a-3ad0-08dca69c213f 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:48.3854 (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: JTolng7QH+bo7vQZGWFyqcjAOUnyUv0F1QMzjdyn+RkSdlKISRlnX7CAeMJAe+apWGHz8231pI9qqsUROJv79g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7694 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 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: E8g3xFjVZzLUZjxdi8zZspmxq34O1EtV X-Proofpoint-ORIG-GUID: E8g3xFjVZzLUZjxdi8zZspmxq34O1EtV X-Stat-Signature: hk9nscftrhbi7pm9dfu93twm1qzw5a5m X-Rspamd-Queue-Id: 1C0D640026 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1721246881-1392 X-HE-Meta: U2FsdGVkX1/n0dyPFFnE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T235ywf068m0WTOEx2UKMuIKuD2lwRmBUqVR6P60tx9KDVk+rXZLjwwfjbkFKxGFKzE5RrWJx2CSTXyG8nYM0zH1dyfpkAglms6pnDN8m7R2mW76o+GI+zV8w7R3msypv1AM3hzQedZVxhdYwYO9HKYlcYI6sDJD5Y8bmJBKlFVXuSDh3hEEDU5W47t7nZ5Mw1utxTTiyiZzJyqQx0P+BQk4LZ0/9Cs0lAw72k8BAUYTkEcFcfbaKWiM+NCGM5XJJRwJ6dmHB6KLP4Sd3DVXu+KdOryMaGbzCsiP4CVkU5W4bY3kymetcqWZtfPGMZP9PCqWBHU752yxER/OoUXNLnkmLqE7gx3yT0LfymIqgE8uDVWhYosViXlKnh7BrZzSAf+cxOkKW+RV9iaB3QApWnMgb14wV251nwiGTX1fMDzyBaH2WytiROkHXyAkU38v7xA0c9V+SbvShNOFvyFOfHULBgz7sDmR7OWCYoJvi 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" Change from nr_pages variable to vms.nr_accounted for the charged pages calculation. This is necessary for a future patch. This also avoids checking security_vm_enough_memory_mm() if the amount of memory won't change. Signed-off-by: Liam R. Howlett Cc: Kees Cook Cc: linux-security-module@vger.kernel.org Reviewed-by: Kees Cook Reviewed-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan Acked-by: Paul Moore (LSM) --- mm/mmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 45fb8725a6c5..9f870e715a47 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3026,9 +3026,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, */ if (accountable_mapping(file, vm_flags)) { charged = pglen; - charged -= nr_accounted; - if (security_vm_enough_memory_mm(mm, charged)) + charged -= vms.nr_accounted; + if (charged && security_vm_enough_memory_mm(mm, charged)) goto abort_munmap; + vms.nr_accounted = 0; vm_flags |= VM_ACCOUNT; } From patchwork Wed Jul 17 20:07:05 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: 13735751 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 68590C3DA60 for ; Wed, 17 Jul 2024 20:08:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADEEE6B00AF; Wed, 17 Jul 2024 16:08:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A93286B00B0; Wed, 17 Jul 2024 16:08:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F8D66B00B1; Wed, 17 Jul 2024 16:08:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5AC096B00AF for ; Wed, 17 Jul 2024 16:08:11 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 16A061C3A72 for ; Wed, 17 Jul 2024 20:08:11 +0000 (UTC) X-FDA: 82350331182.04.8CAE4E1 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf14.hostedemail.com (Postfix) with ESMTP id B8EF010001B for ; Wed, 17 Jul 2024 20:08:07 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=KfwXfwWK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=IxHpVFHs; spf=pass (imf14.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=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246867; a=rsa-sha256; cv=pass; b=RKyZ9GiHDH5aZuh2J8nsrrQHC4E1lC1d5FDhHf1TQeKxGdw3S1041qgcSwbGZePWeFN82L aVMGB9miyUEPqbFRd9oMHL0XeXbcst6h8eiYiOVd1MpANH5Zk/vG4g29LwqYgCqWlEpju7 XA7KdNvfvc/aZQ5DLHRJhux6oFdprLM= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=KfwXfwWK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=IxHpVFHs; spf=pass (imf14.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=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246867; 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=o9g1Ew5lheBoqkL3ar2Yr4AYVb1OEZDZlsoHSIlKuKo=; b=YxRVSqAe+WXdYD8sGGxkdlqYKGoERxw+yyRSUdoO939EJpBdeRY0ydAERckuMO2PdPXasl zbqT4fAyvidVBx3j75ozIQ/RxYWNEqjBGyY72wq3YJ2VWvIx6aTjS0l5sWE22n43or+isg fg3Aes6CAESk+oeu3dp9P7Zs3rd3BNk= 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 46HK52fc002035; Wed, 17 Jul 2024 20:07:55 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=o9g1Ew5lheBoqkL3ar2Yr4AYVb1OEZDZlsoHSIlKuKo=; b= KfwXfwWK+pHabxvJSmP1m446MA9Uv9zQ/fSAjXiei/yMHV3gCdBi4w+CRNsuSMFE 3Nly+PtR4Yu66njyfdXmzrHU9+hoRWQqM4xMRApfhaW4erme4YIHU5yZuoELr1Xw 9Z47gmpCChxnZogR5Q+wJr8rnvFdSE/n0ApWwM/hSMWX8KmxPo73bKl8IwRhYoev m66mv6Df9823Db59uPHxm6EUjmj4dDapfdZjB5sbk0CdmoDciJqxlT/nRFS1AZvo Te9lAW4BqKrb1bDOiF6ZE1Z/7MxZG+19nEcLgGoFYcjhpxi32Rcay9z3njMugqfY yX+DC+wo+l56IA67FDPpuw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emp5r08e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:55 +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 46HJ4sqD003630; Wed, 17 Jul 2024 20:07:54 GMT Received: from outbound.mail.protection.outlook.com (mail-mw2nam10lp2049.outbound.protection.outlook.com [104.47.55.49]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dweyhkte-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kuQVEvJOocmNHgpCTBF+mr6TJtFT8m9DVPrDaXQn3Jl6/kLPizO6L9VXoqjP8UNCDHxUo75FmcQRs9ks5bagWZ3xTj9gKRsXtSff7nVAHAcrSH7SYW5UQqBKmq7rdcgRUTOEWyjYXe03uqZKCYUuSizOR9JZEluq87EXRreC+E3l0fEj5PQoMukXh7fIp0WSzew2LZSCy8dQ/fEL3cz+RRm8Mcvfip1FI1h8NKQX4QSHlbGFd6nyGM7wQmZutUjmDLm2p3bhlKhdBDJgcKNHCTzKWmncW+eTbSf9nX44/IU9fYbE5ggErqlOTIhE4DUtZZS/4BPvL2ZiCCW6GTe/Ag== 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=o9g1Ew5lheBoqkL3ar2Yr4AYVb1OEZDZlsoHSIlKuKo=; b=YiFop29XNZQmS1WKdLJhHysivVL+jnzN95bGzIqe6cxKKYDRg9yeh/qs23cwqQjSfQeZ3+jtAn0WAMWyx21QJjVXbVO9UibmBT9bq8BxNa4u16ufbb36B83X0EcfW2jbFMMZHrv9LbQOlJ3MvYMCg9RtXwe2BmKry6TsCj0DkTT2PrD/YTRKLc+TciDTX2ebLZDoKiLaf3jTfPp0isY6HzNUbg5TCk8O9IND4p05jbbe6lhcWeZD2xkKy2eE06mICYhdQsARRV9Ps8tCJrATxqNuv6FCoy+FB5+JoFuWS9QXhAYd+Nvq5Sq6m0wPzLDvkJfboACfIhZO3/V7/mFsGw== 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=o9g1Ew5lheBoqkL3ar2Yr4AYVb1OEZDZlsoHSIlKuKo=; b=IxHpVFHsjYUCzZMf/KEuS1kTiOgDD5cpPhUrla+5/fjzl2lAT/FKbUzlhpBly2stLUc1LXDy5k5Ox+QRdzQquL2/X4le0MuvkCBARCYAEqiU2qcdwlskTYWHmOMkV6RLkZxhKRJmd0Srsfbm+ml062SJIKyAl14+hCCka5Rye0M= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH7PR10MB7694.namprd10.prod.outlook.com (2603:10b6:510:2e5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.15; Wed, 17 Jul 2024 20:07:50 +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:50 +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" , LEROY Christophe , linuxppc-dev@lists.ozlabs.org, Dave Hansen Subject: [PATCH v5 17/21] mm/mmap: Relocate arch_unmap() to vms_complete_munmap_vmas() Date: Wed, 17 Jul 2024 16:07:05 -0400 Message-ID: <20240717200709.1552558-18-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: YT1P288CA0019.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01::32) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH7PR10MB7694:EE_ X-MS-Office365-Filtering-Correlation-Id: ac801e0b-9773-40a2-03ab-08dca69c224d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: ecPflbMCTYZKw2oRdZ3ftVm9mNoGwBIbEDu15UQPwGiygFvCdqa7gBhe7lFKyRV8nwxROkAPcN7SHmepf4/5pAueLSyBG+tHn2Ph9BA8lKJWBNMy9OWXFTgyyLqaQRTZFEbEaHRHakKj+lDoaQZg9u8BG3rKBb/1ZcgBligr0WyRvXZ5VROzHj8QpdVyNbEAREWwHS4ASrWXjlyC4JUnwSP1vzw0yDUKD+VQG8iLQetipaMzdpd5ozTr8hLelgtM4oqRmcZ5VhQeT1+cfQEpOlOhi9pT3Zy61xTyHr2xD4jSkHqx9ERFLmqEAuPW3iy+m8DPCVURlTYXnZtY0V4pnaBTTMmrwkQKxmkjKHi4dmgRtr2ojZPwVdWEqaaMcfbFj5JIl97agN61EvoMge+pqL81q6E6WR6x+yqEwkDwtm1cWgOVPO9+QPp/0Fd5/tLELGfA1enii4Tk/ESNTH0mILiCYf7xVEbT4X4wNiVKZdIp2u7YffXvLYOaVAJtCOH5d4FGpv2CNbQQSu79SP0LOjGtUeuYkEgPSJK6td99dtj2WkRgV/rxmx2yaL4WmVUraBtNrcwYfVZ1CrvN9CIvy/2wWDL/WX/zmsvs1PEQKpktc/mY4CfHT/3+JVv8p8jyJyj6x2XsqfeR/bkur5EXFeJoM9htwb/6dEVmId6yWE2HaWpjGD5vtNV8HFiPkbw9gYNVgV4SjcT595/PR6uevxtGMsUM1OOJ9puU22aEJHkV1J7LC2lNA3TMABrg6SA62IpWVIv0lxT7qdBfaQUd0dfu484pfgdseZKE8Wzk8hjrB3w/YwWqnMmTIBLGz89B6VEz+j0hHxqhBv9m6yxZr1IVumeQWUS/6mjqOthyA+uzhTmhxJTVV/qPiTV8l2hjKymmuZu3gcK5YQ6YU5bVzd66CCliHCTxusUEjpg/9bXMdnN9TEXttMh1VVoEmc5G3FiwaMngxEe6HoYyKlNENGgCbLk1aLKNudRmyseXjVdKpQcC+I25/RvE5Qv09h8OIvLe0GHkn978+b+iOcfZrX8V1HOuypyvArixNC/fBHvoTPhKDzD+dc9F93+KTbzAc8cbP6krKUAZFhPr9UdBzvc9LvoBsFNlxi0OqhYSLxJo4pTaD2BxwTtUbbb41XNcsN9vRoYzE0iZuL6+xBXLJUIDoqBo84Gb5RvgsR7ESJqr+qO627GJOvzcdfZ2LJ+NcrxEeb9qDpPqhgpyukr3fMjSjZ7zAAEIxmgXXbAD6FsGAFw6LVaY71CgBmZh9uv/WMEOj3wkW04q1UQOcHMbi3a8InlcYzSWNgUg9ViQzGioXmzpPB+7UitCofjnuKl3SM6abE+m5dJME8doSaoaaA== 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)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vz81dko8udaUoR4OXplzF9zohaOWy3ObSdsINyJE2om/HCUPo1ZlIKC+hJcZx638J7GFqW/4rDH+18vmGTfzBrJWAVmffQPnbEvFmdvDfaBVNtitzE5PxyLSZD5uNSkr6APGn2/ucHDl+6PnrG5Zxw3UzxqcJ0rQTF+9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dsD1UBcy4svr0Ekic= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac801e0b-9773-40a2-03ab-08dca69c224d 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:50.1756 (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: FRCLXHTvzE+xdt41KmnG/n0IIk68yCxhXwU/NTIN16wTRo4Ths0YwTZZf9fBAxtM1cmRv3wzJDBLWf5ggXvAuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7694 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 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: FuZlo-JsEgFiXD7dNhTSTk0QHtpVuOdR X-Proofpoint-ORIG-GUID: FuZlo-JsEgFiXD7dNhTSTk0QHtpVuOdR X-Stat-Signature: 8x4y9d35azgy967rbhe86hzieb4irux8 X-Rspamd-Queue-Id: B8EF010001B X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1721246887-480545 X-HE-Meta: U2FsdGVkX18D3uJ9yZIBf89LKvywt00o2UJ7U6SgNDMLwC5US3V0xueQZFusGft1CIiU34wVVQNCZSTa8G8x6Rkp3c86bYpy0EwWnluiFmk7gIu2W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tzdUPBnsiPladV16LaqQ34OfRVYHExnJi5jsCR8pLwOf4A9qsWkrPs/lYEKgFx3WECsVlh7WVStpN0ft7usVfzWbJsEZY5RTmH2Ib96ewobIzZeVAQ0qkR0jm0pryQ6GBd/JfBC90M3bsxfuHEDeNV/E+K8Z57Orayj4xc178u7fZA80nHRPj/ld1pkvu6I4PwNEyHOMU/LL6MFLo3wYmnGFR5rPQ2uMUdI3QUYORoNOvplHPF96eYf1HOyM1joKQRI7qp57goU1bBkUBLbTt7yO2wQwpAYL4dF7ET/2NBdr/mkPx3ZL+sZT5uMFwGK7tD6hnRq4M6mWr+J+oXsYTK0J6cWoUVz/rcMZxERJ3ESOUVPObAyc3Y/mgJmTEVbZV44c/J06BBNFdHTaGU/JcpNdwk39rH1jP47hbNJk+AJBMYdH2kkxmizjWn36GKSS13j/w4IDToRIQZc2CPN9MXi 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 arch_unmap call was previously moved above the rbtree modifications in commit 5a28fc94c914 ("x86/mpx, mm/core: Fix recursive munmap() corruption"). The move was motivated by an issue with calling arch_unmap() after the rbtree was modified. Since the above commit, mpx was dropped from the kernel in 45fc24e89b7c ("x86/mpx: remove MPX from arch/x86"), so the motivation for calling arch_unmap() prior to modifying the vma tree no longer exists (regardless of rbtree or maple tree implementations). Signed-off-by: Liam R. Howlett Cc: LEROY Christophe Cc: linuxppc-dev@lists.ozlabs.org Cc: Dave Hansen Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 9f870e715a47..117e8240f697 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2680,6 +2680,7 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, mm = vms->mm; mm->map_count -= vms->vma_count; mm->locked_vm -= vms->locked_vm; + arch_unmap(mm, vms->start, vms->end); /* write lock needed */ if (vms->unlock) mmap_write_downgrade(mm); @@ -2907,7 +2908,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, * * This function takes a @mas that is either pointing to the previous VMA or set * to MA_START and sets it up to remove the mapping(s). The @len will be - * aligned and any arch_unmap work will be preformed. + * aligned prior to munmap. * * Return: 0 on success and drops the lock if so directed, error and leaves the * lock held otherwise. @@ -2927,16 +2928,12 @@ int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm, return -EINVAL; /* - * Check if memory is sealed before arch_unmap. * Prevent unmapping a sealed VMA. * can_modify_mm assumes we have acquired the lock on MM. */ if (unlikely(!can_modify_mm(mm, start, end))) return -EPERM; - /* arch_unmap() might do unmaps itself. */ - arch_unmap(mm, start, end); - /* Find the first overlapping VMA */ vma = vma_find(vmi, end); if (!vma) { @@ -2997,9 +2994,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (unlikely(!can_modify_mm(mm, addr, end))) return -EPERM; - /* arch_unmap() might do unmaps itself. */ - arch_unmap(mm, addr, end); - /* Find the first overlapping VMA */ vma = vma_find(&vmi, end); init_vma_munmap(&vms, &vmi, vma, addr, end, uf, /* unlock = */ false); @@ -3377,14 +3371,12 @@ int do_vma_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm = vma->vm_mm; /* - * Check if memory is sealed before arch_unmap. * Prevent unmapping a sealed VMA. * can_modify_mm assumes we have acquired the lock on MM. */ if (unlikely(!can_modify_mm(mm, start, end))) return -EPERM; - arch_unmap(mm, start, end); return do_vmi_align_munmap(vmi, vma, mm, start, end, uf, unlock); } From patchwork Wed Jul 17 20:07:06 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: 13735749 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 F21F1C3DA5D for ; Wed, 17 Jul 2024 20:08:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 252476B00AB; Wed, 17 Jul 2024 16:08:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 203876B00AC; Wed, 17 Jul 2024 16:08:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F20B06B00AD; Wed, 17 Jul 2024 16:08:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D18676B00AB for ; Wed, 17 Jul 2024 16:08:07 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8CDBB81818 for ; Wed, 17 Jul 2024 20:08:07 +0000 (UTC) X-FDA: 82350331014.26.D8821A8 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf11.hostedemail.com (Postfix) with ESMTP id 5474F40007 for ; Wed, 17 Jul 2024 20:08:04 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=GLOGm+kS; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="S/LT+9rU"; spf=pass (imf11.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=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246865; 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=alInpUkHwx1KRSQLZZxXfT1SsoSWLZXvIxTDx6NvE60=; b=J67dTcQmni2PbHfC4EUUMJVQBJayHmMMW3ho1d4wqxu5vsuuTMe89MCTYfmqWkxXBrVjgf 4WNEe0U+nQ4NC6dVbZARhDwnQLxRwC63hKLroFiDJyB+S8teK4tQ/rFrKsd8D53uowXIVD NczLhYKC/PelXJajGQV/xXdybv89B4k= ARC-Authentication-Results: i=2; imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=GLOGm+kS; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="S/LT+9rU"; spf=pass (imf11.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=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246865; a=rsa-sha256; cv=pass; b=t3kAyx9rXbxRkhYQMCKUeCnVIlwemnRBFtdp8Z6y2RJjL2Hg0StCZjZn8Uay0xbYWi2NdG tAh3XLMQZhNRi55/Tkqb9BHBb/h3q1Ea2w+M/VY0Asys8o4/HnP7kXqwuLyP5zG2yNxQxz H3AvFc4le5h4oROfaLTks7amK4SCAHA= Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HK0l05029078; Wed, 17 Jul 2024 20:07:56 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=alInpUkHwx1KRSQLZZxXfT1SsoSWLZXvIxTDx6NvE60=; b= GLOGm+kSe5xHMd3+JFkSs+s9NYkB7jcSZraM9bl8vbkLTtZfZQN7fIaNgni8pOr0 r/q0vHyk2DiDeqnup3zhhpQt7z3pTUvhGu43Lh9a/td3WPKCJb4P8QOA4+n37QXH UaKYwAqQPlruswgpH/t8FA9FTHyGesJZVTAMQNIqFOxfUW4F+21jF0hAJ8N7AhO6 g5/VQzrSZf+6n0xmVShg0kP1tHVtAtv2zNTR7OzW7ry4lrRXNLOhbN5Vf2koo2NV 2ZsilOM8QCNJrXgNQFnCfXhiBpWYoZ1NpjHEvMLEYgsratD/qr/6b8n+cSYZCt1n zXOky597WqyWCEU4878uHA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emkyg1ab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:56 +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 46HJ4sqE003630; Wed, 17 Jul 2024 20:07:55 GMT Received: from outbound.mail.protection.outlook.com (mail-mw2nam10lp2049.outbound.protection.outlook.com [104.47.55.49]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dweyhkte-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GWSwpNNt8hYYkaPQPYySEA6Wx05kYZK1KHCvWH/cy1lEJ1fhEbQFPfrOoaqri7bABpZPk6FISCALK0572SAtagjPOrlP1LIs1++EM7lp2hHNUM5UtHA84F76Sc14yk6zoP8JILlzXBLkuaRzk7p7qyAwUYdpv175VWayWsbkRmD8RrmEy+SsIyQDPGwDu9CnrFQsGtK7wxL0CLqsfGjJSILXvuQNY9dbZaNRe+KeEmr33MhLTrTskU3MhR1E5wgnTAQdR3wctqPtcBMbWJd8FXhqr+95NePTFLRL938bu0qcyS/T1kaFVobbCoyPd3/aWMyJvs7TcEZ+bAA9T9JePA== 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=alInpUkHwx1KRSQLZZxXfT1SsoSWLZXvIxTDx6NvE60=; b=eMsRC4yXab868fs5LVJdMHUYsjTONmHJjUHCiPpHzxzgMWBexMUFq013lKhC4CzGQgh0ReB71DZbjJ0pW6PQMrbmSatSR84jM6vuhy2J3i/0Mn0GWifHmwdRS1y7Yzjc3p21TuI6uuyNJ40+8hdl9o30VjpgIPYlN93iQeKkdSdMi0nfi5Ehl54FyU05zE0GMngkdkew+NfV6CiT6c+Bp1K/SfvbnYN7TkOvaMKoywNPZMymxD/Im7kUN3FtZGGS05+bQmore567AtToz1o7Rv7laTFrx6njCuOAf/Rkw9kYYMXOE9zSwd4gOzEtk+oxBfYHEtvBzRzNFIFNTX5H3A== 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=alInpUkHwx1KRSQLZZxXfT1SsoSWLZXvIxTDx6NvE60=; b=S/LT+9rU3+vdTLZ0xZ0dSkcl5ULbi/c1Gy1l0Bm1sbtZbLRzh42phEJbmnSMtln7PFnbPc03H18/MUtf+/OLZNfkusyjr9TnK/vKjb6S5kfW2qUYt1SqFenI0nLnqQIhsJXsws9FrrvnxS0RrnUs6tuqG9WWK10ytEWu70/g5Ik= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH7PR10MB7694.namprd10.prod.outlook.com (2603:10b6:510:2e5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.15; Wed, 17 Jul 2024 20:07:52 +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:52 +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" Subject: [PATCH v5 18/21] mm/mmap: Move can_modify_mm() check down the stack Date: Wed, 17 Jul 2024 16:07:06 -0400 Message-ID: <20240717200709.1552558-19-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: YT4PR01CA0173.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:110::14) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH7PR10MB7694:EE_ X-MS-Office365-Filtering-Correlation-Id: c3c92b67-8c43-450d-5433-08dca69c23bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: KlTHHrTq4JCijQKufpxcTlZYryu7vlg8Q0TBMX0Pd/k/1q0/7pCgK7LNpmJGhcpDgK7RRkQzrLtPFyW54e7+bP6ERZCROUZRU7ZrwQNRMr9p/uxCPnVP93IiJa5CANrT5SQ93G53tw0+F510NGTPg4xJ3OwYSpE/d75fvOKZ6fUHwGd62DxZxlapY5W6QbqJYfD5QtS+4Sy1qTclV0FbvHtpv+U4ayd+5BNCssTwUz8KE5oBPq12jpnXA7x7HfPdjwp7s037OGmliT6bNT8wd+Jr5xGhrVNQ2Pe/MyqSkHqclm6IC7wbmxDm/Q6lzxR+FpjAqcGJ7JX6hKJZn6fw3H//m00nV2VdlsnrEBLHE7yaGWZLVlpmMLZf0mgAr1ZOE5gPGElaBA+X0A89mvrXixkk18tkuvByJM9gH5SD3FFiNUdhG1JaiIKo8kB86NRq9QtBe3ynocpUMjiqkrKGXnDpqiX01hEVb3R402HOIl4j7CKDpxStbqvO6Lfdo8co6DnCR7Zcyldd3acXzZpA18HGCtvcUuHF/Uj7dt8Q5T85nSFVQg0hlTNfFrUaDnSCNsre1mNtKYdmg3UHA2d+1iZHZGBSxX9MOfH7hnldcHbpKH3XTrSh9SlJhCdeai+8rwJuDxM0fZNNubHN40w1/vo0KIouIKvx+aCP12QwVm51k8JuiWNpj59jtCesbrHgoD2iTTqNCdQwbElI3CDbv/GfrVz5DCZue2PB9QfdcJ+qbOY91Aj0Y13zNGuA5yC2vbTpEUnOe7j8BP5dAoKVeSuLblfklCI2b2Ps2yWwJxOtdRiVJ9zlx3lQs9SxhE4Eje9+qERBjMOEuy0FUnd4+wZSCWJa4gNeE5d2lXLF3+FKKXJMsJ9Y7YSjfZPyQYbwXL8JCu/l6JK2VFtum/6fj4yHgHZf5nqL/uHxXPxIE81WhYrUI9XIGTuXSEFBBg1D0t35GAaoVsfxmK84evTCcYgv+5EritSnmyRnqvzsrtdfeMW9FN2NHnEFLXM+ZsBbaQNg5Ha3/eVCVLmch0AE4vploawEQFTee4ow1TFOw1pAqVMy6KhLo+XoySSbM3vVvUpUIqjA0Jr7GMZzdIgR0rUc+5iHH0PVQEaC18P15kumJuDk2yY9/zOMSqOFiBFl6tjik6tfHTEPvxcMXc2LGz3KqKji/gToGauih/cqwkHITc9i88fDjDIg2pPVvzPovlo0KB/DqmbjAxdae8OrfSgHygL4XhqcOamkytlNkclUEkvm+hESxuGUbkf/ATzsv0AZ2Wgi+piJMXswdoqAhwGPYHnrQtrmD7HNwQ5skuMRDBYhUBN637rakxrRAII7znuvuqN9FLF0QLtXzMz+cg== 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)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Kf9hry9eqkKKPG/VEBvMHSurQK+d2qnpO343TBLKrsKaJAvoBc6UQPVPmBsiFFHBnZCoAhdX+scXP93D9EKva1awFNwn9xBagwpPq6e3IgITw/5qhivP19KJYOrLJOBwXlggdVZrPbMi1jGmKSFA9ToB3asMhADaaVgVmbfzB3WK6LqegYQmftGtXrR8JHi2LmGlVXRkeKeFue3RIOboLJPpufdShk5Adl7RWQGKfdL0XCeBmIaSxOXBmTj2q6WoVzWZtv47C3cJNM/zqTlsfXU54b4ra0NrrPGERNNcXtyGbHH7mmJ12VKbyaVrfVK8Y5JGClee8pH7T8ppoWGHyUF/1T64KJ76Czv/5b/Jw6k/o1GklYYCqnCWbskd5drv8tIi+Fjv25Zp26zxAFj2UsY1lDuY5s6bVv/kpQA0+pEoN0vHlCJIcetGzMDnyHI0ea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0UCLYimM/snPQ2M3LARTVlrPY/Qtw5wgh9LoVOoiiPjMNPgkwamspOzQ2ilUSCivRLSXCgw6o2Vhx4dvW1K6DLQRAX5Ww== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qRXQXvt01rDLnh/7Ir+OD1oeb0SfNRC4YUaU25A0PHnuV9CO3R1x+FtNYL9+Bdge/rlCvmmLa720G+NbR46OVvGZEJ6vIeZJSb10rVD/zuzxrUsFvi9nnsNKmeMN/PDg8D0hsxDa7lL7QgpqeX8ol/ZqtM68BK09Qx8UFWcveGGIKonwphiLMeiqu72d+OiuSidtE9pSFzD6vlNsLmX0HAenCMHgwWTHQ3U9mbFSN5HWETyJ+lrOl1izXcD0Z3ypxxTX6tGWU+Iowb1XVRvbn1eYHQr3Y6fwCsPuU0kliCYtF606llyK8MNV6lkKD5X2ugRRXBFGoQFPw7tX88RClyS0OYGIgQbwQkNKEqDer31nnUrhvP2/IusDY93If97Po61RYEsaGyyPuHDzQx+n6zKNp2GRSCj8FnmeFCCB3qioIl9GXmV9jWR4txnkfYzD7zRzJTqkfj7Z4r76AEdk0tBeqiYeT+Qcjz9m/oSAl+vDRiezq5wr0yOrUxHhubddtP3H/sErNTLJEdg2oDY5Ba16JgOL2RCBfQfVgpj5Geks7iua1BcWBeyyOYc00qcMdDqGLxg3xBBAjjfJbWI1fEl/SVjHyGUe3SoLK/pUWps= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3c92b67-8c43-450d-5433-08dca69c23bd 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:52.5441 (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: 6l3ahmWUFFrl8jcHaQE4RWejIES3zvXD5HK8kgPQV5wDneGIbkASrFEwNQ8echd21+ZAqDoFnmAiRG1shZUZ1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7694 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 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: 5ES6hINEOpLpXYFxRKR1d7GPaRdROhHL X-Proofpoint-ORIG-GUID: 5ES6hINEOpLpXYFxRKR1d7GPaRdROhHL X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5474F40007 X-Stat-Signature: 7pbmaww9yimyy5zj3193hiua8y1bozic X-HE-Tag: 1721246884-423722 X-HE-Meta: U2FsdGVkX19Dd7fx51cl3ptALF8bJ+Eg5nSYTx0dHTfpYMLDPNX0aiIDhsEuZb0cJ0LPMSL4vnwMmkGA27pNSupP4T3jtgPmjHNz3x7ORDq2hEEU2d3xQXFdOK9HsGsflxr9CmcHnJf+pKNnQTyy0tZMs6l8hCSxlwi08P6YNFgkH5vl4xq44fj5x3xdAGAyruKhwPQfusL4iIXxBKVC7lXTu8Gef7RJe32QpBGONDuF89xTiVd4R4XVhIzw0Asuls1o2qmGVBhXO13b6KuPe1kD7e+ERuH8V8DaUCTwWe+T5gSeaYHbxvduAOyn0c6Be+B0ZIGssmtyXOzewS4NzCc3KmMwOYPM3wdqFRSjUX2gF6oQGe+RkNHhecqPRmlQMFi0wj2+F9SRe2c55u+pIYGonD1G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O5gnQATLMPyiu2BCBllKo0L1qVgYeXsMfuhSX7nh6O9nMobs8plMi2mxVrL1Q7OUAHRivmYvRfyZEFM= 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" Without an arch_unmap() call so high in the call stack, the check for mseal'ed vmas can be moved lower as well. This has the benefit of only actually checking if things are msealed when there is anything to check. That is, we know there is at least one vma that is in the way and needs to be checked. Only call the can_modify_mm() in do_vmi_align_munmap() and the MAP_FIXED case of mmap_region(). Signed-off-by: Liam R. Howlett Cc: Jeff Xu Reviewed-by: Lorenzo Stoakes Reviewed-by: Jeff Xu --- mm/mmap.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 117e8240f697..a32f545d3987 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2877,6 +2877,10 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct vma_munmap_struct vms; int error; + /* Prevent unmapping a sealed VMA. */ + if (unlikely(!can_modify_mm(mm, start, end))) + return -EPERM; + init_vma_munmap(&vms, vmi, vma, start, end, uf, unlock); error = vms_gather_munmap_vmas(&vms, &mas_detach); if (error) @@ -2927,13 +2931,6 @@ int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm, if (end == start) return -EINVAL; - /* - * Prevent unmapping a sealed VMA. - * can_modify_mm assumes we have acquired the lock on MM. - */ - if (unlikely(!can_modify_mm(mm, start, end))) - return -EPERM; - /* Find the first overlapping VMA */ vma = vma_find(vmi, end); if (!vma) { @@ -2991,13 +2988,15 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (!may_expand_vm(mm, vm_flags, pglen - nr_pages)) return -ENOMEM; - if (unlikely(!can_modify_mm(mm, addr, end))) - return -EPERM; /* Find the first overlapping VMA */ vma = vma_find(&vmi, end); init_vma_munmap(&vms, &vmi, vma, addr, end, uf, /* unlock = */ false); if (vma) { + /* Prevent unmapping a sealed VMA. */ + if (unlikely(!can_modify_mm(mm, addr, end))) + return -EPERM; + mt_init_flags(&mt_detach, vmi.mas.tree->ma_flags & MT_FLAGS_LOCK_MASK); mt_on_stack(mt_detach); mas_init(&mas_detach, &mt_detach, /* addr = */ 0); @@ -3370,13 +3369,6 @@ int do_vma_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, { struct mm_struct *mm = vma->vm_mm; - /* - * Prevent unmapping a sealed VMA. - * can_modify_mm assumes we have acquired the lock on MM. - */ - if (unlikely(!can_modify_mm(mm, start, end))) - return -EPERM; - return do_vmi_align_munmap(vmi, vma, mm, start, end, uf, unlock); } From patchwork Wed Jul 17 20:07:07 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: 13735750 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 3733DC3DA5D for ; Wed, 17 Jul 2024 20:08:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 032F56B00AE; Wed, 17 Jul 2024 16:08:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F23016B00B0; Wed, 17 Jul 2024 16:08:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFEAA6B00AF; Wed, 17 Jul 2024 16:08:10 -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 AA5B86B00AD for ; Wed, 17 Jul 2024 16:08:10 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 615F3120C47 for ; Wed, 17 Jul 2024 20:08:10 +0000 (UTC) X-FDA: 82350331140.05.C840E7D Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf22.hostedemail.com (Postfix) with ESMTP id 1F7C5C001F for ; Wed, 17 Jul 2024 20:08:06 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=HpAHzNR9; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CFJBvBNq; spf=pass (imf22.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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=1721246866; 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=1JOtMp6ytkbFmdJPiX5X/B9862zAZNwTtK3hdHWBpPk=; b=aq2Ll0IoAyZGz1H4EBxnAKZQes/XK3KNOP6JcJcT/QhxqnfPsfRkxF2FiqPaZ2p9QZAix/ EHzJ6RLqlVxkWIoCkUMtSZ0cEdMCu6Rp6NCjfA3GBCvARD9pkVNMVofMQWaa3slJLhW1jZ cNw5h2II6BnA7uoPZGAPLUSajvOxhG4= ARC-Authentication-Results: i=2; imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=HpAHzNR9; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CFJBvBNq; spf=pass (imf22.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246866; a=rsa-sha256; cv=pass; b=X42HV7NIxhrWC3Msxcz8S7qAXtNHgzRDGbrZPZheScA40zNULCfk67OjQIrUXwEe1LC4WR OvIR+8OVOUp2Ndb1eBzGzI/T/gPAajpsleZOaRtyRDglHOZVjAiVywJllFagh7YTcIc+im kBV3CH2w77UelfnxcV0FiXjmCBLf0sE= 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 46HK5ARs002719; Wed, 17 Jul 2024 20:07:58 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=1JOtMp6ytkbFmdJPiX5X/B9862zAZNwTtK3hdHWBpPk=; b= HpAHzNR9yFPcLvRudQklQI4H493/DxD7zuA3SlC5gAfc6md8ccwqp3KpPJxIfpWe XLFd936DhId1/4MF0g5XXxISSW0vykiQTRyNB1eccE32sIpKhtXgQJv7VvvhtSig ImZuvbegtX+rkj5elZ1XtWOC49pw2oxPhSMKW1Iad7qGAZzEj9ghKOoMCYDnWmFS GDNRIKlfNGvwGfxdMLfbaNhVZbTZ+QTdpyHhsYzqoAA1OBQFax+sOmfugfpFW3BY iscURLt0dtu4Iudqw9yWhPGlzejk29EWaP6f6t+2ukPUQwDgxyzTfi4aW/jbmhjC UI/V9VC1t1Rn8xminiFkUg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emp5r08n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:58 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HJEjNZ020154; Wed, 17 Jul 2024 20:07:58 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2046.outbound.protection.outlook.com [104.47.55.46]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40dweyh8qh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ye4YG2AJim55+RJiaKZBVInQ+8vHneJvfNVl7BEJapPfa6AfPHgbpeJe2ATrO4Aq3pO5BJACr8MfiqIYog6re0Ra9k9WDtDRiHlylzmD8U4ENYkpTam12/WukivoKUgt/T71iOaJdedqO51uMKh4+XiWcwckHPoT4feuYNBV7WG+LgO6jw6k2riG21M94rC4fnBIJvdE/g8OQaaA3I/IUl6c+1rqDC5H2gBkw33lCB0R/VkonIWjhU4txjKe5TGOk995zZo0WgsFQUGqcFB6aPtCebrfgF6MEz0d0hhYmmzXOcgmfBXPp9d8/eBxwCQCYWOfvV0A4m3COZVw4W6ROg== 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=1JOtMp6ytkbFmdJPiX5X/B9862zAZNwTtK3hdHWBpPk=; b=SEGHyDLGHjW+mQQvSvNK6E9VC2o76yfgxOP5pMInXiaIwPSqrTfvSiqrWDlrKpZ+t43cjozwypn7889x8kkLFH8lqMqhAbuqfMgfiPO2zVJ8uB1jquSfYP8x+T3LbZNJ8ksWs3fpAvodAdFUXHk4/KOXomr8Rb5u+AUVR7MZjQ8FcQnSRwlokivwKCWzb+OjfEcxPpr1ly0hxnWY0BzCexnR32ysXzSnrYRHJk5N3gXTdHWe7zH2E5dPZm2VUuTh9EIropmsNOwI6WdRHdNl/L1Fx6d0pBovONwCFhwWHQ02eBby457WUu1/S2JMWRYCJrmMfdMBAMyi9Oe4TXGJvg== 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=1JOtMp6ytkbFmdJPiX5X/B9862zAZNwTtK3hdHWBpPk=; b=CFJBvBNqLV51Z9DMzlTWzNRZbnFDGRNOdZLnBjdteEsLhe1c639A81pdBzY2fd3Mkfdv31yXWjYrtmdHk5hHz/4inb9jf3VSUlmz3f48n5XJn1pkn599FjVljCCePjPY0T3B2zvwsv8yQQqbd6GyoXes02TSDM0t5CBgjhuSv9Y= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH7PR10MB7694.namprd10.prod.outlook.com (2603:10b6:510:2e5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.15; Wed, 17 Jul 2024 20:07:54 +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:54 +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" Subject: [PATCH v5 19/21] ipc/shm, mm: Drop do_vma_munmap() Date: Wed, 17 Jul 2024 16:07:07 -0400 Message-ID: <20240717200709.1552558-20-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: YT4PR01CA0275.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:109::26) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH7PR10MB7694:EE_ X-MS-Office365-Filtering-Correlation-Id: a499ed3e-3afc-401a-61e8-08dca69c2513 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: sKEDJ/sRZHHtTrmXPumU5lSAlHN2+zSKMoibKTow+6ZlDjW92f+2kQ0Kt9/pU/D9PtHufMQQ4bw2DrBSBtD2vyvxZneHZYlyT8g1+VxdrNAb2Z8+YrGYoCGsZBmtKEPEaG0CAVfXuH80h+3uwE58AOn3/KFk91k1EEL03vLKgjiQRekvpf7mu9AwZKIysQ1WxdHeSpY3UZ/aBlnqr5EGn+c4lSqt9ZDZbtT3dHfGyCXsWjjN89PrnPfX/SM74H9/OyQZucSoPVZHaaR+goy+Bny5mYimHSDLqcqPlrlabwvKcgpyL0RMY2vFxqTJGseriM3pzmrHYu8dVXkzTpYzQ7P6rXSQb8Fbf8HRMlIIYBXKr8lRBFE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d10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k0ixBapY2mCl3f6/1vhOlv7rHCYjhFDINbdQINzf7VeTCjhzGCpevEe2d2qsJESDS2C3QiUS+cM1iRgtw6TwVhaiKu2eu/wLTqt1JUXbK+E1Tau/K8MeEOsGfFzanWhi/PNR13vGROaeesNtrCagx69K+IGoJKspA+dtQQBEDMdlXJL9pS4DPwlz/9pJZgLgkz8CgrzdtCsKFWUdehtX7d/qT+zQVUCx/LBnNDNrzua+vSQNITF9ORnKBeZvYJNz5t2I0XeKGp5vxpj4yAS0IaCxbr0Sk6ZypINmudDzsu+otrTlszdygUleHdr/AqZVal1EH4dTItcResrI4lCPpZFhJe+YWWqzr9GtAB8D95PqVbkCnhHBpsovNIRFR1VziO3VxOOpRSNOBsEqShOCJ7rthEolWrKlE4ZLcpx9LXxedMSTwGUSeqlZOTt97qGPvoG1vD4iXkYfRVJK6b3dbI5dLXBCjFjTL542AZTG2QUvaPj9qkfYyRr4LRglg6/U7SElQLCXyJYKm8N+t0Kvq7Nwvp2tvD2R1rSjG30cyaxFfu/WxblE+ZS3tk591kTkv6OmDv4L5RPYMH/rUU+YXsO295pFBMbfBZHhS2I9/UhFQXNOCZTLvc+wzwBOxLJwMI3f7O8caPzFxn7bwg3NSl0ePcq+uncIHzvUsQ3N1+YdAY+Rdzb00Y/EEFx0+jbv+SgQ7LbIK32a+bIXKnd90bQZYMNRAqiJqB5HdMJWegLIgraeXWbDCDltUNV0a0mzA16O5uhFyvmV8fcziSqKn7Vxzi2KZlsRCyBOiVDcoVU06Vmi7kRKWHYTdWGK3AOpO0eknu7mVynXjg6/0l/ExoWemSaNTMlrpDMjmCcwMZd/9UYKdIeR19kMmWDhg2E0vfZ1V6obMxsnXwxq1Yc3j3+JZTZHJ8xFSeEFGFaRVcilUYm0oAzr1MEp5rjvYIcrdurRLZcXWaQrz5KYL/UGdc/GmKXzqhbTxiR1Cgo0WZADb6xZ4NnFTajR8LwS6yEjvd6nZhRXsCqmfez6MePOWXci3q2b7Sh/uliRz5lnzocM8M0zqmw77QXg5Tle2NqZ5NE8A8MCDVOteUt9XJPMf1s+6UnrylCJdxhuxlkbcIiRDklAXx/7oquNZzVJMpg5p/7HJGarFJUqiXb66LMSLxznBXkbpSwWzqAL7nXohXQtkh73bbtp2n9eW8CgR8KCJ8D3tJKjGhFIqUdZBYi3dm4d7kfTkb8+OyKOz4DNH/7SDpGbz+09n+G6cjs6AgzgJBwmthGJKPMdyshmqOjp23SsZ1APIEcels5yoUNdtLqN0/mZ54TLj6jiLaci8ZtzUTGXNbcsrHvNmq4qkc5TtaNgomnVTqoVDCXxgwJ0sEBTThvICVRKoWv/1woTH4yPgot45Hp2agxnidvwoaypQMBWkn7M5sOPjud/YRivrC+LEVD3JwnGzL0Mv4wCh9+H9x3y6S9MjF+IXe95idp23jW3WSx/O/Di9yUgdT8ge8/FKpZgkc27CD+EgEp9Ib6suM3MA7vX5cz/EWhjEMU1iuQZ42CwXfJK+jvVT6tq239Npisb29keWVz7Sg83Jml2OflqGF53ruj1hCH296Ae4Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7yXKUITeRxxi23orb1uLZHjPE6ZpBIJ++YflZENKnGa6m4BZiIeTo6elpaoZBQL/ZEQLv6tI0wXBJ45k4ini8C23MgBgA13gAHa6BhIPmnIUT3WBZpJ06ttsa2GutrBk7NHP8DWdla4ip6H7MCK0yXtvAtleCaY2MEzRs78A4yydTi9hAv2dqX/+IFFmz7TRLPULAmejIag5XsV0kVg2EcN87W97l7yi2S9nzaC14WBrc80HtjC6C26kOUiYU4SM6MmjwzWv2O+MsVbqGswj43x7ApcnzDdvpTz3Cjl0LrDF5lGs78EpAkzcbu8pFUZlYQK796LppiHLdCwUyTXJnyB5CFv2/jlb02rJfAfLARMi4RiPcsX6I0JIBIIW0daukXhmrJshBaoRDeqKzQvi6mC8eeNObWtEtiQkIZZO0+7L+5uw7t3mMfkJj1qj+cSRQy3AeECMmmHcyZ+TQEOJHO1IWKHjAKIzjOBuEBBvXrLe8HrqONLauoJFF1fM6WYSAGQquhAeEEmhpe4yAFvrnVUgAJ58ThFI2ohLNNubejM4yLKCSUhBdoy8KAAh/Nur9ekzdiQHBOcyoOPHfHTS7a7z+Z8rXEfrvRLC9VAgU1k= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a499ed3e-3afc-401a-61e8-08dca69c2513 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:54.8300 (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: cPGPnt0FJv+IyJm9sivBVCZWSOvbc1gFkGLZpc1kuB7tNSh+o9SCJpVTZfykuJh0A1S+qCrpxTkpljkJebFX1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7694 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 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-GUID: z14d3hxX0ix4cqEGz7T2ONAneHPtAb3D X-Proofpoint-ORI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xxHqKrKZQAoqMW2F8bOk2IdMq3w0F9u0ToR3zKWlCsYX3Ti5h9LOO1fj2zH sywfI+OC R1zwgRM/4wIDRNuFma6bgJpFlppxQm/9lsiRV8oebS7z07C9hb5Oevj+XtXm6cnzKtRzMTp8VC5UyqNLwG4TMzRBtS5nJUFltxO9nIv7WtvHUfmOrlujK0+OYfGnAvIQbOzz/JVsogZg4fMqV8D20naRzP5BEO2DCB/NTNuTHd7CHY5mEtziBiDwozJ+PL/Pr3gzOSAi+FXeCMOH8A0YnjFu8e2/AFFZhdnSUO/DdsuSkCKC1Q7LO3yL6o+9208vOh37Br0hzIHtkrQnvccnhPAXnoQZW2mhNx3vVvk/+elvqvmPcz6YaqLStmDUBJpvpgrfOeKABplCiJGJco1k+T+MwkX59eTltCSPjgYdq+7MEE3cyxb2Ygpv4tTG7YI7VXz3VPq7FdsQYQ5mWaLuTeFIuLSeFuJHvZaJxJvy9SxbOU4n3ju6avRHahDMrP/ZBN3Iv/XPx7lbOcCkzHF/jGGHBFdZcR+L6JjA/1ZhKzdXhmAHp3zMOsQGLVDdhrGRkcod/EVFb0hZBOEnt4ogZ83j4OA== 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 do_vma_munmap() wrapper existed for callers that didn't have a vma iterator and needed to check the vma mseal status prior to calling the underlying munmap(). All callers now use a vma iterator and since the mseal check of can_modify_mm() has been moved to do_vmi_align_munmap() and the vmas are aligned, this function can just be called instead. do_vmi_align_munmap() can no longer be static as ipc/shm is using it and it is exported via the mm.h header. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- include/linux/mm.h | 6 +++--- ipc/shm.c | 8 ++++---- mm/mmap.c | 33 +++++---------------------------- 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5f1075d19600..49a24c023153 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3406,14 +3406,14 @@ extern unsigned long do_mmap(struct file *file, unsigned long addr, extern int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm, unsigned long start, size_t len, struct list_head *uf, bool unlock); +extern int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, + struct mm_struct *mm, unsigned long start, + unsigned long end, struct list_head *uf, bool unlock); extern int do_munmap(struct mm_struct *, unsigned long, size_t, struct list_head *uf); extern int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behavior); #ifdef CONFIG_MMU -extern int do_vma_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, - unsigned long start, unsigned long end, - struct list_head *uf, bool unlock); extern int __mm_populate(unsigned long addr, unsigned long len, int ignore_errors); static inline void mm_populate(unsigned long addr, unsigned long len) diff --git a/ipc/shm.c b/ipc/shm.c index 3e3071252dac..99564c870084 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -1778,8 +1778,8 @@ long ksys_shmdt(char __user *shmaddr) */ file = vma->vm_file; size = i_size_read(file_inode(vma->vm_file)); - do_vma_munmap(&vmi, vma, vma->vm_start, vma->vm_end, - NULL, false); + do_vmi_align_munmap(&vmi, vma, mm, vma->vm_start, + vma->vm_end, NULL, false); /* * We discovered the size of the shm segment, so * break out of here and fall through to the next @@ -1803,8 +1803,8 @@ long ksys_shmdt(char __user *shmaddr) if ((vma->vm_ops == &shm_vm_ops) && ((vma->vm_start - addr)/PAGE_SIZE == vma->vm_pgoff) && (vma->vm_file == file)) { - do_vma_munmap(&vmi, vma, vma->vm_start, vma->vm_end, - NULL, false); + do_vmi_align_munmap(&vmi, vma, mm, vma->vm_start, + vma->vm_end, NULL, false); } vma = vma_next(&vmi); diff --git a/mm/mmap.c b/mm/mmap.c index a32f545d3987..ca752317adef 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -269,11 +269,12 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) goto out; /* mapping intersects with an existing non-brk vma. */ /* * mm->brk must be protected by write mmap_lock. - * do_vma_munmap() will drop the lock on success, so update it - * before calling do_vma_munmap(). + * do_vmi_align_munmap() will drop the lock on success, so + * update it before calling do_vma_munmap(). */ mm->brk = brk; - if (do_vma_munmap(&vmi, brkvma, newbrk, oldbrk, &uf, true)) + if (do_vmi_align_munmap(&vmi, brkvma, mm, newbrk, oldbrk, &uf, + /* unlock = */ true)) goto out; goto success_unlocked; @@ -2865,7 +2866,7 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, * Return: 0 on success and drops the lock if so directed, error and leaves the * lock held otherwise. */ -static int +int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start, unsigned long end, struct list_head *uf, bool unlock) @@ -3348,30 +3349,6 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, return ret; } -/* - * do_vma_munmap() - Unmap a full or partial vma. - * @vmi: The vma iterator pointing at the vma - * @vma: The first vma to be munmapped - * @start: the start of the address to unmap - * @end: The end of the address to unmap - * @uf: The userfaultfd list_head - * @unlock: Drop the lock on success - * - * unmaps a VMA mapping when the vma iterator is already in position. - * Does not handle alignment. - * - * Return: 0 on success drops the lock of so directed, error on failure and will - * still hold the lock. - */ -int do_vma_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, - unsigned long start, unsigned long end, struct list_head *uf, - bool unlock) -{ - struct mm_struct *mm = vma->vm_mm; - - return do_vmi_align_munmap(vmi, vma, mm, start, end, uf, unlock); -} - /* * do_brk_flags() - Increase the brk vma if the flags match. * @vmi: The vma iterator From patchwork Wed Jul 17 20:07:08 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: 13735752 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 91225C3DA5D for ; Wed, 17 Jul 2024 20:08:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 676136B00B0; Wed, 17 Jul 2024 16:08:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FA8D6B00B1; Wed, 17 Jul 2024 16:08:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D7E96B00B2; Wed, 17 Jul 2024 16:08:12 -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 1DC666B00B0 for ; Wed, 17 Jul 2024 16:08:12 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CDB971A0CC4 for ; Wed, 17 Jul 2024 20:08:11 +0000 (UTC) X-FDA: 82350331182.14.7446293 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 5ADE1140027 for ; Wed, 17 Jul 2024 20:08:08 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oCaIEyoE; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uT53cubk; spf=pass (imf26.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246868; 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=BpN5Sb+yntfE6ooYu+FyKWdD7AXq/Jrvngs/MG7YjtQ=; b=TYwsbrMOoYLQ2i3WQdn+1P1zrrzdWpzchg486gJcYcA9a9kchlU47utkI8VFWTuZWvLBaF bq2atKDjPaX5n4eUsYF1fD6w3cWEBpsirRQ8J8dKdKEIx3smUA0aTClSosfoaxDGBU+VhM Ll9UaDRgbnNtfuXhuxREwmNrIZVoeD0= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oCaIEyoE; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uT53cubk; spf=pass (imf26.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246868; a=rsa-sha256; cv=pass; b=OSeUFtrgCna76TIcfeQ0P7FUXi6EXfcRBmpkbm8wmlZC+K0dlKgf3Xkk9NZjeV0O+4cFlv 8hjJV6slmwrNDH3h9Imq6IvIvAYF5AdAkvKPDlXJ1JsguzD2ecgeJjSPr0ENWLSp8KS/YI cNUb+uWMQKaNq+b4kY1+Z8xyUYN4e50= Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HJsRsR016988; Wed, 17 Jul 2024 20:08:00 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=BpN5Sb+yntfE6ooYu+FyKWdD7AXq/Jrvngs/MG7YjtQ=; b= oCaIEyoEOOKweepnRY/O17gDQ1KYf+NiviAOEN19MseRbz8orrvJYpuYufitJbch 8FJCmDpv2YtIcafbr88bWrj+3FwqkQW2XJflTGkY0u8WiUD07R6NCDQnQFngs4xy nam+SYrNboE9Rc7lZP+p4plijOoq1vQ+cveBCcAkFvsYBdNorzExGH0zJ/E0xuC3 aozqm6iifoVFN0TeJ1PmlwJjLYwwcGGp3Qo91aCHnhx9RwPanHXZAe/KKoNpzWEm 09rceZyySoYd0zWXHnrX3H6lq6Pj8sH86yhiJ7S28W5ybK9ZWP/gF9lI/2gdBNi1 q78t8eVEEQefJ32f0hqtDg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40em3m0344-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:08:00 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46HJFPQn021621; Wed, 17 Jul 2024 20:07:59 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2044.outbound.protection.outlook.com [104.47.55.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40dwetrpdh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:07:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TYYAjfuJEdtoe8HscfTsht7RrpE00gqgYTMaDwUGpv1Y0QZvzaOckc1qc19L9Zi3xdIpBF2wFUBLiM9Z/WAdZ2z+7TEaWSCh9P6kWUowY8JMCeT5bhmhPVjzDiN+SBKfp/hYKaG9TTd7qKi7PPFhjiBpP1S/YKPnZr3VUnxywuBRYIjvoBgviZriS5J5DkCqj2sIvH0dr4FONyRq/cGTU4T2qx3tGwL/UaY7Kgi448OpF/poUIQ+ED6O66brVUamWzeuCGZ7NP+o4pepxWRg+CTBpPPu6nZ7nYeZC+pl3f1nURNAM8y0nJnzv1J8PGjpkP+09mUPi9f1XS7Rgcf4BA== 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=BpN5Sb+yntfE6ooYu+FyKWdD7AXq/Jrvngs/MG7YjtQ=; b=pdSgowjc72smq3Wh68L0XgDgeBt7Pfp5rhdW6XiKKwX0eCrSYfuUmRwq2g4F6DcjlPqyYefDUNTLTFZYE6t56wVbxxHr54UKRqtN8TTZHIgZsrmeccY0qlNTTcv+5DwNMNkprIzDopDRol+yAS9OcTTkPuLvEOV9JnlFLJtXJtPYuUHPtq+mNhIdurh/2O6Ee5eoCh5qK/rbPGqjz6PwIiif/N3MGMp43tdAOhehwpgV8aKo3s5bA57lhbcnHDr/rw93CG8MkWZL9F0zgu3lcUCJ/BtqPGPZyqb6ATDWda1DLmrADaphxD2099WeI1wHE9y/+JhY6zELv0WGHmkaCQ== 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=BpN5Sb+yntfE6ooYu+FyKWdD7AXq/Jrvngs/MG7YjtQ=; b=uT53cubkZd08e/vKU+Xi0owlAcr+NyteekPZpA4YSl3o5Jh1Tm3byvpBzXhlS3KpaEVClu3CjtBzS89OnxrgByBO47QfWiYSRcx9bb4k9BNlmbRmX44MEHn2MgZ1peoMVyf2MLD4iSvwUjZkTTm3GVEgQfOKvCIBvuPFcg7SIMA= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH7PR10MB7694.namprd10.prod.outlook.com (2603:10b6:510:2e5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.15; Wed, 17 Jul 2024 20:07:57 +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:57 +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 20/21] mm/mmap: Move may_expand_vm() check in mmap_region() Date: Wed, 17 Jul 2024 16:07:08 -0400 Message-ID: <20240717200709.1552558-21-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: YT3PR01CA0057.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:82::27) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH7PR10MB7694:EE_ X-MS-Office365-Filtering-Correlation-Id: 6742c728-1243-4ea8-c0c6-08dca69c2680 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: d1XnepONywIkVt50e1BlPFGlOKT+LeJE75heLCj+ba+PuS7UytO9fOPEFhQCCNlPBH9FAaZNggR2nRmeACvC1PjIkCFZpOLI3Wrh152HJEZHTvRK958dxB7g+TiqWL4JuSqC/nMYEDrS64KrpPdaicaj3WocpH8TOOZ2/FJNuNtQer3TqECP8jKReRvEI0y3u7+UcVOPa7Wq/LsXge1z8qVms6jh82RciZgMLT0vk/oavommpkvupavp2PQInJveYh94dA0ehLbd9GhkpXM2kGruy2sd0B92tjs21BG8bzg77mnPgPnaGGgPo/6dVt7CS/oNg8KhpwfYTrt4CYV1QBDuwTcGp0TTnO8zIsH9S5TL4KREphgReZvNV1v6jGH6BgFIfs4vqg+8KCsp+YdsW2LnOBsP9iB4fHJ96cdtunxhcLOpiE9Lkjq7Dp8a693pKeB8pppCETfkZV99Nd5DuL1a9dn01EcyjIxB+cNQ6frrCGu1XjtloZZAxRkB4ZnEZhnCk1x5hAe+dyeODqTLvim90DUXzf/HkxR+fBB0xv0rjU5ROcD0mWGhfwpUO5cCM7TKetdOlFPutJM/BqrXtC8QG+gbNqNB5phLjjQQqPEOfiBlbnWLZ3DdguOm8jhiM0qHAM3LaYu1rnKTOR+VmYTXqJNe/1/E1Km+eLNXoiljL+KKB6NTkyqJ6Ex5VQ3p9kcEjs9+FRZt8trJmCAXBbJ/+lQNIA1D9/72NpI3uEZLCRbUlQlYnAkzmASlyOGc0bAZX2DcSoHZHKy/eMJ5sbOC+myT26+PsrbVGPFxF81tNTMxhJ3diNdABG9m0HrEhq3smbN/l82TQZvZBjdfB2b/8iBqFOt8dIjhAAal2c0cNVO6TOaVR2539SNcxW06B+hmjyOBezoMsliJSF1sVd0hlBZ3NcTTxq3KamFcdCtlvotGppGzwDDePQZCi8W4hGDB8zH/PdLqU3ZSx48r+AQEkDphy9YQfwgeMHt1vmsD/10KYBLTJtGUvg3wfQDmg6kN3CmFpd1hAl1bLDscpIWtjLA+J6wcGHu7UyfQRNJPD8QRq5dD1353ggsXiRiuUGiWREWIv2zwUzPBnb7eEnXwm8/syxRv9HOFsP4NbtfcIj8rZUR7HEGys0wl1Ax4lH7KSSlWQSdhQvPOVHC4gEeqUJw8Y0g6JXVFeuReRWVhZ4qyQgN6i5Wn9AHJJ9AGT5FOr4u4XCImK++JsgMSlBDIWE+Qk7utCWBWUNvCNXv4XC3VZEvVmf+CAIlZBBOFUymHTwOQ40qizUwnMfrTioLmIP1mZ0eESNSaBWOpujeZJ8/xspRlRNgZkJBrJYRE8QgCXVzDpRuwEWF23j6IIQ== 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)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 85KhO5mnJdpPwZ1pWRPBOPcKwXrfES4Xmos0QtJmHh+CRhFxHgAiha9npubT8MFZt2kMG+FXIzLKD0mtJKmt7gfPAWGhKLLjUFRBmAdkgcTQ5momUrl58LPWz0DIvcZn91mFneIsciNRsA12Qlf2FP5NfUenrpuVD1d9a6DxqUI6pXxCE9UNY9rzmltnswbfWo4I+5RPB6DgZeYP/t2QfD43zfLHHquQ1oJyLIicT/76wv4OUgW6VlgEFHnUF+Vw0l8zHeshO7M11GpbNb6kSlzw8Czq/RI0P85zVMaFSrsIwQbqRq5CRDckrETegDqchu7Zm58PHFx7p4KdJdpoF2NMHzJDL8czqbX8qA+VR/xs7yubHUSpQJeya5pR4l7KNrcjtvSlQqu//DQINVPEKK3mwn0r7RdA/EJxold8emJOwi12zrNIGZ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lDidMmIfFFPhA76sEUe2g/IahDnVX4RGXbxqcdgE6YazxxMcBjl4C588dREJMT/KttQ9lbMwsfPWezoUy28o2SWeosCsgbg+gBoaI/JI5w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0ukej8JiF1LNZymd6+Ehlb2vaGQ+vZTTEVdYZgfu/eMXNVFGMTzAYSZ6IjWvIbSlZkplLkE9sZYER7MaIEEqTDtmBtwOUh76pwbk/aWkU6VpML7QBNuSAfAYbXVHbBTAPjXqOi4D6uKmOQPmSf/Z5On+1Sq/9m7aKWlI6gNpXRCCMFWvzsfXkooWxTNMvCUKFrycQxKPsId7suyftdYPG9Mh5aqEiv7G1l68BPUd2aREiaPyrHIna1x1bBHvSkiIANtdvMkOsLabWRx/KWzBqudhb9PTwV4AnBzD7YPhN8JUA02U2AZDMDqZJ25IrVQPwzFXber7eVU+aENJHFaOacSD7uuOtGlWEX7tqKfUFH6+FKcaZc3WdOXKm0vqBMcQVb/FC9HwothXN8TNW23x4sjftmJOwuRvYBnxjHSQUbQ+GMhIxXBq2xRZ4bFCobTvsi+p/jaGCuAOfqlpZoLII7aRf38kIYIVwQFL7t79mCETD3lS8eSBXAQ2zbM1Xq1t/QZj8gZOkX7rJXxFqFLI3aMf202Q151PiFypJqHpa08EbxSEHIvHrtq2PYkqPnPTF6T+TlsCJXWxpRgNATdOiS+/rau7h24xFbLOFjhedi0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6742c728-1243-4ea8-c0c6-08dca69c2680 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:57.1984 (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: 8nYccWxoLGSDwzKGcR/BA9QTJc19dECB/2OVhXj+4Yn1qB3N5sSbaXCQ9q9vB1ahRavjTR+GK4eAQIeQJ6R7uA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7694 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 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170152 X-Proofpoint-ORIG-GUID: sgIgW5COgo9dI4b_YDTuOfL861fMObY_ X-Proofpoint-GUID: sgIgW5COgo9dI4b_YDTuOfL861fMObY_ X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 5ADE1140027 X-Stat-Signature: mf55xaga7o7apymjaj9b5uqmfbgc6hx6 X-HE-Tag: 1721246888-428410 X-HE-Meta: U2FsdGVkX186uOhw9NnxqxH7rRbC+iPoZNs6ljgNrgBfb5msf2zWM9eJvODJv+FEN392AVg6MB7HjmfhtPiSucM0hnYWHDBWUbux90VdREgjU/FWehDC1OMGJDEh3PSOdSUrGsiFRyDulo5ML3d+YkJuHSLL7DOe4T1iZpyAq76Vqlt9PkhMObqH68yR7b+wbRSoJT3map3sFH7o4TityHGHTciMtUG28EwJQ7pa0GMPc7+yrPmNDe7TT0LQW4d7pT8NBGYNUswdMo4HGAZWAWQpJQo2CxrZwTC2OJ1QX81SEyuRfIgO6Xa+BQBPPrsjfr1nAXLkeE9P5YXwU4L/HCJWN5PSpNhZLR6enSeugmZKW1c8JRkyHcVKpntAB6SuD87NPP9bIRc/ndh6xSgd309mV4f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DPIdUNkPqb7/QSg0Bq1n4pKKIzGoT7UbShIiZGOcwWgsY+wqJ5T4FAy4ztIX7BY= 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 may_expand_vm() check requires the count of the pages within the munmap range. Since this is needed for accounting and obtained later, the reodering of may_expand_vm() to later in the call stack, after the vma munmap struct (vms) is initialised and the gather stage is potentially run, will allow for a single loop over the vmas. The gather sage does not commit any work and so everything can be undone in the case of a failure. 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 Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index ca752317adef..5e74f5cb7be4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -402,27 +402,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) { @@ -2977,17 +2956,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; /* Find the first overlapping VMA */ @@ -3015,6 +2983,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 */ From patchwork Wed Jul 17 20:07:09 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: 13735753 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 6947FC3DA62 for ; Wed, 17 Jul 2024 20:08:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C3B16B00B4; Wed, 17 Jul 2024 16:08:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4750D6B00B3; Wed, 17 Jul 2024 16:08:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 202596B00B4; Wed, 17 Jul 2024 16:08:18 -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 011F36B00B2 for ; Wed, 17 Jul 2024 16:08:17 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 04E85140C40 for ; Wed, 17 Jul 2024 20:08:15 +0000 (UTC) X-FDA: 82350331350.24.E1D9029 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf02.hostedemail.com (Postfix) with ESMTP id B8BDA80004 for ; Wed, 17 Jul 2024 20:08:11 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OlqCdy9t; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Sfmag6f2; spf=pass (imf02.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=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721246872; 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=0FDbMHu5kyYedV4+qkYoUE3hPMV5ccTD7+pKpKjplPU=; b=uLmo9Od/7pfXwrCey8N4L9BAbeHws1Otd8ErW/A5tQ7b57aieB4U+MqwyxVqk/kxKu5yd4 Ve8jI8M/7ezNs9kMd9IfecJnpHTd3bUbl8Wt0CS3yq6PTk98nj+XiTcn8QfVxjwbQ156/A arkDK0QiDXvsHh+tMZUjuXodpFsP1s8= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OlqCdy9t; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Sfmag6f2; spf=pass (imf02.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=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721246872; a=rsa-sha256; cv=pass; b=6rKh6svs05H/gSGM7leZ4DG4FUXuiQAsQOdeCObjvEuYRqmDIAM2kLBhMKvqLLLipcf9fi mUKDYusf3yXhOGyWfh6T5rJc5Z0NTADq/4tRpVQ5mYSMzNgXkXlKxgubQRfe1F+PB+vgrB mT+hfmnrugtQiDMR4LFEsbuAiKtGfHM= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46HK54Y9023261; Wed, 17 Jul 2024 20:08:04 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=0FDbMHu5kyYedV4+qkYoUE3hPMV5ccTD7+pKpKjplPU=; b= OlqCdy9tdyXgj9G9cpmK/2j+F6G+Dqe6gO06VYJ/eokeKqxMqujBvAp2aMxXY5Zc aF4x9r8XKgpDvlKI37Krj5XJywdEGp6Mmc1nDybUQLuH7jHqjz1NmoZ9m44BBK1Q xjMtXyfBW6nQj3UzeagbN3jGuwRethaT3C2ggRuDYnPm2xBaI9OhG6NvYPGG3r42 YDwWD3JFxQNzr6OYEGudYov3mT4VyErf13BPVuvjHCXmXiO6vkM8g4QbLH5qHpNa 4ocNkDzAZTbKtIYdb3lMd3cjSKMK1jtkhf84Jf13yXjQncPD2KiF2LEXe9hhkp96 Rie4iCw/WDdcLdJj/Emz0w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40emp5008p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:08:03 +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 46HJ2qIT038872; Wed, 17 Jul 2024 20:08:02 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40dwevgjqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 20:08:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JjylnEV0Aq/gJQsQ/uLvKBLOvCnW/2z99r/BjRExPVVJFasPhF4vfkz6k7q46XniNLZg6BkLFN3TS4W7zxt9HLcMoWNJqMc3f0ZE4H5Anjk5662+XczJ/1mmtilv25Njx99TK5zihOMVJ1DDK9RRXY+2hR1XpK7kLbHe2yX+iXzqa60baXrq4Nuz2S/WSsWBoP/icChnhyWCLX0Ui7dVArxw8InWan/qonIpaBjFeVNIde4gxcIVUxtGNqgxmnNPqZ8exLV44uvBx3+oqybYpx+Q8c4/krXszxr5vI0TcLzNd1z9GI1QxIt5V5KmXY7Vzk5VOSYqX3fzHvYSFNPwmQ== 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=0FDbMHu5kyYedV4+qkYoUE3hPMV5ccTD7+pKpKjplPU=; b=QoNwtJnzNk2Bmlp1FnhX/+rqD40mr/g29EWuRRdfJ4/aVOoICPrimdkzPjAR0AgJ0ztCpFRoEAqUoF0I0VbNsSMgDFCr4deLgHVsQBis4dQFnzUStncGBpMEweozT7lS2mhfaiiWTyYMaNVNf/BIDOMoTq42anXSkiDJcuq7SCMkdnuMq6I+Y69T5DElQXc4Z0HCD/50/QZEWE9ULNSbk4pn3n58gddvUjjs8d7VVu/Xa4IkP7J9DhvSMRSUGSIyBNI5g1k9JwvFuD69RN4rCJ68Dcy8AQOkXBPglcgqdNqM7uivYQ6r4CJuZN39wiWqgAefbYDl9f5qcrnlCIVDIA== 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=0FDbMHu5kyYedV4+qkYoUE3hPMV5ccTD7+pKpKjplPU=; b=Sfmag6f2OwxphZhJWrtvY86OimBkICphB/PyHE6BZgpUUZGV2zRfem+/fsK8OndXJ7U2SX59bcEGt+GReoXhdRCAKOf8KoQ22xMfysyoHBx0kClvnC3d8ACTWYH34HK4rZvvzV/sza36W1xRgMLurb8HpJQkRHHvTVgNLFQu7ac= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH7PR10MB7694.namprd10.prod.outlook.com (2603:10b6:510:2e5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.15; Wed, 17 Jul 2024 20:07:59 +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:59 +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 21/21] mm/mmap: Drop incorrect comment from vms_gather_munmap_vmas() Date: Wed, 17 Jul 2024 16:07:09 -0400 Message-ID: <20240717200709.1552558-22-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: YT3PR01CA0058.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:82::7) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH7PR10MB7694:EE_ X-MS-Office365-Filtering-Correlation-Id: 78fbd985-9b02-436a-37a6-08dca69c27d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: mntBeOd/xwEyv98d/LFYJftjVGJrNVbRbk3hbK6Tpw+lB30iXQ7I03I32UZ7yTxGFbBHG5e8udD2CWskat9ZqQBoacy3zn0ie55GyIbQE1R7FUnra34wJ13gZQm+6hErbyc694cQ2UCenUux6CzuOCvhX3xrzDYS+x160GiTnN7hqC/b0SpesItE9i5YcYWSQvpYHXE2Hw+H6x/ELbjJwPl0kPpZlXJee3jhF8wV1gU/GVlPuwPaaRjRQKBe3iBkzsS+8JC+vT72rX1r2VQ1tzSbo0Z5vxhNG5rk58huUlum3CjxWDTs6mfmN7tu+cgRh601PYo40WYjLToJiFbOQSGys59aVIpVtRCEgispPuJzlq+QCcUAshbQo8PuyYUenPKPFOMgWyM1lLRzns5JPBWur3RcB4bZEm49rw714WcPQVzv3XUrgP3BNAw1SNZ86w7HVD5ASlZ5EcNuANUE2S7kY2DZiiY7gdc5T431MIvTfX4M1bXubI+d5aT5jIKOqQi7IcvqEEKPYqlZeD1UBoadTaVOZAfAODUopYIPiF4EQRKLubUeTQoDI0g9yRi9/scblpjZ/xTUor3I8r4Tsls5DpN/j3FQ6DIbM7+DBOpQdV0u5sAFxG2w0BpFkLF1k3ALLKE82CLrSxAvgHhKeV6rPpmh6TyjSmxpyaswCUKE5LOT1v4duzeyS/jUjWRihs3I1vRi5R581WPVGPriq9Ne99Q39EZdZzoxLXhq/XUM3Td8j4TKxtoEuVUeB5QFHY7O9x6Sf5G+ogAfOwggb0Yq7fWjLAuUHteOOqVciZF8inB9uGv7isX5JKFsMawSuwsAiiuvn5o37GtAkPkI6TI8HBr5q+zCaWvvpRH4qdg14JPaAZ3v1k+4f9Ltaptmk3I+yCxrvZ/4WSM1Dl9+xZKQkUTHLmB9Xng06wHoEuMn5fTZ5MbspfqBgq7Jpk4JG8DO5JGAM9WWnMRlqE6/V0/Gf3t82/i6dgu9XoBBZXtak3oAzmt5z31Tuuv351NVr5iy3IAuMgqRMB+A7cSryqQBe4HZlDaT9ELu+gcI4rFhheZJAvLm3Yl33b9g1e0jdzFLqYUell67VJsgjNbqiRJRUDnwE3b5EV1CZAdhwsPNuB/XK9kbZMkMeBWNNzxyjqEpeJU530LWEdbtgCPYekNDA+420OjooPKaCyfkMkGnXlRc84M6qpjHh0R9S/CLQd4GkTejAuVBGCVm/RMx/oBeuLinUNEbsrrg4pZv+gtU6w2taaLhAv01BeaagaUdhhh64c4AQfSzCuCa7loFgQpHgt5/M1rLhBm+GNufQk6P3Njlb4UX2dw1R/myKXIsmXyBf9jANTeFTBJrSeJQmQ== 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)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5p6QsE/wDegjQy3eRMU8mF9O+ZdDA/NlRR6LK9pFXaziOr1OBUJCtcd56jp2qLqle907iTQ93+ZxdVPWnfhhwcl9rRS1aq+lAiyIb98acrKOld+3Xox4+G12RDhULJV3dNMLXoDzVOQze4XkaGZAUZey4+/i/GObD+CmOgnWeq3nSPaAjzKrqzFT6PSei/QJmjXk2Uf4pq6ehbHBaERpO2j6C21m/vNXNcflfPil6Y+BtDIefc5bIBdQqTM+y+HZ/JlDxySR4lJoLS7KOUatnPrNCnx1HvcRUOkpOjga0+r9k0airc8SvtkNOWDCaQTf+XG9n9MR542OYEkQTO90dWb4H+kssyhudALdQj6IlEcLX7x7qylXDDF/pIY/8cMHwIoVe9/PQhh1xXPUasCIhmvg2tKnDxAC478sWTYzHwfhFHq5JoVCx/PzuL2PykHFBxh+eC29bTONcJEkitth5J/y3OC16SDjY150RbUoKBhZcO3y3bv/4L7Znp6KyjXX7h6xRXrzMy+itBQGScsah3MXH5zvIEdWQoxExj+AZewG+9Ojet3eoGw7cgi70YZ7Vd/1zJg99X5uCIdw34T2CBk8jn2mISrA6eCV5v7uIJw65FUuJ8pLGMQbAsqR/1qhBiZkShusRWC2JiWVf/eiCgahwDJ+22++g5hwG0k/HXG+2B3vmlmVTDo8Tz4g6DVBCgpLzgPYdwv+x6eHNVyOiLdYU4BWsiy6f82E36BQ+m/svcGisESaZZ+9rPIhkNJMf4C4D9YIsbyXtgtYGwMsia5l8DqXUXsecaDog60zyjYkJyQbNzl8Dtshvwdhwjs+pUDxPlopbGxLHEaHqx49wGhA2iwjq4Owae2yECKeBNAWVw7m0gNPeyj6L1gXaMxgHHHtHEGyh14cMKqUDQ0Q//DmML5ZFY6jxAE6mX6kt7846KfJHi7cdOvlciU252MfazDingt2lNI4wLSk5Y2eg6/JWtV09duFZsI6ZItYjOohELovabjdlZqxTb04VSIzOb36RNcYTqI4oUD1/9Jvz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HJzq5nV/Bt7NBXFG+vkCQu+XnKuNkcuUlAfTJIjEDj2+zkWcgsDEFPrXKwPNWOJffSCVb3LgR/YpOOvqQUKk3gDCFi8VxRFUZOMVA4QbrY/l7ejxdMIPPXBOBfxigkRTcfxIS3Zk+l+l0z4IcYOwkJjMKJvpce+zYZTU0HsTEkN+oTt1yESPL1f1Ykoo4vI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78fbd985-9b02-436a-37a6-08dca69c27d6 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:59.4778 (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: RU/k7UtLDrodjU3TJCoxNhJ9k9IC/hcVejq8mTrfAQ8sbmSa7Ylo8h/lWSiTeQ43Zh077JSfE8rAawPhjGHdzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7694 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: AwpC33ZR5xbBRPdPCldc6582dugGfPRZ X-Proofpoint-ORIG-GUID: AwpC33ZR5xbBRPdPCldc6582dugGfPRZ X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B8BD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pG4lrDgVPqDTp5FiWS7AeAaROn8EZi1R5OPNG409um3kt1nj3ebuUuPNhIaUsNuqd9yLWglFbe5IPG3LSW4BzJroOQpElGdw6uF3bWJpL0dfW5vWeXRXSNdOevKXxH25ylXrVHS6RvarXnlTWo5HuRa8ADD1E+sNg/4hpACRUA0eA9d8GTF0HDBL4DedWJHz6iN3u5lKK+Y4TuX2L4hHzltjcS2gkCM5os58q/3Q4CZY4iIMxPumKvs2XMxowOehiziqMBazvdODYzCahWtsoHxVqOnGoIoVsK8JCemqrAbO7jYOdhrscUDq+ymBd8v5lEeyn+edwePlbfBYnmNTZR+hGcMwzCj8NbIMj8oSr6Hm1vKVNfBMUDKZbERFuadRoYCVMR7Yp+kz/JFnoo/9W10TyBeWfEbPhh02b5jiKSc4c+SpgKvsKPvHKBnknv/pPlkVgxZrCsZPOizXAvURc2BKeGrTdeDGHAJ5yFiibsS9rCfXW5F1chb7Hq8IICUumE4zGIDFUbdzm3lgf5NIsLy+iGrRs8P9yKRSI= 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 comment has been outdated since 6b73cff239e52 ("mm: change munmap splitting order and move_vma()"). The move_vma() was altered to fix the fragile state of the accounting since then. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 5e74f5cb7be4..fa726116346d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2703,13 +2703,8 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, /* * If we need to split any vma, do it now to save pain later. - * - * Note: mremap's move_vma VM_ACCOUNT handling assumes a partially - * unmapped vm_area_struct will remain in use: so lower split_vma - * places tmp vma above, and higher split_vma places tmp vma below. + * Does it split the first one? */ - - /* Does it split the first one? */ if (vms->start > vms->vma->vm_start) { /*