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+DejJGfqN6dnBsZ01q2ytPtgtd7fLlilJceyFfLypIvDsfx8YpZi5OT0S3F27RH8tvYxwMPxHNlZz78j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j2oDkPCM2i2FDX5xrwh0As6DPiIggXZl4El3Tbe7KV2hjsYWsZXORyM7FsxmN8UwRK0W4c0B1r1dEF47YojEKxl1fATMbGv5hlXDqSV3aM8ODp64Jy5JNuhtwbuYdbaJJJnJZpC5uWRYUnBPr5rgKermdyu5CP8cyusdN1A0J8gZOpUtuWqCPQC9hKCJWnD16hDX39mlJA4zY+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/MQLPlphbyboqEoi4eLOsks85gZrNqwwJ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M45hl+sHvauBhZIj2en6fzCVV/pWy8M6oSn71ob6Xv1o3BgWfpklvE2qfpvvmjM1dHAmm3TSOhJ+LS1Ewgt6+BZC5j2AMSvO9A/aGc5WEvm+CqUSCOZ8WuvIyrt1Co/BzV78n3XZoBvcQZ4zNjcaQEab9jwVyvj9lIUJLszry1kPAD4K8HytAZazc34Z5fMw== 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; }