From patchwork Fri Aug 30 04:00:46 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: 13784185 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 1B282CA0EDA for ; Fri, 30 Aug 2024 04:01:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96B966B0099; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F3036B009B; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 682BA6B009A; Fri, 30 Aug 2024 00:01:41 -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 3D2DB6B0096 for ; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B9A164141E for ; Fri, 30 Aug 2024 04:01:40 +0000 (UTC) X-FDA: 82507562760.29.14C63AE Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf15.hostedemail.com (Postfix) with ESMTP id 5D45FA001D for ; Fri, 30 Aug 2024 04:01:37 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=aJ48e43W; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="g/lJOcu0"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf15.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=1724990407; 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=Lu6AtId3bBP2dooEzmFt7N2rgO4+X+ZJGjHwi2y0j+A=; b=UjtJ+BECVCYHco2uCTQvZ4UqRdFvhsz11Ggvup+GG/qBKpcs8GeAGJ0M4pyscQ9GxuTuan UARGvSGViX7Clnl3rL3Ps8o6KiKPuh9aJxH+l8PzDGg3qvEqaoszw1/z0v37yI4P6HHCTu jGmRaNRM9S7Vgr/qZxAK77G+FrS7Bn8= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990407; a=rsa-sha256; cv=pass; b=biiB736p+/09BoNrE867OWZnb2l2M+EZ7Fzo/IxR1VZwPydjBhjt1EH2zdPmWhbIBniXkj uIKwU6uv2ZQff8oTaV5el1PycRigbz3nqdkxW60RlJaEfPdVxIN+YaVGTgin8c+yg+Toii Ml4h+T/ZdtsKAN0CPKlEuIn1yvOmOjM= ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=aJ48e43W; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="g/lJOcu0"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf15.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 47U2fVNw022839; Fri, 30 Aug 2024 04:01:29 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=Lu6AtId3bBP2dooEzmFt7N2rgO4+X+ZJGjHwi2y0j+A=; b= aJ48e43WBfbdc9S7ChqawcjC1oOPRRsWYWI1suN4NpKPslbHNf9gK1HP735Ue2Wh 5xotbR/2UeAXXeTbugJaZPbuV8ND3+aM9bj4RTwuG72tmmyr9pMDuJ2UocdE/o7P Tq3f2eeGOWsB7tM+04kRxZfm7C94NJhwtGB1Pr1VkshFO+faudfx6h+KId99RzHD jb2dz0rwk2+jQocgo3VLUytlMYAk1DspfcQ9RjA6fQhvI7pC4Kvj1TEl0qLQjh4h VJ7zYuDZkE+dl7ay84J6FEJgKDVMZNo9+/nGVHEtvtsyf6IfuaAM7wgIbOeN1/Nv bcdpQtH+cGOufGxsw8pung== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b28508ne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:28 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47U3jJaM036502; Fri, 30 Aug 2024 04:01:27 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2swm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ERTfAd5OD4ZjXTg/2oTC/Yedei2Law/mkdb/TTx3lAyVrhgQVNYlB+vENXiDyr+2KdatmNVY3zoyQ039lY4j6sP5pvJJfIHFyj0kCyQZgO7Lu0LNL5tvq298C8GzBwoGGncdHknJ3FEawfVHU5tN4bGMaPR0FgoM/FerKlZTq0k/4FFJ1xOuEznFARoeefbaPbbVSwg9Vva4yE6CP3mgFcbpuPQjaIuLqQyBLJDmZLPKubA5fc3aZluqGPwlSpLHSz5CKxF6hkiw4ALA+OfcQdpFo0EaHaf0gJzztqy3Ah3Nxju7eeZs/njCaFEOVQA1Z+9VsS4pR7og0DdxMvf4dw== 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=Lu6AtId3bBP2dooEzmFt7N2rgO4+X+ZJGjHwi2y0j+A=; b=nniIUiTEk4Ma2VQ+684FvVLsMHYvYRHxlcPtVLDJUXZ0NqBXPnt2byapqhqO5t02nneUnJtHcsOZaDJ2LchtB1dzRw4TJPVfXv72BUse4ArDNm5GVEiBV3WCNatdw5taATOWnpXUwY4yDN8ExHYlyUprAer7t5gLvSZcFuFKTkVWV29MGHIgYKHbsLpgYTZWSGFnYqv951+g9AvydqthEG6Dy50er+9o9JD8rHfwjb5xanm5nm2O+R0/KCUpyngVPQHnGBAjf8cp28RIAvc4f2Pzp8vkpysZzsZcpYOTbFF+Prn7TdNe+RNPqO4TKs2xNb7VEB0KbOSIfBzZ6bvKeg== 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=Lu6AtId3bBP2dooEzmFt7N2rgO4+X+ZJGjHwi2y0j+A=; b=g/lJOcu0edZeGzEzW9LmDW6Iu0cyTo9fvIhoU+n43/LixiEbqx8DMg+ZyTVscNa2OrVDAmtGtIO/GwutJhlGh1Nx2wgiHHcQV/Zt1ixZsXr8hqI8N6c4olgoETey38CCQHVYIBjOzzdl53NxsWh8cNJv2/XmfSPgg0Y69h7GMiM= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:20 +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.7918.019; Fri, 30 Aug 2024 04:01:20 +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" , Jeff Xu , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v8 06/21] mm/vma: Change munmap to use vma_munmap_struct() for accounting and surrounding vmas Date: Fri, 30 Aug 2024 00:00:46 -0400 Message-ID: <20240830040101.822209-7-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0046.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fe::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_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 575e3351-636a-4be0-b1ce-08dcc8a867cb 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: IpQjrzZWD/pgrLcHjNFdaP0J546FcdRDD/ETHYq2zpKsV+lGXNQt5oeduQzWfN196xxxa38sjKGgB9KKMKwFStVKYbDg+ZuRINrL2nU8Io5fhJBL/q4481rsClLpkwIxuwk6YWERB3FdOf/l+3nAjSrz/wg72dWKTPwmp8fGu939SWJMPISC0s6Uf6sUJcu5TfyOiDujHrIA0w/dyQ97iCborF4fxga2FctQCDJcfv6BYHgifXsLK6U+/JQyyWYLRdu2tsp3ZEViWxobVe4FlisOSEaySKZE8HJkdrSoVKafR73KCXW5PHXMLQFyodong4P0djpciXcUyUoan6DClJoFFGMos1BwnyUVVkSKJpYiGBfYaNa2+vzojEuusA9cJkyFTUwGh40q9KXn3+g9DJYOKtBUKvQHAzDmnB2x7yAA2mN9dieBswcFxSTUoI8KGRv6fCGTCtelxerImm7lnMxE8+2QyPl2VS8gK38MQg/z7UMFbHxwbGxu9niZ9xEljpp6Nqicf5uowH9NHTntl6rN916NKfvSPnIHG5xSXwMYOxl68EH1LiTIhRuh92OKJFI5OfC5/yB3rBA8vv+iF/KY5TSd7irQrX2w0gaNYAqmJhd9tW4XY1bKdfJ1w5ERc3u0khWE3gAXEzmSP/arIWYEH5Fe8e3136qO8ET4FRrmTyTrZQuQzXX99287jHXNX8W6/ldfVSLOhcS7/IhVSgRvUGMCoiKrvPieOT3QJnIRiCtEKifyBPTAgxU8kBE8dU7tE6CetGloVgDfAJcDtA+wjhUJtG5tZ4HMxB5nWP5gaSt1ckmVWujbAJmTunphNT98hvX7SYMPyfF6H9vtOgrpeNWbOjNVzABvFNYDl/Lza6Z4WSCWwsirLtW4hNHgdlaEuhLfLfJwGju4akvuYsA/C2/cYvmAAROiY+xcuQTKKnqbTV8mGiZhNEFzpKl2VY8t/Om5+ROowEqO4WuHi2va920PzOg2ky0NszEM+kUKL8d5kv9HEo0cmd60ptQVP5WzTtF6uT8Dh0BwheUNL/gIxIfBDzWakearjpHmNH2yD3tDp+eovQ+AJXRNN8aw9OrXdlz6i/JjOInlvxK1bEBeOuvu0eiBKyyZWMQ3BOdVIM0IZ4Spms0jFgdUI3cA6ZeLFg1tiZjXith8oef4YGmh8Y4iJOOeNHTKiOszxgvEat+38KI7XuW66CkMgeng2oYy3W2MVEexwDJp7cWc+UQjikPB2SiKHCMzJybMHIMXcDaqhwhJmQr8Cr5Zg8sA9BHzipNkVbjya9orvBBi6FsnD76cp//01tUWxm7Tj5FMl3HBqUdqXMSW6CTCRA6INM6tu5FXlOg6aFlkZdrS6w== 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: lIROTDVWHlJxRkEDAkcSFkqBBnQ4wJK11wBAAsdISKIqzuLlFHL/tC7vSio+DcZbsnEoL/nc2MM9UdkDHzJ+gZuGMOG1jk5EhqNyshcbeE4YdIs5wA2Cr1NDJXA7e+izulKUS52G0mFpa8X5t6JBFl7fKecy351Rv8ittvf0c7AkmGaf5ypxNT6MLlQd5KBIvRnYXYs4SSFBnsmAEmP4uZfEPzLtYSfkM2sOoj6d+cvBIiuhrSPw6AiGnhhliH/wojue56js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ec3Mc7iES+3XMF0EXfPPYgB420vktCIZILtLj5Dx2RtzX1tidnWu+wpN4/R49cyWlrJwvCwEAY4bjlLSHvJNSOEtVfL2bX1bspCjs4WUm2ofy+CupYvjbfVj18lInY91NL65qteo8mGfC9Pw6GGVgflSLqOZYaFSXvMt6R99fiYkOGcL8m19WzEQqYuJc5zxuGE6wADA/uKmF/yRg9bnLfkt/CglGUN69K0dUtS7ioqfU6XbSUU6IOVX/Gc4RpQG X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: xcehb3/PNlst7lu6wYejJJlG6X8LOpZl+8VgvrjkFQs3vvJkQnPPf6PnDDrabuqwiNaxerr08nU51bkMTQCQzeAqNJxXFKHOJloL7Tyjg/FrBOxgefIZxhtYeF9VQRXqsEL/yqWc4vNlBCoqiqx/SnxRILJ5YkKQu0d3JdBxHzDYvOh8e6fCGYPm6KQ0dJlwmQknPYnHzHgSoR1vIZBzNtN6ZjIZfAaBg4mNE+qatd+Jb31bYoL60MuPM4kwJk6abWdXtXhaX3CSi631dij+7zJCWtmJsbvn0oU1hfKB8HuAAxsZFe39GNOyVsM5TkT8fW+W1Q4yI8tYOqpg9jzW701X55BIs5xsZ4tpTrD5BoJHyfWDsCC3tXnHD97iQKdmzNxzwciqzFgUSFrfNOEnP4LCY/ZsWZTJiWKb5kLOPhDV5d9re9YMwCm5cIHqDZS3RIR/K+2m/QT7zZx3TcnXcMSlUPqoCsWji7bBUyEzwE4JIWrpQczcR7M3dBWTgPwrvxzbZfEVzLfsbSb+yidNHcs1XcElhNBCQ8g+8vrkxfEtfcnbOTvccUuYC/isLXZ8ZL/2b8W+cdLFz+W8zs4iO5Ed/xvT4MvLb0K3ks5CguY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 575e3351-636a-4be0-b1ce-08dcc8a867cb X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:20.2381 (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: lSK2wP88qjL2baUazf1rBfe+V7YPObaUATZ48KooU7SQ3e3kLAoBBjo25z+k8sT2SKxMcAnGw6JL679cEP0kvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 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-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: s1TuJUxGpeLi_9DLnqI84Qp9tEc4UvrV X-Proofpoint-ORIG-GUID: s1TuJUxGpeLi_9DLnqI84Qp9tEc4UvrV X-Stat-Signature: 35weyatemzi97wddwgs91msen4tigwgy X-Rspamd-Queue-Id: 5D45FA001D X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724990497-900943 X-HE-Meta: U2FsdGVkX1/tus/pteTIo80HR59FQMWGDLrgX6zeAafsXpBD62xgkfkG04hxplrJoVeHHUEQidGbtKCXMVmGk/daAm0/IqeFBJ3pJ/ZoPdASmeziS40c0bZ89CnEQeyuNzQwNBC1UxGXiE4UwD5nDDvimcDRI4rz+wwnr7LhyVmFhjuSE9s0NqDZV7Dm7xqZc3jXNToxuDuSmBhMFKJFBEgaqsnlxJY65RKv9OEFOaa3MsArd4Ec72ET8D4+WJpi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udHTYg9f8+LS2RiybhgC27kpyYB2NYio5noi0eCrWbyELnO/QSowmt8TxBKOSum3E80pGSYVnKqri8jQD7KSDX3uTAovCI3uHjzKyUgvGPXIefni1Ms3wAVizuOwMcTQINxe8Zvfxgn/gW8LikZIk2wUt6YUuS+M+k1YWOmEXQa/dobaSETrhuGRph5KcuaJ7nffaeUDv2nxGcWyf7f86P8pyurPmEeJIiY5sJ0EKmdkYzoMLVLi1TO7YYe4g== 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 | 83 +++++++++++++++++++++++++++++--------------------------- mm/vma.h | 6 ++++ 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index f24b52a87458..6d042cd46cdb 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,31 @@ 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); + /* Paranoid bookkeeping */ + VM_WARN_ON(vms->exec_vm > mm->exec_vm); + VM_WARN_ON(vms->stack_vm > mm->stack_vm); + VM_WARN_ON(vms->data_vm > mm->data_vm); + 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); @@ -798,18 +785,19 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, if (__split_vma(vms->vmi, vms->vma, vms->start, 1)) 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) { if (__split_vma(vms->vmi, next, vms->end, 0)) @@ -821,8 +809,21 @@ 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 += vma_pages(next); + 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 (unlikely(vms->uf)) { /* @@ -842,7 +843,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 */ };