From patchwork Tue Aug 20 23:57:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13770665 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 867B6C5320E for ; Tue, 20 Aug 2024 23:58:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71DC86B0096; Tue, 20 Aug 2024 19:58:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65C996B009B; Tue, 20 Aug 2024 19:58:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E7696B0096; Tue, 20 Aug 2024 19:58:14 -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 E22586B0095 for ; Tue, 20 Aug 2024 19:58:13 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 85B961A06A2 for ; Tue, 20 Aug 2024 23:58:13 +0000 (UTC) X-FDA: 82474290066.20.BBD944A Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf02.hostedemail.com (Postfix) with ESMTP id 572E08000B for ; Tue, 20 Aug 2024 23:58:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mjDXQUAA; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KXtX24xf; 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; 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=1724198250; 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=umj9YQLZTIAO4p/q1uoqol053BLAnZXvnRL4qkPn+G4=; b=kXMSGpt8ftEW4a5Wcwu10fzXmG/5oq/6STh9xnEAKetRi8/CPAqxB5y072w3KLorYru2ud g+00gXzFkB/M0whAFSWUP5LM+rgY+SKFt7IK5uWaDoD84GbY9Bp7zwpuwwdb0lnxCMbO/a 6/vu7DTPHA+h32bBRlZLEjWVbdZLEu0= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mjDXQUAA; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KXtX24xf; 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; 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=1724198250; a=rsa-sha256; cv=pass; b=vVfIUc9//CMkK6vh4ce/YrSb3MvrE2D6wzlAoCTgwQZa2fbXpxEQBGDPUuLCUnDBiBInWE oqwq+5l7VeVPE3K2SNJHkibPErNWSmiYdI4fNtMAQxATIfGYYLIyAPWLWLxD8odYHXCtpm KaDIGjBkUT1zzrp4cneuR3EfyvBNtAU= 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 47KMBaE5028808; Tue, 20 Aug 2024 23:58:02 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=umj9YQLZTIAO4p/q1uoqol053BLAnZXvnRL4qkPn+G4=; b= mjDXQUAAtKxlXA6Hzcuybf5sAVSpYe478Gdo6nM5Ei6lZOsFEqs+SkxypGAhTM8i V1PdLSFcspy4HsISdchLUkzDRX9RkGEKTTe+a+CrhYn8vdEBPhd/uV/ZEod+z/6q wautMDQ4GT08C5YEe9nlccA/FoNJnFO0PfA/KmKZeTrvcvghWHjzz4vyWGM+nJIR YT7jnHdG/XjrQOI8mle79By8JP16tEzMtqhYdYjluYUuXR+rUqeID1HEENEB9VU3 lwLEdUD3ElQiMOta9bFYVYCXdFmlFShmph5kOcslrVlI0uKr/YQAhu2cpsdFBhc1 bLoTZtEsotdIP7HcphaDsA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m45ebsw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:01 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47KMJJCr040079; Tue, 20 Aug 2024 23:58:01 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4153u2tbed-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zSSjQ84ghEPr7NhQ1BgtgGHvm/yrCn6VhQT2TvjAaY6gsfnLEnJgy3PFWcm3Cm4S5W/E1HxZdSQj2KEUByMuJjSiio7XopuSqgrbnzodOWxPkNi9fzRA5RXB85ibQ1j+KT+QiV/gEB9KGvFMurMqxQa9Ea6r/tIGqI9NiLynewcq/8FPvQ/QgvIp2pp9f+J40Dg3LcrBgzA2RnA5rzynlX1zvOq4sk/orJgnQ4lfdE7RdzrVrftrCLUll0q2as+UWvMVVFiVZo1IBEGqvePTSo/YQm6fhwF5mBRbeNJhN3vjd8KXSCgRHdiXeYVVfGEpuO5xWxt2vCO6NGYdcpGSiA== 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=umj9YQLZTIAO4p/q1uoqol053BLAnZXvnRL4qkPn+G4=; b=rUTm1MRUvGpJ16wS9Rj9GAaetNT1nXLOJmgeexvxvxusyaiCnNxLCGcZUMlKgIiREP+0ybeHLxeooKlflf1LZNMtLqoyVCTFmP0NgTF+ppaMsrRojdKZKuvOGiOdkhWyM0G2Wu4nX8ccC3THMC3IZ4DgwF8s7aXY+N3P4056np1qMg2ENdnAx9wZ11PWA1gniltFxQUnOv+ll538CCgmVfaQVxmVsXQhpAjHgjTwOHKrJ/xv99Kau4FXODozQ1SNF+tHHd865trSdooXAS7v5jk2yae8BdhQQmNjck8Y7GLhj35ZsVRu7yYKnog9AVGDYFnXrNqOpghmhyUr8LAk8A== 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=umj9YQLZTIAO4p/q1uoqol053BLAnZXvnRL4qkPn+G4=; b=KXtX24xfgPKQP0J48zpLvRdVvZMetzokGd4CDcEfs4mff1QIRShvG10VVJquz44UkXxsNE/Z7OFBP5MEO4aFrHN63GDIqmz6SMNsPXnZULYSzXe9E1Wd03/YuhCicIRK1rsoMaaonBE27iJVqOytsR7aBx5tBWEM4bVTHRZt40o= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB4757.namprd10.prod.outlook.com (2603:10b6:510:3f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:57: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.7897.010; Tue, 20 Aug 2024 23:57:59 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v6 06/20] mm/vma: Change munmap to use vma_munmap_struct() for accounting and surrounding vmas Date: Tue, 20 Aug 2024 19:57:15 -0400 Message-ID: <20240820235730.2852400-7-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0419.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10b::6) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB4757:EE_ X-MS-Office365-Filtering-Correlation-Id: 269f7abe-bee4-447a-c2e8-08dcc173eb06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: bTMeUvEiUtvzTkiDVg+af42A5W9kN53AH3nn6uCghi8k4V9N0uWDuaFiplilMWegGNJKgEwm9jHreO2zEfdKGxBXTazT7+k2Gh+AiO8QK/oNul8Yd8q3rG8vsAW7eXQwNbj+ykGsBWcd0KioQmJPgZugfCXiDX1RtrLge9/y5/S3WRxR/HYsbs7LhWPCoyg3RSfp+WG46+JcovsVoen4ETiAIrK8PdQ1ix9aARN+4lM9epoLtI6pTuBLHrtMUf3M0qnvZTHgsimhI9fV3nutTLD29Fmm8il123kE/HVWMu8zF4fGowgNn2Vz+HTU4LNetmwdAbMVJAK8kQXyEHD0VkaxwQuYXgomjTqQ36X44tQVZPlooCBylP99pMlJ1Zad23XdLJ/mvkCzEwNCbBbp8vHqyBIoNdozfWcL4YnlGk+PqNzoZZjgF257t7Yonk7GcEn5SYzczbm66ljnLNCEyEutvC8OYrlhmXkobc1LQDhMqaEVkRklN2lbBVaIGdkvw89bTI5efImzYWwUtJYbWBOBY70UXpoeosNfF3DMICZxSFOUOUHAnD30ZqEYy171EBdLpXIYrPPh92vfZ6GuTKsJ2rPRC4h+1xg5rHGhixo29f+1m+N6YUsnzhFjcAi25DZFQyr5JTSeVVHqqJFKHIRCLgop6hVKh0YUi+RTTSA6TnISpXb2pCAVcEkvbq/M2kcK5/Pw3xqnoxKwtOc6VGOItdwS8UIpipRAepw8hF3kUk6l0AYbwaVVSgKpf8Ucmxljx+Q5W1Mp7oPuB5T4aV/NBzKk+4sidsQJcjCgjGKGXbTXL73lzQt1x8itl+nJ3JG/I90f3a44Cdxo9K3JH81APgGzt3X0PE2DXMtp2AOCJ1RRSLlMc9yYpXfQT3Rnfd81PKRV6b791tzZDiUHKVztGE4ISbPXnkvZQShI6zkanS/FwtM+OFc80qyFyTgJHnU03S0OycyIuDU9WUyn0keuzOy8xWdcdAT5ofsR8T7/2iVYB73Wf66A5pf7N1RmC8+p/5TUfkN+w2kqAPk/86A/00x5fR4pYgX+6fn0n3DC+PKxx4Uozphp8g4owFPo4GCnwfWD6f7+psCbNN3kGnXhl3WARpLJmT3OT3i3Wm6KjVmkTwONGP8xhiH1lKPL2Hbr7TNd5XsgHq3pqHKkx3kFYYkGKXPvL9xDlbH5eeBsU9oL/2XeMdVkG18sJXNZtyPIdvjWz6Iy6ZHquHGA2sH5EuU2Cr/BydWD9ihC9YHWWUgIzWlyFKLeph94MwVspukhV6q+oA1xfvjf3D1zlJSc7X1oqel/z7KFnKsExgZ0IUIRMVgTSAj0KErff2/tDVXObQ89abrg1rUnnQLA9A== 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)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BPuK9mcqh4JpsB4QD89JfFJ9Ax73ETTVpyYDwyrGK06DHW+OLsGU9jY1EL9hlV1yIFPw6sRRdTj0BEXq/AHRr1HWpMSZyIey1/DLFKiYaYqlB/1tft17FZ19MQpVyrCcMwgC624wVFXar+TX/Yq+WjtOfmfKr6r6ttATM9jiCC5WL20dB235Jo6V44j/AE71/CE834+mtsaptg1Sq+gAYQ2CgOoQ9iT0wAfFDly08iGTmoQAmsLClFpelhsRdLtE+GflTd3osbwvdtU/rOksr+9yP6OMIcFLOHX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7CNFbRKFdrQ8V1TDj8z756Zs24Ak0HKxxQvpm4ScJ449zf8nNIBJxvcREdT4bQunLs7ddTTgZtW+LbovHU73pqsgm7UxW4104nsM0jo2WJvfflnxwWcNl7N6xbb819fTqp0bd/O/3Of1gVCa9tfgurfBcAqWpSHandxAShjzmd/Cdy7g4UEH/tIhWahXsQb9Fwqc0WQjU+KMSv8zrpW+U7tKC+WcPmYe1pf6pwQEJik+ X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: UpR6DMPSbM4frFWOjhpwHt308x74kkJrW5KzTxlD9Tx2mC/4+bB7WSS9CwXAwb3jnFJ1IC2gwNM5+DLASERZJdYBSJSOgO7Q8WNA5auRWR3xUXRNSgHRb/zbCBdrkYeuoihDwEwSRjUPYipUuxfrPsnjRvgc8vVe3OppaHohz/chD0mluuK7fL6XgG+BtxbP/ob+UvqHIUJgKIoRRmTGgjLxa539JaH7seWu9s6RrEcXJXAaswma1ZppMD+ljZKjDAnvW1qlvIIb9k5c6gIbUVIqOTaTA1MZxHFaVRoXchhDA6pfDtfuDoxxd2UYdF0LnHSCPKisDs/r77dTAX3rnAnuYC8nII2mqd5n2MDE2SVdBC7R7o42YU0+wjnw1ikDWRlBoZYzN+9rcC5bKy1g0oiMImKxmjdS1hPNqMHZ0poGYKl8jr2Sv1/IyVPQzzcNTex6jEWbrZ/yDqI1AdOJujkT16AhzzlBsooLBxSte+H20Dq2q05FEd+W3am+Y3X+2zUhSDPZ39gjtPwnD5id4lWClKvkB0WG5kOfokv9v4K81uTwtc1R+gzDBEXaXOqZHQEsnC++mOskeJgCCHH3IX2M737lDRLFkK2xZRqHX/Y= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 269f7abe-bee4-447a-c2e8-08dcc173eb06 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:57:58.9488 (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: NaI1HHgF5BbWIXM42sE5dI3FoCB3ZedyS4TjJ0cI/mgipAYE1OIXYuCKFi1jyY6WrpVnV3Lg6GewcGvKuxz8Pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4757 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-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: e7p5JRB65i7T9U1pTr0Pcr8QkAaP8Gnr X-Proofpoint-GUID: e7p5JRB65i7T9U1pTr0Pcr8QkAaP8Gnr X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 572E08000B X-Stat-Signature: hg3qeremhsoj5raepgizi3hptuizccgh X-HE-Tag: 1724198289-821115 X-HE-Meta: U2FsdGVkX1/22UjUbEbChP90bYBd+syv30bKTqho5nEIvz/eBWZmggC5VdKZ0gq1KWgZ/7MNcuCBlpcQ1gVWONOpEq/WWX2mRlL/vAgZ0WNxBdMyPg9fn6BcaAPgt7HOdrQbGPWl0Nk1tnUkrk9W6cl9ZeF0B+TMnzIc5W99cXgLCB0bvzY26y+Eraw3dl6V1EHO+ylprQBuuq8drN7D7M4C7N0U7fKr5t3HfvZFPrwfDvqGHqJer5TpP2mHTIoegagfT5gJMhu7w9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weMvlKuLYBombPitOCIwB2dqlxerqdxRNBpfH+We4S293FHTxLrfrghomqLrT6npiWHPnLhX5mXIwqI2XzdYO11hU+8B1uEKOjwdFd3/D0tsT4QPmgJcUjfdSiQWE5fnRnqOJPBGwQY9bB9bDyDnrao/wkTF3TvsPv0tyKilUPQ+0iYLlycr 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" 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/vma.c | 79 ++++++++++++++++++++++++++++---------------------------- mm/vma.h | 6 +++++ 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index e1aee43a3dc4..7b8b8b983399 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -103,7 +103,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; } /* @@ -299,30 +300,6 @@ static int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, return __split_vma(vmi, vma, addr, new_below); } -/* - * 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); -} - /* * init_vma_prep() - Initializer wrapper for vma_prepare struct * @vp: The vma_prepare struct @@ -722,7 +699,7 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) 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; @@ -731,21 +708,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); @@ -799,18 +781,19 @@ 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; + if (!can_modify_vma(next)) { error = -EPERM; goto modify_vma_failed; } - /* Does it split the end? */ if (next->vm_end > vms->end) { error = __split_vma(vms->vmi, next, vms->end, 0); @@ -824,6 +807,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); @@ -847,7 +846,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. */ diff --git a/mm/vma.h b/mm/vma.h index cb67acf59012..cbf55e0e0c4f 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -33,12 +33,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 */ };