From patchwork Thu Jul 4 18:27: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: 13724170 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 56806C30653 for ; Thu, 4 Jul 2024 18:27:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAC986B009A; Thu, 4 Jul 2024 14:27:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5BD06B009B; Thu, 4 Jul 2024 14:27:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 860216B009C; Thu, 4 Jul 2024 14:27:46 -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 5B96B6B009A for ; Thu, 4 Jul 2024 14:27:46 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C9536C0FFB for ; Thu, 4 Jul 2024 18:27:45 +0000 (UTC) X-FDA: 82302903690.30.44BB577 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf13.hostedemail.com (Postfix) with ESMTP id 90DB720006 for ; Thu, 4 Jul 2024 18:27:42 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="k0/I828B"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=HvGdWVyu; spf=pass (imf13.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720117643; 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=CR5r5SlcrI9HaSM6OStIkTOvAIfiXnGdaLZK//vb76c=; b=WaKr9OUgbOqaPg75yqAHvEYOPKw5U6HTP1lfKCbhL0VhLf8urSR5M5KlMnmUbjLMcvE5wd ehAYwE3YVy0HRxPWTZDkxr7XD+yZzi7DIRsj5BvcBJFlKvmlfelEEVimTAa/VYXReCsLDZ 9Ytf8YPc6fkRRaVtKB+XsLBSuzwXmRQ= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="k0/I828B"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=HvGdWVyu; spf=pass (imf13.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1720117643; a=rsa-sha256; cv=pass; b=gJXKDXeLjwyQD8pX1Wz+u5RrFaqTt5ue+phHotmGQFPfGKa9FyfIG3qRJ3Lf3cUsAAqzyo KpxTGcLrmyDGi/V+1lpDVqHuv8OlsoVRTbpUW8w7gGRKYpiPS+vph3BqIwRvqvuZLl3c9C tlqVoWDW25Y5PnW694top+LC7nmlbx0= 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 464DUYbg031309; Thu, 4 Jul 2024 18:27:34 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=CR5r5SlcrI9HaSM6OStIkTOvAIfiXnGdaLZK//vb76c=; b= k0/I828BESnLBHiZfvYiG4k92TEbEtnrRsjPeO+6gxnOCysWsKcxqdn/59qEwLuU DF0aMB8XaeJZbRRWpX3eurFiekOpc39i0g3uPnn+UToJggdE+3Z8k4anZoYrO9hM Jlpkrif3XUyu4exLP6okHxeBrhjCH7DeQJmeAC5SctwrMeel5VW3UlRf58BMP+wn LRN8/pOv3EOPEKONSYT8RP/Op4CJWXDYlifNequfnut1EHJZAeRS6IMBAlHqP9sU JdHo24MjUhB5JrAqUKUF2wIHkM7D/60CgpIDhsW6SkwoAFM38HdaqBdUb32HqVxL RDOALb3D/yMwYD3uKJPGKw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4029vstk3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Jul 2024 18:27:34 +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 464HF6rN035655; Thu, 4 Jul 2024 18:27:33 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4028qacuhm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Jul 2024 18:27:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iT3NTnDBUJ1bccDpogxpkL3EJTe2drl6FCF/v9CyInSbrDeRqT5H2SVglUvA9MF2b1dx5V/6LPx7XddMs9gp4/+K/9tx+pDvwGmfFRADgV3e8lib9v9z60THH+ApfpzlAGbnLE0O4MEFgHFAV9asijhrzi0O3QtiLkgSzAO8lWdfQaxSm+MChgYkkJCxcAjy/Wt38SB6TUaBppmbN91vDRRlqX0LQ79ksZavMaqYtVXQBxlK4NEDgXWUtSEQzRjuFcOOOy8wjcDiqLHp4FmDyviE7T+T2Vpokmb1zTek6ZyFDgt/x1f68874XzTgpXJAGEoAQR0HGK0arsd5ElbTyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CR5r5SlcrI9HaSM6OStIkTOvAIfiXnGdaLZK//vb76c=; b=lZP150JAUdvz6H8eTpiiVbOz/K/Oxv3yXSIyH9M2pnh5N17I3nrZXU20faJsyBU0VgxiO73KA4H2m9I0cANtg1YaJz54d0iKseBnSMyj3G4uw4uA34WYM2RFqCee6ICLx8r4+SV6dt6t5k/XmcgNWA84aLO691e6MjDXOWspVJA4IQmpvC5p0eqgEhagzpGZiLAkeHSxLXx5g8mt/wTQwdvaDSgoP2AO/f6AbxcZh4jUbxpz0wDIbkwlKuas1yI7OdQ7Okb0hDb7cVcKs+2Jz2CgvTDQ9UoTIPrbYShRVBHDiLOPUURuezV+ZSWwDMxqGF4PBOledCVg0VTDIBdyeg== 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=CR5r5SlcrI9HaSM6OStIkTOvAIfiXnGdaLZK//vb76c=; b=HvGdWVyuPqVIWCRgbVA0JXyvRr1d446JAYcm13rBvpqQYyT1f9ivdy61+Tn0x0Wk4t852O/nniZytnMNfMCmnDCexDeR55aObl+IDvH6lEC2ebRenQ7667gMevRu+lAWdxpmGInELddbh7yC6vnuHcGs88EMumRtd2phbS/4qQ0= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by BY5PR10MB4242.namprd10.prod.outlook.com (2603:10b6:a03:20d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.29; Thu, 4 Jul 2024 18:27: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%5]) with mapi id 15.20.7741.027; Thu, 4 Jul 2024 18:27: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 , "Liam R. Howlett" Subject: [PATCH v3 04/16] mm/mmap: Extract the gathering of vmas from do_vmi_align_munmap() Date: Thu, 4 Jul 2024 14:27:06 -0400 Message-ID: <20240704182718.2653918-5-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240704182718.2653918-1-Liam.Howlett@oracle.com> References: <20240704182718.2653918-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1PR01CA0098.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2c::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_|BY5PR10MB4242:EE_ X-MS-Office365-Filtering-Correlation-Id: f670aed8-e1d3-4459-a810-08dc9c56f767 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: iidFsdmsAN91xH90QafBtpV3UI49GFjIY/5+e0qWhGV9sIO6cCXJqLrQ1yucxV+xESEwsSG1UDmNHdNZrMf+OQ8yVV1CUtIk6+SjfZlURNuhwYwB4IX16s11oVRcafoWubDFpID8uatR4+3EB30MIBysa7RaRe908EJlhccQXH+Wra058Zn2NXaeY7FA1KhWmJwn107vrhTCOTSwTLTRWggjhP/uAxDXRdsLMRrJg8mmwsA/z5BNe1dwdD/+vwTRFgX5xmORSbgZK0n2nxV5/cHqsHXNfQe1dXI0i37abK43Cea/3hTwiyllFeLJq5McSFcJdu9p+Ulbxy/Qd4fOA/cioC3hZEbf2O8g0KJgEdft15Ii+667M5YOFYrOjEMOGQW4Gmdbycduc33FjjHPbQhpz6p6O3caWA+Q6UQXQtr4RN7+NziixAPYqIOrw6gxXhIMXOEArOqalrVA5eo/KyFpnnAgJb37Cwt6Fenko9HMIyobKwUe7Yj/nEdV4SjC8jYFPcUeJL265oHf3/FMiMVg2LqCxt14Xu/jNMWkjRhXz8bI8EHMJ/1AuWP2GG/bUnotIVuv/hTFVI6ri6CRUbBPSnOXF6gvwcZcHNUepkzD28XVcO8vNYg02naCdQxacE3ej1XcfUxpibgBCrwL+F/bctYf5XMDq7ae54X0oUI+SiYbIQvJ2UmQPwb810Cq6jd+wYTXEEaShkDzyCM8J8G4sw5O58OWFDXPENI4jB1y95TC5XR/QwtGgC/7Ea4u6+nruYsszDGY0duVdjLlYFua5k1UP9c+ZGOLQUWy5UU306qwOmrPGhNAXB61V69+UBKZorE/3kQ5Lq0PQInR4cHHG+Fr8OqbwRtwu79UDVWs8i+7ZHobN2jiM71bjZ48WbbZg/FT9+tVlYjxapsdfvGZckT79ADZxFfNGPzIAv1U6t1MRTIOhvWgrCp0LmufrSGHAQIWfCvlqCjwg7Hk9aCKCJUsuu1FT0eDdx3QBcPyqPCt4w6ca9/r/9t5/iaWPOOaqrPUbTwAFN69QFaQx5LvIFieuCVyntoXdI++A1f5a8iapW79cvepKOnfhhdZioXTrqKuOuUeHF1twq9uJh2EkeXoVtFps8BJXQYB+XBTD3nKRwkKNdQPLSsWJ17FFpTaq/ltN23spkgLlg95u0fgka9TZSoIx8GnAJGPa+sCgUAxLTw4sZxW5Kac6Ab666tk1OmNX44nxhR8d9KyLCtWjwn0ZT9PnTSvrTv9QcdddarbaKNxtsSpDk3QAJbT4cj9l17MiVMIt504j3CVrxjN5gj+8QhzzuSZxQ57b1D++eZMBOH5rHV7DXuu+qwPKEbNQ33d538n/m+3Cd+zpQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /p4oqDMQ/Ehpw63abDVFfF0CpCzWOU00SGE9Lye7N7ldqF9v53QH8UDicTRMXsEBdbmEw7NexsjdqXtjKJZHRg+v4i1SJlLHqtGODKsHcJcGDRfTEyDDU92ft8rMNBJLn0R0thWGN7aJKTw3P1Bat4eBNIInfnLFMUyi0cFGp0yimqG9B9LamSyyONLxwr3eUjWLvMuDQMAAkvE4zDVYX9H2P2SD68lDegjeM2w3SVe8NsP+K40NWNaN8ABbmo9up5fo05jtJqEg2d0fcefYGgMvWDjlDr7T/trg2KdLjk379MQ33hR6ZFtC3NefFPmiReP3Vc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c5wXX5EPKm1yMaWBwXGQEdrBy9q+NSgmG6gVmx1jAnjQ9rpIzUdtNsVfazjH5enm6a0I9XULMqZqe6nBx0NQAatJQcPRhpH7VoIu/GHkGPvkm+1KNOBafkHdcoyzkke0r5GwW/KkXaHBIJeRSKpinuVtCCQ4NCkbNl79ZGiWOCwP3KCwdaCyjlMJeKGXYa/KUDnWCR6XuewMus/1O/Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: IriLtbFdEvg/aV+AeDSUIkshBv6PoN5gTvEVquLE5HwmwZW9nnUc2V4UYmSOu8KjHqQMKjUjMxlukIcQlUVdaipekIAfFeZ0YPA6MabHHmDs7eupFqkyeRqS9aB36DuET+34Ei+umAwZOzi2Ohy5Ev/8be8CEbOTeL9+G2xJ8oprst9WARwtZtMOAl8l8u/j5N+uEjPCX3Y5DDkA/CwR8bIb84fZZqbPN/YdwDv7MCG0YRUsTJix+Y21OM/n0ERPSeHSWfEJDaw8FhghVXKHR0om9KEt0lEVJ7+GcOe+y0J1XqVu6mX4bRgTACnELh449j2lHa/1/MnhIWjV/Jnx4QB+LcvcTBoVZZFJq4mDh+2Uy19eEmii0exAF/NkeKTulpu5ne6vD3XkZEckn5xCo1vZAgTuTtJj9D3HRA6Jtjs/v8g1wyNOFxv7k6RWFo+Ig9wVWFqN5ZRfl2IVSEh5vpn9eQxsMhSOcifrVm/TfrH7S3egtB0RPeLA+R4DruENCdtBS2qHpEAESQc0ACGvIiKVUv3zY9zKYtk9X/AQOscaRMA4O/VAkHNxk29B/gd4rJznSg5kPw2YXWDwmQqkAv8nGVBf9y2GaRQaPRPmbEM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f670aed8-e1d3-4459-a810-08dc9c56f767 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2024 18:27:31.2439 (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: /UbAupT1Dxp7r7PJ8YmW82wYmQ3nElQAf3TFizAFR+yH/GS35LeiE4APDYQXmfuWP7fZY4J+wDWSY12lTXKJPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4242 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-04_14,2024-07-03_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407040134 X-Proofpoint-GUID: wE1rpxM_zspPWIc0_z2CuqokNmyF2go4 X-Proofpoint-ORIG-GUID: wE1rpxM_zspPWIc0_z2CuqokNmyF2go4 X-Stat-Signature: aahky1e6kixrgjwyusr4z68zhpgdiykr X-Rspam-User: X-Rspamd-Queue-Id: 90DB720006 X-Rspamd-Server: rspam02 X-HE-Tag: 1720117662-608453 X-HE-Meta: U2FsdGVkX19DR3x21USRZSKGh0Ci2QNhSk0WoTqKG0GoqHHAkSTE3hyO6wZLzi26zZ/jtPlCAjbolCsn73M4L7SmEUwlb2wZ7Bkh/RPql9y0KDoL/4eGj6C6EA1lShB4uWpZI5Vg3xNEwSYvBt8t41cjluGlFKCoFm2LCc/sH7UeQJnv0fj6NDVVGpGF/+ZHdREoWjMWZDo37BKgXAfmZ2IUSFYVxgBZ20rtci5M+0jyJ4G6Uum0ddZGV4ua9Fa/pUGHWRdtIesixdcmmn1OvtIQc8vEX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IVrqQeL7tuS88F6dnxcBrz3Q3l7xKUoaudcGKBjEUsIEuZIHg0jwLkwrnAun5ryx25f5iOpUAzg9yAv7N/GWuqoUHDJZpYmohn7vGt+ArULk7uvoSGh70wpDwf8x6h7oQps7dLDuo= 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 | 82 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 411798f46932..8dc8ffbf9d8d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2656,32 +2656,29 @@ 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 * - * 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. @@ -2720,15 +2717,14 @@ 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++); + if (next->vm_flags & VM_LOCKED) + *locked_vm += vma_pages(next); + + 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); - - count++; if (unlikely(uf)) { /* * If userfaultfd_unmap_prep returns an error the vmas @@ -2753,7 +2749,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; @@ -2773,6 +2769,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; @@ -2783,12 +2821,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; }