From patchwork Thu Aug 22 19:25:23 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: 13774110 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 63D62C52D7C for ; Thu, 22 Aug 2024 19:26:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAA5780050; Thu, 22 Aug 2024 15:26:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0AB38004F; Thu, 22 Aug 2024 15:26:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 998A580050; Thu, 22 Aug 2024 15:26:24 -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 6265A80049 for ; Thu, 22 Aug 2024 15:26:24 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 00BD3A048B for ; Thu, 22 Aug 2024 19:26:23 +0000 (UTC) X-FDA: 82480862646.08.8B74ED1 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id AA25A1C0019 for ; Thu, 22 Aug 2024 19:26:20 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=hLXbAvK3; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C9mABP53; spf=pass (imf20.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=1724354672; 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=+SgEZNii7vamI+Wr52WRA094htKGd868kPJiAHCbwa0=; b=7e5BvESY5NJKY1CEM2o2471gYr3tXX5C2wYhnR1UxHMpWMJ/lVDrPfnxu06GmBgw0d+qBk +NruNrlqHIom7EvgQItUYmjws4JgzXhI4K6NSv6sM/S6IC10GKzFl2jG1IGnSYIAMDzRnn yXalTACxca3VrcmhqctoulFTysCVVRE= ARC-Authentication-Results: i=2; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=hLXbAvK3; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C9mABP53; spf=pass (imf20.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=1724354672; a=rsa-sha256; cv=pass; b=pCRqTnhGOwkj1tdoTK3ENy1nUqgdw6nnPgP4mI2oBnv/98Sq13NB0UzjFTVCl5cCYUIdae K6v0CPG2MjO08/XufIjSmzvKIHJz1ALAnV7/UbuJaTM4ZTUuBvC9+5jhoELyoR5vXHbO7T fy7mxRM/HQLlJzSkPtsFWUhOMTXIEps= 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 47MIMWwB019187; Thu, 22 Aug 2024 19:26:08 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=+SgEZNii7vamI+Wr52WRA094htKGd868kPJiAHCbwa0=; b= hLXbAvK3NkbS75NtQvpc6TD/FnM9BFdqq4+1JAWZJQH0jkhiwXVIDaOecLPLYnzJ ynVbllmPKc0+MMlbuPZVkmzmBqmr6t8PYwz3YaRyIx1qjQG2cJX2l+zosYMJdoJB ifP999VS1TWyexO/+YICQlSyj3+C/Al1ZgN/ObGr0d+Iy0BKXehCd7FhjzB+1j33 b+KELZmo95B2CX8cRPGtPI5FcsD+70/brfQ/Lz3xzhwcbd4vHEaXP3r18sanRIrO Jq8uhLeJyf2MyWn+YpRwpG2uRFW6fBzly+5M+BWkLyQb0ditX3jJAoyfIl2eYxYC idm+UgMs91zd3X/FQw27LA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m45jw8v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:08 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47MJJBvc028114; Thu, 22 Aug 2024 19:26:07 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bct87dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IA0zdRyndS7PQUlwnGqe/mtzqnw1aPzzkENiuCCFWjVY843nkD6FPi9b5cKpeY/3eZQhn/CohAsElQcjlOk43Zy1eX6ec2j5+kia2gl5MWaU36qg31/7P1Tuk8dBd4a7j4F6CnamcOFjAur+r/uUdIKLEyL778IQFXmncXBZ87UXjpScX/y0ypXJpZ1OzVe+Smw9BYI4g5MO68xuhxMxyjr2BgMqYSuYwWMFd9bq/878MOMCipvDJ0qRC0eYt5O03xXA3ANmikOKTnNmtUtaDFq1yKLSdkcHg2pXBuWc2ySMAbiR3UNyVwRIo4nf02ZIeWVH2XeJT2YiEqYMHaaQJA== 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=+SgEZNii7vamI+Wr52WRA094htKGd868kPJiAHCbwa0=; b=Pl8KLi7BGF0xlZBoRsYKBk8OGckbP1CY9NZc4cudMjK8TK5aCLV0Sj+tMp5HUVCLp1G2QI5UuPJmBLlA1b5lRiv35sUgpD7MIRra8G0EZtNzYDOHZlyoqFO7ppo8vh6fv2HI1YyJEIxLibm64sNn/jhwSKRW07Pm6hRim0xnD6jVzA65HzgfySsxNRN8xg6t3xXG1rZuq3tmmbOw8Q0peOg4w+76U8Xc6krO8jogSU/nkIo3rQe998I73wYWKbfJYQJge4UTTqlvNtnsVbTpn7B6e8E4dEMijd8is5vxEVml62HQq+YMlx4Bb4DR9eN2UGrAB3KFRHkB16n/4nZFhQ== 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=+SgEZNii7vamI+Wr52WRA094htKGd868kPJiAHCbwa0=; b=C9mABP53k2wuLEAf1X+r9YKLOIG38XD0zfOvZD1c/v/uq3I0CAQVX5/RDfqBUUamc+P3Pg0KFsHq7k5WT9Wz/XMDAN3gmjm8x3m6bRsHJ7ZLJQfWxEIyb/Wqu0aV7Xy1jBPQREYGqFUgJW57/2vw461c5509SpfjfzuGPqd/UYE= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7356.namprd10.prod.outlook.com (2603:10b6:610:130::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:05 +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.014; Thu, 22 Aug 2024 19:26:05 +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" , Lorenzo Stoakes Subject: [PATCH v7 01/21] mm/vma: Correctly position vma_iterator in __split_vma() Date: Thu, 22 Aug 2024 15:25:23 -0400 Message-ID: <20240822192543.3359552-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0155.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ac::8) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7356:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bea9c5f-499c-4dce-0f17-08dcc2e041c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: nrojkfse8nWjCvRRdZXsssK3/8SXgusdz5b5kjjsOzJXsvAPMPibyWbfsmpeGr6m89Jg7T8T9PT0V8LJyouNon7RMlYVz4fQAj33Z02PSxBEevbdJ4HFz2K8nTFgnE3lES1pL2IFlSN/JcBg3yuUEwVqoC3yHhZJwPOy+g5WSKlhzbDiDyMvanqxKyYd6XycZORJqmOra/IdeW2BTn7BMme22s/wu5naClXROKlAeVQjbRskm1p0wOyp3Vw1d+8kzxnoOTfMHDEbYBhi46lvUznnpjvRuD+CLNiGwIOvJ8wZJIPUCfJTxgYuggRos49kFIe2U6UOBx7wAGnB3RxYeM91xPheG6X17Am4Ieq/h2PpnVke9mMBYpw4T+RRjlzxon66/1o/IHhZPfqWAgBWMhvfVkjMcNS4Obtd6cOHUCpCjNSGJ/L4u2ZQcX+kSYTOtDEcWzr82tAJPs1xGXgXErmjNWMieKQAmREOnVuMeSmeW1gQiysBjhyxlMHfLDbdfNiu9RgZZuIdJTn/Lax3RzsMtQGgfYb0NVYWJht43OELvMSmoYkvH2DsZmGvoVbMdww8cOi9ho33S212+gJbbiGGvXA5a1H2JwbPPNKrmCvWxFmdrrv2lttzBuEPS6McgeIivRJc/2Z8He7BlEaUDS1XP/DfwbgbURi8YcNFIBB8YyP9ifM53CER6e/bn2oWaq4MsqlLG+UC75EV56Q1PuBbX1XhIAGZX9ONCLizPQT+kMQ7q4qp9/qewME/jMQS7AxtClyRNn89CknRMNrCtwBdzCWM20cvA5uQI5iKk23b5KOtnMndJ6tqH8U0OLCTrFvnPhLkGdOrw5DRXuAQgZkkMFrxNXR3Av3r0ZLosNEWrq/723w15BW1O9UJuaJr5RI6NGve1tcvoDJvjVxmbhs3L83Ew4JSypfb7TMvMBWs5yEcVI11dc0FocXonAbCM/TA5J2EocnYM2vdQIFK0JQUYppgGD/SduN71lSit55/hEOscnGgUaJXJBunbzKVg7+ZaCOh7tYgf7Etp8Gr1W1E6TMUmJ5Ob0wxSMMRFIr4E5jz09pEOAOqXUf7UkCszE6M4wRq1axFiwNIcsKZQwNCLAfRBUYpw2Q62Y7g670wyauLG2bDryJGS9NF8VlFuQshYykdauNddt6JLRlJUzrT/de8Nozk18cvAOVSMTp7icpUzxR7DOEGo1BFflhyuXTYaVXdUqGDiNGqalxGrk3O/5Vv++vnNKpRuJZg9lI49bdGJcTjKLAAtYOx6crmJGFmnEj15hs4fsnp9qUVUhCHIwX4yQdVoodoiVcwYob6leDur5hLhhNkBTwYUlOj9hVPrkYzpgz5tRFCJVxS1g== 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)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z9ebnDYdFG2a88J8qCAsaGDqcYkuHw4eeUWqdiF0gFO5NZZj4zv368krdcCEnO4e0XDUiFwe5FAQbw1zsr3iiAEMtfKIYFgdrT7b9YhwmKkqagX7mZRh3LrPk3pHLAbPkXrNdzF+P2RUa90kfqZ/7PgSDMlmDq+OHIrZfqPmX7aamoUTXXsheQqwIctd7B21OCf1m7oBA/nl2aGoFqE7mdiJEa8FFiUotczUzt24GvstEvL7791Zb3oU3bLUKlGT8RCp/5PuQny65yeULAPgqCnO/AFWNCnecD5+5O7D7bxrRdLb03tsOqpZIY1VBFA0u41vl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1RnRkVyYXuPRZnegMEzQekzhvc1+nOmEFnh9MmDmKgyaQOCVQNC7djEDhIpDRZ7Sjar3PJyH5dHTrvUoGtQd3UwPDeudrCaQ1MhApwKZevMW9L6OuhocarTAvr+o5WR32EBPVSz1ZX6hB2CbKcqFcjB+YkHIMCyCNUSqbnt2VcwablIhi9hEKcqvUBFMO0zRfL02LCfe1FlNX9MqEgWQjqOQnJZg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +qh3KrdtlvkJW/kb4UCEdgADbMkDE/+PSQMLDCYCNmweVj3cFcpHZ5bfosMBh18bqjKwxHw6UarDI6CylinpQNThAwbf7TffdXs950+++NtWFhW04C6VQ+7kvyb4beNrQlZm8PqHCLBJ7LQkepnV1Ym9WgF5vBtoqljwM7WNqTDWbjSoarBoZE9GWiGbu0MyavUDPM2Xuy52DlXJUJ9CxNKuQjrx7zZSmGb3OQcw4VzEikPkAJnBDleoQqPXMJdLT490yQ8Tc18Me6/p0lB68qoxBvpq9eONJalNrkWK+yEyEcKOP2p+zI7cywKW6lpIYbb55anr3c8rApUkVCk8sSzqAQFEjExUKKbOSs7ZrT7GofYGA/Tlr5nh4Umal9EdB/+wHz03tItlMnNubg4iXICWQsX5qQNaPFZm1AQp7wHD8kULwvDjm2BuGTe7MnADgzquTZzLOVFT4SGo7QZ7hLQ1sbqSN2Ksgthyz0mq8pPi+n4QzEplFhcV8nJmCs2apwdqyZVBXCF+g4U3AI+ihcuO3JpDWPKh9uDr6kTE5gQrQaxV6G4PTnVKij4Tqeb640omU4iFyyOj3b1q/pViWi52ctPCErPxWKX0MYbKu/8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bea9c5f-499c-4dce-0f17-08dcc2e041c1 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:02.5333 (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: 19c+xLbuu8cD8IvYxsyXaN5sp2Ej6TAUG/Imqk/Z6/qSM6zudNhgIvTddtJfX8cItOBQ4/KY4TjAMULEBAM4SA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7356 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: PM4w9XTmSZB4njjbw5GPv7D9Scax0FBb X-Proofpoint-GUID: PM4w9XTmSZB4njjbw5GPv7D9Scax0FBb X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AA25A1C0019 X-Stat-Signature: y7msje4r3saqfm5pihb5fs58oedso5zd X-Rspam-User: X-HE-Tag: 1724354780-943845 X-HE-Meta: U2FsdGVkX19U+ZghdXYM3AK9FQvQAcxa9IHkcjfdfOxh7+5dm0+0dARM2ca55SpBlkiSFnNzWU8EiaNn5WTyxOHoUW27toPrh6AKoZNdW1nmOlG/1TYn1/aCUNGbMcxjBLFEUqYEJgswvlRqEIP/PlhdijU2nSPJYYOCdkCH+lmfhtYwRXHcHmFbxWpRcCJMnO9CaDH16lqKDQBPGD78s+5ErLIRFeG0yEjePo4N1a+VHbk8Ksmrc4tM4t7uy7Ohbs/s7gI0rH4Q7xJfMV1/iBy/LEoT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xErPqSAe0xG27dFkwWcPfne3EeGpsGZ+CCXhEgEPtR7VlXAcQ7WlIa9Y4u6ydpAsAwguDRSs5JLwnklzQBx6To6oUt45wqSons8MhSTIqiPtFQXGr/1J6ks5Ww/uEEXX5rGaXKKA8yrhxR/eeBom/Aa0f0Cxs2SZfcF+Zhws8Ebolfx/radLDCOqwBVsmcoElZqAAMpT/PW3Kkrfj2A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 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/vma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/vma.c b/mm/vma.c index 5850f7c0949b..066de79b7b73 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -177,7 +177,7 @@ 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) @@ -246,6 +246,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 Thu Aug 22 19:25:24 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: 13774109 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 D25ABC3DA4A for ; Thu, 22 Aug 2024 19:26:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BD928004E; Thu, 22 Aug 2024 15:26:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26C4A80049; Thu, 22 Aug 2024 15:26:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0710B8004E; Thu, 22 Aug 2024 15:26:22 -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 DADC880049 for ; Thu, 22 Aug 2024 15:26:22 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4BD60121037 for ; Thu, 22 Aug 2024 19:26:22 +0000 (UTC) X-FDA: 82480862604.10.902384D Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf21.hostedemail.com (Postfix) with ESMTP id D92CE1C001D for ; Thu, 22 Aug 2024 19:26:18 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=gKQ8utzl; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qjM7W4vq; spf=pass (imf21.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=1724354738; a=rsa-sha256; cv=pass; b=FupyqOjvk6h3Ghob+KUdClUjC9ZYJ6YwH6jgeqtC0i1sRbvhkBSCIwuPY0D89l3vPl7TjR yk2U50B101DAd0YHDDSpVQ246aAOnDJRSAZDw2BDrB1bhdZ1YiBWhVc+4ri+xn3FGMOiTK Jb6x59F71iwfNc+/GG1jFyFlY/+yVEc= ARC-Authentication-Results: i=2; imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=gKQ8utzl; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qjM7W4vq; spf=pass (imf21.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=1724354738; 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=WZRaFvqKhmeZGOgIn0cNM+Fo1hKAtKZhH+jC5oCYViw=; b=n75tVTS53cBeBbIpWtfM0sdVDQahCbDm0wo75/GP5Jq1/Y3u7YZeOl0rREjkNQfkZEUx8g m8jG2ncl8Ot0fIBWxq8nZCTWyl0ipok1XvuIwrIuWQlqqq4j6D8bMWV8lz8T2p3akVn12z 00TOfrfaFhqtlbIrVMSxrovd/G8aCpk= 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 47MIMWus029723; Thu, 22 Aug 2024 19:26:09 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=WZRaFvqKhmeZGOgIn0cNM+Fo1hKAtKZhH+jC5oCYViw=; b= gKQ8utzlvjAp7q/BXzx6kIa/c8Y+gl431/Q/QT6iHmgi5C3CuW98YVjF49dgPQ1g 7GCnTe+C89NyB7AlL2muRv8oqhS06nWO0H2fcIfCqvDX20v6CSEtw2yHw3NH4OJO 3iv+SHeiLK8UbtDrCR2o8FoA8/cF+wgfE+6mZmWqGpiFPNi8oeQfLWKmicZqlLrl VKw3BaNko9hf0pfiUYbQmldCl9Egv3Y77xCpEJfj4RDtSHu/QGI6IXwKToBL4OSr VtPVdnWriuXMfwceTY9mUubPgEUdaLEvRQlokJ34YBcUxMK1PZwgGpJzx4kG4Bsu yu+PtoIFjVF8L425CoJlIQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m67jrq5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:09 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47MJJBvd028114; Thu, 22 Aug 2024 19:26:08 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bct87dg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o/5RILsvsbkzSgFGAvLWuaqrqWSAo7zjJHWVfT2AECMZEIY/GusFJcRv1A++qJ6LCHPeAHCACas0u8Qc6TQUscu822L+p5vUB1DIbJPDLx+sQt1LQa9tm/sHh3+T+6T+ShVLpChEXp8tkarPr+VkRH0q6QxCGBEy4wLnpMiU14iqpR7kF0AEryp4gXLYm36KO+46zc/aprgJpyQXJfbBb+OLoFUybXcdvdIpUZgGJNxo6FvXP8TvT3DktFTC6mLnuxOQHWnWH2fEcJvnguAFGY/7GQFK5nl55nxmyaMlTZ0c7XeS502rb3Odud+slO1bsmJIvGMeV7jyL4eUKuxG7A== 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=WZRaFvqKhmeZGOgIn0cNM+Fo1hKAtKZhH+jC5oCYViw=; b=b67s7NdNglawLPDU+XXY15wLMiWKPIRtZijQzf4p0RPqo8CrXNg3iGhu9QxQCuW3BpE1vbnwNYkHcpYUWPjw4OMjWRGYqrk5pFzqRxh+TmcLBd9JAtIzZcZ2lDolMyiQMqjdQvzWMgFdlnKbIerAmXg3AkbROjQxP5a2OzCEeqbcH6E42bVPkReETJYv0+WX/M03bW0LlXO30CcvHwea1c0JdnL8Yh9Vlhg3QAWJYRPYr8zkckuqeHYtRMwmhElhBYWXdlK5XbLSY50qLJLP4t/8dctSjDuP5CQX4jddBvl4mjhWEQ17vAoQVg8xSrlQmlHIU5d8pO5HEdJRiF2vGQ== 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=WZRaFvqKhmeZGOgIn0cNM+Fo1hKAtKZhH+jC5oCYViw=; b=qjM7W4vqgKe2obWs4ZKZXwX6FRdhrcovjRMUXtz/2KMRpZ5my5PlefUxfXtTEoyep9zquE1JMmszgue075NiGE5TINcc7Kkwww+Ng6maTNQRPUPJrt7l8oAA6NkZ3FBybDQSQQgb0zXRFDr4oi9cpM4WMVpUJ8NFoD6xbsEgvLI= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7356.namprd10.prod.outlook.com (2603:10b6:610:130::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:06 +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.014; Thu, 22 Aug 2024 19:26:06 +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 v7 02/21] mm/vma: Introduce abort_munmap_vmas() Date: Thu, 22 Aug 2024 15:25:24 -0400 Message-ID: <20240822192543.3359552-3-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0210.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ad::13) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7356:EE_ X-MS-Office365-Filtering-Correlation-Id: c1b148ec-7f5d-484c-565c-08dcc2e043ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: xTv0v7D9RIzdzqhD6DGwmbwTb91fnz8kk0oBaOOgJDMBK2ub9Hg+goUVkupfM4gPmmCTQ6M1u/iPIx6fc+ztjWexrQ+OPPxWt/rghGU3sqTVtO1mSxKEDXLpx+RNT6OD7BoEACUWY31ssvizPFfKX6he9cbBb5ktFO0n0EADm1w2mDXL0sLS7Ok7/uk37J+iujTRozwr+f5TwYDNLns74ydls3PMJpW8pWXY17RDb4pOg8396SHBQ8J2DVt4tzXL6AhPxi0iqgOwJPB4RUTCx6C2ywwmbDKLJzQNYNVCztKuOeYDli9GgifNXa0qbG682iFGBzyI8RTBxwUkuDLVowmZnSVMe/CEckyctTK6OeXvDYPo3beq+Q6qH+SIHD6uHUxJ4zLCtMbxBShPScJlMzucOKHAndzeWGt9iepKVZ0F+PS2HfAG9mHUh+gKjiLcS9V3VFqNUIWEAIcAZmzbdrCNFSOyYxiR7KmSCqhFZ4JXg05JWas3WYaatf92CxTXFG8P2j+4PmTBSDYREivoPUNEK1ru9rA796F5N3eXvN5Z6Tc2a9+E2wiJPzr7kQOsDQkwiVAdUG5MoyqqwxcJ+rRT2mg/MHNEJ8ILY3lQv8z64d9L4Avo/a9rQ0eUKmMSroFSMdHgdENGWrm2L4UqF18Z9ZBo3YtAjGEOAWRLlzBfcou+mAVrG/jU4/8pK5DLRMTMHVrO561W9uL0kEx7xMLs/rojmbsANiHOVYrMp3GpMVHajObbO3wPgtoO3w/oa3JAcJvSo9mofBfQLULuiUrNxXAVe+XcUNhlW1KjymHsHfNceWYmUXWv+kuSOOBVXRsj0eAxdbHLkFE3Z/CKfTtLBcPtyFFvwDZVBKKSdJXkvLCGBfXsbH5qcyAWWnsLbUFTnU7QsvSR9Uwq9jd4v79wOsLcGdh3kWI3pUp9esDFn9oFNin49izqqacojJMSYHIn7sjrUAIFqfXkTiDx6mqyQh1NnQIkDoLn9UrCwbpipuOZruiFBDPUy9Hvv/WB1PgxaDBjXlEbZU0UZSVNfE3mVFv4pQJPsoSrUjINkhOtwcmPEOnWpRR3475ao2LnwDd6s+/HELWSoITSqGiItlHR9IEdCxw+5IKf2ewwGb0tU2aOCxE5GPI8eKimqq4jZ66sazkd0M3eRXkyE4br4Z96OCQbKgx6bO0qE/BoUn0OfatFGHQpbJMWS2cGzrOApZbOli/JFhz568L2XrnQvJeCIAmmePOrVWIS0f1RFHfzMtFLpmvpVQxPnc3RoEf5vKbGCH/NCHR/QILrtjSTmJzu0XYG03Uzd0+n0BmoBn6OH0pbueX2/gEg1VHEt8TB2jW3E1kbW8W+6yKhaw9rew== 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)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wO2xlB8Wa4SFdAKRQzSo+Fe8oajBTtu6YDdihygTnV0Mwccjy+0VCwI5ozchMl8TNIyyYLipqL0pR5Cyam95M6pE3C55f6X8QFoU32oqI3TEClpqTh3R0ulSjtuKz0A8vqOCA7AJAEB5qwVZKvZp7PgFyw3dr9cJSgTVoA4xHtCZ99TVOU81/URVzUaAXlfJTBcoqRFVDrc2h5u4Zprjk8oOp8ubDxG/zr8PAyt5Zxdr/GIgDSdMsrFHF7E65WxJXFDOAERfqYcORb2f/DZi6GP1iLalPv8eKXJ7AUEBJ2eTPC3BKnm7/zj90GLtwqncbrpQ2REMsqjL3rt3ZlzTdXbgSwQ7dVitjOLc2xu1V4tzwvlzapaFv0G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P0OtvEb7oCo3qka8L4zSVx7q5Uw91bucNlwollVLUr4EN/FWXYW/iclKKkmgTEjP+P40YKYcvXo6uChHRCvy3n3TZ9pR8JP3jYhygfFWWFea7+7CiXN6vU5Wtw/z3zbjP0JOLQatHOADp5tnhERy3mNXeaquRrQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: soKAiaZhohOoEd+jemYB+9M4civjdqm9PowouiAddtMFYPQPaSjjsCxyJRdRkBri3IvMt/MmRSFocpPCF0OdtXns3nQDpABTkfwsK2zQttUqh6PYXlA9dJY+p7nT6S4HMA7q6NVi5eiSW+wflCy4uEgvgoKDyFTUJWJlwU5heaWqIpyIwIZNDJ6GMg0Zs4k3u45tCSsjy9IMpVJwlXkCblDGtbCuIJQLlI+3fZ42zM9ya4lP4YRe42gChoGp02KfEpjFUazsUW8fpU399xyBzur1iDzAQIvKOFCwLxi72b7XL2Xs1kdjR6E4/3nreZz0R+xghQqYs76EKcYmn4clXuq/IibJiACZ94BkT9k/kVWoI/QSGrGO961mIR/wLI2gRgpQzAfZKkQNKlZfmK3RHh+rI13vRt1kyEUZkUaPeCkmKNnAccNkBk6oo1uyGskCrx2OMnK0VGEP2aByin53vR+1L8Nc34CSO/3O5yARcf49QGXq4acaLcyWFll14DQeBwc5zhnAXp8FfoDidoF1bzRiVMR6NPINGnXSxkORW5/y2fEcSnJVmGyRAS1J6kfm9xA9RUvsn3QyjrwYqIHBa1kvDcVNPTY8iovyFSkx5P8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1b148ec-7f5d-484c-565c-08dcc2e043ec X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:05.7147 (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: PbejhqFJ5G62Ya5rg1btcmSORiq8rBW2Po7iRwGFCizdf7seSvwRMVRA5MKj+UdxK3ixZ3/u49TvvstdCM9U+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7356 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: qO4n_krSUpo-SGONhQuPymv_sdg4C2do X-Proofpoint-GUID: qO4n_krSUpo-SGONhQuPymv_sdg4C2do X-Stat-Signature: xn41ozybnzgyni1hqb65w95cgaoiremc X-Rspamd-Queue-Id: D92CE1C001D X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724354778-678433 X-HE-Meta: U2FsdGVkX1+Vor7Y962nZUTggZEY4g98/0ZjQhgYuRq8qmEu9oThOAKYMGyuLc0Iw3FeDsF7Z0eRG09GqRFs5NEaETTJH2PAe2Z9YDKLMHlDTV2WGtaat2lp0h/UcuG2QpJAzKM9g5GxZhuVtDpy7iA4i0LuASXMlMzbvMVa4dhVqBn5IrSfjcatzvy8ZapZHW+CkQl50de07Uef7Dh3O1GuYQDUPrUybQzogFW6vVVinJIIMqLBix7QjWxIFFoNWby7hWn1yZ3uLi11VpOPz1v2VQ+DvITYZsJ28xKptAu/CUF4S5Ix4SwZIE8hiSnEMvuDsh43rc8fd8LOt9S4RQh5Tbnr0ymptXhgctO+6g8VVQi1iTEmo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8pWxYWPErlmmdqdL7oK5JlYn9VubfjDNIQ53P/qNSZfTc8CeueplNu9sx7Dz00VWAlxa1GMrMqH/KXOe 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" 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/vma.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 066de79b7b73..58ecd447670d 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -668,6 +668,22 @@ void vma_complete(struct vma_prepare *vp, validate_mm(mm); } +/* + * 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 @@ -834,11 +850,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 Thu Aug 22 19:25:25 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: 13774112 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 3751EC3DA4A for ; Thu, 22 Aug 2024 19:26:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5556B6B024D; Thu, 22 Aug 2024 15:26:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DBF36B024E; Thu, 22 Aug 2024 15:26:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E4706B0248; Thu, 22 Aug 2024 15:26:28 -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 060116B020A for ; Thu, 22 Aug 2024 15:26:28 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 71CDD807E6 for ; Thu, 22 Aug 2024 19:26:27 +0000 (UTC) X-FDA: 82480862814.19.F44F358 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf18.hostedemail.com (Postfix) with ESMTP id 0F81B1C000F for ; Thu, 22 Aug 2024 19:26:23 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=dupAzYIT; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=pXYo3iGS; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf18.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354767; a=rsa-sha256; cv=pass; b=IY3RYNH8Jkvxgzwx9Cnz6NK7DSjCcCfXYFPdamgdi4VYVi+4rXZsiLso24vCdL1dzQapYG zCrWVgiviqYNdo/bwk9UKAkgtV3KdaxBIKWAwqLGsyPtLUC4YCOmvBUZkaqNpKC/WviOtt SzgcMJUjrqS6y9Tw2ZBpxZXGNZRnm5Y= ARC-Authentication-Results: i=2; imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=dupAzYIT; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=pXYo3iGS; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf18.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@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=1724354767; 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=INR2A1cBDUV4GAxtVOjXNUJPR3TPHjuX5sIyohpW8AI=; b=wI+y/VvIgQedFW8vqa3tqkQ70IoCenFKfABzScMnTNqAyfZNuN6mKE25nyLsN3CjEDtJHu 8xjsIH6qwa8NM0HIkezyRI+chT2qi8MrNO7Gir7XrfsVJgXMfQapO6o6KLyI2D1tmRoJDr KYU+Isfd3xelxy4Fa2CK7+HzfySpgkc= 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 47MIMVOt026316; Thu, 22 Aug 2024 19:26:16 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=INR2A1cBDUV4GAxtVOjXNUJPR3TPHjuX5sIyohpW8AI=; b= dupAzYITeS52BILtOjtV4BO9piYoydwjSEHsPPgom6f09JOJXK3tFGGtaRS17R4o r31+J72rZrMLmIx8gn9UEZJ+ILxAhRdDPatqmfuJVfHkQJ4m5GCJHHLD5qtqK8B5 VFY2xME4OLYjjimR3T8AarTlk3El3ATYOQccT2ONhFbpWOc0kkyMhl9bMAzvLN8G rAe7oNzKMc0fncSGuzU4fAwNsgD7ZpMSTaOMCbhXkQ/7I0b/DSB7op4XB8kAZiGy Bax/Ry/kAAW9FhzGpKzGitXRR4D93sQ/NOxyg77lU8B/iFQKTHSvVJ2Wd21lHgJx 5ReKH7JzGucOzF9iIa+GrQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4v2w8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:16 +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 47MIqZYC019418; Thu, 22 Aug 2024 19:26:15 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2040.outbound.protection.outlook.com [104.47.57.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 416b0b9cbs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UI0cPL/90wKn3BMv+7Auv2sai2JAwl2UhLlN1j9dECQgO3ZapQW77QwJW7jXTgmJS0IJ+2IvJfnpVlIU6fJXbMOu5WLOWaCIGJeq41Ad7/hY0P9ppkzRJbUSbPPprwcs/eVz/qhYaTnX5KLAX9+AoL2RjLac5t1wrQknnoLgc7gQ7pDgCL23+LX6TPIzeR1G6rXUNXl7WKVs+NaqqEQU9fKPDvXB0t4Vj9PDQpfKSwl2HBCm6bzNw1wyYWoh1x6l4sx5jxQ3eEmP3B1KFTJL5zlh11KOLG8fSoIuXek5u9rwf+vxbl/4mX5xlv379q1WMOzpjsj4u2fEXdqht35Kcw== 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=INR2A1cBDUV4GAxtVOjXNUJPR3TPHjuX5sIyohpW8AI=; b=trK8UqMcK7Dw4eAcnX0ja772JlIZmWwIXPKNSryfiDo0m5TaIVP7yuliKwdo6tCQBTSUz/zxAVMt1IrYmVRmZW5GoXmQjvYHYlr5qWvf0nXyVKLEzTefrziQ0w2For9qfILROMgVWcH4BmYxIznGrRu+2esUXQ3PgDGXwzhtL9Siu4GmO014Qaq52LNEHCqQmpXLOkbeaWitvVPrQpNc4jBDJHbjMO4+ATByFj5WRqFRxsYcXzaP9qFwdwgq4UynplYV0RM+W0xGEhLcsjaLacQfBYNoOa/gqPsedFH8bdPCWNIxNhE4HCseY6yLSc+hFnwOxW6YdP5AYz4g4G/zBg== 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=INR2A1cBDUV4GAxtVOjXNUJPR3TPHjuX5sIyohpW8AI=; b=pXYo3iGS7Izz/mUZ8sgzK1712KblpdhequA2zvrdV/I9DmFxskoU6hKddLvWPVrj/Pm90zVqoJuWk2TTPidMQgVjtmk0lNDAAkDsjetVYwayTqMFCvUHCcmryfuCgy3Ldxvb4V46YahFbLccpilrdD793eyYm+tCuw8RlAcxm5g= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB5729.namprd10.prod.outlook.com (2603:10b6:510:146::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Thu, 22 Aug 2024 19:26:11 +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.014; Thu, 22 Aug 2024 19:26:11 +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 v7 03/21] mm/vma: Introduce vmi_complete_munmap_vmas() Date: Thu, 22 Aug 2024 15:25:25 -0400 Message-ID: <20240822192543.3359552-4-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0200.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ad::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_|PH0PR10MB5729:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bd4a611-180d-4139-31a7-08dcc2e04621 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: 0v/0oO0pV+E0h9C5Q6lUV1j2ymmiizEkuXa4S8OkXigorklb5e1DfM2SDsyoaphAYVefAV6P9GzsTD+v+OkZVRa4KGWE8WZnLHm7qbSoGnmBWgO4ZkGVMyISjKtczE/Zbj6m7hhpAwylM5gX5ZUyaMIHEKTVvlF6GykfRpJA3z6yCPqmp2CDj01+JMYbBCxf7ve0Iz0OjZOQqoGkXcyns+y61EW9tuNq68INJSH55ZafPVAdJ/Bm1Z6D0ABrrRMcwx7DvvDNKo1fFlzi6qx02hXM9caOFQA9xySPluJ6WUB4rhZbYKCQIufG1Dh+pOL+uIlSgymjCf3kbVRYlleGbeg/S1FX1NKAsHNSv+l6jog3wz88AHvWiWPHlexKlCdDHProglwfx4WAEZsBs7DmChA5zZYXQkudPz3LRPvYqNt/vlBTV//RLtLRWUBgZ9DXMqwIbmS5C77WdJJN3HYvo+W9APZFbtSKMo318wWhcpekOS/QhcF7mMb/vo/cV0T8luzdq5IyjJQdMCIFL6YEY2/aLbo5zAqXdLQ9t9x/1WH/wSccpzj8PQpXOygcYGJem45JYAfm2RJ4LRZs7/x08fJNhGK9eGJnndLvyBNvsh+mp5ImjnHZACbBm6HqWrodfXhLDsieWt3prFZMDBfi6duiL3ydmjwtmL/wpaegFHAEq6bZWu5RLxQ5+9BusyUgRo6K+yzvQLds2pI9WYId82r3Hgxf2y8VMCTL4l4hv5H3ksqtOYkYurp7StXS+bcqBteYYZ9fIyiXSurM8XSRnSYhieHLO+0cHL9AqN9L/IIgwUAUMQa7iGST5DmH1JZebfcdGWfu7+Eq4m7BdR56gMNo0xzxKKGj2xwcBbRKNgTG8DqpUr9lCJ6R49hml+/pnoyDIxrMj/AwloALIvk8kbmY6WXaf9w2zb8H2iOkQeeQrIJvO74jVPkj23cBFxiyNmGHfimC1FObj0dI12JxJt5TUPyoY431Asutx/nqEdbM7/DtHvV6yd5CPZ8x/jviaas+Duy785MpwK9cGDCj1E/rcnbgS7+yAJamVpffAF4jZjOpq88UBTD3UUkH+ZjOvDz3gm6KZKKFgTk8QU0oGhoSvmH4EfF/EmIU4LryjHkcdPyLq+2wcGThlKZK1ryYZQx06GfqLPRSmQ1ViWesFwDjF+89Etn/aA9jOds2PkuJI/tF6ZcjijQKYKt2bMxz2pWItg9yYHsHdgMYjRev/gS6vUU/fDCcpL1P+GX3R8XMyDDKxvpoWU7efzWRRst4NcRp90HEi+46zcdIt9eLIIxS18gHazo3kT3AdAx/rIUBZKmt78McWBbxITrb+JNFMAILxMmSjJyLbp4gNGuEcQ== 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)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lQyvgzZkMurYZmLecR4tQeXUCg0ZAOyPcrjNvnB+WME5lQUduQLcbAIBVaMOYVZ1edy8nrdB+IAjxbm0H1d0keKq031JoiyIDY5XyUC3UmuYdrXcOVOQ7LDTw+wCgAFZILvfGit9pIJFd2uaGvKdfj0/e8RUCszHhV1s5lrAt1uqfTlvUgtWRCGWmBcca9uqWtyvqiegXR9J1Z2rjwPfcZeuZAt4K6g1VHwAu4iRSbaZgGvv9P45rvDrzuMj2pVT0sssYvuR9VTXITqCiv95fsFVcPcw6zsqCJEBKjMgJZkm0BCSrBlY5xJFGQP4IgDzF28hXdETZoinNHHNUeItGJT7itSMPYEmOWQszuZ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Kg9+2W0PX2OAHcOq/xYnxWreBaNFEc+e783bP3Q1urs9/30WQOACLvcANk2n1i1wjWz8EazBJD1NT6RbInlUGvYsNZjhaNCYulLhTvDq88pB2lr7S8H96yI7EDFVZkYfbaUEbn0tk/O8SSk7JhXzASPWXVCGO8I9brseaxtGwl X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: NUzN8sIqkCkZa6NLipnkLFpVhYfyFqDgxe3V7Ocrwa3NgBFFm9aan86WfYLXPbh3dgAPcgHweVAybaMqSFrtqfLKSiYpkelklx/At9eRLcb+K7P6LGf9WFecAjcxqvYnwROhPoSUNvALVZDI0go1iRJgB/4IzlO7d3TvRF+KbahA0OShwRi8C7zPL8Qbg1iGaxL8laVhA6Mr1DsLp6bjc3ocs6oLXD+mADf44yKQQhz2SkBAAK+CKqrzp2G3XCl5BWDO6Eg5Fljbso2Q6ekspBRKO8QLMRA3aWV/o32H/IHx+SqTN6KoU3ngb3M65zNwnJGzT49u0JUqsh9HX5LYgHn5ojoreiuPav18ShMfhEgAB2p5P+kd3HmjDZrv3HrWjFQ1+cime2I/Wm+KiThU0cVtSZlaupCo6dQSe/VS7J7nFYlazGvaYRk6nwg3/h7+gS5D/YcgV8Sv8kdMbXmYwojMx3ifhOXNeGQQMkoEu6iGLBolcfZ0YPVFgBT7dh3A9vpjg+AgT6HUMYXuy0WeJjC8VsyahBaXnu4pAFK42N0LaFSfrNeGRoNnbavStrkXYsQgO2VDTkDsvhzdaxA3fUqTsM2R6hRqBKL+/LKFYfE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bd4a611-180d-4139-31a7-08dcc2e04621 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:10.5564 (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: 9YvamDWYvzPsBuxhnqXhGpa4FzO2HcJv9eIm6PYQKA1GkrSllnZY9Hy//gT/a0j8Pmh+WubLEtYXzmperjV0/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5729 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: Ne-zxH17H-MO_gQM2zMkd-G-NKT_wia_ X-Proofpoint-GUID: Ne-zxH17H-MO_gQM2zMkd-G-NKT_wia_ X-Rspam-User: X-Rspamd-Queue-Id: 0F81B1C000F X-Rspamd-Server: rspam01 X-Stat-Signature: bqrf9hjbzd3txm1oa3wdrttyoug3pkur X-HE-Tag: 1724354783-544593 X-HE-Meta: U2FsdGVkX1/zLq7qle9azh58yC4b/nuJ0c3kVqu9Kp8uCoxxW0IRCWG6twgxd4oE7xtpkSMJYt0upC5fg3plj/DbtAxHznU7Ifd+mTYDNQLt/fG57Cj/Yl1d3HQOc+XZgC13iR9b73yyVTUbb62SyySGLQvntFSlyH83BbbWF3H/L3czIoo8dzHgu6dHcAI8nxIscTKnJhAS7ECdym6xmByoO7RptkR9wGV1EtsUopvkQppzCJnUjXB4T6ZRvQUbsYaa5XPQAWUHLalvXuWf37WJc0bFtRSBF2bMud5sAcVCfVzhej80He8et00Ms6dsgK6gSLsezWti9GVkKKNaNW1MW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AQJuudN0AI4J0TnMe2owkknM3+nboM/M/SGPye24Jr6uEwWulH2tvHwGOrhfkL3rCkqeKHF5gxEyW2iugkRsOEZ5bB6MgGY/6A/XSW0BXj/fqsIzZYj+iDsSImts0tiCU= 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" 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/vma.c | 80 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 58ecd447670d..3a2098464b8f 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -684,6 +684,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 @@ -703,7 +755,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; @@ -818,31 +870,9 @@ 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); + vmi_complete_munmap_vmas(vmi, vma, mm, start, end, unlock, &mas_detach, + locked_vm); - __mt_destroy(&mt_detach); return 0; modify_vma_failed: From patchwork Thu Aug 22 19:25:26 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: 13774214 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 58E20C5320E for ; Thu, 22 Aug 2024 20:52:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A714B80063; Thu, 22 Aug 2024 16:52:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A215F8005A; Thu, 22 Aug 2024 16:52:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84C2C80063; Thu, 22 Aug 2024 16:52:50 -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 5DC058005A for ; Thu, 22 Aug 2024 16:52:50 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0B86A121A0D for ; Thu, 22 Aug 2024 20:52:50 +0000 (UTC) X-FDA: 82481080500.29.0590EF0 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf14.hostedemail.com (Postfix) with ESMTP id 95F4210001D for ; Thu, 22 Aug 2024 20:52:46 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mlXkmc8P; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=zei9FVr4; 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=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=1724359902; 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=cQBQ6roZjofnRdkNhVdNis6vJDFY3ZS8i57oI04+9wY=; b=rUR880jHpVMiv2hFcZ6fjAeKlmGBiUJLzANPZiitvkO/mOGM1bQic31QLz/8IIqN6UMftm q20bGDZml97569PdgzS8aX5EVYfv2+vyICoANuqi+yC02xTs2cq2RsV38/RYxCUThXvCy0 0Y6BDSrjpFTtVVNIGzmkCRjm2ue0k/4= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mlXkmc8P; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=zei9FVr4; 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=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724359902; a=rsa-sha256; cv=pass; b=y6zV1h/th6hysiSYnI9hNqevNSWEYJbkETBtuD78+p0FazUAtj3uIF8RO6px1IhOooGDr2 yWBzc2EgD6Uhnvhx+gxc1XJanjKgN3p3VZ844CQlfSFqTPH58xyiiuiV1mclH438wtXDyU 9+/UlhxDxVwkmCN5aCPXVS6aEbj8FGE= 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 47MIMVOI029699; Thu, 22 Aug 2024 19:27: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=cQBQ6roZjofnRdkNhVdNis6vJDFY3ZS8i57oI04+9wY=; b= mlXkmc8Po6/KCAoQzVI8qOo+BHYa9KNTlmIyRJ1jYDxTIRNFlRS2fhNWFAgcrGSQ GU/F9U2fOuBp7WFdVt8ouQYUWPhJjLPLEaBqNkFysTUlk1SGZt50FHRNY9wAKB3y rTzU+j6CZ4o0v1w23gJaOOv1Osrtutm6LiBbj5QihYmQAAijjQPGqI8jr77wqswn eGlsx6jd8eZ84ZCGXvIYlXD21zGmz390OOxUwfDXeIrpuujnIft/AI4ZpiCmo3C/ KdvvNLt7JBeXOfmp9yAB00DTUbYCxu8WhI8UsCV5EE2wzCRObG2luEZqYXgfh1xb NzfN3RC7euIk8ZCltcXVwQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m67jrt1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:27:19 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47MJJJKm028323; Thu, 22 Aug 2024 19:27:19 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2045.outbound.protection.outlook.com [104.47.56.45]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bct88au-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:27:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=czhlbSkWWHKUTwDXsI+KYP9U7554ppXEwvAIIjXBAE++za28D7Bo0TdZ8C1QQrgqAYAzMTML2+CIn1XalBAgJawIPhJKueUarGyrpgwd/xio3hvTDwMIoerYfCSqhtRjT6GFHDpJQ9xPCrGXXBHsJN6UYpSofh2cJOVQPX7nhyQCESjGCF3Yqya/wyxpY2BnpgcZlb318/wBv96zHlIlIEh4athbc84AzeEJcHulDrQzBrnrk1ERdImj118QrUoD4vP1iW/zvGU7kK2e3nYpnlqeoKoo5/KkFyylxu3XEkWuVGcuiVgUSmNzNPeoVTLwsSA9SrWP220cNR9YAj2WIA== 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=cQBQ6roZjofnRdkNhVdNis6vJDFY3ZS8i57oI04+9wY=; b=EqSlV5VoHWVAUsPV0tMq47aeFKx/iX/+QPywFr2Qa35kfB2kU6cU41JmV+GHQbwqyNAXrpcTZz/VHpGVWXlX3WbUTq8fttfkKSDW61xM9MakfHpMbXHp5uW0SJYUh/KmJlo9/6XcYa//M+8ljKgYYjx1dx4zme2rF7zXFS+G74FttzPJpotFA8ngNYJKHj1fTNCJxYNafSRNlGRjM0Lxt9V871KZo6oLumg8UWUwLYuDkybqN4+UIpmWa8VU5eMm9LXirAnifBTqXRf/oDL5rH59Vt1JtjCyF1FRgu3K0FmLlSrXE9nBJGPzpCBeKlDq3H7YflcOfD0jC5YCn0ukSQ== 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=cQBQ6roZjofnRdkNhVdNis6vJDFY3ZS8i57oI04+9wY=; b=zei9FVr4eMif492iVDn+yG6ko7WQjKtj19Ug/q6KFPAtjyj7sW0wa9kUOmDEiUy0ha3OGfFSdNSLKqPZ/OfsOd3nnD18iPhxItDYYkJ1IkSu0d83l9byLCnfLPrmUDizfsaHgdwUmzQ2ZQ+D1Ek54hx2mZfgBPzSnQnII8/Owr4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB5729.namprd10.prod.outlook.com (2603:10b6:510:146::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Thu, 22 Aug 2024 19:26:14 +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.014; Thu, 22 Aug 2024 19:26:14 +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 v7 04/21] mm/vma: Extract the gathering of vmas from do_vmi_align_munmap() Date: Thu, 22 Aug 2024 15:25:26 -0400 Message-ID: <20240822192543.3359552-5-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0282.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:109::28) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB5729:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a16c7da-5664-4ec6-4129-08dcc2e048d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: 87Gv1SsTzuTSEp+t0azdve4O2bs38yh9EFtZ9oQEz4Yfypbx23UbvgnRIaZaW4ZcMEyrFNiSdPTHfzqEprEZ8ENUpJCLPn4PxnWP9D3osvTBsZ5ikP2c2P8f6NeTKvacxR6qfjoB2/PP8MOULdbpw+CSG/QYENh4JOR5YuSNkeQ8HagVtfm4y8Jl2qBG+FfXHlscejhJTxFxxHWDnm4ZyKVjLe+GW9pXt9i2b45FUA0acVCqZqY27c5+M6gFQ5UEsgX85gt1DZuiXwZfMHnh0emby0s3EjdAbnyZa2bIr5DwP9mzskL5pmRge33ad9IKlM6wZkwpx5JoJiLFnrMU15a3nFnlOBedgkc0DL+kftGiBegPJbSAyGpa4Yu/Eo9yrRbcLbqO6UPYH5R4Z6cOYjB2879mDa20ouOQ6ScI9FUIAi42KY6/gyJTbgmwpYuessFbAQGgtqeb3NTH8JcdHaiAf3C/CzQcICaNjjInhEQeDhG/q9mO18PhwYalHEa4Kqo7+HBsQHijnkFryRz2yi5byiVvcuI1z1Ulnb1OoMj0lkfeYo2Fm483Hn/fGX7vE8B3gnDRbtGIOXSAkYaORFBqWhndrGmJi24HKZgDYI9OitJ0OOSfPVnDv/zh42JaSAZjfiahIPzRpXRgovyL+1fsIdQ8bj8renP1ckGA+qk+mhb7CBp086tMi7fvUcnZVb5TYM/xp6QxxbZautT+Zj5916QpY3U8pnpBxX4FOFjo9tEJOgSVvzu6xluklc9ns/w80ZY8sEoRclDAXD5B6y2diJZ1IefUzdCPZeO4IPqD42rsimVoh0BIWPvuR/xR1VWR3nvI+V3yLwcOes7RywHJ6wDxoUjtXurpKIA75HLrOroR0mtLj0SQ4uxVo2EDlWfgdrzX9rULURITS+TnD0vxECR35QLM9Yga83HiaN7M2MC6D+Jdgg6dxDz6nTCB8w674GcS+GmBg3jK322VvPCCeCSvNBmsU+S4d+xODZGfPedcTfGylBrIyLnS5x1c+VnA17mYA04vwG6Vtt+X6gza37P7D8oeDWbDOPFwRB+8GG6bS0NUB9PqKF1uRImKpT+yCR4+aYqLbNhrGKuc6VRnwyf/doAAPHnn3DSApkxwlPHu455COHbocVEK3e7lHcRJAsMOZeFwp4nnFaFe9+NpsKVvxT5PeZfK1xc9PElkeE29AwvsyE4afhuKrrQ9JI+S+MORx1+sNepFVGi1FhxLd2o+C+WX1NWG0Rb/rk/IL/FT3EZUnG8RfK627/e7pcOOivJMhRvGrL930yxI1XgKTSITqN/uYvenNIajwz3S+D3U7MriH/IMalp3x2Fh9mMrreuf0GTcQeLW2UFqbA== 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)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ff3xX5FUZhpT3NYrkagEaL7dtjUAR8POaA2QfUpkS6ooux3cSaVnVs17XKaQ38HEES1YALWn/0yoXXqc1K2ds9yWK1e+s/uRiaAGYntjec5JWAbW1bg5h/gb9FG6JuWdmcLlolDIRb2rv23z9W0mjHqitiltvIBS0pUaDRhEWF7WptzU0EtMVOqwCc8PtFJPEYn/9v7J8ZN1ef6rP1j2zwrQ/GretyB5TU+Kv7dJs8AKKvVsu3wMfJyOGsGWgJGh+z4aChIg0ezPl2/EdUIksPKNk+nUIGp+6GvyKcmHbuovq1wLwSRwtLZ4PlXaFInKtk5pPwDf3En9KafaDndm8LmmMCZJPyjFG34E9/g0W48b3wKFUhDA52oj2sxXYY98BVKDdODxNmv68kTmJY+qJYGzBjVbRiAT/fBwh4hGhda73X5cThpOQe4FJn+4gLia4yDnpkLz5ZC/2DzWvssohpfyR7URzLxXoyb8weh8TtEtdmDa0c9rkubYT8G8e/bqp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GyLJ63/CMIfdKfa1vV X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: JhE2OfoTarwhTHmmrW0e6meN9YKDhPU1NomE8dhmSEgm+6bHFEmI04EPJfBQCIL8h5/fQzUuN897IjVSS52xP+wYRBrQT8EYhiZkreyLS6TWTbiru++QWshAE/qGm+ztfE0LO/8kSxpMSiMk2fczPyg5BgIaLKEx1ZUmM5MieHkJdRdRfPCbM0wCi7dQrn5W/eCzmgXbeFdIcrnjZr6tI2RDJwYFNzXNLq83ePlrUth5fkVgfQKzT+Dcqnxia0ffqcvv0IKcA7ZrpzfP7Fj7/351KaccPryALNj7KW2EE57X1MG9vM2LjXuKHeh3qk6Q42NWmgxFOpkpmnAlm1KYjLCPqKL3awaep9jt9nAVhg7SlNnL3L68VW0/4pLCD8xzRQJw+UBl7jBlg0JBQDQ18Z1chvu/svmG/cu73AySrXXVHc2cyQjBng9wKFsiSh1DmrhpEJVD8sxaLLbR808KgF/PEwyhidAaqukMwRuAo2Xv2++GIi+y3NMUZQmgVd4wexY6yyhSR26LFmrRIod2jXb042kMzwlJxRohpbIuiZHM3oYPWwi3rKm/MIyKJSUK7fyheaBNiGNu+0fqu3bsozVbML1ufhdl/D2AarWjV2g= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a16c7da-5664-4ec6-4129-08dcc2e048d0 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:14.3433 (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: Ypxva6bjSGDO5ri/rBG36q5tz9QeXbzKNrJ0sqIYMW0pvx/GRWJn3x2/+2IQjZHylE0Tc9OZLNjdlqYQxJPSag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5729 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: IntJzcRh19xmNhO6MN_tDhiinq-XEC3M X-Proofpoint-GUID: IntJzcRh19xmNhO6MN_tDhiinq-XEC3M X-Stat-Signature: u7siau3iasksbpigsaihr55yhw7kqms4 X-Rspam-User: X-Rspamd-Queue-Id: 95F4210001D X-Rspamd-Server: rspam02 X-HE-Tag: 1724359966-546998 X-HE-Meta: U2FsdGVkX1/UrRixjUOQ+yYtUXsjlho3znKztOBuPYkjoJuWV8IzkvvdoKP4eQ5yt1efFzYR2ivUDJtE/OIJvFGz6iuy2NBeA0OkjXvpO49u/4ceakALckcmSlsVvuIkrjC4F3OZ87UPZ82jKM2rZkJgmqwJFGdmks5U1Qi3hx3hyU1DGCxMmF18jBxDaYbad/RgeYaJyngvjQwGWPK5TsEtGNR/hN1sTQOLbfO6x5SuzdXC6z7cWbMnS8FqPe6hM6OuwhXtCHBaBd/wS18f96GsZ+Ly1mBk387TIZoayWcfx4xVlblMG3nedNe+9Zr/d5cttfwlh23p6ah9Mv5eJI3ZVkcRQdv/zcoCoSHzsTs7mpnNv0UNAsvG8fdS7xEGPWaTtb/Eo78ldv/6mFMOTqk2KdoFUEt115nuDmtdj55e0xb9K8TL+lUBJf704aENMvvNN04+VTSevUu4pvsdDXItd6NOj576tO8P/0f3pOXcuPDtO/kUc08p5aKDaDv0+XrY8xxwn+hpMT0sihIk1Ff3vjiVwRqxWiLugTCaZIEjtHeVKjsabD4Dw4RolE5TKLR1On2BNQcsKJIkJwWUDOMXk0J0CsbEyDp4SQlbzUqMNbuTz1aL8S0qyjP/2McoLirzk8Lxd4WuNtGNdLAQgPvAB1U2E3sY40M24dCb5lMCA9HWCttimwQuY9d12/jBw+8u/7rA4DgfR6mU4I6op7UMSiTViAZG0sIN9JAqebaB+yh4Lgi6TUBow++z58tqZwxNpZE1vHGwVDQDlC1btiGIm2GLJuxLj+vJwaeBLpo4PsR1HQDg+xey7DwYjfArg/Nc0AQw9k8VOGUIus3UR04I2e9XQWsXGAKAzsdrFnJHMJ5pYyUsSE3YVvCQOkmbWJXmT2hnNaMYzppriFl0F7WfOi4h7+XqRdVyrKaippnetRVlUd2RMUSJ+v3euy1/LX6bxst766xa5t9bNTB vo5h1NeM hLKZphMsnv4fzRBvYZSrMBDV4ihNkOWgShi5FGo62RQQLVmTxn4guN4g13r5oZGHmrdFEfos5zHVWMusowHKzGXFu7IwMaSxZaAkJ5hKx9W9sWyPHv2/gFKiCznJG8JxantVNjQqsghsCQRiXAu+3dvGtVn99PMDKBBpNdvdCV0kNzvQcVnmddiRVrGzVaZItbyfl/8nSkK18k+Lsx/JKmdb3oGlJCQD478FYG/IxLnFRQ05i2lZ8afQecD2ie/dAQcNlXFxYmSOKTGDMDelfdhwbSrG9aICLaQ9sNpEsm6eMpyV7qN0pj78WsOrw36WYRXtIfo1WLJNgaY9nd0G6AT+lzoWByDM4W228QHg27IZ+p4cA1h6AxMmQHS5GDIVMoGGqfb/4L/7HTXjYGKaMag+Nan7B4/RAtAPzrS+V6zFgaOn9nokOzuo2X/3PwNOI94y7ZTjJGqatjA2XH40jtNb6A85btQwxf+e/kUsknPZZ6zDxrXFkcZOy/VgxKjis/h6XGZn1lS7FrcI= 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" 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/vma.c | 82 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 3a2098464b8f..da489063b2de 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -737,32 +737,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 */ -int -do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, +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, 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. @@ -812,15 +810,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 @@ -845,7 +843,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; @@ -865,6 +863,47 @@ 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. + */ +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; @@ -872,17 +911,12 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, /* Point of no return */ vmi_complete_munmap_vmas(vmi, vma, mm, start, end, unlock, &mas_detach, locked_vm); - return 0; modify_vma_failed: 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 Thu Aug 22 19:25:27 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: 13774220 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 B7066C3DA4A for ; Thu, 22 Aug 2024 21:05:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 357F96B026F; Thu, 22 Aug 2024 17:05:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 304A46B0275; Thu, 22 Aug 2024 17:05:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B86E8005A; Thu, 22 Aug 2024 17:05:06 -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 D72BF6B026F for ; Thu, 22 Aug 2024 17:05:05 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9E5701C4D98 for ; Thu, 22 Aug 2024 21:05:05 +0000 (UTC) X-FDA: 82481111370.17.479F139 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf05.hostedemail.com (Postfix) with ESMTP id 3F31910000F for ; Thu, 22 Aug 2024 21:05:01 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=RTl1liVs; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WI6zJDvu; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf05.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=1724360620; 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=ttsU2jqtp5fvXasFNgS0NAcV2R20c5Zpzh7VMtrTw7I=; b=amQpGZsOCQeeE4gfdw2lirtllHVZWy3WRFFTRbsD9545v1qKE5p543mjipAHjnb6NwuQNe yvi1QcObZ/1XCUzLoUt+zRthlgag3Ozpm9S9izH6Ytt8xDir5zZamQdBQ0kNLuNf/0E3km T5F1FoyewVNsk6+G768j/kI1APFHosc= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724360620; a=rsa-sha256; cv=pass; b=H7/9U2H22Iq03kObjj/sIztt2CUntZMIWnT+oWfPKOeN4S1DIOKQ3T6TjhAmqUd/wljdDv PXeZ6aZXrqIx0AO/f3sOCrJrAhymMhmbBzcUs+lVU8JRU5GEixV5iam+u1A470P481m5YG MJ4nVgQpzDEFFmfqWGv3g4dCqOS0+vc= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=RTl1liVs; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WI6zJDvu; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf05.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 47MIMWJF029718; Thu, 22 Aug 2024 19:26: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=ttsU2jqtp5fvXasFNgS0NAcV2R20c5Zpzh7VMtrTw7I=; b= RTl1liVs/WFF9wMNs6ygEgt/OcBx6LRF7BcwBLHuVM38rmY7MnHTjA5qDCh0Udys VCPHusMf1z6+a9W2WudnUlG/pe4iM+/PKAJS3cR8Bq4P2dRR5vdYkusN+yb7+jMB re4/nQ0OmiWokRqcVdiO8nx5f+rSfAXi/lAZirS70oz6Kx48DovTCWDSZrCkUbcE GLSHFgNWV8/lseZE572Ftyht4m+858pEf4DYehVVs8oqwU+pOYwjb1BPNctC7JTS z7om/7JAdfPNX9dyTAVGIh16JZcmjoiBPtwnEwrabIHRSKfCIFYHvJb60cCrOwE0 xvH8zlwcdFnQp+9zRDpUsg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m67jrs7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:54 +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 47MJJK8c005374; Thu, 22 Aug 2024 19:26:53 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2040.outbound.protection.outlook.com [104.47.57.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu08ec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dn7O3W5N1fvsepHLGZ1Gwgus+1P7w89R3qbY2pQfKTktQjc/VLISks8kw3zdTn4s4sqV+5dxPHHFexTXhZWRAkP5/8WXJgm2Q06NrPStjHABAidvsr8HcuTfXVo5WKacw7jcIfqqDl1Ia4Iv3dfbRirvQxBcTmPNemS51C7fpgHhgXJLOc8zpysTGRD10RSxn8ahFUuIlyLW1L2jEkyMWNjtuEzopE1gTJo95Lrani0BH4eEWhKx67IJ34F3Yk4gi7JvZHhe9MwN1qqLyQ0gA3X6bEWS2j8feHTXUiHcFKanoMVx3emYPC/NYvYPvlQ7XpkA7CAgRd18brM0Vc0XUg== 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=ttsU2jqtp5fvXasFNgS0NAcV2R20c5Zpzh7VMtrTw7I=; b=MTHH519SjBTuGMuVeKf1wynqBM9rLoThWlZEo6k8vJeyIL5AvRHHrOznYHSJ+0ighc08FQL3pj/sbnj9wLd5tGEdqKSQ20jYs21OnMUWxE4IEiYlBuAtMxAi8cQ+CrRpLTuZW36c5WOjX6+7g57tDeTgu+tS7HGB/3rhcm0/Ok1mO+4zqgMgckYcK3cqlkFqE35ycCz5vdNrmrwvn2T9vqAUPVJKfELRcBINR16T8LakIR728YaaMQWp+LEfIhCnKdQnTsq+VP6GlJgznqV8WN2kalCsF95LGPc7G9/dnicG4IQl5yv61UggeAOTtDa179xcCjc0Q7MPh1BrYsytFw== 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=ttsU2jqtp5fvXasFNgS0NAcV2R20c5Zpzh7VMtrTw7I=; b=WI6zJDvuP0B5ZtBlEx9abq/Rt604tUXLSsNBcgPaWtKRA0dLg+uipHCcPyTRvTXyuOOE7w2syjBRsDkGR8xHMkN66Th5ZG1P1LST+alCUQ6l8eSNbFayVzj05RK3nQW7tfw+o1TMe8HrHgGBsEgDkGNU6fzcVS9EkozXpIJYKT8= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB5729.namprd10.prod.outlook.com (2603:10b6:510:146::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Thu, 22 Aug 2024 19:26:18 +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.014; Thu, 22 Aug 2024 19:26:18 +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 v7 05/21] mm/vma: Introduce vma_munmap_struct for use in munmap operations Date: Thu, 22 Aug 2024 15:25:27 -0400 Message-ID: <20240822192543.3359552-6-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0035.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d3::17) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB5729:EE_ X-MS-Office365-Filtering-Correlation-Id: f7075146-539d-4c9e-3da2-08dcc2e04bac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: EuZLaPH1nA3kWq+lrqi21uknqlJWRkN6o87TUEmKN2NOGq22NetB7SIu+0FIEI5VdROdXZirfjkov0E/lk9FGMwdwJxIM6JqJI9zUwUY3dAzDUEFDp273VRXbQdt4rP8XXLuQCE4Obc2IoFb66mYlxo0bq1XdfLo8/o1LSo5Leh6OZxv7HAuTwnbV7CSY/lZaKYSmrpGyzAlthY31iZwc3i0LHATu8cIUfBTzH5m3NRvpZFQ58UJ+GAY7bMUeH+aylFH1HsKlIIc9gz6TV72H2lIfDqz8yIU/xlezEOxEtYFkmKkl2sLsoxcOEr6GoZbbxLtzQQ5B+lMnafJTH5jKoLROzDePP417KyB05Q0WzBlpZsEXZ5vxFAkGckLC7WPIZ+phc/td+RZVBaKYpoZfriT3GYTJjl1pxb4OYDih/YV3iZHyH91e0yGQFcAxt7oBWQMcKGhcidqlrxYckx9XdsxWLZlx9uULW2ZBjrHZrtZgMa5ynXE4xYIW9UUZHvnDsxaFIDPkkXo1GH1F2lGa+zFXxhkUd9IgVH1SSbvNL+qyoRM2r6juKSzNHWImgI+shIXbVJQJzsX33JQN/R9HT/C5J8Ym2C2pDyHf4tsqu4bYNOsIEKzp22cIQLOVtDe2WWwE3pPa+1l8sfnDwB/uXm3ViQuZazwPKPSL0shHPKNJHypGFxStCa+2DvZFkRzYqa/cdXgXtrfL12ueH0zFFQBj9OH6auRvvK8B7KCy3noscGxqaaggSJBvwd1rP+bPRf8oUJrVWaRLeeBsU1LCBF2jSincp4tGlhxYIQbHwDaO9kKzO/W2DpvfSE/nhRfky1ueuSbhNU9vZskZgEWpaWyiHNqg1hz+nAINO1c+GxlfWAm9EEgEzZ/d/+1dhCXNV1eMcg4gEP1K5PG+4BHeLeAb6tnVZ5vHAVd4FjtZcLIO/qqjCpTDzSFvbbmqvlwEu9sosjt6BRjMNIMwWcjkFxQBPayTXV8p0BE5OGNB7/kVLvKt33GcpqSSypCM0Qz5tleVi4XB7aWQoDny8dTL5uTVJKutce7bK7Ne6htFW0u/IEJmYnOFJSF4qSfFkCX7Gmcgc29yfRkMLEtl6bWgqyQ7rmI8qZZifMDJUGCq6BoW+tb3opfiF+wp9j1YnRATeK3ez1XVIpM+raydh43nRlcCthB5s8CBKy5fDYWd+a1wGnNxMp9sVnsCTQUW0AEgvzVHEcwvtpPd7JKTQFdFzv/3t+gnpXoHT2snvFXwANFj+bwAfHKaVqx+9ioKkIHYUF2asw95c9YMeVmc4XXpKTKm6webJTGBJaW2Ohy+ifc9buAYAgswKM16ykTPyA/1ilwE6uZgWaxeRetuArqrg== 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)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-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q7wA+VIzRfCdZNne1yEC86E8Z2/gMEirfTgb4iSxi2l9FtWhGL2YpfO0uHSS1yenfDK+eQDBpwpwevWB5fCd25K+UT20zyiicChxlaDwmxw7fIkeXZWCxAmSTauyR7T7jXzAhX8ay+wGxfRpLI136Al6iRElM8ZkAKRr8X1ohhkD6yaMMJHxY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7075146-539d-4c9e-3da2-08dcc2e04bac X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:17.9432 (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: eo4Cu6ij5vmMS93IqzmGusQAs6/Ny+9v6KdU1SBo+b3zo4nTBYjhjTg8+Uyl5E8BW4CdAqdtfRKAUYjvF4/8xQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5729 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: Q3sLeL6SZmcXJJi6C9zzwXOGyvA3ttBv X-Proofpoint-GUID: Q3sLeL6SZmcXJJi6C9zzwXOGyvA3ttBv X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3F31910000F X-Stat-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qbWKXYFo4XDHI5VT/pGp3EYbsozCMNldRmJZ02mXgdjJVXqcG+FdDVuo6+0h0bg2BzD6SdXdW4NTFrVCuQLQT/ffUtEvMQwRV4mClsb874h0ZvlPzB7R7x42weTtFGHY6U9zIhDeRBpaAQm0e6xgglNko3VaswOedtkGXGUViwmYDtPTrhhIANpFmouAK5pseI+SE6eJkLV9Eb+hqld9/RjFOy0oXgnN3u4zrHJnbd34wfY09ctmQJ3A0xhqI5SigxZ1agmbIdKwwstj/9YNIkKtzzxEBIbLlMSzvzWA3aLurFvlrYF+hlCLh3qWBL0wmVApjCmSRnv2XgamlAOWtZ1+2nbYa24aoCuGdfqrPjqyfY4TMhRjjjW+oCSyMJsb3/1V3bfYTADUvsDdxEnb9X6q0E7+NPMzYiV46TvyhlGWOlzXw7A9rEpVCcEcSU9IXf2PQzqiUb5jKkFcLhkyF9puj98aNTexQHXAI89wj3zOg0= 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" 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/vma.c | 142 +++++++++++++++++++++++++++++-------------------------- mm/vma.h | 16 +++++++ 2 files changed, 91 insertions(+), 67 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index da489063b2de..e1aee43a3dc4 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -80,6 +80,32 @@ static void init_multi_vma_prep(struct vma_prepare *vp, } +/* + * 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; +} + /* * Return true if we can merge this (vm_flags,anon_vma,file,vm_pgoff) * in front of (at a lower virtual address and file offset than) the vma. @@ -685,81 +711,62 @@ 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; /* @@ -771,23 +778,24 @@ 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; /* Don't bother splitting the VMA if we can't unmap it anyway */ - if (!can_modify_vma(vma)) { + if (!can_modify_vma(vms->vma)) { error = -EPERM; goto start_split_failed; } - error = __split_vma(vmi, vma, start, 1); + error = __split_vma(vms->vmi, vms->vma, vms->start, 1); if (error) goto start_split_failed; } @@ -796,7 +804,7 @@ 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 { if (!can_modify_vma(next)) { error = -EPERM; @@ -804,22 +812,22 @@ vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, } /* 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 @@ -829,16 +837,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. */ @@ -847,27 +856,28 @@ 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; userfaultfd_error: munmap_gather_failed: end_split_failed: +modify_vma_failed: abort_munmap_vmas(mas_detach); start_split_failed: map_count_exceeded: @@ -896,11 +906,11 @@ int 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; @@ -909,11 +919,9 @@ int 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; -modify_vma_failed: clear_tree_failed: abort_munmap_vmas(&mas_detach); gather_failed: diff --git a/mm/vma.h b/mm/vma.h index da31d0f62157..cb67acf59012 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -26,6 +26,22 @@ struct unlink_vma_file_batch { struct vm_area_struct *vmas[8]; }; +/* + * 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 */ +}; + #ifdef CONFIG_DEBUG_VM_MAPLE_TREE void validate_mm(struct mm_struct *mm); #else From patchwork Thu Aug 22 19:25:28 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: 13774127 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 0D0D3C3DA4A for ; Thu, 22 Aug 2024 19:27:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A1608005C; Thu, 22 Aug 2024 15:27:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74F788005A; Thu, 22 Aug 2024 15:27:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 556268005C; Thu, 22 Aug 2024 15:27: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 304C48005A for ; Thu, 22 Aug 2024 15:27:07 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DB2D2A048B for ; Thu, 22 Aug 2024 19:27:06 +0000 (UTC) X-FDA: 82480864452.15.C338B65 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf08.hostedemail.com (Postfix) with ESMTP id 9910316000E for ; Thu, 22 Aug 2024 19:27:03 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="UyjSsk/4"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=K69pW+Tu; 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; 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=1724354806; 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=Nm50G8hesDrXLpOFDcpgh9FovxUYHbMgImgPa3a7NFw=; b=K900EY0YUu4XQTYFJUJ0fNk0yuc9rE0gXdOZwPCYJ7FS0TRdwJggebdJgIJzEv7IeS5rJd lySe9LL49YuZwBV8k6yFmM8FwZQEtRAVuv5Hv3CGtolSmK0PBNPyizHNBSyCqy9ZMnBttG 2pU4ndiH7V8SAZypalQ7ZGE1Nswb7Kk= ARC-Authentication-Results: i=2; imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="UyjSsk/4"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=K69pW+Tu; 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; 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=1724354806; a=rsa-sha256; cv=pass; b=uWVoWjZqPHq9uPHuW/COtWt8d0IO6sLc15IgziADHxpGSFB1onl9R/LHKHKZvfpK2Pbgs0 bBFkWGfKCbRizkeLEYZZkqb0tYIXfuiXCtDGKRGxqpCbakL1fl3Gd5XJLBa7xPZGxRS8LU gCuJY5NP5qgaZ9WdVnngl3y4597RjCY= 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 47MIMZnR025771; Thu, 22 Aug 2024 19:26: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=Nm50G8hesDrXLpOFDcpgh9FovxUYHbMgImgPa3a7NFw=; b= UyjSsk/4Vm4KBnSht8mONiqj2lqkFq1xaWYS8zUJ5P9YtW83Sdvyr7H/0pDQGReT UC7G7qLIGRaN66OlG8TeTM977G+EuVPr3xiqLVOEXgHA0GCrUeRuOP/XCZ64zh0K I0AmA4+UL9IRWHbdLwXenW3tuLUs5EFd5Xy9zwNtHAS4ZUkURsOzs0XVHmaO+I1m Pm/pjcDjSVuQNCS2bYtlK+x5bJXQSzawA+9TYyr2rGtrC1/Itr5ReJXJJlvrl3eU COLEh+9L7GVoSphojlwkDX/zxjpKmzhgOMM6ad6gKzZ3hlmihZoWuduiRnpmvf81 inYXqxAGA78J2zhEZxBwTA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m2djxyg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:54 +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 47MJJK8d005374; Thu, 22 Aug 2024 19:26:54 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2040.outbound.protection.outlook.com [104.47.57.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu08ec-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vQG01Df1ldRuGNyZ1elBjHO4rHyxYP8tfkgmUNFLj+ZAiAX25pNR4mkWmqRNiUfZ7i3EEcfSVjOZucEDPSd0ZaE6+ixcy9eCMHcLKt8JjUeeJ4LsPIhDaN8xuabHr5+vlNgx54cdyhVOo4atf6d30/xLNgLg907A1RpVKQyk6izdUMrAZU3QqZmgdT9cfnd06ZCcnSLQhyaCN7ojMtiJ0Reot/tzVN5XlYXbpb7Gi7dOsq2jH8aSCSEbqbcqK0DuKh3giTZPhYvGzWSpfFT6nf846Kty6WfsIJcREPXS+Q43P81LHuKp1CzvjRmkHdaTz1LSm5tBu5UEGo2eCbM4qA== 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=Nm50G8hesDrXLpOFDcpgh9FovxUYHbMgImgPa3a7NFw=; b=IGBgowwmZP3cwOVsGHIFjSpi2Uf79Yc8n6uRvL2w3rzniNInIquAd5NWK5eroNhX1MT6hNRC4fvmQrE6w/K8FnaL8xPjwXKbivMr8XCOhDN9eAwVTUpA7gmo1haalb42TY57vtc2xCRjn2/Juxke0Ntsp6GSOjVUmE6wGTaPIPBFmQ0i+jT69UUXadxzMh6FFSCEX8JvgYnErz+msT5KGnNzT2RqQimZRgHkZbryz5szdwgLBfwqZMk1fkf5FN138GpOx1jz8Cc4CS54iWwu18/yKTeQZ+n+FcTWf8dG35ueAXirQy788aiNo6mcw8Jev/3uNXkPuF6Zy3UA9lPBXQ== 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=Nm50G8hesDrXLpOFDcpgh9FovxUYHbMgImgPa3a7NFw=; b=K69pW+TuHnznUN3yZKKIJzqpF2BjKZTyzIiEqkKqDhm6uIek/QIdM5+2aNObd5tdfXws21gAn2KxxP8ova5yMS/SmaKEnIguo3WMpaWFbHFTCGVWm6z9xqPedaMI3UPoy1zQyyzCJg9gUe8SObLF2MqybD+MIPCO68RW7ZEchI0= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB5729.namprd10.prod.outlook.com (2603:10b6:510:146::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Thu, 22 Aug 2024 19:26:21 +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.014; Thu, 22 Aug 2024 19:26:21 +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 v7 06/21] mm/vma: Change munmap to use vma_munmap_struct() for accounting and surrounding vmas Date: Thu, 22 Aug 2024 15:25:28 -0400 Message-ID: <20240822192543.3359552-7-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0046.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d3::28) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB5729:EE_ X-MS-Office365-Filtering-Correlation-Id: 780c3f00-8115-4fe9-a8b0-08dcc2e04d61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: FQUYcPTr3YHZlMRzt8rrfylU1s5o0vLUPKx7RzvHSXQ/TBXtM1u8qek6qNqfUiJGne0RJqrPnOewzSc/eruZ352wXzKwKkqzfGL2sgPtJ2NmOD8srhcAPQeOo4FKAOkEI/3PGYbbF9RqduIoswSFnxz+CuvCjK/efJvJvAI9LD5dLqR/+qpXOISNzxvkg5dRkzDKRnJfMQTODJEjMupsJs4+uAQN4oTgp4Olq98XkOzKAq6u+cp88cuVO8jwC90fH4XORaW33z1YE3Ykl1CP3Yp61NQDOjByS++ya+o8a9h/AoF/fzvXx9bTrE+di+PPlVdIrunbwr3NgcLJMZQi0c8387rTfug9pN/6u+bJGmXSHzRynaj7e8SWZBmrxC3HpV7Tr+JE0zZuSi60y8wduqzouSMcbvkCaVKxqO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:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OCmKzSWvX7hzlWZn6tNCEgTXIbqzdGtaOwK6u1dpBHoLKlR7VEDubfyYxniUEsKEWfnosiOuKga2T+HzM7gnh0+mCRgNQVUwQxWSru1N4pfjMDC4B1yPx01j+0L91CI2vgiGB1ffP9GY4ytbQFu6p/RiX0zkSjtCkqFDnc2VQeZRXY6zGSdJH3vJ9gIt1ZijXoAi/LObfRpVslDFQgYoGQYCJ4rxCKVLAzXQY7sGgJVWkeVAg6TD61IkeWjGMRAbjW6lqfHVkMd4zhP4hiUz0ig6htcKROksRDl4P7XB33ofchXXm3fs/FMRxHbxiL+Vhv4prL0zCBC5oZLS3Vc35XT1Rn8Veef8Lt75LBNbZvTgh7qiAXmMpk731VO9O3FQL979g4S12JWksW0apCo/zN5qO/vhfmHMV/LBjCHL7R2lnPyIL26h/UNuk0gERl8ubbevtzDEP13zdrz6qbIZ+nsvHvU76CGJVXyQcvpEHYpQbQPflcmREHtNu6Y0GsBw+hxaU2TS7sA9dlh/ah1HKXwB5Pib7GBAVg7sB66lr6CvfLmS8xdAKwzMHQyfpQWIoEn4kbHL66Wf7J650L26Rd5+w8gS5nJgXOOtabPZ3ygt1VYrVwuBEBxi5QAnmBB/S3nb8narghZJbaUdYT+FbJCsckAstdBFKi65N3YZhYFEI9IFa6N93qNGAdQAw1lGkcAVq+KM2zaJXKEl/px+vFv6PbOzrPkKkOsz5nS+eXAfu4Z/ZjZHuVSNKFpadJ9w8eQr1ZRmGC+LQjkBjMibGtKcHcMCmszL+eEpdrLOAS77yJCxha3hIbaHC6JkjUThk/D17ahjRm40VFL5m8mbnW4yRei0h+oOdyBu8vvbHqaRVox755cMidZMTceuAj5042E2tGaWTWCCqbta2XmnyhPGRzVR77xQ9zkERT5wvmJ18GP8kL6upJTWZtyIB+TPGAxmXqBVZEikZkXZ6Kn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Ym6OcKE1UB2UycS3ylgpFFHwW1E4GBK/Jj0E39I8gOecoSYBiZrNLRCVUPHC+aym6/RMN20mM010UqoOPw8KZnjovHwsFpL+WO9E/Lmyod4yBevNoY2ANel7LKKCpEipk0IFtvbJPIV7t4xJ+qqiXFs5Ul/Q0QCmcULwdwVK8xt6cng4an1avtvcUYLytZZU4BFCFEU8qpI7BYxITz8Vaiobe5qtdvb46raw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 780c3f00-8115-4fe9-a8b0-08dcc2e04d61 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:20.8584 (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: WvIQwv7ZqU2bMmO/vCef/lDNz36hDfwRvGa2vi4bAIIZ8x6ue8wYekpAYqPJpMH9OYNjukoLBuSfsJOIz1JyBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5729 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-GUID: q_GWAb19fzAGBZlH96lLEyPpnhj6Bq_4 X-Proofpoint-ORIG-GUID: q_GWAb19fzAGBZlH96lLEyPpnhj6Bq_4 X-Rspam-User: X-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vKnXcSQKh9lQ7aO34ZpM WHwpqc9V l7+ZqVW3hjalUPlNl3mly1gYHrP4YllxKmqS2VajcOuKs9iod8Og1d8vMOQSLFOlAyQ4SKlrk3t4WtD4sQ52HlGqvVVzfcBDD1tS1JCdjcJHCXIpALitfLau5azJw9UNLWpahEkGFrBNAf0TVeFkpwT+ekKKb+PxloUQckPmE9AZRMt9eElyl84m2mXBqUlST8uQtAX7AoAz8IgTSEao03s73NVRnQK3ZRmil147XjW+XCOzNMm3YaMm4UwyLBPsesWihghbEfEr5xvxrPg/HM95HyU7TsNN22oy5FNmTsT7+slrvDj+J2AOYSe49aWfvibQ9YZ8l7CEoRG58SwAQYQSrNfk0K7n3s2HctdA7pKHikhJV66q4xh8whV8Oa6NWYP3w/ZxP/GkdbPgha5pkVned0/3wUT4T8GMikn3w4smc7MizdYiyQaQPSQFB88BmQ4kkcATEtJHxmRU1WSOfiCgFErwuHI2e3PJs1Cr94RM3/RG8hgi8ykZ9alvVBN+1gND+KcXUAULBXG2jQi/snFRPu51Ddtb1uIJf 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 e1aee43a3dc4..58604fe3bd03 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); + mm->exec_vm -= vms->exec_vm; + mm->stack_vm -= vms->stack_vm; + mm->data_vm -= vms->data_vm; + /* 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); + + /* 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 +786,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,8 +812,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)) { /* @@ -847,7 +848,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 */ }; From patchwork Thu Aug 22 19:25:29 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: 13774124 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 D6BF1C3DA4A for ; Thu, 22 Aug 2024 19:27:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD3A280059; Thu, 22 Aug 2024 15:27:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A82A680057; Thu, 22 Aug 2024 15:27:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8885D80059; Thu, 22 Aug 2024 15:27:05 -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 6718280057 for ; Thu, 22 Aug 2024 15:27:05 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1E5A41A1946 for ; Thu, 22 Aug 2024 19:27:05 +0000 (UTC) X-FDA: 82480864410.17.F145E02 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf27.hostedemail.com (Postfix) with ESMTP id BFF9440021 for ; Thu, 22 Aug 2024 19:27:01 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="O/WJMKxC"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=mU+QhrPz; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf27.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=1724354761; a=rsa-sha256; cv=pass; b=epri3RMlBuczHf99RMS9+nv1y22PliuDsUfMq80yBUFOpzsTv3AhF/kTRLOIi/YbKK0VCl qK2uGEfc4ky1GxdDePf77dgFDzu+uaizxtSoHIJhe75ErRgoCchVXIG7YjvNlzjytKH1nO e8BfojXwuaWtaR/hndzdSJ2BsizwnkI= ARC-Authentication-Results: i=2; imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="O/WJMKxC"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=mU+QhrPz; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf27.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=1724354761; 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=6vYH9SFXEQO5KOTSg7PMHGnjsSkAedVllgsa8y7P8Xs=; b=ZYMmyj3D0uI+R5LurgPGtROOlu3WJeCEw7l4dx0psCs4fVyts9o3CT/d+EboD/NcVWxZyL UnXbMovUHCw7urpxeF7H6xORAXIfCI22Kz1cbO42+4CNYWyt4u3kcXhMMjr8j3GAQhuQ99 VlxU/XrCkORWksrfa5jeeeum2ghGPwE= 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 47MIMXrf026383; Thu, 22 Aug 2024 19:26: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=6vYH9SFXEQO5KOTSg7PMHGnjsSkAedVllgsa8y7P8Xs=; b= O/WJMKxCYiPs2dSBesNSprA/RP1Vn7sxD1jGn0lWUakHVcfmMf7ywoaeGJ2hkpjg pFCb0RmNRHqNlYuBHSMOs7ipVVbaFS2ToahzBrXgWc+oM715eC79TGTTdefsvwHK LUbZjJoQidDC38kfM8h7OQs8k10pTyL+VzrayyzbAXu+OHseTJgb1ahzKFiF0TPw cSvyVMjc8iEJP1V8UTx0SjanB8wXTzBukswsThPu197zcPCbo/KzbF+YpzTMe9OA zOZUIcyWhdPJHEgX7OD89IhQ3y5yrSMYy25mdNI5pp8WWF7GhDJa0O6Wcaij4p9f Tn94wqLBsnz5BNmF6UhPZg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4v2wag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:55 +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 47MJJK8e005374; Thu, 22 Aug 2024 19:26:54 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2040.outbound.protection.outlook.com [104.47.57.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu08ec-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dFkWXXG3Tuq9pJBq0+bchU6T4CRvXCND+kIfRQarUrfpUDfEGBCuz4E/ky9/nUxcg/wid2duPpAp57Zkl66Ncqc6E9w/Ydq2tZwXnDERv+JMhBi6Si+cTJlKWr+yXQDkBAR9WKNYAjPicLwt6caGznu9GAYjaandug37x4m7zbsw6jnTSyrR+LLQRpNud8922dKzIY/Or+BL0e33/HF4VBHouA7RqcO/q4GW1fTfq6S6iIPvLZQxspiBjP9nqi/qMb8jK6nts6Bl71JawBfMRRPDGvRSG8+qxGmD3ZF0hp7nKXYACyY/rQ/YPKt4734YNwAV1JV8YMq7/95dN6G9CA== 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=6vYH9SFXEQO5KOTSg7PMHGnjsSkAedVllgsa8y7P8Xs=; b=uPLmAu74y4aBVCBdLwm1DlS9jL/CTXRU1iHABB7sTmRyykynzyC+kujWQnOK1StRI6LA79U8i2gmCjXQHg0PmsA/3CuX/NdgB2ZaYnKVVexzv/ux8BxUH3jxsymbE/HgKQwTidPSzzWptD7pCUtrAVU+FuiOkVlKjQZYhFa888IM5Ba5u4erV9FXf3rzEeXm7QsP/yzQs8osEAEp47tleN3LeqPi2wvOqxKoJ4/v6QAJRYglSRx1GhUZXuoDiTJ6zhSijG5jOnbmyOElqJ9OXuUJMAt+2JJ7qA584eURGkIRWSs6AIBxeQepx/xkxHTBfdCo2w0BrC6CgYgNmUkOmQ== 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=6vYH9SFXEQO5KOTSg7PMHGnjsSkAedVllgsa8y7P8Xs=; b=mU+QhrPzpavotwIjunPeb0u5H0Vsgt9Dv/D3NaVHeyuJuFQNyamzZqxWKmKSebGJ0wV3eyL4q9HcWxPpr6LvPS43seDYE0cNU8+V0Qf0+d4AAjObwVKUIjG/ExRF5LLLckzhbzmPONWPBd8m9OT8CZ0XD8zbNw5hTjWH9cCGgvI= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB5729.namprd10.prod.outlook.com (2603:10b6:510:146::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Thu, 22 Aug 2024 19:26: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.7897.014; Thu, 22 Aug 2024 19:26:23 +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 v7 07/21] mm/vma: Extract validate_mm() from vma_complete() Date: Thu, 22 Aug 2024 15:25:29 -0400 Message-ID: <20240822192543.3359552-8-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0269.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:109::25) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB5729:EE_ X-MS-Office365-Filtering-Correlation-Id: 3aa4f20a-36dc-485d-4253-08dcc2e04ec0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: gTYL3NMMSVB1Yq5Xa6NgeWT6QNWosn81z6Y+59RlL1omlI39VF6nfRDeO/5cWPj1XvOyNrya7sGOwbtmmzddXcumoOIwCXpDhA3y+9eDlNicxXn475rs4w44eHY1jfttQh6REX8T6RX2vLwBdbYG/6x3Q5352GYnnL6nKSRwmFPxllnTO19FeWAXZICn/HfoO7cR/sQl0EyNfppAm9FJoZIXJ3DSOJb98a/mTum48TB+1JwfEB6CuLa5WgQDND7dQfNEW8EB0Y+AaOfGMssz+M4XvOmfZZI3R79dx6L89AiyEBVOn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ispam-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)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L1Smw93KYn4B/eVzUV2vwz/CdmSYYYTQNcV2HTyrq2Nb2oft96tKdbOUTid1uZWZHGdlkR+75+SbTNxaG9nMJIvLz3VgPZs0nyUlfGQHTHKwUcCFgvYb/jMkgJLr55YmXTo1rz/zByuhrz1mQsR4yVoQQiUJyhkz1SOhf1+iNxV4Krkr64k8dCVYSnEqxm4Y/glWcJWtNniwYyk6581JV+6mdqLTLPQBbWuT8AWuv0f4HdNCXKRq6Nubu8Rtl4ROCzr/25Wt3N9VZ5Bs5LQq0v7t/KZjY/f4FtmGzk4SZjvwO2b50cHppNxoVxIYQHbpl+wzfRN0lRUZOKyzmV9sN8zvd00gkU18RYzriYlcdxxUTifFuUgMeJoVp9SrV3DXi2Yqq9mXRv2JWe8pCx2rlqfB1osgrtD49S14gu8/7EzOy7zuToYStTw70U18iHm6NwNiHgkFBlff8nFRJLAkZTZY6zxtN4yqzGTzR+4CZenRRxiaw0D93hBkuAOOuHXbzYlOXbZAU3tC+ll1QQVNPO8Mzay7LExNSUsn9BGojssS4YCY+clrBnIl51rEQ1x/Zf7MJ0CLUAw7KsADhoKo8PWChOYSyotsTUdCkONj+fbWMP5GTKaVGlEiuStatVaBVOfYGtVMjBOY6n8VCU8+HN/t1pN+leL0v8PKEF3G480nPZvV+rdg6zt7x/ssC+Ww5qANoqTyLzwF492Vom4oELTsfe4n32MJU6nzrHOePT72acp3n/i5sG0HX3ubHZnetTOf8Po85I9qmR84+FsBQXFkNfB4SvQcDH9JlcbU4LND/lnp0pLrmhCjJxvSx/asCrhrKeOAxkDDUP6DbpfJyjOMEBd8egeOD+uMk5jqY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FPqoLnwFnLfF1m1Sz4CC0lzmnv0krhQZE0TpLfByNrpLBn9WDz4GtN+sK+relfbJk9YFAtcRTj5xWt3bq4uaUNj/pB8jlqKGdgoA7LpmzkSGS1k4W5W+u8gjFMVJVHfmSxXmKVCycZ3A4j9/8meGRNwIYqxZsHfkKqKRUU2W1UAQIxmpXck5NEVDD6hnL11s8CgaMiThppYoaRl/mIf/tllVSrE6dW3CVfoEKaF/XlFdjBt9TDwREQ03km/5Fvq99J7745np37Gq4wq5Z+VwZNhBfLM881A7/zX4C6Zzd4IdrSHthEzbvSeSY0JS3xNUreZN94Q+mWaMxiY77SIL69seqM09T0TyyQwLDLM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3aa4f20a-36dc-485d-4253-08dcc2e04ec0 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:23.1717 (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: eoOikg5A0OFVYYLBeqPZxJDFz6iGgwmrnG/VUIpDfv13j52WkpqQ0LczBL2maTBcZRnHwH2eEPtJnHaXzpTVPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5729 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: oni2CGUnKqc-DXUWQ8lgtjynDhRirt2l X-Proofpoint-GUID: oni2CGUnKqc-DXUWQ8lgtjynDhRirt2l X-Rspamd-Queue-Id: BFF9440021 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: sw3fnmz4nnqozcjhmts15gxwj795o8qx X-HE-Tag: 1724354821-285420 X-HE-Meta: U2FsdGVkX18WXkf01f9RlHT3MbWLLg4HVhV9f+VMbpVi34Ggb8YJ0e1vHTkokGFfhMkdoSWBk1tA2ce58M7pGlQup8IRsQ7q4Cn8oj5K7cpCtkORjJ2wwCLWUgnMIrR4qOe1RO+/ni3fKUuW6tLu+qYALEkFfPbAi0e9HpzPkz7lSsVdY6Ng3Zgim0ctXBBbCUydfens/2MAxCCjUD/tf+7IMDUXC51GNOe944K+ATzEcogFl0Z7cIXJk7ASd2lpXH7km/NnjHDPMMGq7Cwq81zlloeMAXpSjkoHGNxG/1UzJ6knPzVvhKBQJcJLqeBq3ZQjoqz1Hh9/hJKT3dzTtPP+9TaKPkQPPmpN0mSb32ZEt+z4r3Vl2McfmFND1wzO4Y24wQFoVapb/g05Ims1ckMnWPiWurP76ojtdls2WJlrTChNM7g8dNnP+vRwsUWuMv1tIqtkme9B37SM4AMMfKKTSHuqY1Tog3pK7uQs8FLsh/hLAi87JzmGhcqsh5z7NcA48KiuAX8OV93VEtlvr0Zn5Mbl6j/uUgqVzL2+SSPdtBE8gxv/xqqb5tMEE2Hbze6EC4kqott+dp0yP3DkdtaYFvV17CskE0utnLJ6pFQB+HnJ8gRlcAIyfcaWiJKsQQn73PNrT5tljX7c8Nymt4iOUYc/2IHcIFgLHDl5/X4ZpcPPu4WErtduMV6YxzWgZQ93GuWH5ZCFSmD75GWhj01URcmYb+Gzo20ebhGCTr9pM7b1wEbRcj3upIg+CCVdObdmk2XcWxeW/V/Q4evW6HmKn8KhpJ1PFNvbw9sL1RHBnVc384v4ll927eK6vxODK8Tu7PLOPtEkftCnxdW9eGwHC3bb3RVNiqcB3/vFw4xBPy8RTjvJwPqeoZ9roaGSOfgJWBBjxmm3HDt6a1mea/94XU+Mr1u1/Spv0lXfa1zslyf89lCKlO7QvlkcaXKEeZGqPEo3ISGlGSGjqvq NBD3N4AO /GxnQ69/1Yi2QPkEVdW0KhXPOMZfLXrUTWNS1VQHNNbxK1VK9VwL2Y5jXDO7XQydNCixVb5tlmA6vUSj7xE3RpY5XOC4zxAN3srfx1dd6d6Z7UmtOg24oBgexif/zwcjnwJ5E5AgUpIzKEKunltvb/VEYizFRd77q1yOQTV38sMyjZD8UDk4VvMvIT9tbXD0PsIavYp8VO8V8jg7G/iDY+qalgiMUgyejb+aOS3y445uZ1k4psPvX0WzaZjGyi7359kD8q/YWd0ySQv+kCntfnUaEJzX726cRyplP+QeChUzujGuFciN8/BXUT8xTdF9nzl/xBj0VWD+25ukDk6f00YaJaJsIU0f91FeTLN+zGUNewsVP0AuzaLrl11gvpu3/u4B2PmzI4dZhz8U28TL2CCtfuPxmceSxtKbrHKCb5jEbzV9uTDtwj6GfDXZ1NOFyoQ3Bve6G3IWI1m2D95btCN7wFGpYSARjyGzY60d0z+DyqiF2YDcXY1kWOIptbvoZnsQY 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" 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 | 1 + mm/vma.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 30ae4cb5cec9..112f2111c457 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1796,6 +1796,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; } diff --git a/mm/vma.c b/mm/vma.c index 58604fe3bd03..f061aa402f92 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -269,6 +269,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) @@ -548,6 +549,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: @@ -589,6 +591,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; } @@ -668,7 +671,6 @@ void vma_complete(struct vma_prepare *vp, } if (vp->insert && vp->file) uprobe_mmap(vp->insert); - validate_mm(mm); } /* @@ -1202,6 +1204,7 @@ static struct vm_area_struct } vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(res, vm_flags); return res; From patchwork Thu Aug 22 19:25:30 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: 13774128 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 79A61C3DA4A for ; Thu, 22 Aug 2024 19:27:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B5E78005D; Thu, 22 Aug 2024 15:27:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 666858005A; Thu, 22 Aug 2024 15:27:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41B778005D; Thu, 22 Aug 2024 15:27:13 -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 22BD48005A for ; Thu, 22 Aug 2024 15:27:13 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D0C24C07E0 for ; Thu, 22 Aug 2024 19:27:12 +0000 (UTC) X-FDA: 82480864704.13.75C3EBA Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf29.hostedemail.com (Postfix) with ESMTP id 954CC120014 for ; Thu, 22 Aug 2024 19:27:09 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Ij/wZyPv"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=sMIiuek7; 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; 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=1724354812; 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=MpWIi7cMQmivMHPf3/Pmr7r1vB9/WxBvplax7ihq6P8=; b=SkIsXHc9+80l88I+pVxBOowZvKOxo+k1PXSLENIHT9pMXvqn2gwPBoGgEIqZV9chesdvml IUahWGjPNS8K0mqwUUPFTDrSR8uhbnVx7wF6tNKtphTqki+ZLRNXe5j5gZ1D1ilVZgtYlU 7JOilydiYn2jCrvF+x/IhLm9IxGjAFg= ARC-Authentication-Results: i=2; imf29.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Ij/wZyPv"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=sMIiuek7; 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; 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=1724354812; a=rsa-sha256; cv=pass; b=LhX3PiRYm/kCT1p4YmMoaiXm3PJW45IX7e6bWtvUS8TkR30psroOUNp/VCXQJeGIVBVmpI PTtXZJGwjdvYM1e7CDKFbI06ugB5dhbAKCBhL9/DsebwGWGByefUWf41IYVTKoDUh71Zli j/Afl4/V1kWGHAXQCqua7vdqfTyN4d8= Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47MIMijE016087; Thu, 22 Aug 2024 19:26: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=MpWIi7cMQmivMHPf3/Pmr7r1vB9/WxBvplax7ihq6P8=; b= Ij/wZyPvePB65w1aeiQDxkwS0v6kk60cTbqXjYGw6zz6xE4zmOZCeRY/lxwcXKmw 9GitBAFTZLDi9wIAIRbTJky+Huw1gMO+6tl8ui6/E+rYITOdMFcFLfyj6VxAAyoW IKd3vEhxzDyLmcG19XaTBKMjxo2j+K91qnXjueQLj7AtwGM8s+b0ZvxsC1r6ppiW 0E3qUVqZDuaaN38QMisflmDnmtZv83qWxipiDU77T8uZgG2KT6J4laLISdHLFu0U sH5Ar1O0s9Ca/PTi6Wa1RBDPbKMucgXDEW+s9llsYOIQcY8veao2I7D0/41nCuRx FINV0gwsvX3Hm59RQCmqoA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m3du5kj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:55 +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 47MJJK8f005374; Thu, 22 Aug 2024 19:26:55 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2040.outbound.protection.outlook.com [104.47.57.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu08ec-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ho7qtT1nbx7Ahu5PZjjjZs5eTZekmcwM6tJuUkaciGxlLtES6mfZhLkzwWtfjQT2CgkbZHn7ySzWTaW/T8XXq21hMadMWFvMabj0TAbvVbnFzly4xuwOUclFCtopfinV0UmwAwxDmSmDjvTJ7XgRCNdR0qrnhf+lDBmRseLKH7/xmtSGzu7KEacFZe6gDVPHD17fWsZXhNJGbmWv7l+WbajmxmSZmSgm1rNRxIfToxld8TmLTCFIGvRp7tVDXHt8bKgIWX3taR9lVgHTsq5XkuwuDNFlfa7xVsToo/AMo+k3zsUk9l1OcXDWRt3MqUgssC6XWUhI0QirlDC0uIL67g== 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=MpWIi7cMQmivMHPf3/Pmr7r1vB9/WxBvplax7ihq6P8=; b=g+Afx9R74JCqqQO2zw/yjdS9nf4qjBWBzCdOo35F0HrS1sLJYIFjBe+7/uPIcYWv4bThD3emsysQGXzTGp85v8e9B5FmdeVfbrI+d2N2IEfPB6T5S0/uPz3wrxaQcW9SctqhiZTm+BKwnqbY/7N7bMg5dKGiwVQaRJSZwKWbKiwU8BrPMDCqjgWOCGR26q3c2lsB+NinHUhcIk8rX3EGr+ngcfX07pOvo6FdOp0Nx2h55jDc8K6QbGPBeE4I8Zo+2Q1ExJLqK0DoOPXaYdIZ1V4o5JpyD3T8mPflbQ3RtwSsaDMZ5TkPICxapC301dgy6qeZCmzKQDhVvsPyerT+UQ== 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=MpWIi7cMQmivMHPf3/Pmr7r1vB9/WxBvplax7ihq6P8=; b=sMIiuek7GWajIofwmqdYeqvyVsjyaCzH9XormY0+i6HXg8H3RlfrKKcMMce4SUjRVfIt363I5KjnFUm3G1jZ9S9Si+viWE7I7kqVlGljcHu6lQKcTXOtxnmarooTHmzDWr+ikTPFaEGXeBd77ilmkND6YWyc4UAFsLiTVSydoDc= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB5729.namprd10.prod.outlook.com (2603:10b6:510:146::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Thu, 22 Aug 2024 19:26: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.7897.014; Thu, 22 Aug 2024 19:26:25 +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" Subject: [PATCH v7 08/21] mm/vma: Inline munmap operation in mmap_region() Date: Thu, 22 Aug 2024 15:25:30 -0400 Message-ID: <20240822192543.3359552-9-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0199.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ad::23) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB5729:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a8f1d07-62cd-4fee-253c-08dcc2e0501d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: mouoI6yc4hFWSx5nVhptBO2SlM01D7zirctezm0WCGd9y7j+BvMT2n1gIXnupqV4IVk6ouulEgNrqNf0QrK6FYzdXEGE8pxF3cK/vVRbi67nK03/R75XsXoJPwqkdCQ6e/kxhhsSrk5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YpbYphfwpZlTuzC+5U3KeifWzPeiEZLZ9nc+tKNzoPHUWHYS/y+H0VrCrQ3bI8vjig2yiK8Jhbg97d/xb3D9XFBg9oRB0wy+To4UKmgodiFAOAoYqIfvfQlqaPNw0j8l1Ugu+ixrRtxRw== 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)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wl6XKmCWNjH5GZMbhNrQkrJ/ty0JFNDoYw95DeXOx8MvpfbsGmg31EriMQuGYZU1lWVINT83oBhVk1vN+lcUg8gny8/BEv4hfHBMe29JuU34SVQz3vO1Sk8WEBlUpasi8QRZ00ZmX3gs/hEfSMGsKgqGqAP9p77YRkCT+U3/OhBCTjTD1L8XsvzyPwgE2jdtRLEHMvEze+lgwyFAt4s3AYznlDNmVTc0bOpN6u0NzJKkPUnsFjYpCqzq5dOMlVvPLlNSS6sSbMbKjkNo250wF5OUzMJLIi53IOrr8IjwfU72t238OrziC4Y+/RpiiPhhwjwEea5n9/AkH5nIaxKyFCC79ykJgGaE5jotF+rLW0BpgQHYc4j6WZbab1U2QnB5oPm7G2Wg1KRsdic9sJG0R3cruKBfchcdyvLhoq8j7V278bm59dC2JW2yDOeX/afuJPSY83tIS7Ds6R6j7wTvHXd/11gLVRXgCRTwPdD4+Ov1zx9LBT9SrDJAcT40y3khbwT6WyWqr2CA1GBooibTdxFka9O7GVNDaeGboVsLqLOr+b4J5M/laHx3ihN+xK1nX8gYE+N3o+W0aQWC8NIMuDeLrMRIiKBqjUY5kkPpoyOv83dv52BTwIzjY1P8HzVG5wTAU5CrMekWOgUvcrfvsn6yaGoicZ6mBquXpSvN0KXuGpCqOMc7Nu6DRAoPUSXT58hozTqMwSk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HLCK/WzvwG8M+cg8Cl3QfeElNJhHlhtuhKimNDY48bmY8kyYtUi94qU9fqSs8yEijqdrpI//N/cYrhuI2fAG4Yg8fypx4Capyqt+J839DfJks8kVEwOf1NPnyFCVIHjloWNvRCGq1ipe6a4e0HZVyHwFe/syY99kO5HJ8BWKgBlfiNl26pGrK8fqWEAx1+zOe/PkFsJNHBg0SOAdPlG11BsmPznXQi9g8MLTCG0yEtnfrTmL53ev4vaUxbErcCU0+YmZ+bwFsRHowanJQ7vCYUf4Rou2CTIGISedybRztxwbSrczrVC11gMD7uY7UVlXcOt1wPDD05Lru91cAldXpVDbFEBJuEZxtFtVeT1/YKXiG/mvB/ry7HBqaSZHSEe/8AFQACVuRc2MV8gwMqPQP+jFQtezt6UBdualWk6bYmY5JUc3H10me5zTu3AgQVwTbr8SW+vAJmvaeHYneQZJo7M1T8PCBCCkZtOM/7NuTd+ZP+/yyrf8ubEguDe5tOW+PA63XBgxofylDGiBQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a8f1d07-62cd-4fee-253c-08dcc2e0501d X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:25.4892 (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: FAHVP44Airy2GUCJTw54OifSDfbUPYxlD2Tmbik5mcLHDjLicOPglidFlqWaWCHWkFKDJNXA2JxQx54whqiGtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5729 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=925 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: dW8BNL22iIqjVJJGV-2vlWIi2aFHEq9G X-Proofpoint-GUID: dW8BNL22iIqjVJJGV-2vlWIi2aFHEq9G X-Rspam-User: X-Stat-Signature: ngppo4s6ksbhaahrkg4nwp5h1s87tcez X-Rspamd-Queue-Id: 954CC120014 X-Rspamd-Server: rspam11 X-HE-Tag: 1724354829-670048 X-HE-Meta: U2FsdGVkX1+8voxlzDmtyrWwEitVBtIehasHxt4LdrJozbiQ9ncb8Yx2FfmqmDuVvtdP1qyjVQHBnuqJ621OReN3rttdnjN2N4U2sS4rfE6WtrHIJGtMOi8/t4VT6vV4/ra2OJeCD/NQcvZ9SYj6skfnxnw3Q69w1lFRdaHiBtIjifTkeERqHZ0+YWVUPUgt1gsi53Vi4ZVqui9/YeRULBhq0xbzTgimy/haZypbNDRH3ILIIpwqcKs1mbqyQDcDGtHyjXMeB+VXamNdpOo75K3F5xxbzw4lR182xm1nVy7PefJEEp61MY2eKuryfFJjI09O++gExvLuPRf0iXqZNj2ljqQCF4uAsvENBHvijScvWU093KRO68stmFYd7zXqUDPFgIjs3+3cOjU4jLBZc9NrFG4iYWQmbJQHpqLMW8o6OjqUNnbpVm3HcM8UFzd8USoipkk2we0ABebuXQBC5FtpFx9Bj86FPLGCgPMyTBCAt+xxSs6RKKRcVJvGlwdb7BxC1b890i3hL+wnrUfSFKI6sGfz1JD5pgyItD2rR5XUCpOsOW5DtBv5GbOZVJERnUlalxlQWIdyw6JyZRTizyhOachDJ6E8lu1Mxi9WLIMyR5boeWOA40Y5dU5Y8uF/tANGFi4S5N8xpRBYqWcChWDDiUl2pZjUjzhT/qvSpGhImdoohSsigl2+6KTUVn3WONtwZQbARVwP8oIYh0wXfxWHoRllYDoy02QNUaAvpc+myVWH34zHQseb4IeS2xDrKAca3P+9vgIJZgDzcUpOmEF+4NA6I4iMlMgn2unnIcl+J66FJNTj/nMjnQp9kzphjtUAELRm8e9f06eJjnEL8hY0xbSMdV3JvK/WXC6hAK9C185tDdyYcZnY9fU0yAoZSQuKElsfrkawDFWL/tBM5UEj01xeMAJyFTUYBaMg5B+N2sefkgl8gcz1G0qqlsqKT/FGhzNhrq1juBEjksZ 8NhdpEzb hKSdIc+mcoAamhQ4MXl+n4k6Iv6nQTPJm8TVBbOai/FbNWvzgU80GbGCB4GxRngF8izrdlRHQhuBBoCNc7PWudMxqyb+j26CJDH2Ou+P7jKaFhmzMMeyH45yqcuFP3z0n8ZHM/KeoQpWT6ULp4MNVhlypAVEnHxsetY5YrZPwUTA5Nm7Q1lhGuCQn8DiMnkAURF7D5xO0DAwTHVbcNBHJUCeD81lMNFK7LN0F0+/7789/eA36d/cIGmt/aY3V8UFh1OYbIplQLr1gjHf5LvL/zvEb/QGus9UFThI5glv7zAgQnZA5MhW+CZ/heau6XLo6mC2qaNlIhtipjtIUrM+zzhQkuyx25h5RYfIhJAdwZBfhJ/EAiKVZSJyZs3lXAAQ9aFKwjynkSHoyTySRifNLs3wXZRkrWEl9ghbemKUdeaBfxMFutM34OeKT5tJnQXzhX+DOrjidAUItHG5JzxoMyiWMq0pdROnNXyRddj+U1/5FlYEt4TischlePBOafk3gzmalRCXgwvo3UsjN1b3pF5lfVSj4lLGOCF3JusPcqy2EYUI= 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 112f2111c457..0f5be29d48b6 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1388,12 +1388,14 @@ 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; + /* 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 Thu Aug 22 19:25:31 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: 13774113 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 715D0C52D7C for ; Thu, 22 Aug 2024 19:26:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1A6E80051; Thu, 22 Aug 2024 15:26:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E531D8004F; Thu, 22 Aug 2024 15:26:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C571680051; Thu, 22 Aug 2024 15:26: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 9ED548004F for ; Thu, 22 Aug 2024 15:26:41 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0E341121468 for ; Thu, 22 Aug 2024 19:26:41 +0000 (UTC) X-FDA: 82480863402.26.A232EB7 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf27.hostedemail.com (Postfix) with ESMTP id A15EC40012 for ; Thu, 22 Aug 2024 19:26:37 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=K6l03OSv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=oWUDkyDG; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf27.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=1724354716; 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=jbqzxUpWaWhe7HX9TTqUu2TcUsDnEJBssn9V4YZ/Zgw=; b=4YcAHSNlWSKjUSzttJNEZR4HGquyYcYXfXcZrw7zJS+ZNRAcwcZVXNYumYKBVFmh0SS/Zg Xb1VxjxG1pJT6noNkMCNAi9CUAYMbsq7NLDOA1wjuHZv7ZnCnwgeqq6CO/+hok4nUKp5So wZkU4aLo2kOoacZm3mTcf/lgPaX+vE0= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354716; a=rsa-sha256; cv=pass; b=YZ1VHhVU4dZi23vfVhVvOsrubWZerO+QSJYt5tE0pSv6hrcAwiTIMa/awsGTjnPZkgB0vz DGV36V77VaqQLDPdNFpmZjxf4CiJxweiHXN738dFmu2INJjhDvAiaAMvd732iwdlQ3Qyd/ 3l/Aajog+YvGLbtpdeowX0IMONMC9tE= ARC-Authentication-Results: i=2; imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=K6l03OSv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=oWUDkyDG; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf27.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 (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47MIMWp1019191; Thu, 22 Aug 2024 19:26:31 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=jbqzxUpWaWhe7HX9TTqUu2TcUsDnEJBssn9V4YZ/Zgw=; b= K6l03OSvOpzRptIlJrTntQ44YyewF3XNDFmUO0KLsF6uxQBQKFCq7D841twyZGj8 eMlOyy1Ts8M5Y4cOtOtfbv46pcnQQLUTo/b5BKmEGPuqPZ/pTUdUx0PZEJ0WdLn7 hG++dY/RE6GpyPfMMVJFBqP41v4Nk5VkKXNNxLHWOpIcUCKH153r8Sksep7/Rm9C x8vh4BN0TtEz63aGTN2VFzPKl/0n/COUYJz9CgFUQkOLReVeNSM0SDg6VEYx5SDX 7egTvuHSIsmIC/abup2JhAsMNFtWIb4cL7k0RKSM2DVvxl+BaqAFbbdhKQ4MII2C ntnsENVfO+F4V7Xzj/XnBw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m45jw9t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:30 +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 47MJJDAA005150; Thu, 22 Aug 2024 19:26:30 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu0830-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UzezXIb3l5IvbG0edol9qE+NzezrHfQA9S07W7Jx8obVj/dAYKBbYIpNe1yvOBW3ujx7i4n0pbPX+k/VBUvtJeifPy4F40R7jho0a1vWHCptZeqZLwFRsTNvxSOrSSrKG8uRkGAuLdu2hu6bWyd3Ue+sIOv21zqcYCYxPyWHAZXBDl5NmFmQHOqRJZ6FN6U3JQ0fpLSnGrYXLH7lFObXek0cUj7Ytvw7iEFfZbELwHZ/uJpoHhOlIjfu0YYjwqqvnZiyFUtHiF8o2gltq0B+ttAKW32UkAziP1TLCLjfksRxI/o6glZcrvWRLxbLokzQK96xS3MKI/HqkDnIeG1PmQ== 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=jbqzxUpWaWhe7HX9TTqUu2TcUsDnEJBssn9V4YZ/Zgw=; b=P+ST1HZMOhfeYHg6huLximeHUZ/QHhkUL5ogGv8Y2nW1rwh3Uc5QJd+cmjRXAf7cFhrX4aaaAHekNeWLMAnHbUFEhfJtUxBheS8xomqNw/zT9e5z8qVx1klQt4Ujh2J6UA3jlMC0/ode98gvF//PxlabVsU0ex7YPO6ZcNPbdZ5PkR7cj36RIDrozHFfTq+Z9a+FoUuNJUvkpHjsLK/9D0MhuSAS/zgKrBox6eZrt/6h1mJZmRTYnCS452DBTU2A0DoQUF3EVxLpjftEiW46vhqL/yFjud62ewSGordxI2LbnEHsRV3ITRWOCNPf2TmOcSFOx7YD4N8+7Yq76SfVqg== 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=jbqzxUpWaWhe7HX9TTqUu2TcUsDnEJBssn9V4YZ/Zgw=; b=oWUDkyDGcDEu9JsI3oUKVBqWyQSXjCDjX0u93+CJ3x4XLQ+st3wO4DFGt53G37NNpkTQZGMYKqTt5VBZHQhrRB88E5RumW2PB5z6TIr8cg0FE0paSBzHsXQcGwkDeMHODoLswd/ki9uqdjPNDHLo26BehUi07c1y0g+Y+W77sKU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7356.namprd10.prod.outlook.com (2603:10b6:610:130::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:27 +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.014; Thu, 22 Aug 2024 19:26:27 +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" Subject: [PATCH v7 09/21] mm/vma: Expand mmap_region() munmap call Date: Thu, 22 Aug 2024 15:25:31 -0400 Message-ID: <20240822192543.3359552-10-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0408.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:108::13) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7356:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ec38b72-d7b5-41bc-99b9-08dcc2e05133 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: LEsX88v9PAIfVgHjRJO3egkqiTLScIJ6wtrGDCdzBOEYEVS/7NhmoNpJhtO2djBtxpe4bJuyRcy4dRSJsUm+rAeRCTmQWVSmjAYwVk3Glpp+fQ8wV65gtutsXA16Yy2jOLSHzFZKMMkBpwvKj25dzJWxWvIKHlJL+JoJg6ax/34j+qQZE6WW5090aECqYcu//7MnZ9DEqt9xWvs9+K4779+ARoV44scyN1R+isrfQl5Df3NgKTxFS+KAGXxrC58ItSpphbYjo5hWuthinqvF6NSA9OQl9G7xy7Re3W2IO5d2+WO0m4IXzB21iC7HF6G1ys+Ql8EBozK7yTJQH+V2RXaBf4qPw+iJ7ZoYVH/207UmoHQv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I;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s2JXRcJLYvNAEiZzwI2bjfv2+sp3cou3XENZ9DVWGT+wjYAR+mm2jIQYWkMxNrcKcx6TAZWVeJfRDnLFDu9r3bB/PoDg3yA5+UTE5y8VfXnupzN7olRmf0rX7Sc/m/BYfoy++dSLMR9Leidr/rMYWRXzgxj/6Xjsd3mPZM8GCIdFUNKb1OxpnC+IAiJn9dKjqPUP9Ux3ikec/LcaOxmuUhKPK3cT6/u95JW7HGj2AfbKzEVWjBJKzC1AzkNh0zb+UNt7ub0pj4Tn+phuo/F32BGDMAmmV9a3mlY9tFF+6419NYi/09w+f62YXTj0fLHIRHf1AuQIOkKQlDUQx5bcjPUwME/xyUA8CE/ATjModaMlzxFuMSoBsiyVM5KGKOSk8FZv/XrXRap8a+G+YGYKl2JGsIFMvjCY2cIiX8+RwpewW6yhSBHS6WAAbVbBbFJVMlS+ISr0M6lWhy1AX97y05glb0O5x3GHRtUdoyl12FB2M+d+K5MlV8X+qD/2Q5/lvAqD66afpEjPrIaRSTDkBouU3AhzLJ9yFmD91pUtzmbC/uZ9nmzy7sQhNuByMF4jIY0XevPwZOouvB0i8ZjoLjzoFX8Q0E5X+GcZzS6GGaEVQ+e3Wm+fu0bEjhVHAgCZcyJ89yuwrn10h7oly7x4pF5z7RXrmeK85zfLNRgFgRJ2aDOtC5cXZ311YOxp8mN4DgjVNNzcbW0WEJWht87Uri91M2ZhAhKSrWFpYyOpcxpns/YYd5mttELe3qtniFCDgLUDqMHVx5FKmV0AJ7+vxzAdSRuDyfy4RnTjLBLr/fPhDIkHRSf02js3O1qUaqokZucnAzflHSIi+g2ohX93GjSsB7nJDLaRJC7FhAO69bzpi/lbslmLyIVq3DaORJBZtU2pzFkmvxj3q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tsPAjGcbcpJiJ1DBc0vXBe75p24cN8YEsH40DshjhNZW96MmMKwTvuavVA4jJfb0Z+fjLO93GakSDRO48RHnu5UW0DZKtUqA5BBiAbfNPcx0jExcWfWlYiqbsH94XaLIoBKStR7JWnFv0ab6OPMBhNaL31f0II52fctvcHfPXSqmUGAEq+sVdpECYwmvgd1chVpw46M1D90/tv9M/DtHzfLVRTDQRYUfUF2Ho5gTEfQOMkvq3fUtBttep3UJcjU5sDAuiAy7zFJ/6n6habkeClIJf5I1XzRDRr1qeDIJfu0E/1kyhG+X4TIvT+yVASXHPDxQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ec38b72-d7b5-41bc-99b9-08dcc2e05133 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:27.2878 (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: wxjpVKx/aAihFkLjjsOrc0OHttvSit3O9Juf4rthlm//io0M1N3O/4Xzfy5skWHyZaMeR2TfcAfnfaGy8JPVlw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7356 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: -oVf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CqNK6s0dv7fBQAs/UrZleRlbG0O34qsOjJhpEBOdBHb5i3CpdP6ZVjJSimzLQwMj1EQVZj9Lko4Sz0ujQqofo2LxlqoznY PjAfZ9MB zOfeaJM9Hjxz8UK41A0GHbdFgetEsBblI/qoVdpFmgmJ85/N+ng0/vdD9BZUrw2LKSyshMEhFLvGi5FfYdIKsswYZ+agDiDUwnrU7fQWbQwsvm/yKNPk9r6w0+E6D5GB4Uoqg+WTVtxVh/pkyWq7PZx8aqE9tSPQcuYF25bh0yfMRjhSFPfwSDclW0QQvtm3iw/UcfU0sXQXx0RIEjUEX9WZTfYIHI/xsG5UkiQaNbywO5VxOxvImcXneqkcTEFch0vkOzInfi14C4yw7bPftULWTQnrBgWh9z2evMAsLzUkoWmql1oQ0w3wGYuS5t50P+p0GUn0T64SEEpGOFMpeJLU9nsC256hOxa5vDnAc6IEWFTjEKr7chL9SwA5pjhOhY5GGmYRH31wISYGRP9DdwGjID86D3OP70dmFkcqVA4+9RZxjqka4FgrGa4UGOlC6zlmy45yD6inl8YaFF7uYXxkcnQ== 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. This requires exposing a few more vma operations. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 26 ++++++++++++++++++++++---- mm/vma.c | 31 ++----------------------------- mm/vma.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 0f5be29d48b6..e7e6bf09b558 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1366,6 +1366,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; @@ -1391,10 +1394,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); } /* @@ -1407,8 +1427,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); diff --git a/mm/vma.c b/mm/vma.c index f061aa402f92..6b30f9748187 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -80,33 +80,6 @@ static void init_multi_vma_prep(struct vma_prepare *vp, } -/* - * 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 = vms->nr_accounted = 0; - vms->exec_vm = vms->stack_vm = vms->data_vm = 0; -} - /* * Return true if we can merge this (vm_flags,anon_vma,file,vm_pgoff) * in front of (at a lower virtual address and file offset than) the vma. @@ -698,7 +671,7 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) * 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, +void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach) { struct vm_area_struct *vma; @@ -752,7 +725,7 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, * * Return: 0 on success */ -static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, +int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach) { struct vm_area_struct *next = NULL; diff --git a/mm/vma.h b/mm/vma.h index cbf55e0e0c4f..e78b24d1cf83 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -78,6 +78,39 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, unsigned long start, unsigned long end, pgoff_t pgoff); +/* + * 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 = vms->nr_accounted = 0; + vms->exec_vm = vms->stack_vm = vms->data_vm = 0; +} + +int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, + struct ma_state *mas_detach); + +void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, + struct ma_state *mas_detach); + int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start, From patchwork Thu Aug 22 19:25:32 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: 13774119 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 482F0C52D7C for ; Thu, 22 Aug 2024 19:27:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95AA480055; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FD238004F; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DA3780055; Thu, 22 Aug 2024 15:26:56 -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 4B4618004F for ; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EE72B1607EA for ; Thu, 22 Aug 2024 19:26:55 +0000 (UTC) X-FDA: 82480863990.26.9BAEE46 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf21.hostedemail.com (Postfix) with ESMTP id 983BB1C001E for ; Thu, 22 Aug 2024 19:26:52 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=VYg7RxJM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=bGwzU7jx; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf21.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=1724354752; a=rsa-sha256; cv=pass; b=zV2csgQR1bD0jEMLF8GddpK5u7E+WgkgSezZY2mphxaJgNWZdBrc+TKrwv6StvOK2QdpBE 4NwedNmaMW+j1cqGoN1m0WqxxKDtb5OWoudHvuCU0uYdULkkr67BrLY8v7UOIO8izFMdgV /ZerBQPX4EkvLv8jUHI8cLJ9fi87H0I= ARC-Authentication-Results: i=2; imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=VYg7RxJM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=bGwzU7jx; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf21.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=1724354752; 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=RKhc07Fbuk3qCe2lrKepHFoKO/JwtwJK4RHQzIAhFhY=; b=WPInljHUr4lOTpCqXogGMSAPLNXWfqhzutOFlO92yT3fg/eu08P2mrz9zYa4/H7ubJkMXP jE01bpRkW2ifiHPj1W+YZbVtrQs7oLcqABcdT9N8nF1SDVh9CXXIeIP4SjWpXdyEIX/emm 2YrrWmEV6vf7sRE8L5J0CO2TAaEAnYI= 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 47MIMXAO029758; Thu, 22 Aug 2024 19:26: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=RKhc07Fbuk3qCe2lrKepHFoKO/JwtwJK4RHQzIAhFhY=; b= VYg7RxJMXC58fPuV0nhFlldKDexpm5j2kPsUsWFjV4Tcj+OAsmPESQ3VI1NfTuRQ ctvac4oYpHu3zfcajW+pkrEeNKb+nO6LfVbkue+80C5BipqWP3cHglflOinfCej0 WVu9EISCns067H/YOxkIoGOtwpoOeTjn3R0R92iouVxwTryTpMA0BjZ2YowRbkDQ +idOCEbYeyOuk9daf5hdwA+mK5GbHxUH8rocBvp+u7D/dJdXI0j9XJilEPxXc3bY jr2Qs+t/Tj2AVt+qxqji64ER9Ga0FlIGy1F4W9+qbZqO2chD5FdSAJoCUIgrs6qj 2kvKIzCgH3APs4NW5Nyyuw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m67jrrd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:36 +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 47MIqaPw019453; Thu, 22 Aug 2024 19:26:35 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 416b0b9ckf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PfOQSiI//qph2J9YwbBlhiWCqFYxiLAouuDLEbFld316M/mYg6SdSg0O8PazuYW2ghsVLNRWbgRjRZF/oUzo69Gg8t9VETNhK/2LDV+7iDsQGINo10QcCbDlUV6JdPPVEjHxktXmd+Hb7Z/7z5NejJBHmqrbnUjDb7SgL4Dr8glzf/ertUnAgZql14VIlXfPyKoj6NgxSWdOV6jH2XscbkBxQGuUzwHHwottdmyS5vJjaq+HhpJlEhc0I8BD8NGEmUyArSbQBaLddmIW9Il3qYUWKun9k2aeQLUWwJqBzsbY+wsbcvLzoNJ+4eAXILugPFNGgVpzIgbDkUq/D5lYAQ== 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=RKhc07Fbuk3qCe2lrKepHFoKO/JwtwJK4RHQzIAhFhY=; b=dUWvmWDw3Ks3MoHt49csrzGOqSVWf42c3YRIcdHcWUknDSFyUu28prVnoMqvtZYv/679Qnxl9jsTJ9bjmvxYPNyEF64fU4TtoOU1TTuKCsJZY0k4eMHhDrYXyaVsrz2FpPHbEF+HKLXCge3BE4LnsKt1mH/h/iTPgrvVtVuziIQwxYpSZrV1sMfq39QOzm4D61ibwuI/bvrVWPaPqcW/0cD+cEsyM1/OtzIj8I0lTOesJGApuyJz5PcvIS1/Jj6pjKlOiVmUSwmQI2w+qgb2lPrJ3EKILleQtfbRb2G+B1eDP7eMQ6UcCa7bpzVxiv/IqlsG71mDsAtFeRq/v6WBJw== 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=RKhc07Fbuk3qCe2lrKepHFoKO/JwtwJK4RHQzIAhFhY=; b=bGwzU7jxn7735D+qhG4eDj89ka/22j9JfvjfBmpDvStZyd7BpbbXLLtoHt0dAfuR9DhAd2UFf8oZrrWO3K9iRjVyk8M6suQQjAqQ0ers5ArV/ynZYtS5ieM3tjWwkodeVYT9GVcbo8cyQbmu2bM8WqkzVn/1zLGShIJIikRnVq0= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:29 +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.014; Thu, 22 Aug 2024 19:26:29 +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" Subject: [PATCH v7 10/21] mm/vma: Support vma == NULL in init_vma_munmap() Date: Thu, 22 Aug 2024 15:25:32 -0400 Message-ID: <20240822192543.3359552-11-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:82::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_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: c89b1153-a699-40c9-3512-08dcc2e05261 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: fDxvVSCYSgsRmEK0wd8IrowfhdGrp7zIpv316qvoWn0NYcDED0ZPKPqiDU038wp9ePTkbrAPRvnNEKGPwnE7c+dYeUYKOHDz7hyX8VoW6sS/gsJRKLu8DCNY9KlfwXUeluNDzGho5MMZe9b+Fa5iYXJMUCGgbEqwOQ5pHVxH+/LhjQoB7S6sN797e7Tx8GLRU5JacYxBJByVpLVVkcM4N86Nussdn6b8ic9ySLavBIYMlkWSUnjGioOwDJ/nX8M9SMJDZClYGQp1oxVNgyZQmJqRlQvq5sLtoNyAZ4kJURYI7NzXAjt2a9JpwW15JkV2uiIRZQuC3QOJlyH4M5SPNXkaRjGEd6jsScoeyNw3nGGCNTAs0cwCrOU+iMAXirPRRv69AxJDqXHRbuzrdMx5Hq0J4wFPJpUnYTkbYQXDBIb2p0yBjVPI6bUhmszBj9NJ66pZhGXO52R351hC//eOjZH4dXlW89KfdUXGAnXJa1llM+Eeown2o+UXBEqG4pDMM5P2NjB2mp/nUpk35UY7EIZRsRcJPasJBKE9uxEELurnS4AAGcQZc97aAqusq5/go9HrrxsdbdyCkVT9NU0HEiBVxyoDGeN62fhNWByW9v0x/EDsuAT9AMM70pg2seVr1ppgBYVg9H9cUnUOE0HCvTPWcVB4Zpqo/5hW0m0nREOd/vTFqyLOW1NGk8UJ5edIv0X3yO11elj2DK701D4aNlmwhWk/U8zaWeaZ/Dp0nOsLkiBd6BiG+rapIve2t8G5pBeiPBDtkrmU2JgFI92zlDnLMA2HiYhALS7qy3sU4Qa+6djoxuopPddfna2QbG781Qb8/Ly3BWRxQLYr1hNm0DQPyEYId5c+SxR+sY+jcUEMnRWvFJQYvFYAkFsHJfm8DEXnsAL23Rb1f9z1bTQMAbUOqokL64i/zNVU608HJZZz0ILsB3GIAtWdgyeRs+BnSeMCH5QnWgJ97zZKmqrYDFAzbuz3AgY1KWGC/E3mjcsfisaNcD1N1LanGNM0hLLdxkEsFt3ktoRg5sgF1fQzIvByi41DmOkO3qTqvOfMBISWhvc4P7+vinsGAtcu2hQ+WLpjnbW8cRi3KiEBUCDruc6FVg8IpXk/gxCOaM7oLqPiNh4jUqM47rW/k9rTgYsLly0MdC1ccNQxP8ipoIT9viHdBRo29phnFBEvUOWK3rEhn3BM78la5GPruFBjyIc1Sqb6NQuNyK3GFDoL5wnqtTK/9N6xh1U0MI+khTM42obGHva0FFxh2W9kRmtRIeU4HOrEHyAA/wLRFwjeL/2yPN6W46XlQVakEaIsafbUmBsUuuSxmo1Pb44Fw3eMkGwNfDsYhd8pElIFStMbtG/TVA== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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FkhAbY9atNoMT1p0IxKLT55+erI0OvX9Oq5fG3SFnGfX96OMVpoQaee7P60Gw293FdfGdqsAlLxF37Mi2U+ifbn+RU6scaJZ+8LS24uYF2X+pO9jAgMFYPlo7iagof+j9Wwc5K1Vdy0BznBs1AQg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c89b1153-a699-40c9-3512-08dcc2e05261 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:29.2401 (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: 6lt7MTMHA5MZC0rJ02GvpMnPVSL9V8M3fNJvP48Smz5uWh/G7LKFnMmOczX48RBS7Cl4tSu+LbbPxbzv0PYCig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: ksJX0AYixcUgqwMp0-Iif4tsc88hSg4Q X-Proofpoint-GUID: ksJX0AYixcUgqwMp0-Iif4tsc88hSg4Q X-Rspamd-Queue-Id: 983BB1C001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xh3ueymmqafprfcanb9ejs9f3pfp3qw7 X-HE-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T01z8qHLVdFGjtCCngJ4h3ktVEQCz+1gLOuRcsLu2vpyfz+nBP0CaHtW8KL98or8w+aiSTaw4qZYnAjCl5JHYEgKdvF5iAiC62031ZW30bXhdgsDLNYwBkSE2xIhMo5Pd4BnJjmj5uUo/1V177kbtNhBvAZSdu3zJNl/QvpS3qePBm5BaU2IRjC4njZ75IuTpGn42X14qhhnF+EL+099+6nb11zm2m4HxtV7cGhot99nqJx/BN9CaC16bE8gSVy/fJb9kVppkVcYIxxP6eceI4i/bqTZqVBclms2PUwa6ScNNgAgr+hUKGPqjqEXnwNQhCX5aVTkmYwZvb9ytWAWCOgFkOiFC3qvCjIIi/tS8x0DxV7L6EbGUWM8sjcSRBNRn8+TI1n2SQSu5zMWhGNh1RcQI2DWcGJU7zcEtbD8RYIjQjfLS+1U 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 | 2 +- mm/vma.h | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index e7e6bf09b558..2b7445a002dc 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1393,11 +1393,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; diff --git a/mm/vma.h b/mm/vma.h index e78b24d1cf83..0e214bbf443e 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -95,9 +95,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; From patchwork Thu Aug 22 19:25:33 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: 13774120 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 1E76EC52D7C for ; Thu, 22 Aug 2024 19:27:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D206F80054; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCC698004F; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94BC580054; Thu, 22 Aug 2024 15:26:56 -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 5EC6A80054 for ; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 014D41A0804 for ; Thu, 22 Aug 2024 19:26:55 +0000 (UTC) X-FDA: 82480864032.25.ED5A52B Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf16.hostedemail.com (Postfix) with ESMTP id 9CA7B180005 for ; Thu, 22 Aug 2024 19:26:52 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nm5rvLNa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TMTzKMoo; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf16.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=1724354732; 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=0LLZ3RbsTLjZoi+XWRh7T3mXeaSWkQv5kP+Gqd3u8CI=; b=xYDmX8zLPDI1vjysfDaX29EsU8BqSnYFoOx+/EuW0Bq2wESbBlfBzN6RZ0rzS9objPSAos VlLO7LrnFoJseOhUDukuLtRy90YKJvHx+QxJX1ZFLwpfXP4FX8Xu2MhskYEg0k9XnlK4jq /ucYWw1Y9Bfbk+sO0AZF+ak3GZS2UaU= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354732; a=rsa-sha256; cv=pass; b=pIYoQCMhKPc88qCnGgrdDfxGpGTIv+79IGdkmW2t6Pt1eydwJqasat+SzO5HWPbtHQ8Ff7 l3RFVsFUSAi7/0UXfPapx0IC0ton28YdyCkx/eDXS2KiI/xzLxdQo9OvIxqT89xodc0/0Y Yg8VBFW7X4il9aI1aTJu4H1NsmQOLb8= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nm5rvLNa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TMTzKMoo; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf16.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 47MIMUY8021045; Thu, 22 Aug 2024 19:26: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=0LLZ3RbsTLjZoi+XWRh7T3mXeaSWkQv5kP+Gqd3u8CI=; b= nm5rvLNayggSx6nNjcRrDvawcS4XkwMeNKVRXBV5pLN0idtarfv0G4WOiMyA5OaX nKe2LSskSPQWIioWWkjprn8bP7EgBh6rpmw/bgAZ8iRMvOzQy298WsVs+5kBh7Ys RfUiIN5t3dKom6TEqH3Ffn8Bxu8/D5oVoQu6aXvxp8DUtf9tjHsOEB5dWrKEnaGM XQ3oShKDTh9cOZ7fMhoP38tRwCa0XmKNktRhqgMnEE8HXZ3Yqcs6cg5vtLJ6UWyg vBnuv08J8bgW5vIrC7I6wzzxx5LEOjVS+IqF9Fr0Jv/I7DanpPdsYac7mWeRsJ3L cLm/vqpXjSYeGx1hUJdpSA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412mdt2w0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:36 +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 47MIqaPx019453; Thu, 22 Aug 2024 19:26:35 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 416b0b9ckf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RCwiZ1hYkklBzckBckEyK45sYFUprp15FzFx1smCgA2qz+bucH9UdNBTaD9vDMCSk2uFh2mKzEO29uKMkbOOauXncD0VKd3/qtec04ST/mzqAibxekNobnRfM5nqeFWL6pXHcITF9B1I4ax0PqYrheFDLWFJOZyrl1GFEZakj6JMSDTORKjHp9MVi9SA9M8KdmNfIa/m/M4yR4nH/+UGkdQnQC410mmBvx3Cg0nKMBKlktjzzY/hPjls61EQhmN/5P8dDB2ylF5R0O29x12wjCG7BJrzLN8gWj5hhVEFrEUuuIyfxqCBeYBfMthM2baTRmENZD80fXenTYT74N7hBw== 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=0LLZ3RbsTLjZoi+XWRh7T3mXeaSWkQv5kP+Gqd3u8CI=; b=BCHRsie2uTQgp/fuiBRPJB7M5LoN8lSM/2MWITTDdnX9M9GSqLm4Qcb2G5FLdXvhKkMiEiMJm5cAvSJRRW975WZUMGfPFZgu7Q3df/gWM8zQgIqiI75kZDqWmp39TmXSMPBhdg+lV767iXTCjd/i6sopJ/XZZbF5G4M+REnWnADp62u9XYLOM6tQewWvIBq9/6GdHv8Q1M22dCrc/rIHxSXZleWB+mF+nxrAlkQDX/v7LTDma8vdtPGWD1BKYEzY95MuKplLeg3iu4+BSpi7w2Q6V97vn7c3hmkGtj3zSGuGmYZ2k0LaDi13KtRCOARLoboMUI1hpQsyhXp1PyLD9A== 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=0LLZ3RbsTLjZoi+XWRh7T3mXeaSWkQv5kP+Gqd3u8CI=; b=TMTzKMooAPFdflTd8A8AsonJpVk4knAhvgzdxWP8H20skpZ/uI0cJ0+0RGG8bWQPlXPjVRicy2d3b1O5Te1/Oc6yuHM/+Ytr/BoNBEsnWam+Xjv0AC3QyXSdlK1ycUaa1y+ltPyRPUWomhvDRSNiZoauExoeVunzQP7wiz6PgM4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:32 +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.014; Thu, 22 Aug 2024 19:26:31 +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" Subject: [PATCH v7 11/21] mm/mmap: Reposition vma iterator in mmap_region() Date: Thu, 22 Aug 2024 15:25:33 -0400 Message-ID: <20240822192543.3359552-12-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0054.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:82::25) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 79d22c16-ff67-4ee4-ed3c-08dcc2e05376 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: wVbN9qBbEX2Yr34+iAkSQkwMjF1XhPNlvnKbkWQo9bmeXCKZxr3Im/zkHSnz45oXFuhsHiR2b20v94xs19atH582zP+xvVD+tQNq9ufAT7gdJJtZyjlXsF3rBRY6i5OFIm+jg3rBC0nTCUUgeC+v1e+bDJD09Oq5vbQPjrrdJaH68aYNmqDwMi1RyWNVTfHa+hw9oalZshWSwjhxrbk3Ae+qwWqayiWkHuNGDTHV/LExtnYWvGEPgzk+lXNZuN1/G1s7tHOke5agGzlD2nMrXR57KnQdCWkgmiem4gUmomrqbGA/Y39xmkFe2JEzcT4UmIhMW3IIqrM2oaL+U6ylFnrehSDmcgcjDtLO5bavaDSrwKkiG03RQCU9UGGQyTxswNGRQVXTh4oabD8LFOOn7o5Ji+Q7NwoZ7s1loFk9zqjqEoicPBY1VEV6xnKqFYBdoUs5DIpPBm8VdPlbf5xtO2Rts7NhxTM8NUGtmpVxvgaFTrdAJzvbelDso8sOOM5Xhll8en44gFlI/j337+ByYoNnvqE+dV/aOeu/eQf7G0jHwnlCsa4J6Hnf/5NY5MP4ha6cXwFOoW0lSeo8sPsOOh7/1lvF+UQpYQX1URj6AJlbjbGS8lbc0iPIyD8ya+CoqtHxrMUiAD0B/R58YR699i+m2euDfE2FxGKol70pV9SC/PuBlFsG73KlUIEJtco7yCNIqq59kNpmso1IHIMw0Oad9vrFNLuUE22jBbgmvZHWSIZ0Xoekcd0S6N5Vq6j9SShFTtizbHLwUX38lq4yRBzFMfLzJAsTo4munul2/agvMkYg7IBjpMPyEsyjKuyc+yN9xlSJ3F53O2k2MaTCCZDBZit2ow9FrNMSCZOrXjLd7acUP+MaF/lq0NDNuNmvJLl+C80N8GYMh8g6QLs/NiRFnj/snSzoU+HTGsdYNJWa5muO2EyDbY9j/XpwMV/LysjtfDBHtsJYusubEXZsw4utGL8/pOPGUw/qIidMzt0cySgBi/XvgB+5dGoHEMoL7WGj7nELNeskQ9EqLn+VkGeSxj1Q4MZxBh4K0gGTFzIeu9vR258Ra+3iCTZ8Gdoa/iM2yFUDOY4vFvnCWBoWBOt38gfkornJ55rHZiNivHb/dAR4vSqNJrBuBsuw9R8HBHqlfD6IPrQ1BIe7/vzqp9/FF2PzFW7IRehkpvj1LzTIHqbqeCWXuQGUqJ8n7yntFGhaAGDIVkHVW1JKhKWWvxEBfYxXpZGcQCWHKoGOT7UuwlzUemPnl0ZDVMuKzEyvz5O92ewxeVpoDbcsMagz6Y0MvXQikb+RUYFDvVSGMkES90k1ePg2kHsyWeogNUAmB/tShDUgujc3gS9CVXvWPg== 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)(366016)(1800799024);DIR:OUT;SFP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VHrBpVljupf3NkP9/7mliLNw4lcMLOo5wgeFA/xTvtKJ5ds0d8vf+zVPIZYqREeAL6Gp0uRxmi+pB4PAbQfFSRf0+tOQ116F2/nqOmzRuiGGKytYjlPEExIS4bu2JdfUfx7E0wWuOpJkarSd9bwSECK17VWHsRrRxJQbjnbs6ITYgfFTkNcB5Ga0iIRK9ldjntvvgspdtDC2qtyoa8Rr7T8yWmWUIrd29Xpmya0ha8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79d22c16-ff67-4ee4-ed3c-08dcc2e05376 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:30.9921 (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: cnoWFhziwzOaUOy3ptztsGgaMlcSzAjZbVhJXGMpIB1k2wrSnhpRfk9freonrWOkzPDHdlQ52BYCmGQ4nUn15Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: FXYv3_2sO_CnkqvU7CMsW2o6DeTEKatc X-Proofpoint-GUID: FXYv3_2sO_CnkqvU7CMsW2o6DeTEKatc X-Rsp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L5k8W/IODRfGG1mrvvL ghxMlJj1 wUK2Bq2UEq/3XGwr73yJLg/x42l+e9lyfISZA6tc8dnsDOCAV6XqpYObzB+3rgCjUln5swS7eLGyoAqEVMyGSaKyRGWry81P0sAN/L77GBwmNxXJkFWgWSdqjpjfzITrDePXgHol+rJxzyPSNQRgO7okxWmOjVHeixu/PpGo6BiT1SZ7RcinRj/SprksweX7NLyZaENn2SOleYOA40uCtmESR7sgXiRPUJHgQOc9wD02RpBbC+1g+LQj3YPlB6N9eFfwCw2KE+2E8fW3S6TIt+Gt8+xhztPUVqrLgKC1PGqF77KAXoBBq0+HSDLmpBzb5HD7p1NJHQpdW52xnmY7p7+VJTu4wcHOLEsm45gBWl/BJILrzOr8Psagg1do4Tdxlg9RUeB/aLCPKjBEYfHvjS92LumzH8xB0PALeYXIVkCOZB3f5EV56WbQm3Dm3SxUsARhvZon4NBdPpOz5RgN2mM+lZovLJrfU07cd7g7s+B0uAUdOTAjruAOKZJB5hOa/F/0i/zlXuC6cdJI= 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. This change needs to export abort_munmap_vmas() from mm/vma. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 38 ++++++++++++++++++++++---------------- mm/vma.c | 16 ---------------- mm/vma.h | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 2b7445a002dc..9285bdf14c4f 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1400,21 +1400,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); } /* @@ -1427,11 +1428,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 */ @@ -1452,19 +1450,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: /* @@ -1625,6 +1625,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) diff --git a/mm/vma.c b/mm/vma.c index 6b30f9748187..9de41e1bf3b2 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -646,22 +646,6 @@ void vma_complete(struct vma_prepare *vp, uprobe_mmap(vp->insert); } -/* - * 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); -} - /* * vms_complete_munmap_vmas() - Finish the munmap() operation * @vms: The vma munmap struct diff --git a/mm/vma.h b/mm/vma.h index 0e214bbf443e..c85fc7c888a8 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -116,6 +116,22 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach); +/* + * 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); +} + int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start, From patchwork Thu Aug 22 19:25:34 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: 13774114 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 A9C70C52D7C for ; Thu, 22 Aug 2024 19:26:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B1326B011E; Thu, 22 Aug 2024 15:26:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 330628004F; Thu, 22 Aug 2024 15:26:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BF4A6B0138; Thu, 22 Aug 2024 15:26:48 -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 DA3EF6B011E for ; Thu, 22 Aug 2024 15:26:47 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8529A419E9 for ; Thu, 22 Aug 2024 19:26:47 +0000 (UTC) X-FDA: 82480863654.19.2F4D49A Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf24.hostedemail.com (Postfix) with ESMTP id 317E118001F for ; Thu, 22 Aug 2024 19:26:44 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=cJ5TO2Fv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=rP0qG9Zt; spf=pass (imf24.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=1724354763; a=rsa-sha256; cv=pass; b=yivHaEum2B0ZL+bTzQi12IrB6u1SlGAwNHOw70dZDOtA6YQUM2alAtpeM9cpKxDztjrdsA qfkzy1LstWNe1PEfzLDTBI3x7EeQKJeIb9iTvNCJV2h5bjtSkREOff3Ixai5XREL7AoOho Ewm8sDP/e3pC1CwRaoOQ4WDpUYn9g/U= ARC-Authentication-Results: i=2; imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=cJ5TO2Fv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=rP0qG9Zt; spf=pass (imf24.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=1724354763; 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=cmaw/1Mrrp9JLuXw7iqgGPqWl0hYk2ZF3JfbQyhb8XI=; b=WJQ2lAz8KDgha+732sDXJ9EPbLQkNuIpwDkNZZxsGzQohIfM8MbuNZ1jpYdwgQ7md3Cheo 1sjYWB5XvLzLsjGCp+XBotPXjouzBq+mQnL3PCUEpO5KftGqVNL2dgJ9whi5wDpL+32BBF pSXj9/2yPeDnqmdoz859F6CdkmPChTw= 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 47MIMWwK019187; Thu, 22 Aug 2024 19:26: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=cmaw/1Mrrp9JLuXw7iqgGPqWl0hYk2ZF3JfbQyhb8XI=; b= cJ5TO2Fv1xutqCEkrZaC+cCFyxPBh4FuCsuCDLge7LCcUqa/KavUJUSLohN9C+d4 muNB9xs+Qj9TOH/tbrqLTy7HdEUcnPyynnHzFSFvgz7aVFM/R3wixulj1497CNMw X8yNbcdeuNHE+Fm3mClEk309/2s7E1LIw4nX3AM70uH9584pieu7q9pIhRi9+6u+ w92MllYRWyAJ95oWIl7WjCKE7yckrb/IUZiOSOPUl+IWVsrPzLXUQGqMqPRu7C7q MwZU1ecyp/SUJF4tX0C7w3axXUdVwjCbXnEM8ermM6s1d/sZTY07Q23U9z7cE9rp G3nlgFgza2P+BvFDPMae6A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m45jwa6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:37 +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 47MIqaQ0019453; Thu, 22 Aug 2024 19:26:36 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 416b0b9ckf-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N51eNV7Ul/gPm7P1GyfKFYsZSVlhooWiF/EpZDn7S4IMPOkNJtmQuJKBeOqNJqh0iWKH5DcTkUr5FU1UWLRyrw0WKdqTUN/wFt7FCKLpEiNz3JPSTCSEQEvEix3q1rnWkYGHKHDqQbZWMOtZarRhyoqrI2KAjaqLQ1ZQrjsXcPv6rrhy2qC4/eJaXeNjh8XFaifn8yhfDh4pjxKIKDDoSmaHdSVB+j8N4mcWkOFJs63DoO/5O5IR9SFU15R1MehTyDhNHpXyAt/wO4r2cQlVGMrzvA9pmTi3J23E4t/VfRZJvIsIqthQTfKdI8nw0OBWtaFnxq2aNYf7QnB/REJyDQ== 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=cmaw/1Mrrp9JLuXw7iqgGPqWl0hYk2ZF3JfbQyhb8XI=; b=PqyeddQBmqK+BT+71osGUBh1pG7L4uTMugRGil7lGMFcF+v7bK/6ECzRhWO+7y+YYwn5wZMnXHLdcxrowwgjOIit+ltf4aWBQ11rL9pfilICOJ4Rpjqf8mz6c3LmGZ6TwGiICuGI7pyS93bydmf4dLjB2pOvxwJy5Bee9DFNnmX8gK1Uc1LruWOs+bXJ/xzC9kaORKUn9P7xCb0+IJFSJVBRYaGieUzo9Qnfwz99iGEu/Iw68GZbKl4l8qvclmfUwUYm25qSVUgUFGkX3s8kbnPayzVp/r0nWdGYPHIsmZldFNeGw7s65ZaDo8bJ8fiGJ94crBskFD4XRpvQKar60w== 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=cmaw/1Mrrp9JLuXw7iqgGPqWl0hYk2ZF3JfbQyhb8XI=; b=rP0qG9ZtaH6dffR9INs0owwEoL6gQje+f5VkJq+AnmASF6HCVKnVTD116yfBLa3TYmDJqGTF18kRpgxXCY/z6S555lxZq3YlnHHF6YDy9oqyp3bgyXoCZW6VZoTnV9CjXeYPC9VnOPOStkjPwGaO7qO2dlFug9aPJZhbx55CZKk= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26: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.7897.014; Thu, 22 Aug 2024 19:26:33 +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" Subject: [PATCH v7 12/21] mm/vma: Track start and end for munmap in vma_munmap_struct Date: Thu, 22 Aug 2024 15:25:34 -0400 Message-ID: <20240822192543.3359552-13-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0076.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ff::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_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fce7fb4-eb17-4ee1-1eb1-08dcc2e05495 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: Zl5m9uWswjpJuSyEA83zUyeoHPqx8LxlXge11OEhw4KMZVxPo6sHYGEbSPg5DJaXVtQM6UsOXS32jH5WpY9HEKfs4d9MyBGfqe0SjIFOQJ+Oe33h75A/8DWebgPo/9pVfeyRoFmPiiszIBi7Nc27pXdwnJk0JWFC2EkbClBafB2KaOoPaA37mZDOlZMxpHVz5q8W+IxbbmKQl17fC4k4Innyy4znaMABdtGbNRw4a6wCVANQq+zHccbPVkttQQ/i7xa+XpvbQBENxgjteWVURnt8Rl8m7C2qBWMZr32ETs9UCz2HrdY3WXZIk8Z3O/6VysPrazBpbqgV1oN6d6wSFlMPgLqG58N7KSeC2dazm1cLH8gnB4wJNHxjCV1CZeglVNqAndKoPbJ86XbbJgNyLTNRG+tCKopnpJ4L6HggEAcvZRH/RM6GA7Vqi3+04ThCnXep+eR4voa4X4z79rTd6gH0bIq38lUsQMcJXOLkEof0vDXY75705TrG6v1ZgSfBKu4JLCnmgoHHwFMB/Xzqd7htwwm3xo/5rRh04WDJuW/W65+hpfsXyRtIH4j+UqcehOBzf8mEifE+pZk5U/Z+XiQ2c20LZyy9GsBWO8BIDc1ge2wnGBJHQASKYph4XY2wNTlXsSpKQ95L7rkStt4u3A+fsvUNollK9qa6HVU08wLdiakhznZ9dGs3SKersolvG680uoIiUY7ariE7j///zugy/0IzA1QvJoaZl+24AIC9Ld2Q/u3Pg4aatWx1UTop4+6v1aDFqZU/9lYYd0AvbdN1/I5VANJCPGddif+b4b9QYkIjsgBHBcZRV6rGyKcX5HRrz4X3BvrFfWYmv72AKeKvO6ncj0VV3tN8E5ozVIV32gN2luZVguLITlVhxdfBHMJtqm1PPu6/QEIG/PORjULDSipNeVFxUUmxzzQQTZ+3tqw4hd5SVq8P4c+PLoOeBLWb3r69j7cWZzNTost2E2ZVgNxIw2M8ZMhp3T2yNE2Sot3eNe77/YsNVMiLxQ6TFlq2jgzIpqOLQQPX6N8GKfYJFiue4A7DMUd/HQSio0mEUJ4Y160uI6aLmk4REUuyxGINIXd3SS5QAYn9O+kWa6g+DaOKbd+qqiSV1PqVXI5cUWzAQlx6WnWXcUaw9WljYWLHfAkEFfDP/tEaQcFxP5/7lyFk8Ue6SHK+rN6PNPiqk7EamBwyZ4NUBe9XNWu1D4Qx4uu98ogwYUP1y+EFZmlKwlyFeZ+jhn+7ZMQJF6JB9b8CMou/1nNUXYRQTSofYs3DIhpQWcByFhUipurmprPGpnqCug6LhB55xLJzZeIPSC7HEeeRnAcjc+AQ1aECBJBqvXX9cCzVmEvPbJ6lQQ== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 70SiWU+v6TRYfytFuX5ktenH9a4W6O2MQT4F07VviKASyXiH1j9icQyA6u2XvRzy8sAFfxoazAWvmZjIX6St7DIMJn5CJvF6unGbMS0Rtkp4J2wrnXQkJgBnvzKNO+poaXoApKH0YYa4ieUMVht/Hj5wlY7v0nxQp0IrVfFhsd4GcbaYTSPmzZM696huqcW3Uvrk2vB5qxCu1Y6/GLkeQozUEDgR3MK32k2fAKvoZOtWfQSd/A7l+AVXf8uTaFWluagM3hMvq20J0UfdOtnmngrEb+i+5VddDO08+O/rO1E0V/INGGTMW5dqesXhoPOjgETknm2pjhuQ4AN9FRSCY94QOKKS9GslW7mernPbhzQb54qxFwMPnKzFn0/MhkUNDevxfFWIkpFK+NuV0h5FhEvMJXjlO1kbG/ULPZXIZnqjZs7+oNs1h+8JI6jtst00KVAQhIehN1JaduwJJTTMCgXMc21dSFinZfZY/0QvkUS7hhmjL6VGy6TiYsAumBEYP5PqYOIMk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Io89Q+MVxByNdSnYhIES95NZCIw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2j8d/EA0tN9TUx2ag+qe02ed18qXqaY6x7o+LcNQmELh+lgkxXaOVy0cFAzrxGDOtrIR/vgHF3YOcyUjejcOwhiL55GpmUvcTk/Z/Wn+vxHfmIwBHQI71XtKW85hhtnAwPPxYKlVwl1f6X/gjqnfE1fpIniM8LQzfaAKVc4/rjJr/db+EApJxDR5qPdkH/AiVjXfynf9TRw3g6JGgf0zaHX8bCxnDHQSmX/IHuXCoJRx1rKWzbU4CgDfAfE7Jl0XorgIByQj1lZplwrkh3Muh3Yh3Xduz6098fqF6Gv0aef3FlZhNRWAcoyPqWK220ufeCp6FX/Nzf0TG3j+54UHLQ4gPgS1Ms4PcT7bf02Hd14eNXUMSffDZ5452QTqMGAvUI6TFV0VDhTvHvak1cMfjHzoY6uU4OKFmkyBWBcuBxXORcaJAidcYZ5/qzRkl0a00KarIunqXCvnpAmjNoKtS7MQYrb7FjRC3s3+E4Tz7lLPqFiMNrxser1BDUqjB5f7DmgtJViDPVvrtDwf2BJYcI/BC16Yux0DpF5G/V/Oa1b3Tlm3LyL06kZYgf02mMe/lIjn6YtZa+KEPv+1lK151qK5EuEjrJZATyHNvocWWnI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fce7fb4-eb17-4ee1-1eb1-08dcc2e05495 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:32.8850 (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: YaaJk9UdI+AEI3Z8IIZb83/1mqkens7BESWXG2b2W6MsoakzLOYQDJ1XVB1nBrEnGDHIJjYGI6x8orJ9q4dtHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: i_8CGIDrfEBl9JSAre4-N8OErO2kVPbw X-Proofpoint-GUID: i_8CGIDrfEBl9JSAre4-N8OErO2kVPbw X-Stat-Signature: tdc54k7xhh4i44g9xaximny8zwtgwnz3 X-Rspamd-Queue-Id: 317E118001F X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724354804-191030 X-HE-Meta: U2FsdGVkX19H44Y7UnnMRezjAc7GuvD9qILdENzVQfKlsZtoAxtji7yrnP0vaLnThIVqiwoocrRa6AMv4sPSrYuOZMRQ9P8YAxHU06/6ixjHmRvVDryISh8sqZH2v3MhhmU6Gv40w46T+utRf69QO7HnMQt80a63H5zNT2IUCJ3ba1UNb2nIox4bVMtPV3EFNNVGd8rF/cXXus8vvzoxdBBwXmdRAZQOUSBPp7BfUEEAmXkTNBRPi+/1rJZcsgPIx+hUeGlm0dg4LEnnuK9qHdPexgIL7I5+vICGE923OFyXDPQ37e8A4rpy4Sh38nTyh6ufEe6QoUp47qP/If88FR8NOsUGHrrjBkdaRe1YZH5pZnGfMyXW1OEgczRwbABrDIDrGwFvDZvgnG+Yi8k+Bo9KJnENaK1e4cWrUfrPAZutBlz2haLrvkQ1F/tVyZ0ta1UEj/M7T2helSK9I6ivP5VK4/8p2Ka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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/vma.c | 32 +++++++++++++++++++++++++------- mm/vma.h | 4 ++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 9de41e1bf3b2..dda0dae069e2 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -646,6 +646,26 @@ void vma_complete(struct vma_prepare *vp, uprobe_mmap(vp->insert); } +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 @@ -667,13 +687,7 @@ 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 */ @@ -746,6 +760,8 @@ 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 @@ -810,6 +826,8 @@ 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. */ diff --git a/mm/vma.h b/mm/vma.h index c85fc7c888a8..7bc0f9e7751b 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -38,6 +38,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 */ @@ -108,6 +110,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; } int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, From patchwork Thu Aug 22 19:25:35 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: 13774115 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 EBCFFC3DA4A for ; Thu, 22 Aug 2024 19:26:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B97C980052; Thu, 22 Aug 2024 15:26:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B469F8004F; Thu, 22 Aug 2024 15:26:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9730280052; Thu, 22 Aug 2024 15:26:49 -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 783458004F for ; Thu, 22 Aug 2024 15:26:49 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 33776161934 for ; Thu, 22 Aug 2024 19:26:49 +0000 (UTC) X-FDA: 82480863738.19.A0734E8 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 4A90C14001E for ; Thu, 22 Aug 2024 19:26:45 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=o2ZJQ3qb; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=O8BHHaiU; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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 ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354745; a=rsa-sha256; cv=pass; b=ofcaq8p5Wcdooq1LIUkPZjy8K5Y6d9t8XNFW227R2RN/pXq4p23VjoccV/MO1AaXIh1Whp I+t3qi/yu7s6PVnws0mubsgu03wk6Iag67gjMTmcetZWvKVatRqUPqJNmTtJRZuDzfHeiK M4dVebDEWjtS+jMMQ9RXGr7IIcpmV0k= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=o2ZJQ3qb; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=O8BHHaiU; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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 ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724354745; 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=cgnPrGOzOxWIrdBQ3R3NT9Fecz0tF71K+188l02T6BA=; b=F6n3156R5BZXrxBDkI2/Scoed7HEHABph4uC3LNK1lWfCWxkU7zNLC66RK+uuALssEH/T9 ol8iycBNWLNJtigu0U6PTriPdcfiDp+c5fngDDJBjecNUuul4d0XsgtcOTdvphl47E8p+D 5DEcYEgEOUzVUEyVsau3sv6ZNUlDzL0= 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 47MIMWMd026319; Thu, 22 Aug 2024 19:26:38 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=cgnPrGOzOxWIrdBQ3R3NT9Fecz0tF71K+188l02T6BA=; b= o2ZJQ3qb63qJAQ6p2MH04wzbS2CXWwe+C1mGT+HyDCGuPSsaNkWy/wA1OSUXIXzj GLi46Q3utlqecBSNaIrF4ROheK2d2stv8RFCnqPy7jfChcns80aaIjq0rhVoIyl8 1BhNh2b6q8dW/6QWtsEsvCwAvh+pArPD7VeAu2rgHUIPBquPpwwhUc9FvlmjSr0e RtVlpewyZ6NN0itG7cHTo9d2KgFsuWVas/01frpAXs49nW75Nk0rH8g7BpojdRDX SBjt/5xCN1+JlIcp8TY7mLHSRxPHCwHj8LfYaWtxLaKocKEaHVNoLmJqz4If3HPi 12ejlfCtqTHxFIElfFvUCg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4v2w9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:37 +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 47MIqaQ1019453; Thu, 22 Aug 2024 19:26:36 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 416b0b9ckf-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DNd7l9YbWk2/jhl/PyEmFNx9k2hFBNwdSI8NZohEe97TGFNwaXXEeOwt2a0RU3XMaY9fLqtiz8ycVzvMuDER96sjRs4/GjgwoxCGM/p3UBYpidz83qIP56bI2qZlvCTxg01gKRjID28zLVX8jUbIPHndLA/eB0w8Aa1dwFFTYfUOYBnokxf0OFcF0UqDQCBLmMIRFuqExW1r/8p2MVptBIEpARqx3hMXl49p9k6YKSkFX30YIrR36p6rALS47sbeVNvyxo2yZ+keGMH/5Okz1k/ETXiH5sIZaEyRcWcMnViGLh9SMu2PdiU9MuwfgFzbcfzKUsEDvKHfbdmBjsOhfA== 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=cgnPrGOzOxWIrdBQ3R3NT9Fecz0tF71K+188l02T6BA=; b=i5kHbxywR+keKx7i0lV9WdO6LwLDgCJp+lc8tBu4M4ftO0yP7wzAx1WbaDUPQYOptDMl2tafRPtuAhzJcB+D71o/b84Gl4f3oUqfFTrFp0+6aYkArrgxi4Zh5u29foL7ufjao/uFuShtbUkr34Us5NLpCPjSScVJUFr2wycF3v48Jv/9G0+THnt55uNyXiyR9CCHiLzVAHEzWDpnR+fn8RPEkEWULeGmKt/l52kNg49xFPTVNhtJER8C0DQJZq4OrB6fFTqbTgTfq7vNjc4MVu2DcYo37cXzEf/hvOjhNP4UDAX0v5k6Yf8zUUxmEvAIMiNdFL3SddO+y9rl3YRO6w== 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=cgnPrGOzOxWIrdBQ3R3NT9Fecz0tF71K+188l02T6BA=; b=O8BHHaiUqYwWZs0BmwUosB1TZJFtJgtflGwPMpUb1hKTBY2L6eKxKaC9D8+WK4Hn9wXnWnN0+v8iHEk8KWxYySGwo3kf2UnFgRkuVh2sjUgTX5Pliz1L/CExj7eFUWa99NVOWaeqzwfRkz5fhnlyp2/necnMVEVx339l3q7QTJ8= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:34 +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.014; Thu, 22 Aug 2024 19:26:34 +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" Subject: [PATCH v7 13/21] mm: Clean up unmap_region() argument list Date: Thu, 22 Aug 2024 15:25:35 -0400 Message-ID: <20240822192543.3359552-14-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0385.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:108::24) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 227d80f3-a105-484c-1fa2-08dcc2e0556f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;AR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Q5y1KGJq8sjKzufwLBAZExehfAKSIEdAATFCYXvsJku6I8B3+jYEMFsXmYh9wOcFudaeRwqYsdkrAlLzV7RbzLDmRCvt0bXDhGxt9oxbOa2B72Xlc7BfH+kJd5T6i4MhEgztLZ4RpW9ND+O37zkDOSVib+Bx9vruMh93L1GeLahSXSIkLFmPi2maabqrFirXzwM0N56/N7aM+jXpUqzeIDJb5C9i2qL7oHQlpfMtPIvp21N8IM3x7vgvaaXDnYIVaMe0g6kBLj4JZrPpfrgZMlqrzl2t0rLDvWkV++dMd5Z/1qMvzdftSqcRCeFv8EiVmnSbE5aCDvijsHRHeg== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1OMKBu+PaG7eMD/3FuAV+tIjQKZKzOPziKoOmnn3rnwVB28KRFgh+yCK9VfHnRijcRsbj68z0QACKYReMV9JP8UJ0TZSmfahpNtmyv+ZhtMXy5hW2Rpx8KI3/UCXMzccFT0Gv0byqjAbKLdc6jhXautfksN952Gyavb5YbTbIJ1ja/S5FtX9kfTsXSN/xC65BanLv8WIhiDnKtWvirYxqwxw1/9U+DKyRdPj27V9c6xv1HoRqiUW2lAiPnvgRdcfPbAJpt9W3zrNy7ywHAxj2AMJrGhnpunIevuxHcw6tFO+T8fDKLvOg7pHXbMHqueTI6B4V2L2xZVSwDjgwoau9SUox9rss/xePUph5ePtHVrXkDu6qXOK2DtTHTx48Al4S0hIlbRMR+KodZAmVTrQDizXkwAn8lzr7eQuoW4hYwBKPOsPbzS/3j+Ccp6v+mUJQny0b7aJXDA5dmK06SFax2uwYk0LiUafta5cD+YL+ziuZues/bdvLCmYz6h2xMRnt5OnaPQD3Cva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1ccleEce8HHZKqEW/U6fdw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: AxfSdg7x6OawfYdODFMsbTsQTOn/LDxohO1SDfCnUmVtNop70faunE4nBdfS862jQUK+JCGosIps13QLmkm30lUqXhNKw2bGvXAmHqk6ohgw/oa9loTOxb18lsQV/wKJhp40sxdswirRcGve8BiLTbTI29Y8iXYXmuGFAy+OTst3k9HO0BgX6m9YMIMj35jz+l80KKjQCfDkZi70f02BdTYTnQJRcWkI5ESvzucwCCx+U5PS7lowNKDWC60/vsjTg95Ekbq/rwLpIOOfX1+MU5Vc5E/FEbEwGbM5Ook3X5Dws5hdhrMQoT8Kk2xMLMKQaH0V35Pb2p3cnvpz4qVRUTElI1SIPQ1rEAYaKQHyOY9gEnFS3SqdCR37o+REswX4DyjHtNGfNCkAuZRAClBIVkpa9pMfVYFXQwm82EXsk8PCbSUPyxxpWKLL2f4o9xXCMPNdErvK2l0GnHJnvmUoJMCScvcAHSo5WW0kOFsdY1RoK1Jeuw9+BPiveiywoNKPueH+0xzHkVfcl4/5vUDvTgEWbew5fZFUo3x0eYL1H9joYL5HlBhW+Ml0TBfIGXeHnTOktkcIYk0o9CaBi35g0iP2FHE9r64mxdAQDL81BS4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 227d80f3-a105-484c-1fa2-08dcc2e0556f X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:34.2807 (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: qf9h4/hd5FU8UUq1zyWQOef59A10GQDt7quNS5/KURL6pETIbU5/sd+0fiYu0o+Cdqt+SjzM66hIFCK0YNMhvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: cFL0Gs0ZQ8Qc-ft_vAURaoRk6ov--8Il X-Proofpoint-GUID: cFL0Gs0ZQ8Qc-ft_vAURaoRk6ov--8Il X-Rspamd-Queue-Id: 4A90C14001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1yaxcsqo3fkforf85kp8yorargait85i X-HE-Tag: 1724354805-645573 X-HE-Meta: U2FsdGVkX18840A3UvU8Nq6rdnciDVWI6RPbMJqTSWcSj5aO6vH5MPOM4O0wa+qM/APd+mmyddw80fXeQbvbUqeasfzHVCHSLR9TKuGwVFS08FJo2rECTfLLyQ8+rtprH7trf36LrM4udBdA4Y7T7lRK78w5ruILcy3J+t6JXdYHpCccDvbjA+QUswBSlocUuWYz7D9gTNGaY6TM0e+naUE3dF/aPowsno6YZ3/cIAHsJWN7b3CIFvlupByMrZS6b6lRW1PekUdgAe9dvVY5hS4bhUNCQYao7BT3DWiPbwUslmaMEby3u3DFtDbedLImcbroTEgSfg5rOLJ0SMp8QZLTDITD6zXi/KrTU7E+Ck6mL5CF/ywktG97mm1d9TVQxvHJL0yK3elN7IxOmxsefYhqqy1gshnvZyp6aboTwcB3dl2L12Iaj3XjSVxnDnj3/ykvr6ygTNB+Al2XOHNKH+jqkbGcG1a+hHlWNqf78b8hCLjZQC0ILLCz024r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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. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 3 +-- mm/vma.c | 17 ++++++++--------- mm/vma.h | 6 ++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 9285bdf14c4f..71b2bad717b6 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1613,8 +1613,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); diff --git a/mm/vma.c b/mm/vma.c index dda0dae069e2..9e11892b0a2f 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -155,22 +155,21 @@ void remove_vma(struct vm_area_struct *vma, bool unreachable) * * Called with the mm semaphore held. */ -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) +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); } diff --git a/mm/vma.h b/mm/vma.h index 7bc0f9e7751b..6028fdf79257 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -147,10 +147,8 @@ int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm, void remove_vma(struct vm_area_struct *vma, bool unreachable); -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); +void unmap_region(struct ma_state *mas, struct vm_area_struct *vma, + struct vm_area_struct *prev, struct vm_area_struct *next); /* Required by mmap_region(). */ bool From patchwork Thu Aug 22 19:25:36 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: 13774116 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 65119C52D7C for ; Thu, 22 Aug 2024 19:26:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7065B80053; Thu, 22 Aug 2024 15:26:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B39F8004F; Thu, 22 Aug 2024 15:26:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41C4C80053; Thu, 22 Aug 2024 15:26:53 -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 1D07B8004F for ; Thu, 22 Aug 2024 15:26:53 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CCBDC1206FA for ; Thu, 22 Aug 2024 19:26:52 +0000 (UTC) X-FDA: 82480863864.11.F819845 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf05.hostedemail.com (Postfix) with ESMTP id 605A2100014 for ; Thu, 22 Aug 2024 19:26:49 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Cp5EN4mF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=RHdtwA1G; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354792; a=rsa-sha256; cv=pass; b=nvOnyqOP8OU7fjFz6jEtJLw78dvBPNkq+wwE55gaSBqPiBeu65MBPf8SH2QBfrTcpfNExc zQ0qukEaJ8LdNBKs0UT51rx7a+fu9bvBToajNF6zgFTjSlDvc2bls6Bk5rh+TP3R3S8fju +y6HIc9A3/3B0aTNC6adyA53wof7tkI= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Cp5EN4mF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=RHdtwA1G; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@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=1724354792; 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=bp49Hgw37mOv99yWoEdLs2gNO2kzyBNnJw0rISKdOsU=; b=liP1AQLgEayuX5vsBr8Qj0bs9vYsEuBzTVwH7g6UaLtNaU/vw4TWINiP+AJhOiQ/0S7Ta0 vsCvcpaoRplgp0IqO6j+rHcYpjNvjaZL4UwD0+NHBNO/L9YjxeAK/cgnM8iR0oLU/rHwOB B43R87I7MZfZX8aA0rSYlZyoSyx0pWA= 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 47MIMXIP019213; Thu, 22 Aug 2024 19:26:42 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=bp49Hgw37mOv99yWoEdLs2gNO2kzyBNnJw0rISKdOsU=; b= Cp5EN4mFaDleZt1mTbvmU4ZMhU5nVN/1CUcl9h2kISOOsazZKGw47eRSBAVvEakS vkkmqb3RQFAjw431XgIZbSSMhnH+zhIMpe24US0v3AjEFiti5PL/KyGYGUiHvEqH T6U4mrB/lQc7wsjca5/teVh5Snqfe1XU8erVChI4J4Kq9ZvNcHMTNNAgM0DnBfqv qDIGZx57V7pc60cQYLa/S+YGLfKYxY3ymtQ2ll9m8uU/TEjvmfvkSZmZD3T2vRO2 CR1qOiwf/Cp/FhC+slqvp0bigUmEEJ4lGJSV7hvjyrYqlrsZUj63tMtO3SKSHQIy d1ZkXtZoK2D6E6lpagWCng== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m45jwah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:41 +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 47MJJDie005125; Thu, 22 Aug 2024 19:26:41 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu086e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZWARxIBNXVD5p4gCNQ+CI/WLyREbzsdHVJRHuFcWu0bRAcm+U8kKNhlQ9cx20yGoEW4VmGKLQeAmzLmBvlwVy6sIwIuprnhC+e3LT4YQ/ISMSL1Ctza8BtuxOI9piuLtqJVaVcnNM4YL0Mn6T+UjpCOk/efJyuBzXZGWS9pyucyv3ohFgqarzjsYBbhV17/2FnqroAPhQMvxEixg/a0Zds9yuRJsnSWf7d+OdCRNQ9Hizc1E/AuzuS0oqwRw2WhnOb5iKV1qEGOwTMIM+DRZck+gyTPkBKQmjvjFWHfAE+4utzbmRxye86ZclhSGeeGwUjfhWRwxEi2amzlShWWlAQ== 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=bp49Hgw37mOv99yWoEdLs2gNO2kzyBNnJw0rISKdOsU=; b=dgtTjDDhFHZbnci8FkEK2Ng7D5CzrtCsPONwWpabJj1evNPKTgDYaJ/o5u7s5BZdZaqokfIs4GHPWlpt1js0WvR5l3+fyMGN7fklHxHqDqmMg2bCPa2Ubt4e/F9NH6vRF5jXYcscqul80clFMDpcamvarAjfEz9R3QKNGfNABV/52fMHtOqCrI9ixKpYUZzRQ4gfFYDYWlMOBAujmp8wC9fPUqkyP1MWBF5YmFbHnT9nCsco54p1pEfQtmeUwkIpLET97HNFieF2cdU2sMNPQ9xtZiyN2anR9J4n4bN9muKVTJ6wH1CJoJQv5KI6iOnekp+N6ond6HJNTA6a9EZZKA== 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=bp49Hgw37mOv99yWoEdLs2gNO2kzyBNnJw0rISKdOsU=; b=RHdtwA1Gb7ydDEHldNuTwW/iqzp2dnnfAfJqPVn1kMAgf3nF94tThGgoJWUfdRAb5sdTk0UbyVYnNBqT11qPchuto9aS+MkSxxQKf5HfvVGahxiLv3yH+tmKGOnkNxfVDfnhZuLlnFUjgBdEZ3utdo/4jyuczpm/9SP2zLwWcV4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:36 +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.014; Thu, 22 Aug 2024 19:26:36 +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" Subject: [PATCH v7 14/21] mm/mmap: Avoid zeroing vma tree in mmap_region() Date: Thu, 22 Aug 2024 15:25:36 -0400 Message-ID: <20240822192543.3359552-15-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0161.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ac::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_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 6974ce3e-ed00-4bde-2b2f-08dcc2e05692 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: 0oieusz2rCb3WMT/OZyFsaq4SnpGvafKETOgnUqQQtMKuikgSBBqq8wQA3BO4WLq1sgMaAgb4m6hrg8cAai2pYY92bq1bdaGGtw8e17rWeA3UHo6F6+OCp97dLA0cnj+NR3l0mm7vmGC2EW9+Glt8M5CafkJYugTFgUCF9qziGS7tRsSZUoPiuK5MRrKFW6vvGKsi1YpW9lRUIeeNZWStapYSZ1zmcmRBjAucu2rK+/i59OjLoK9L1s03fAzVYEcBgfLmDx3ZWDa2jfN55FzbNK6PY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0hCOw== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2nS8sgHIuDVzVqnjlXJZhlH20N69Qn5IDagZq+t9w/RRaTXIZCMbFXEtg42NlvI3miLSSlDOU4wQPLe2TDaRThUhtGzQZpu3+9y9PiCDGPWMZ/ThJ7NECXnhaSGeW1JisRXicfsRjUKOzgMZQME49uDYflNCGXnhYp9O91Df3Cq3VJJv8ddUyIwF5R2WlGwjJyx63V3glHyJSYHnYcEuBkW58W6gyboKMtGvTKFk34oORZVlaBSa6X34wLbdJZDngAZnYwuvCLRePwb3U9Wg1Nvn9MQenTAuPSxEHSyUxhhnb2Z2OXlOKWGhpYySkL5OJdhJH/+b4d/75Rhgh1vcvAnIou3n0hQ3iI3B8KUcYEHVXg5azuKMaQFB+E/1UHewVAP4NGPsqRWm276w/Ska6MJwEBwotKqkx1JEENSKJjuMXmiA42bAPsnjER94rMdbdhrbzm7qu5I9L0OrOH9SncArcBLz8QmBWBTBOoNqL/fEbkr1CnPdsbOmGF+kpg0IAb/MbEX6gX8kJ8p7woevGHqGmwoDJVOutwtZObZ4Ag9hIZMpytO8gFlyJJ/X0mwVNVaZxyGkAZnYDWGwNaxC4VWw8J05yzY3qboMx+Q8wPxUo73HTwmvWFf451RLi8O2clriUkDJr9pRmYXtZqYv7u+dfNZ3vKRoAsWndOMwx2Xv7JRRsH8WHu6gtR61z326pO7z4pnuui86DljhAdiH6EQ6E15ajrygLVXn8mSfWRUzZVZWXn0FEPLqDQDTm27K5J6dTT3oDoY5j8w2w2sxzWAW8+o9v9F9nbpWkOoH+wjiG0TpGr9uQQR8wqmq9+uxI38z6t37qKQhiXbG8gsVAjU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OxfLJUiK6QE+juRlp3sZGLGncwp9A5oXKHzYWP5puCRPZZti2yqpFnC0YrlolLBiblPTMnzHlcYqlazh1crcgXEhC3pURvrw8UaiL07wrSvSoz/R4Zu+TlS24ni91Zb2MuDS5aLLRK6ZA7/bkE0SK5GczXQ40kqY4Hvo7ZD07iSBAe49vHoXPEryRQoXFjwxrihmRyQagryn+uEWEr5qdxCr+XxbGlmmm51jIIZRugslrVQm0/4dA3v1T6ED9J0Un0wEYB6eGYgkERBwNiR1Su1bMODAW/ybbcZJULPyBYCTpQiFDxji9MjgG1/m8SvedhA4lo9Jz6SGcyMhYGReIVA6GCZYyI73LiEUIeEGboEaeHJSzjhrSMxa4eJG3QE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6974ce3e-ed00-4bde-2b2f-08dcc2e05692 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:36.2041 (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: j1zW/WZxso9N7/ZlUuTmPyTltU3rjAqtOUkqkHUFy6ET28EjQO7w8D0nMCZ3W9Ktlkg2dHntInbC6i649Mls4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: UH_k-W4LfbNaNtCA9yaoVaI4_cgwOAQ4 X-Proofpoint-GUID: UH_k-W4LfbNaNtCA9yaoVaI4_cgwOAQ4 X-Rspam-User: X-Rspamd-Queue-Id: 605A2100014 X-Rspamd-Server: rspam01 X-Stat-Signature: n7aqx1srdmyuh9hciouijqwerq7m4rnz X-HE-Tag: 1724354809-772144 X-HE-Meta: U2FsdGVkX19WoUCrhBWahmgjqhj2yGjxx2JpLxxiZVoduFk5P4SDFDMBsm3B3Ki4SHtdvHzu/vxoiOxkg6Che4ALPACO4xGvmXU92puirYlwoWZc0915K0oJbGJ35yL3Pw42IqnCjy/Z+4U+14HY1GbiVdnELSoNuweFbWZtS7jqdQ64qS7VmAsiP+9oHzyr5T6fy0RAlKLRKY8dDICXlQxeaqKe1kcHKdln8f6x7YIRkJUFBKg3l6vNNsht3tJ51Tj7bGCSrrL9xAUYkXFTUyT4boa4Rl2D20wwXyQucN+xjQEp6uNvyiTiF+vpEmqWGbxGS6ginxklDRJ8aK4CGHJsT/f2fTD9mfX4U46V06L0JHQh3fpQUrvkUsZfPudZr0UipMjl5p3yPwsgAQt7herU7fFDe3vTi38XZg1KDYmJKPM6PEZ9CpFTsagwTYZ0V+KGe/81kUZSMNcAGb7xVHdF0EPCu1HST9IpezQClPS42nu6jMX6Bw7SNtlbE1r0essnpXbVc3V6q7xuun3LEqXhgeVHEY7Cnd5HauTgVg2Peoh0lRKWGhay6V6k3FB+J6OzwCdBetBGwdX5SpmN87sarZI3aiNCf5auLxGvv9SVH063sLxJ0N/adkxbbw9r/x7K4gEDdkk21MBXnuVLCvjmPaMRdv0Y8lBO7qVpOLymnkojLgKFQupQ3pH2HuNIaSzLIqIBmjCazYYVP907y/s3uUefJuX3bTwbbLtXiBaG6oiiyDW/73FYg5c/rjUU3O2XWjKXrMp66RlYtzDer5ZJlQsgbgYEUfn8AT4nDkYrfIi4c/VfJVctcE73euGXcotHe3A1SKCjPqzmuiM4rtWtFCNU5Uqbu7N7VjIO25iQSmObGDuhGs12MNsoM2Rmf6OMwjEyXCXuW+/taFknFFEMZfCgVqCJZuiBT+dRux9bHQRNFRzzkH6W2EnX5vEW5h7Xa2jHUwRQJjDc5bS bUY3Bsmg 1ebAcflx5Fw4QXhwz/7rrWma8CcESjpbvxVHPzjCw+R3MMNtNWV8iRvjAja64mTXx3QsNEmQtoBwbcCIRGzUIVSw7J9mLBE7FxWZMOyywq4L5AKgV2g8R8qUmflhrgQo7/dre5TSBdSP58xh7yZaltBCaxqECJxojMVNliVkMMQ+PXuJgvYo/ePSNnDUSPQ1Om5GBr7jN35vNkr1ni/84uzHoTubRbH8TsfCBZYkQtiezJiZ+wjnI6HMqG+9/Lk+3gawXzxuDobLKFmbDdGIqdlIzgB3wG6G13uZPzB5+5/s7M1duCHazWlxg2aY5yEMQ4TJHS0EOtnCAjQ55m2Cf+7p8XrBgurLr3AqS95xR5yk0GoiO18HECpUhDoUX+C25fZbWRZZIRlMrHJrHc/2wCocZSxwBij6e3BlrJBjP4txvFNrZGaICQbziDhpmPTZpsVxFB+VsWH+sWByJLnIBWYHi0VkNMGiLyTnd066Q1dKi6TtZMZA+aYA2AgEwscJB4at9pBIdjCbiRUw= 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(). To ensure locking is downgraded correctly, the mm is set regardless of MAP_FIXED or not (NULL vma). If a driver is mapping over an existing vma, then clear the ptes before the call_mmap() invocation. This is done using the vms_clean_up_area() helper. If there is a close vm_ops, that must also be called to ensure any cleanup is done before mapping over the area. This also means that calling open has been added to the abort of an unmap operation, for now. Since vm_ops->open() and vm_ops->close() are not always undo each other (state cleanup may exist in ->close() that is lost forever), the code cannot be left in this way, but that change has been isolated to another commit to make this point very obvious for traceability. Temporarily keep track of the number of pages that will be removed and reduce the charged amount. This also 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. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 62 ++++++++++++++++++++++++++----------------------------- mm/vma.c | 54 +++++++++++++++++++++++++++++++++++++----------- mm/vma.h | 22 ++++++++++++++------ 3 files changed, 87 insertions(+), 51 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 71b2bad717b6..6550d9470d3a 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1373,23 +1373,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; + nr_pages = count_vma_pages_range(mm, addr, end, &nr_accounted); - /* - * 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; - } + /* + * 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; /* Find the first overlapping VMA */ vma = vma_find(&vmi, end); @@ -1400,14 +1396,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; @@ -1423,8 +1413,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; } @@ -1473,10 +1465,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); @@ -1485,6 +1475,11 @@ 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 + * call the vm_ops close function if one exists. + */ + vms_clean_up_area(&vms, &mas_detach, true); error = call_mmap(file, vma); if (error) goto unmap_and_free_vma; @@ -1575,6 +1570,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr, expanded: perf_event_mmap(vma); + /* Unmap any existing mapping in the area */ + 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) || @@ -1603,7 +1601,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, return addr; close_and_free_vma: - if (file && vma->vm_ops && vma->vm_ops->close) + if (file && !vms.closed_vm_ops && vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); if (file || vma->vm_file) { @@ -1622,14 +1620,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_vm_ops); validate_mm(mm); - return -ENOMEM; + return error; } static int __vm_munmap(unsigned long start, size_t len, bool unlock) @@ -1959,7 +1955,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); diff --git a/mm/vma.c b/mm/vma.c index 9e11892b0a2f..3715c5c17ab3 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -136,10 +136,10 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags, /* * Close a vm structure and free it. */ -void remove_vma(struct vm_area_struct *vma, bool unreachable) +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); @@ -521,7 +521,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: @@ -645,11 +644,14 @@ void vma_complete(struct vma_prepare *vp, uprobe_mmap(vp->insert); } -static void vms_complete_pte_clear(struct vma_munmap_struct *vms, - struct ma_state *mas_detach, bool mm_wr_locked) +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) /* Nothing to do */ + return; + /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. @@ -658,11 +660,31 @@ static void vms_complete_pte_clear(struct vma_munmap_struct *vms, 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); + 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); + free_pgtables(&tlb, mas_detach, vms->vma, vms->unmap_start, + vms->unmap_end, mm_wr_locked); tlb_finish_mmu(&tlb); + vms->clear_ptes = false; +} + +void vms_clean_up_area(struct vma_munmap_struct *vms, + struct ma_state *mas_detach, bool mm_wr_locked) +{ + struct vm_area_struct *vma; + + if (!vms->nr_pages) + return; + + vms_clear_ptes(vms, mas_detach, mm_wr_locked); + 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_vm_ops = true; } /* @@ -686,7 +708,10 @@ 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); + if (!vms->nr_pages) + return; + + vms_clear_ptes(vms, mas_detach, !vms->unlock); /* Update high watermark before we lower total_vm */ update_hiwater_vm(mm); /* Stat accounting */ @@ -702,7 +727,7 @@ 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, /* = */ false, vms->closed_vm_ops); vm_unacct_memory(vms->nr_accounted); validate_mm(mm); @@ -851,13 +876,14 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, while (vma_iter_addr(vms->vmi) > vms->start) vma_iter_prev_range(vms->vmi); + vms->clear_ptes = true; return 0; userfaultfd_error: munmap_gather_failed: end_split_failed: modify_vma_failed: - abort_munmap_vmas(mas_detach); + abort_munmap_vmas(mas_detach, /* closed = */ false); start_split_failed: map_count_exceeded: return error; @@ -902,7 +928,7 @@ int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, return 0; clear_tree_failed: - abort_munmap_vmas(&mas_detach); + abort_munmap_vmas(&mas_detach, /* closed = */ false); gather_failed: validate_mm(mm); return error; @@ -1620,17 +1646,21 @@ bool vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot) } 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; diff --git a/mm/vma.h b/mm/vma.h index 6028fdf79257..756dd42a6ec4 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -48,6 +48,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_vm_ops; /* call_mmap() was encountered, so vmas may be closed */ }; #ifdef CONFIG_DEBUG_VM_MAPLE_TREE @@ -95,14 +97,13 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, unsigned long start, unsigned long end, struct list_head *uf, bool unlock) { + vms->mm = current->mm; vms->vmi = vmi; vms->vma = vma; 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; @@ -112,6 +113,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; + vms->closed_vm_ops = false; } int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, @@ -120,18 +123,24 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach); +void vms_clean_up_area(struct vma_munmap_struct *vms, + struct ma_state *mas_detach, bool mm_wr_locked); + /* * 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) +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) { vma_mark_detached(vma, false); + if (closed && vma->vm_ops && vma->vm_ops->open) + vma->vm_ops->open(vma); + } __mt_destroy(mas_detach->tree); } @@ -145,7 +154,7 @@ int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm, unsigned long start, size_t len, struct list_head *uf, bool unlock); -void remove_vma(struct vm_area_struct *vma, bool unreachable); +void remove_vma(struct vm_area_struct *vma, bool unreachable, bool closed); void unmap_region(struct ma_state *mas, struct vm_area_struct *vma, struct vm_area_struct *prev, struct vm_area_struct *next); @@ -259,7 +268,8 @@ bool vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot); int mm_take_all_locks(struct mm_struct *mm); void mm_drop_all_locks(struct mm_struct *mm); 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); static inline bool vma_wants_manual_pte_write_upgrade(struct vm_area_struct *vma) { From patchwork Thu Aug 22 19:25:37 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: 13774118 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 A545EC3DA4A for ; Thu, 22 Aug 2024 19:27:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4456F6B0143; Thu, 22 Aug 2024 15:26:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CC988004F; Thu, 22 Aug 2024 15:26:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 185A66B0208; Thu, 22 Aug 2024 15:26:55 -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 E1CA46B0143 for ; Thu, 22 Aug 2024 15:26:54 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9FCC21C3483 for ; Thu, 22 Aug 2024 19:26:54 +0000 (UTC) X-FDA: 82480863948.13.9E0ED3F Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf02.hostedemail.com (Postfix) with ESMTP id 4FCC98000B for ; Thu, 22 Aug 2024 19:26:51 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AWYXOXwt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uSMO7MVO; 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=1724354703; 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=3MlH+o+RVXMOs3uRNnBWOsfwouftTpxW+3+Yfxn9fgw=; b=lyTvWZkLAKARq7Vo0lMZM3+3r/O91Oi9xuOS/YCMN3ILvOKi8pa35ZOa1DMrw+i835ZZV8 XZA/3yBXkR7bk0ShP+O7hCQqvTBbZFUewAJcMmaF9KswOsVtxFbWzb6n30jeO4axUEdAvF rTljEiIWHhrLRImu6EvHrgtHPrTlD0U= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AWYXOXwt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uSMO7MVO; 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=1724354703; a=rsa-sha256; cv=pass; b=bIpk6Sa4gcgXZPZQ5zOx2/sC5R1cKjif9nqhNOo5fFFjNNdjivXPSc5NFgX0Ux586kaDWJ ahKChLgOR03IhDZb5wMm66DZE5FuxzNHSQi5qCwSfM2gUEBj2zUmmUS2BqWlsLNzeuUoX4 XLY8qL3xkJUwylTiaOfQ6KacpiGy+3k= 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 47MIMWZZ026341; Thu, 22 Aug 2024 19:26:44 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=3MlH+o+RVXMOs3uRNnBWOsfwouftTpxW+3+Yfxn9fgw=; b= AWYXOXwtcwa/oPvCiQWRg7oPYBPF5QX2rb2x12UPjET1DPQPE6tI2H9J0T/mrj6c 3H5y0jXlShWrNqdQNz4JBQkf8EiTtkFOp/tn1GMnqO4I2aNbvUEYdpLjlY0neyTZ SQWceC3+lS5eNhR5TPs0CDKKxaNJtGMxNDYrL2B6FSlwQ90P7O+2clF1JYFE1jLw g7IWygBwoskfQmJgYANaX90hEvFmEzHWzvNUadOTUS6KTZjC1fBOO7tTlhGd90f7 aBrBqpHYJhR3DcmK2B4SBW+MFNs3oa5877aowBcCCExO/KVrV31TVuUDIPdNT0qt NtLDLuVaTxFh0BjkRLm+WQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4v2wa2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:43 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47MJJGAK028263; Thu, 22 Aug 2024 19:26:43 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bct87sx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=plmq3VUVrJRCD8HI0Ty1JLfa2jrog+NTZIpo9qEUpMsSFwQOQTxH++T4RWpYhzLA2RQhWuE2f+kWpaCZ5oxDl1brUs7ZPqQRDlgk3iNEphNGvPwyK6M1K6Iy7QSEkCag/RstKHXN6OnIId2V+VkkDzjyM3zCHm9i+cAs2zWjTLX9cnC6SJUbJGwDo5QBWJ1K9kZkDTq48PxYP6CxD3G/3h+8q/pEXIKdNsQuv396YkcrZ7qgS+O98zth3rqDZb01VTUMktZzO1h83CkqThdDFD+nTZ5GS5eGpuTA0nfJPhrwiAoDoJZAJ4wx3YCy+By0z2a5TabPOYZXdrf5eSvguA== 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=3MlH+o+RVXMOs3uRNnBWOsfwouftTpxW+3+Yfxn9fgw=; b=tK+hCrVZ9ik0DVkxBDcIA7BeCwzDwyJBX8zzSf7sPiYAlz+CsHSH0h4uAgMqkoNSLYdzk9yuUI5s2JYVqYGmWnNrXC/9ycO8ztDChQIuNjI0TlMYCUG2aB5zRQrLQWj6r4k67HCYPrcTZqkT2vvV+W0DXytqX9yMUkL5H6mGkjdeCR6RR4Ez6BPyLR5xHEc9UU7lrLqZTAgbcVygkI2fm+Yse36UpIsWmOdIbljclKP3UwVlokAYYV3fKSAkqKt16lVIzg5ar6ldFtdCJ6R7NeaybNKbMzK9lzVtiMok3PKuTcL+fsDz/nZmsoQGcvsJnEVrcQwok0hFq6Q5OdRV3w== 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=3MlH+o+RVXMOs3uRNnBWOsfwouftTpxW+3+Yfxn9fgw=; b=uSMO7MVOAYf1FGZNGPiiB/lbHpRnPlKaTfhIwJqlxrRjKhIdikWmcM16XiD6Lri+fbcOYAZ6sRykPFSqWobdpxV+//HhQovJdSkjQP5FWyvsOxEl62pRokpgZZ9WsRVmiB+tkMEmXvneT8tfl/6yFPnlWnSWOsFOoIPeoH0GB2M= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:38 +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.014; Thu, 22 Aug 2024 19:26:38 +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" Subject: [PATCH v7 15/21] mm: Change failure of MAP_FIXED to restoring the gap on failure Date: Thu, 22 Aug 2024 15:25:37 -0400 Message-ID: <20240822192543.3359552-16-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:82::13) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 57581fdd-0d88-45fa-21cc-08dcc2e05795 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: CpCtepK9bkSLT3PwkCq7o7yb3+mxs7b+XxMfGtT42wy6SqexosZEbf4Pr2ScHD5LbA1luF7MHno5mEdfSXCF2CRtjrrlNf7Zzpr+w3JgfkJ6kSyTMEfaJ2CcEYIpqtBfCaq7MGgxybj/vBe4b238HdfoiMDqY8WaYqTnYdxcj1QJynfjzCp60vRkb4h06Sa+MziYrNTy3Atouk3pNCXmRaKpnp3bDB4Vc3NRXroqWrM7BuLJMMobyC6zK/4h1AJv+6zBB6e2kg/AUdmVxXhxuDX/5mIQJ0nozlCpBzaslvfKsJp7QYpLAVV2No3rea5HFvDH6+ViPUdw4A37zuiWikCUNzi6R1inEEh2hvjKosRtANfRYtooRmLRRfFUK5To6We+YIRpk8kHbX09s5l0C9sYRCSYRtbxFeWiPWYhal9HojR2NlLtw/TAhc8CrgsUl4sFXQ7RCIXOBNIVaZIqhfM/v3hOjA6zvxlmwgNP6N1lGDXbmKQNefWbXQR1OvlnjzKciprXy2EflPmjpurMX+VAMFVc9kmX2Nn8tyRvNw7qFMKVH1MrBNWqemOKdcQ5vOUuTymHIZjjmtYF24ByuP+IzR8YcVDECMXbSXXBcHmRkSP0Aa8t9ekFh7kqS1omVBCK/Mw7Ib0yoe+eopFrFjVxRAHSZ/YirFnhb6to7CE+aVhFTe5dvAujn90uuwXUtvEjOx8kIrTmid1MgeeV2jBogZsC/vbVUO1UhzfVCGy7jYGRl/aECWwmdUubStYecuLzcLa52ccNX2XmG75mSIdPS44oeCJoC+ShJa2Mvf33b+aoV0l8RFeKddTAfBNuxsI5h6mooStKR8YnuRaD5EYn3U5KMdlUMIg2XMybONr1qsBggKnCHG2P5lM8weRQK+phAK6J8dnQ5IUPeTYpVBheTvAtHUQpyws8kC3NZ5Gcn0EAr8aOhYF68yEvfEE3v6Z5Rshmoh9Pj5zjg0/TkXTD/BJthU2aFxHfCq+TAriZCbjik+20feoWL5u/4+hV8D/BH1lxqizo1rcf1gov5tGInnxhbwc7gGrYLHC+0EaMaw/EI0yXjx9a6h8tydRoYHDXA3IC1hP/8rHX6Ue+KnoQIU6zxLkerRnGyb8AvM2+fg4vWUwCEB4brfgpiOVAqYqydA3wFhZ8xX2SILqLUvapprIrSyu9d1MnyDX7RVCVS0wFDCbI1rBqSe0JZC3jzQBwaK/5/dPd8aE+I24wJe+pUEOzTNwsmiZAAB1AQeWPk/a5+TVYbv3A9VciPTg/lMTOisYs5CJJ0J/iqLflSa8Krqe0FF2xpiY4Xelwnp0D6UB0PkgeU3uKR0sp/hMgGxFY4axL0vU2jks/8ODBDg== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OU8q14i5FdYt8lsuES22JZX38MDgXIaGT8v+ahiIzjn/5kNTYnT+rJbTwZGgXlZfgXMtv4so4J12jIl05bWFBPX4s0eRzqkDeBswLqcYB4pgCG4liQ3LqjBXnw7cH5y4nVxzfSdbmdWH6lFC1vtUr9pB70wMG/yzI6ytE1SOfaxX0mUh6BFi9itYt67b3I9SHE0Qfnjtycv5y1cRznnyT3dtLkavEauTE1lM+ShxJGs56WO8ShPMZ94rzpNQzERhA6GRTqQj5esjcuCDdaAxoQHs5RYpKpCBkBD5JLmi+JdhwQ4a8c1zByFa/CG8rCtkAdjHoTlSy/n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3aiMCsizi3ozKkQ4b21a4p4uzGno78bU/7yPiDBsdJbbYfDTeZEcNiQQvO+i936cLyXopbAzh2kAm1JyLjikCgjYIIFd6NKW/ZaS+d2X/lclz+dIPko03TnPjGoYYUy+9mD4APvFpwl37ggiGRddDiIBa6uMY+jsrBYRTpQyKurWNHFymI1PE7f4j+xakquEzqXO0+0jxKdyXw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 42vEWhJ9kcjTlPez7aP61r/0bLOszU9+oWu+LkfUx5+mumOVVzZ/O5YIsE5mUiEmMIBDslJCFl9znfAsFY0CwbhL14fB2/9DrXWihLGPW1Q3XH+aGOrTn/KC0zHYcWhFuiVkxKi80QmDHzghAaqGYXMXLCG0LQmYXzIei0n4nC3pMdSbpJCSfttoeT0ieLYY7kj9/SiWkTLp44OaD0VZTgRTxVSHW0EUWH1srfZKOUwx9HAuIiKu9ajJB0cfBIOnDU55kPu+TmAbsn7nB6rZbaeNGT8RkV04hSOYqtv+rIeirl9k+17M+hAVe+yHKeYEUu4P8gZfJvn5GCP1DnX1t08SSWbOOwNOKv62en2o51rIBJcvqaL/nvTLwcNrYH5cpts3NYzddC6O9Kl9eGy8laIGCWNgQU7Ok+Xl3y+sB12p+yKy1vDiAtTcG4XZRJgEQlvz4hRIQSy32kSkPPPltgAJO3M5eghXBhhwqmW6YdEK564PrDVHyjfIRInXHUtrkLAU88Cf3LNt/KlNKxTKe9Qui25ZDWYpAbkK9fuw5iFDcqUtAE2NB4X3DSV71ZXlgh5IJGjU5lusGtjJUBcERGybhW60CQST8biIPyaS6lM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57581fdd-0d88-45fa-21cc-08dcc2e05795 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:37.9639 (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: rb0TTYoLKo4wr8wOPmfYzMlSr2YRDr4Sm6Ss6JYLp2kQs+EGFOuIM74DYbnbkqW+g1XTDpPNSV6azLPOTHNzOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: 172SnK5gjyVSOoobUO6vUBRuQDIcSWNi X-Proofpoint-GUID: 172SnK5gjyVSOoobUO6vUBRuQDIcSWNi X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4FCC98000B X-Stat-Signature: ci8fw33xb8umu7e1ijfr6q1tc7q8f6ze X-Rspam-User: X-HE-Tag: 1724354811-416524 X-HE-Meta: U2FsdGVkX1+gyAcBsGMLyrW5SCWEABQej96i4rVs0TbTf2WFT0suV16fKaZdy4uNytfNnqIpVBDDS+oOOpxqcpxZInfo4j/WYbu882toIKGQ4323qA3YGdCl/0ykfRLWyre6V59haNb2iPGtSM966trvoITmmUfopzr9FMzM2AjmpnXimeYZcgQckcjMoVv5y+JlKa/R6Zv5NJkuwqMLhuiShVsUwPCAhLIdzfL0HRu8ckr1REv11zT/o4zTB/iD+wSoyaZafgJDBXjrpkevKKUg7EYGmpDIVoS9AQRYy3to8TpRvTe2GJmkJE97HQ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nZss7Ssp0pUo9OeREJv4ttr9R4AShYtjhmOuqR+k3ElMCYf4lyFk+9/dWbUjBleQ2xL2mjIepGvjmpVt1aifqcFi80mEhlxMBrZjfSuVlfapCqvx/d2LhoN2YnnOQN+l75+ObAtiS148Q3e+RY8BHLq1+667n4QRaW5nr9wc= 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" Prior to call_mmap(), the vmas that will be replaced need to clear the way for what may happen in the call_mmap(). This clean up work includes clearing the ptes and calling the close() vm_ops. Some users do more setup than can be restored by calling the vm_ops open() function. It is safer to store the gap in the vma tree in these cases. That is to say that the failure scenario that existed before the MAP_FIXED gap exposure is restored as it is safer than trying to undo a partial mapping. Since abort_munmap_vmas() is only reattaching vmas with this change, the function is renamed to reattach_vmas(). There is also a secondary failure that may occur if there is not enough memory to store the gap. In this case, the vmas are reattached and resources freed. If the system cannot complete the call_mmap() and fails to allocate with GFP_KERNEL, then the system will print a warning about the failure. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 3 +-- mm/vma.c | 4 +-- mm/vma.h | 78 +++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 6550d9470d3a..217da37ef71d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1622,8 +1622,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_unacct_memory(charged); abort_munmap: - if (vms.nr_pages) - abort_munmap_vmas(&mas_detach, vms.closed_vm_ops); + vms_abort_munmap_vmas(&vms, &mas_detach); validate_mm(mm); return error; } diff --git a/mm/vma.c b/mm/vma.c index 3715c5c17ab3..8dc60dcb6e8d 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -883,7 +883,7 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, munmap_gather_failed: end_split_failed: modify_vma_failed: - abort_munmap_vmas(mas_detach, /* closed = */ false); + reattach_vmas(mas_detach); start_split_failed: map_count_exceeded: return error; @@ -928,7 +928,7 @@ int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, return 0; clear_tree_failed: - abort_munmap_vmas(&mas_detach, /* closed = */ false); + reattach_vmas(&mas_detach); gather_failed: validate_mm(mm); return error; diff --git a/mm/vma.h b/mm/vma.h index 756dd42a6ec4..f710812482a1 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -82,6 +82,22 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, unsigned long start, unsigned long end, pgoff_t pgoff); +static inline int vma_iter_store_gfp(struct vma_iterator *vmi, + struct vm_area_struct *vma, gfp_t gfp) + +{ + if (vmi->mas.status != ma_start && + ((vmi->mas.index > vma->vm_start) || (vmi->mas.last < vma->vm_start))) + vma_iter_invalidate(vmi); + + __mas_set_range(&vmi->mas, vma->vm_start, vma->vm_end - 1); + mas_store_gfp(&vmi->mas, vma, gfp); + if (unlikely(mas_is_err(&vmi->mas))) + return -ENOMEM; + + return 0; +} + /* * init_vma_munmap() - Initializer wrapper for vma_munmap_struct * @vms: The vma munmap struct @@ -127,24 +143,58 @@ void vms_clean_up_area(struct vma_munmap_struct *vms, struct ma_state *mas_detach, bool mm_wr_locked); /* - * abort_munmap_vmas - Undo any munmap work and free resources + * reattach_vmas() - Undo any munmap work and free resources + * @mas_detach: The maple state with the detached maple tree * * 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, bool closed) +static inline void reattach_vmas(struct ma_state *mas_detach) { 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) vma_mark_detached(vma, false); - if (closed && vma->vm_ops && vma->vm_ops->open) - vma->vm_ops->open(vma); - } __mt_destroy(mas_detach->tree); } +/* + * vms_abort_munmap_vmas() - Undo as much as possible from an aborted munmap() + * operation. + * @vms: The vma unmap structure + * @mas_detach: The maple state with the detached maple tree + * + * Reattach any detached vmas, free up the maple tree used to track the vmas. + * If that's not possible because the ptes are cleared (and vm_ops->closed() may + * have been called), then a NULL is written over the vmas and the vmas are + * removed (munmap() completed). + */ +static inline void vms_abort_munmap_vmas(struct vma_munmap_struct *vms, + struct ma_state *mas_detach) +{ + if (!vms->nr_pages) + return; + + if (vms->clear_ptes) + return reattach_vmas(mas_detach); + + /* + * Aborting cannot just call the vm_ops open() because they are often + * not symmetrical and state data has been lost. Resort to the old + * failure method of leaving a gap where the MAP_FIXED mapping failed. + */ + if (unlikely(vma_iter_store_gfp(vms->vmi, NULL, GFP_KERNEL))) { + pr_warn_once("%s: (%d) Unable to abort munmap() operation\n", + current->comm, current->pid); + /* Leaving vmas detached and in-tree may hamper recovery */ + reattach_vmas(mas_detach); + } else { + /* Clean up the insertion of unfortunate the gap */ + vms_complete_munmap_vmas(vms, mas_detach); + } +} + int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start, @@ -297,22 +347,6 @@ static inline struct vm_area_struct *vma_prev_limit(struct vma_iterator *vmi, return mas_prev(&vmi->mas, min); } -static inline int vma_iter_store_gfp(struct vma_iterator *vmi, - struct vm_area_struct *vma, gfp_t gfp) -{ - if (vmi->mas.status != ma_start && - ((vmi->mas.index > vma->vm_start) || (vmi->mas.last < vma->vm_start))) - vma_iter_invalidate(vmi); - - __mas_set_range(&vmi->mas, vma->vm_start, vma->vm_end - 1); - mas_store_gfp(&vmi->mas, vma, gfp); - if (unlikely(mas_is_err(&vmi->mas))) - return -ENOMEM; - - return 0; -} - - /* * These three helpers classifies VMAs for virtual memory accounting. */ From patchwork Thu Aug 22 19:25:38 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: 13774117 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 36AA0C52D7C for ; Thu, 22 Aug 2024 19:26:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 113966B0134; Thu, 22 Aug 2024 15:26:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0232B8004F; Thu, 22 Aug 2024 15:26:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA5D480054; Thu, 22 Aug 2024 15:26:53 -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 AA14D8004F for ; Thu, 22 Aug 2024 15:26:53 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 55BA9AA084 for ; Thu, 22 Aug 2024 19:26:53 +0000 (UTC) X-FDA: 82480863906.06.D6B8F18 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf30.hostedemail.com (Postfix) with ESMTP id DFFC58000D for ; Thu, 22 Aug 2024 19:26:49 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AD2fBBFm; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=x6Xtzvtw; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf30.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@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=1724354719; 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=VJwZMoZ9FdNzvr9ihYDV0ermmuz2Um1cqCOecEEoDKY=; b=ROkynL/qx8aRsl1w7CSKcFO6+KVFY6qfuIedE6TnKYET964fvP6dJYUysIBRh0RKhG4jGN o7aPgxMWrETXGAIv8LQWGIoAuUayfiLYjrCct119CsRXFlPuKckgUNMXeOyG6fRuw5mpWz WIMzWlmUo5OJBd8Pql9l6r2Wnb1GodI= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354719; a=rsa-sha256; cv=pass; b=1g3GXDjpSPRSkWyuuUNprsl5G4/G3soD+lexeRvCIhuZJeKq8KavlslV5+a7VfTzTF8rKO v8tcfFRDTNlugjafAEiWnXigvNsFv5pCyE0Ity+7X8JSDVkhVJm9Bf3I4kqrLDUNWCqghj VTQKn/S0d8wC827lGcavewuYesOaEqc= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AD2fBBFm; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=x6Xtzvtw; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf30.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") 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 47MIMVFh019167; Thu, 22 Aug 2024 19:26: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=VJwZMoZ9FdNzvr9ihYDV0ermmuz2Um1cqCOecEEoDKY=; b= AD2fBBFmmkqng7sfAsrMu663P2oGm7R2uBHkJd6vMwMa9JjYdMfptmVaNXy6Lg7k g0+1Tq0KiPhiOPw8Wna9jvVkikDd1mNQWPYp0uV+vyP0nZOjVCaNGxPvw/Ra70Nb c+UdWuCYIkB5R8uv/THzhB2zEJEIqU8wNAlkQebtJpv76QV2zgupCUrnuGMLC4gi RpydR6se7q9JE6RvL6XXeD9R3N/01JjzrTYODvbofUbrvLG+7KZkGW50gNQeuCKM GNy59oXNfaw9kK+y166UxSa8XbnKpBcpvi+a5x0iJXRmCrrGj0DjmV5SkUGRL/9k m0QlthpbYL1odEXW4JQlHQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m45jwaj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:43 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47MJ3jJM020764; Thu, 22 Aug 2024 19:26:42 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 416b5jryjb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WxiuAV6Z9jHqu2F0joVZdM8b82a76/QlHAyDUxrMf1QRBS2uKp+0MIggrxGCchrGr8VZaGOWDzJNri+kQ2K3fCb6+CUXb9Q3b5v6lXXkGym3XI3wW/vf/5SMPc8Zy69p5uDkCf599FDKK6HMu+X7LVRD27PRUSt5kayIjRD2ZByTyz6qLK3BIz0Mut5sW2wwg09eejuDvJyHh7puTDjEvjDxgtkLBqelTLesHQTwdooKQGBk+mY+5zX2fi870ekkxexGDbuSa9k+sF9+lmZAfvNomv6u6/tZOImSYl/w+ETZbGP+YYZpc9xM4gTVBBk6oZfBDrBsvmPNXEkMasTeNw== 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=VJwZMoZ9FdNzvr9ihYDV0ermmuz2Um1cqCOecEEoDKY=; b=bxaOEv+LeiqUES9/x0CKSkXjR8wpgM1B2CI3Lq1tXYTUzLH6Y7qgS5yqb44xvFSHs5xG9Eeg3NwDcXYLvwqa4X3mhpKjQFWHNbalfVJiYNB+HoiNnoc8ozVjpxySYy9BD6rsmSmnXnFYyDMiflGFIwpmxlRvYnveTIQ0fZx57AkZ542YvibxmImkjbiDjzfZshTew2lHiqFEJnoq7ow5P5bOuCLWhBkiq0UCmqY3xj2u5W/XbJ5V2MijoqkHMoYd1Y6SY/TMG6+aiEWqrkJ1yQ2t1IxnxV6HewttArLSc+yFO8lIKNAinR2n+qrVaRfKktoEnLeUMDeobTWdQJEmvQ== 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=VJwZMoZ9FdNzvr9ihYDV0ermmuz2Um1cqCOecEEoDKY=; b=x6XtzvtwPi0lPkibN+XpZz33QUnegDZ3zI+lJjZX4vRbVPXfXcX/BmuVXZ548iAwd5LjMPyO2aB4artQiaFrD+g76Gg9H357Uuxx/UYPlpb2pn4oTdDIPf6OGyBPxSedomXg34QvezQgsMfOA9CXye+Y0koK6iUVNjMV6QqPlvc= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DM6PR10MB4202.namprd10.prod.outlook.com (2603:10b6:5:222::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Thu, 22 Aug 2024 19:26: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.7897.014; Thu, 22 Aug 2024 19:26:40 +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" Subject: [PATCH v7 16/21] mm/mmap: Use PHYS_PFN in mmap_region() Date: Thu, 22 Aug 2024 15:25:38 -0400 Message-ID: <20240822192543.3359552-17-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0323.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10a::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_|DM6PR10MB4202:EE_ X-MS-Office365-Filtering-Correlation-Id: 54d1ff7e-779c-42b8-539b-08dcc2e058e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: xLgfGiI8HXoCqPqlnO+DBDfgc0DSiPuioK00H/rCDbE1PGT8+V2kuI88VKNFNlnfulabeyjlqZHvKnmRGmHl2Om0IKHRZlXX57K1vFbe9nktk1yWG9H6T0zFqD0HQ46Fx5P7C6aUwf6/Ev39dTUtbSZlvCmnEfu4nxCcBVZsp1JsEvZ7ArJMpClKc7v/w5rmk1Kle2VgXy82lH4jNZi7p0Sxi3dL2XY5uouonzmA5idulX6g+uhv/4iT7fXit35CFXh8TI/0Pp8pBYEHFRh8CXTTx9VDHkdyQ4VSDE5uLt+u4wuHMOerf+PqFxaTsyXRrSY/wyGW7DfnpD6j7UzdpVmvfDWj0GSaYkRnce8OzuStAI4d4wGpGhIJJNBgHw/9CHXFxobpBYugQ+U/3kfKUjAj8Sw7xFXm+shSMao4pnIDb29IIdjGstQF0Z1b0imMdKtMBcJuAWkWjM6Yy9iQxHU/0DR2cendXnsGTPPOY2+8zuhV3CawOSiFxc0BiNDI8dS5v1lxwDyyoU5FkVNKN75R44+RYCVzgY+Cbg/Cfg0wkLlz357Ffz+J/KP4xLwGWPBowppttktKkknjD3fboQqwlv9athrX7+ClsicXwBjI6MX85iYtxvVSI4cgglzbGSGtvZHYEYEILw2D0s/EYOg+1GmyMgffnhXk+Zsb3BTqbASdtxBiGvoVyHBfjRK1796Tt96j2S/oIPkAnXDKvGD+2y/spXSFlXUsYRJDm0hbQkKjH08MWuJ8xnsZVZ90x88ryZNRnftdADaE35eoktAuCKcjRbPpkS6SGuc6/S9Bdi+cFmNLgFVJQc8cyARKdBNVzyvRLq4DK2RXs5nnuZssr50Fcw/C8OPG0aPS+iswuHXRXgot8Ru9W4RUOYc9my1LPY1Q9dOKZdxPGcI3YMtV5qAm1B/7bCGW+xBbohrcfEJqmSxqn120gxGkVUEMq0qdW3/N23hC+5qJbOZqF/UiF8OVDdz5fb3GDkAPwG5b0mVJnoizE/zLdj1xldPxbXzL8HnyYysWBQeUc2z1KKJ5xTFvQVSma9kGnaJql0vahAiGN0DwwSOvPhibJe0WtV50nUuiFFpxgUXp9TQ6EL2Wjs4yN8AxPqU42AdUyK/ZROD06+STeWoeEX9WEQFj89hkbqouT6oQBlH+NhlLbY7FFp+R2A1ORxr9ix+2R/wE7LZ9VVXBPG5ofXkvJXT5+cgVrJ6K5Itio4Z2jVKcaikvvi1mcRv5bZt1XqaCA98Vot3Mmxk6xr3ZkU5RC0vGFsch6IzyakRigHdBcuxJk/NOIRZpW3AkkNjIzo4Y/oxwBOWh3FTEPms3q8b2vzQcoC+dTwMQ3eFNzduxiaV+jg== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lnZKO4Qf4upTMGtahz/bMOqBqgbQvYPiYjct2O2KCsWWXzCqPcH9qqgAidqwP4HgPyZh9qEUDpwwdkrgx0D196PbyuAm3tiMe9fxszzbYFnXJq4re785+W8w+YfmXuloqqLkBp8WpqsM7RrInE15qLWBe2u/pbpWwsiCCTkzS3L7HprcTxsJXQ/7pVxPadSxmrYB1+EBVg5kwqM2s9TEZ/LjynXIwnzZcC96Ei0lnq5COL9GZgfi/SeHXOXqjffLcsAMxwCzdCUodaBy+7cFGJV5f3JCkjqfrATQtwSFId5mLz6ib2NxtqWd/nmkwfBMWfIZV5eVEurIWUadvOIDTkUKxPA8L58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HUn7/pTZe6y+4PjEkXpgyGksQ3sSA4DtzwK2nfoNVsKwKnjib3hjivrrT7H+QFAitTgBHawDp+Pt/z0nFJ9fWyUjmloL9VYwKBryXfU/KW7ExXeW2fGWmsN8/0GEYhjdh8TfYH99MuTJYwp1xYO3sil+ZONsFEb5orthP6ujgibBufCnbMtbO4DWiLA8+yH6w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: O9LD6sxGvy6dmy+3DqyAcRVvm/B55JgORo6I+yXKtjuZse0lU5oajBKc2k4Mat8UnGoZFXwQWgkyWaDDXfrzIczBXO/mQHXIFRZCiSDbzT9QQB3n4A+rxMjB4P6RUyDsD+RwPTwdfg2RZ6QDsItyMNezAr+JJ12zo90tallIEDSdkneF1aiY5HJsQCNW7gvCHFuSWZfw2yIAKxjUnMVwVkS7lJdn9uNwsENNpSqOJWuKnOKj5jnpfriYf6hQ7qLOBeA/T7yWe3qN7Tqf1EY6wEAsXaG7Dk6wDjWvCsdlOCdYUzHoH2dkqWUAGWlr4qYFyPCSegrXO+di6zeR5on9ZL2gWF1rMQu08eSkqfKv0tWPAmvn80uTrswDf+JqBMmcjs4X7lGAbg38uKtTIZ+tW3Wl1AN1mUdivsldr8KsxNzI4cOXM5GQ353ToJ+D5UtpbIbrCKGy57l0rC6n+lXZzrbV/SVnrK00kfoXoVKLpo1dMin6MNFVWX0yB6IjxrdWJBWHbBI+ByKT0dxHoYfpRB0GG8BCMTvG6Lj7Oky7womEGek0EM7Rt93jN046aW6ZTI0+/DaO9ATt99AS0C0GwcQP+FC3FWblTjjBYMKnlKA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54d1ff7e-779c-42b8-539b-08dcc2e058e4 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:40.0976 (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: eeiVupgdAwVXg/dl9xlOb5+By48MtMsPwyeBicaJlhfQAGIevCCHZ0JHrNF9xwW8Pa4z4u1pUV8GSJEQ5DO7HA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4202 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: yYUrKUJc4UnKRUsEgQc7arG_aTTZmklZ X-Proofpoint-GUID: yYUrKUJc4UnKRUsEgQc7arG_aTTZmklZ X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DFFC58000D X-Stat-Signature: bmhbdf3r6obk4g19ynqsxgfiinn75azg X-Rspam-User: X-HE-Tag: 1724354809-599610 X-HE-Meta: U2FsdGVkX19a0KoLJNnkuACnJFnfX1wpJT2/EuLWan4isPiJAea1Flx9TecIlBs1DLAJEWnSDDNgkxvjyl+gGI466mwFrJ8hXtXa5s0RCBIkseh8JS5wzjAlTquMBLTvtCh1+tEWTDBwyzwG5K4FxiJXA8fvHCIrc5s8jE995EUn0oGG/nhUGcACvMUbB4ykp+OX+aamDsmO5e0sykMHOlEpQ92+wBKCQd4VB2iDlOjsZq/0h9X1Vy8qDskafRYjAYfFmLa0D8RvHHv4nQqmYEHatn8hKtEGmKr1YXcuQVKDlll5ma5aN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NxtrbVEk1BN8qqfdhOwt3GciIL+vL2ipAbriO57qymczQhuG0a8zCrbpid/pdcUMTdUThCWbpR9e7Jxfh0iS0nzfCS5n9c+s= 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 217da37ef71d..f8515126e435 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1364,7 +1364,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; @@ -1384,7 +1384,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; /* Find the first overlapping VMA */ @@ -1412,7 +1412,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; @@ -1573,14 +1573,14 @@ unsigned long mmap_region(struct file *file, unsigned long addr, /* Unmap any existing mapping in the area */ 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 Thu Aug 22 19:25:39 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: 13774121 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 CBC75C52D7C for ; Thu, 22 Aug 2024 19:27:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E7FE80056; Thu, 22 Aug 2024 15:27:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0994A8004F; Thu, 22 Aug 2024 15:27:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D90EB80056; Thu, 22 Aug 2024 15:27:01 -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 BCE548004F for ; Thu, 22 Aug 2024 15:27:01 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5DF76419DA for ; Thu, 22 Aug 2024 19:27:01 +0000 (UTC) X-FDA: 82480864242.05.217119F Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf02.hostedemail.com (Postfix) with ESMTP id EDCC480008 for ; Thu, 22 Aug 2024 19:26:57 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=lSHD8SxZ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="y8oj/EAq"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; 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=1724354752; a=rsa-sha256; cv=pass; b=y8b0TCuiZTP4qgfzo0h+Btn781g2sTc6WybbTkg62oOlNY8D7JZIwB400GNuepHbLU9lN6 A16AuZtUIMZoAQoI5fY8JrqFAEkETH9XXmpqt8RUDfQ9sCrJW+3nG8VXDVPPLydSaY0tZ3 J8w4qNaMlwVK/sTK9qTgKN8FS7uKFdY= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=lSHD8SxZ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="y8oj/EAq"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; 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=1724354752; 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=ZVYsOiWFMcykFDuOByyZ0ITVxyXF2Jr6xdqxlzJra2c=; b=HtByN9wFthMSMOYZPYm7s8f60D+6v9yyWybgIRP+NMbkBRtVMMEetrSIkvk+82et0j6sqI Kdhv/CuOUYtjw4BXr3LJ7kSPrQP5THrwYp8jbaUdkduOijiWm4Otx8ogvCvNfGiOjblHt5 IsjXLlGv4+KyRbdH+LNI256bsS7e6S0= 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 47MIMUUG021048; Thu, 22 Aug 2024 19:26:48 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=ZVYsOiWFMcykFDuOByyZ0ITVxyXF2Jr6xdqxlzJra2c=; b= lSHD8SxZnLGoPKzrAV4gSu3/j2L+QLkR3IXhOXmiXh1ulVdX7dVFJXwfrmzhEOBH KL7o1AvF1Wzej/65bwN1WVSUxMaPQlRV4I0WyP3T4Zk1lGup4+oQ0qRsUCI37DKR rCTjHOGQlwhnUOozlkZkPMzFLDtczy212OCVoinngPqCV9ltiVeRt1/wt2ELJB9G uWMV9b03CuET+mKvyGT/9StbCWF7TPIFR00+aTgZgTXXd/R/c6bZORO8jKvOP+1l 1+ahNvaOghhbZgK656S5r56YgD5T0Itz/2Fq4cQZKbJo8s0HkiqqJBlxIfhzQct2 KM9UMWXshhyWZWwdBd1a6g== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412mdt2w1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:48 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47MJ3jw8020777; Thu, 22 Aug 2024 19:26:46 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 416b5jrykb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TlJkLjmvD6TCzUqNzl3cuMjqyQ9qxri/ud5/ydWgFOfpkrnty1j4LItdsb8tXUG34EDTRRkjwPIqiIKqvhFSra3RBmXAs+TbwM0e4IyJOhuwKJBHrQm18zyDpkCPxfMg5sIZvTad4CV7h5rb6Mz+uz3pF+uYwDnQkUiivvSEMi5CXLMyjwfhaF0hAD3zTsJ378YNeQZYF6iJ5ZaLgtbmqTmTV7VtOp6A/mdeDgWfN7L7KSf8vmWGZGJVzMA6Xsb3rgxD2kRE6YaoZskkUii+UtMRIfBR9497o+uu785NrT6ff83hphIGk5zMRjgz3TCzJ8SF0/6MWaUAXrN1K6O+Cw== 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=ZVYsOiWFMcykFDuOByyZ0ITVxyXF2Jr6xdqxlzJra2c=; b=azRFUAKN2eiNDkLiPDfvecsUIDts828rz6Kei01Fp7r+DEJ+g1p+FuiNTkV8YwhsW7iYJosLXjgKlcu9g+3X79T2g6L+iqxX1l6uw2CLofmiGTNjyMJsoBxgeIi60kwkNp4zhqtpfHvN5xTza0/i+rrO070vyNjeidCyaPHh+NfLeXB1E8p0sj1M74Sgu3Uwog+QZYRlxdHqNQRI/FisxLiDEtF7u0EVXk2r0kqZLaW72cGCqpCA8J02aqql8H0zrUd308exsAz5xCq3i5zKFN2HEUHu8Qqa/dL+BeQpZYFYY7pCiLyreKv8krL/YW0vTy1j5Xu2iS4m08QFjg/AXw== 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=ZVYsOiWFMcykFDuOByyZ0ITVxyXF2Jr6xdqxlzJra2c=; b=y8oj/EAqET/pxO861qxTkpL89SjiFS+5B2kR5z+KJPUfTYAduTxtbRitsal5aMkvyVh4XyPzDjhwWXu6uVm7kjunw009aEB+T9yt3bE5NNOlP6VCDBeEd0QqWUJ3Ovw9DaixNHkLTY/6Cf9L21M6lp+G8MH9TeRruRGRAPy+o98= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:42 +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.014; Thu, 22 Aug 2024 19:26:41 +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" , linux-security-module@vger.kernel.org, Paul Moore Subject: [PATCH v7 17/21] mm/mmap: Use vms accounted pages in mmap_region() Date: Thu, 22 Aug 2024 15:25:39 -0400 Message-ID: <20240822192543.3359552-18-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0332.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10a::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_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: e3695565-e080-47fc-95f4-08dcc2e059f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: URcT6e/SAVD7Lad5bSOqLIRNxajJ0cAXHFCVm6J320bEOGtMA8qK2G/TpJRzkuVgU+u9DbZSWWxgyKkZpsHR4xqi7G4ByhlRBQq9kxPWmQSOWNYcoPf71tdex/SuJ9t3jF0mTmEWdaKWcbAtpBeZ5hIBPuDlURItIOU9iCpxvzBjdaWSTnkPHrybBRu2ENMi1quULEsQIZmfHuCH+gvgvw+HGjr8ytgmrGIhTimiJ+MZHzAGhpmgAmYfVV9nEp54V7DN38scbzonz8AN0z4Q3GQgmsH2OHY73sgow+rIIQZ4gGJFYzQEWR0nZUjGW2YYD9gwXhjKG6BJcd8JiMY7dn7sgPEcD2KE1di7lbP4ctH6C3tvZEu43+b1duOl4+JSG1chzMlng22/CsJDTvn0epxI5kM5pmGQb7OWMaX1EMp7xrEEbzTgwb6L8+3RRblerB0JKR620euhnyRlmMovLa1P/XXnGz5DUpQjHQnTr9B+OtIZtmNAuZcftXZahHIrikBuQmHuYd7gAu9pkDupuDjMRWAYjejH/AwM81+08Dr6ZssMfsY/Pk1L5oPxiB0JJGDfGOfXNGZavppa7y10O1S1n+OHvunodkzTzpl9akroIGKcL/JS4EGct3WaF7E/IwVQSZCFkMAk8VBNF4hGkZzrbqy3QLrxJgRLyJMepeYI8dei7ZxO4MzqPoSb41WK93hDdjolTQoeoM9J+0wUTSLdFOvHxPZNzezCqc9dq6vfiLBzHyxLl/gdW0Qtq9TuFWGXF6tqxXspLYncfI4yXheJIbExth3bePM78Wuc0tV+bTQj1yn90PiwE1BsV6GrBIqyAQjLyESf8t1o9Y+/J4O0NclRO+9vHwJCs2xDVBmb2UY2pbwf8X5C+101nY4lGr1Pcoy/I4S14Ileitc1gsELFgRNHOL6h+E5DRzHXl2C6mfluC38hxTKU+aq8c3cMrd1Hxqkete7/e36llXd0nxvyH+LrFUx+O5NB+NnrZWMQZUMWo57DJw/TMbMQLhx6lLTu8zin8Jlm+DQCpzRU16oJ7iP1DOW6urwxxKZYhLGs+q3qakdv5UJfAkWiUSqlDJiZsChFcYfVVaahPy6eHrHGaIVcTuCmJR1aOqZD2fSF6HUsO5kmGGB2a+A7FK4pSO0sbZOzAzd9WLazAi/tNEW/YurJxgNTaBBZ2Ijn3m/QW8ZKhdJ7R2LfM0bxmqD07/9bTdBoHHlsGxddzY6ctUFSxwFrql/2CxqgxpAmJ7hUKyuqO9UDKcvIQZsHcDWCUnTsDqwyh8xmy/iuXweDUa/xGzP19qqZ3FoSGBF61WT1YpdLVFBxX70Odlowcw64sFf/Amr8iKk6fNmnH0qdA== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GxXykM97A893j/ki0bZbOeLVBw6pKvnMoULzeryQ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m/2tSLA12wcdohw8nB3fFZdR12D2aWFmqjuniM54X3rVdl6AJZ/GUtS+kD/SomGCo5KsrfmwrLtJoXcD4zrHMzUr2X0GzXJ/3j/aFGHqw9GyNkRgcbPdabumaB+DepRTRkUM4D8vcERK0azR4xYJR6BMw5gvYtgzcNEPk869QM1yJqWV6dufZ9/09Ql7y0wtJbbUfXGKPJnG38jEZbdHw6gFUIrzpS/uG3T8gM7IhcRypf9pXiYA4g3FZvGvrmTSg47jqLFUAprvRTCoUjRnbUQHyHXx1Gsz1MWPo0WpzMXTUSp8pluFzWfWoTextj+XzGIn6ne5bY2McdPN/t5I3+HEsH97kIGAuCxvSHwIKMkDsva3lm7iBiRP0uw9G9oheKYBaWRVB+mqUBF38lE+lGwUD7tFHZw3m2ksf3G5rHU3uDgGadwQ5bB9wXPC+nqIqixJKfeWPwcTyz70yDChzqphY6S62wPtWlGmfJMAcJW/TQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: BYT82CrKXj6idFfUKVM4oeJ+gGL4MYmZ0Koy3jXqRZ9fnfwyTFxvfbAlUTz82EQ2xDEJqScVc0m3vt7bIhjVFu33b/cIg8RqZIas2jd53BDWlfnwDN53lVRlCv/2AcNqPRcakh4xIg3dRthySsGnbUnoW2RagB3KvtVWd3fULEafyBbvGk+8FDZpMoMlmKrADd89PCVJxoNlpgUT9E5cRmDAO1Dv3/KduR2VWKsXrDWhDjQRNg+YthAMo1DXMEAhl3kinU/DlSUp24524ltO5aD4n2k883ItJf5ErC4hcESssYkJkfVqxs9f5vmYDC2PJehuib6prptE4nrv1aZ1W2+/0WmTFTJCgyEd/AIJrPNJxjvrGSjVnn/gW38it4uurTRPDYDrYRgLPZaUYgnRKoi9D9PcrpgKLVD1ZccWR/W1g5PQsbNZFy0xGT0hUIm9esX9Uxov1w0enuQWX0tilMFVYMerCbB0z8TfuULOYq9i2kYn95NbYc2kKvXyiG7lLkMLSounN1EVn5q8L0nFsXTYDBcRLlL3WSQnBb4P6TuN4E0LrpXaK4248x43eBDpw0XYdZn034LMz/RLZ26RtxjHwlahvRmiVxbnYCn8EsY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3695565-e080-47fc-95f4-08dcc2e059f7 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:41.9154 (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: /ljBBHeME+r/QmTipq5uY0Zw1qoeVjj+unGy/OA7tup74LJt4pSAVX/5IEG0b+s5TpiEhEerIs+VLyZpe9MInw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: wLnVLnmcQ6AXPqzwX6EZxXtDiRQHr5FG X-Proofpoint-GUID: wLnVLnmcQ6AXPqzwX6EZxXtDiRQHr5FG X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EDCC480008 X-Stat-Signature: f4uux5nu97ub7gcicqsorn696ytc6qcf X-Rspam-User: X-HE-Tag: 1724354817-976803 X-HE-Meta: U2FsdGVkX18qRihd7hdOF15ivL+XlQ/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68myPBwoChSK8LKxkYZ2fSIGj0ddh3fX+fXG5IFQ2U6BVfFQc2s37y7dSW2GTdy2OzbYwdQq532E7Z+jTY3W2WSb8r6yiFq4kf0JExm7D59loL0bWiBFyAX+y0JgOzd+uSQqXN/KqHQvl1rjVIlv2/5jc9H2fWRICiv/3ubS7kXsiYR6JWJZCgOgD/FipnGFA1yd5n+SwlwdprV+C4Mkbas6Mzu8fkzq9/6oL41NJusWdQiIlg6vWIdy1QCaJZlj0H1piWlfOh5Hs5WjDKxvmDVh/XlxhQN4ICYza79Y2bXgQ9nW7a0voHJRcXk6ylIBodYx7Pj7uyFRCSpzQyGqP6dYawXWvYGaoj6M9lnkvN4ws9CiWx20eJV3W7QdJERQR9OGNAb08U62NYNDyVSqrSCBXRLLOZsAgVkBfqkHi+VZJ4IZQsjIBHvyCYcUf10q/E1F85Al81bW/9F+TGvLgYCDEMtoE/BJKg33WJ35orIulwEhzLqSqLZOwU+OJHwnodRPiKQKHWmEvd3eaSdErYC4Hq6xA93RA0zzN6ienWdUoXbr4 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 f8515126e435..aa4aa49f3b97 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1413,9 +1413,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 Thu Aug 22 19:25:40 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: 13774122 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 34B48C3DA4A for ; Thu, 22 Aug 2024 19:27:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1BF680058; Thu, 22 Aug 2024 15:27:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA35580057; Thu, 22 Aug 2024 15:27:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0BAD80058; Thu, 22 Aug 2024 15:27:04 -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 9BF028004F for ; Thu, 22 Aug 2024 15:27:04 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3AB841418AE for ; Thu, 22 Aug 2024 19:27:04 +0000 (UTC) X-FDA: 82480864368.03.A64E597 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf22.hostedemail.com (Postfix) with ESMTP id 94058C0018 for ; Thu, 22 Aug 2024 19:27:00 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=k6CpqPnD; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=yVQ0IEDa; 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; 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=1724354756; 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=Lq7kRWDy/JaP69JbRtRp7VUtMeb++6kHnahDgE9Gb+s=; b=7PfGFQ3351RX8Nqc4v1bzYl6rteQX7swTv/0KB2LCaHFZMkSKMK6xFTg5UGXs1W5ltpaDn EyRP/gyiqwBP+exYYFXLc3vpEA8ahWHAMHyt8iC1cqGaw+RRi6T9RK05RQWYA/XZmOf4P8 qzxOVU94hCnafaubdxYPe7LcLdjDHPc= ARC-Authentication-Results: i=2; imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=k6CpqPnD; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=yVQ0IEDa; 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; 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=1724354756; a=rsa-sha256; cv=pass; b=TcEaB9LX303rumLG51Snyy0QhYQKDH8hoFZJJQFHUdP5M24vVo7SCxqPMUHN5/qmWPwo3U fq1Un7MsS4ho/2y54JxPl/EYB5s/vaZyVYXp1BPVXGPrKd4PKcalL76SIedNxIf5+0Q85K kF7kdjdzDGCgt1g0+XjYzlNoHPtv8KQ= 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 47MIMYVF000818; Thu, 22 Aug 2024 19:26:53 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=Lq7kRWDy/JaP69JbRtRp7VUtMeb++6kHnahDgE9Gb+s=; b= k6CpqPnD8aSWktIcZ6TwZNm3udxyuEOGh+VUcTGWfCToMmHA8w7rT4WZ3v8TDIyb UBLs6wcNagqFCws8HhIpe/Y2h9H+RL0ZRnCunuGpuLsoghC/GJfFyF6ttzumxMeH n6rgmswEhQ+MY3cmuqQvipK0nYtCAt+6FH2iuqGy3xOvSH7f7uVrru5oif02qUsB JzYyJccq0CdBEEqOxfJKHNvOQroatfAhnosEV4QwjtVO1Ffd3WLkyl6KTCOXdcf6 9B6kKorbGRMOHYbtqFxlvLrfOeSvRZ/cvfLg5dm6S/xP7PTcufrPONX2ddE8KyQH o3MOml8YGM9dYxSnTej5IA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m6gjwrg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:52 +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 47MJJOnU005646; Thu, 22 Aug 2024 19:26:51 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu08bq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cG4FSBgOOC96TlP4ZY2TaYtx8TvbwmppN7jCy1lp2wyuB6usjzs05fuMCDDbKH2toAIn/PGqp/OumPz3jIjbQD0d3O0uFDcAdStZwitIoxCCTW64+jmWEFpMJ4dGfEHd6SNbMdh206MZ1d9JF3DO8D4QR6Glbg6LDWKCDtzALg+VhTb2znFlQu/kU8b9bc5VFce7uR0TThpzheTTkz8xawAN+1MADOdmKWOe+Tx8Elvc5phToFIRMY0xA2MilYbYgGVyNjb3EbHBxLqsJDxKUJX639i7CdjnMJbDQLY+qI4hjM9HMe2PbuvBXvRZlPr7tbvN1WdodU7UmYZWOP/dyg== 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=Lq7kRWDy/JaP69JbRtRp7VUtMeb++6kHnahDgE9Gb+s=; b=uUWdHQ9lY6D9buLCU0lQpTzpm3M38JUgPr3VNoeAx+YpDjxqlp6KjprWPLvLZtZIzfmhEe1c6uOG9M0jeRy7oY9fOHDdvp0b46GL+X8W73+0Ay+/agiPmznow8133Tz2ro61wkVeHJHdbJs4HEjX1ICdj1ZBRB3HSUftRCj4Tenr5XVyvUK9AqKo8P+a+9m/MVRPuOHJu/ZCvlldyuU2Kx1gU4+pbDAgn9UdZdqV6lgMoiLUhtWJ3BhnFdxbnAS+ichKuaxWTBsykXOujQQQ5waMQVG9VZIXmfasc00tjHqCRDolx42gK67+hyiowTqJG5Yx6W38mCxxb7x6JQIPig== 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=Lq7kRWDy/JaP69JbRtRp7VUtMeb++6kHnahDgE9Gb+s=; b=yVQ0IEDa1c2wt1248cjptMsTF7Rw+vjLFXFsKpL75cow7ddEsh+XSA2phTcsAVZWkt6f7TkAp5skfLAxMBcvf5giwQu4rok7GNPSyWCNiMoIO/fmrucC9bwid3D4MINfjFDLLl3j9IRTX0DcUOlQt4TtQ9Z67X2aj1s+RlUUxLU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26: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.7897.014; Thu, 22 Aug 2024 19:26:43 +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" Subject: [PATCH v7 18/21] ipc/shm, mm: Drop do_vma_munmap() Date: Thu, 22 Aug 2024 15:25:40 -0400 Message-ID: <20240822192543.3359552-19-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0017.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d1::28) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 912e77fb-540c-4d1d-99fa-08dcc2e05aee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: Jk93jM7BbsHqigYiyMUBREvP2TNhUYzVLD3hN+6xM7hLpqDsr2IzEjJEbN1L3aTEPsVvuDlUF7Ahi99y2dooPpDq7+CpLf3Lm4JxnVRDKhojIFCOjAR+s+v0j2NA+DwQ0DFLaTQKFiGUGt6ge6bT/dQKAx5EJGd77GvqT/9FfsbVFufz3QMqvLLaMqkgoLbi4L05yYwUs9WRUZTEtyE1q9vWuhGN/aJ+efPo0Tgod0rPqO8217i7gznvvZLhbx5ivsMnWvpW05cOkmgHbnc+pstCebpe2OqyM3BNIQBk7O4rSycEGjRTsLEWJRDwcoNxaz/nCvBSQiDlUrczfcHkjsPHy776VOanr6g5QBPpvn1NaFhz2bEB0rhB7KPjXdsCqTuVrPSeFrUSzYX+VJgMzgjiyZS1O52q8WamTR06kffpGfj5QZWjWqm8kZvgc8LVzFwkbpRsnnEocQhtbKCDO55X8i90KsctBUVCWENaTWJdDiBNnie+Mh2Vb7xrUX0dxG6juj2JyGAyBZKnLa0HNFVm43Ew19/KfrDJce+NfqmYEEbM1RB+ufMnn5V+/foSmAZfCZeUQGUbJ6SGxzf1/Byv0iIqfy43C6kpGclxQmcxj3EjlU6gihuginy141s2wwmb1bzGdXjlzoqSsFAIexf3mAh207/bGBrQPq3BjaTqe3y1seE6bb+1wqD/ty8CVXvhL8+EmCwEr+pGA3V4wQeGBnbldhtgP64dzWqiLwJL9FRM5UAlAKfw8UQqaUCBVgx6/1y4TtwM1d64F9aLflTtSwlZklXsqyD6WRu4DGwOMEqgwNapj7pWA/gh595ZFt1hu9KyvcO+mg0OcM1wGrEy3+qcsmAxvfRm5n/cWnKcJQLcEC85Aa9/i6J6dtsZuLakwPnU3LKcQ0szfjXBiOsRGmbxGfEp+HOoc1OON5DPmqMwCykZcaH40Q4vw9AphsRLXlRZrsoXCP+rG/sQXc8OW1vAzF0jJiOiOs8UKCuLfjWz7fRrJ2kKUoRNYRkVrebJE+iKH5oZRJYAAKrSVkP9YUcIxkWrBBM73lPQzmtGbKAvaj5FPCDUz9NKo19tc8pk3FOvFftm3x9+T9ndRWi7DoQjCBXnUJn0DGQJElbZXKvsJ6rZrrqdx7n+ZZ5WLu71kRpGclMNBKE0SQmgIqWAeeG1atYW7DZdnYCaSiyI6gV5hjOA4nnGIqoLXLMVNiaeybwFu/GxGcVajnPoG5XEnOuVeK18bc6dOF3j8+m35bFkWzFNyc+kqGMyhq1NPQUPxuwV2BkHWPmBJnIFIvJJn1ca+LCA0nFhcAFRBI3XgtkGKa6Rds2OxMb1MldohguUOqktvexNSnzU4Iei2Q== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kynkB7Ree5EiqR/nCqaSEiv//0jODJS1MvLXBUFBXB9NODsbctMGF42XDH1pIjnuGW5THlWwmAyPUrfONlfW34zeC7ZuOcQElXRsuqBCe2gM96sjY1whX8zrPk0dc5/zkad5xxqHFu3hTCmqlK5mv49P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OV99eM7CjuLrLugOfPSOY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 912e77fb-540c-4d1d-99fa-08dcc2e05aee X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:43.5711 (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: /3ifNBehNGlnfbd9s3Y4W5JgQIqLdc5TsoQUm4lqdBWNc6NZ+rAFH98+tOhlxXX/dhsvQqijpZbN2bSySbSL3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: Heg3FD0VzmWVWVKfoCUx9ddUPeAg4YOd X-Proofpoint-GUID: Heg3FD0VzmWVWVKfoCUx9ddUPeAg4YOd X-Stat-Signature: bzfgomg6141sohxwiaoggwdqa5k18huf X-Rspam-User: X-Rspamd-Queue-Id: 94058C0018 X-Rspamd-Server: rspam02 X-HE-Tag: 1724354820-58885 X-HE-Meta: U2FsdGVkX18sZlZ5PlCb6kXx7jWIH/5DfDkbd8hs7Q3yL/IkVwrIEg/N0qaD0pSTFaFtimKctdfJyivn2+FBn8wNKPmlaP8DxWqtEz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FdFsVgZ1mFfBXEsU8lQPfrW474/371qcXNdHJVPhfUJOzln8I83Djge63Y/wFScOrH7W7lfVNjPZ7KXRl6Q/hw2M49ysnnOP1YYZ4v308LUdpDfOQeV6YEQb4gg6dJIEaVpvR4vQrxiDN4Lw2NpuLi95XTIosES+KuFAY01aUaudeS+Za8Usq544DyutZI08whwyWAnayV2lBYvl0on2jXYcB5Z+SZeWdIOO2d3K1S6SbGcqmWEJM9efzgY+OVcgaBQt5foaEA9TbmTB/E6k268ekw6/c6PhBb4Fnl3Ao0LWn4oZcgREm8zokPq/Mo= 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 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 ++++++--------------------------- mm/vma.c | 12 ++++++------ mm/vma.h | 4 +--- 5 files changed, 20 insertions(+), 43 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index b1eed30fdc06..6f1835e3b430 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3292,14 +3292,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); +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 aa4aa49f3b97..51ab0bdb856c 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -169,11 +169,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; @@ -1478,9 +1479,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vma->vm_file = get_file(file); /* * call_mmap() may map PTE, so ensure there are no existing PTEs - * call the vm_ops close function if one exists. + * and call the vm_ops close function if one exists. */ - vms_clean_up_area(&vms, &mas_detach, true); + vms_clean_up_area(&vms, &mas_detach); error = call_mmap(file, vma); if (error) goto unmap_and_free_vma; @@ -1742,28 +1743,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) -{ - return do_vmi_align_munmap(vmi, vma, vma->vm_mm, start, end, uf, unlock); -} - /* * do_brk_flags() - Increase the brk vma if the flags match. * @vmi: The vma iterator diff --git a/mm/vma.c b/mm/vma.c index 8dc60dcb6e8d..91b027eb9a38 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -658,8 +658,8 @@ static inline void vms_clear_ptes(struct vma_munmap_struct *vms, */ mas_set(mas_detach, 1); lru_add_drain(); - tlb_gather_mmu(&tlb, vms->mm); - update_hiwater_rss(vms->mm); + tlb_gather_mmu(&tlb, vms->vma->vm_mm); + update_hiwater_rss(vms->vma->vm_mm); unmap_vmas(&tlb, mas_detach, vms->vma, vms->start, vms->end, vms->vma_count, mm_wr_locked); @@ -672,14 +672,14 @@ static inline void vms_clear_ptes(struct vma_munmap_struct *vms, } void vms_clean_up_area(struct vma_munmap_struct *vms, - struct ma_state *mas_detach, bool mm_wr_locked) + struct ma_state *mas_detach) { struct vm_area_struct *vma; if (!vms->nr_pages) return; - vms_clear_ptes(vms, mas_detach, mm_wr_locked); + vms_clear_ptes(vms, mas_detach, true); mas_set(mas_detach, 0); mas_for_each(mas_detach, vma, ULONG_MAX) if (vma->vm_ops && vma->vm_ops->close) @@ -702,7 +702,7 @@ void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct vm_area_struct *vma; struct mm_struct *mm; - mm = vms->mm; + mm = current->mm; mm->map_count -= vms->vma_count; mm->locked_vm -= vms->locked_vm; if (vms->unlock) @@ -770,7 +770,7 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, * its limit temporarily, to help free resources as expected. */ if (vms->end < vms->vma->vm_end && - vms->mm->map_count >= sysctl_max_map_count) + vms->vma->vm_mm->map_count >= sysctl_max_map_count) goto map_count_exceeded; /* Don't bother splitting the VMA if we can't unmap it anyway */ diff --git a/mm/vma.h b/mm/vma.h index f710812482a1..8ca32d7cb846 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -31,7 +31,6 @@ struct unlink_vma_file_batch { */ 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 */ @@ -113,7 +112,6 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, unsigned long start, unsigned long end, struct list_head *uf, bool unlock) { - vms->mm = current->mm; vms->vmi = vmi; vms->vma = vma; if (vma) { @@ -140,7 +138,7 @@ void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach); void vms_clean_up_area(struct vma_munmap_struct *vms, - struct ma_state *mas_detach, bool mm_wr_locked); + struct ma_state *mas_detach); /* * reattach_vmas() - Undo any munmap work and free resources From patchwork Thu Aug 22 19:25:41 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: 13774126 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 44E5DC52D7C for ; Thu, 22 Aug 2024 19:27:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 928118005B; Thu, 22 Aug 2024 15:27:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D5648005A; Thu, 22 Aug 2024 15:27:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68DD48005B; Thu, 22 Aug 2024 15:27:06 -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 2B5708005A for ; Thu, 22 Aug 2024 15:27:06 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D1DCF1C5759 for ; Thu, 22 Aug 2024 19:27:05 +0000 (UTC) X-FDA: 82480864410.07.6F03D4C Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 8F831C000B for ; Thu, 22 Aug 2024 19:27:02 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ZYpnxnYt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=J7xyziGl; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf28.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354756; a=rsa-sha256; cv=pass; b=6FEIK6HcsP0nT6df/ZzaguGV9vZ6Lo1Yzd5ycrNlpQbt9BInZHC0/y8QVVJOmHc9F3RiZ5 lpiAZJ30WMQz72KCkBkXMFm+buis6SmpT8G7VEWmYHe2J6Z1c8cwNrzyS5V17Tj2UEtw97 B662ytxd3OnCqjw/Y3k7v/C7lmNO5kk= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ZYpnxnYt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=J7xyziGl; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf28.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.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=1724354756; 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=2k8vIZw4lxINxvd4XX+iaMyXmk11DEGFPw6/UBf8xuY=; b=aJx99tOpajVuVubQs7yPO3vhRBdY0nRGWkoKOhppeSDR75w/fnYRKVQ83LFKnYpzXN7FjG inBGq+aakfrO0wlOHT9Z5O261O8YK8behKN3IQiwIyL33TmcuSwpmbLhXz0tgjhe2BINl0 htBYVbKBCtKtCzfgoNcEU6tEdizZmvw= 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 47MIMr1d026289; Thu, 22 Aug 2024 19:26: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=2k8vIZw4lxINxvd4XX+iaMyXmk11DEGFPw6/UBf8xuY=; b= ZYpnxnYtusDbMOdnGVMe7Snaz2B9kKhh5L19BADADm7oLcJ70U+ec4dBesFWoYQs l+yP8qqC2mAlSufmkTeZ76fuLhahqFfxVDTEXQBdGnuZ5B64B7HcvNjAGCxVBKnj A3KuNiD/BNRHC38ix001YQb+DLEQJHwUOUDKHG5ZDKbOEjycFOyU5GCOaVzi1k41 azw55clO/N0plQCAmGRc1jrUdEo5xmG+sttZmBNN1Gk+3NzWLZjrzWyEgA3jG2rd RctsVUzLo1xeGKaY0cYbAsk97EUmC5wrX0K/9aJfRfXG3b6mOGCX3T8R+X4jjhsg CAtVkupmsPFCyK7xPUpUTQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m2djxyf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:53 +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 47MJJOnV005646; Thu, 22 Aug 2024 19:26:52 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu08bq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GtS2lWwHosv5dqqVd4A2hDdHrPolpnfql7vF5Cd/IpDn0u/N3wNiWYi6AaefurhscMv7dm5M75zftcWP1vwJvFst0peuvXzuT+eVPFyqwKxp3tH8EZAV6yjQQiW/0vH8vpWLCEKJ+tIUpVSL83Kai05d3pa9otXPzhSR1rWVmTixZBidulxvbL21bXz6zJq9LJgqyX1Ve8WZm52ziNf22SKyZThVkYnYTe8znRzQtozQgWM1CSFjA+GnJQPKatf4aZt8MwrxNdHkVIjcjNPMkNWhuGq4fS0nK1kIDU8QBYsajOmpDx5r25FMIXy6KYyceqhRcdqGhTyaHnAhs0plLg== 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=2k8vIZw4lxINxvd4XX+iaMyXmk11DEGFPw6/UBf8xuY=; b=o6PdJhZH5k6il1QlEP4QdhXbxz1V9noi893PRs2PkhsdNzSUPZSNajO3yyvy7SWtD9My6soVQV+4QVMnwFAx3+kmGydZMIZs5S3T08toR5G61D6ZHRydywioGgshs6ZGREsP2JBS0vhr26TJX0xDVZG2c7CieKWrgBBOY8nE/bpwdQYlRwKxhBq2G67Rfe4sMMkoK959jyVIqlVUDwhcFQGqIcU5UIVV/a17TN+7IahuS+BuNAmnkCrvWE7mRU7JJr1hqhNK+/mqdfbGuINYwKbBm67ocJg79EF2ItvbHcpE/z9W+vkOyXDXUMvw6YmG1JiLbmk1osDRCHeASFBAJg== 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=2k8vIZw4lxINxvd4XX+iaMyXmk11DEGFPw6/UBf8xuY=; b=J7xyziGlt9qpmWf9AAJWX6I1CT94S09siIIhnjLM8P0vGYmr66D2BBd9PSXTa5Iuc46/wZStM8zdYXhS5XiUANqFgYZXoFQJh06LO1nw3TK6P64UJxKBMxekmIbTqCiH5D/D+kRs7xbRSLNTUKPBqo1BnRU1JQrLnG3q7snideU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:46 +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.014; Thu, 22 Aug 2024 19:26:46 +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" Subject: [PATCH v7 19/21] mm: Move may_expand_vm() check in mmap_region() Date: Thu, 22 Aug 2024 15:25:41 -0400 Message-ID: <20240822192543.3359552-20-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0007.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d1::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_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 46e1499d-837b-4ddd-b9b2-08dcc2e05c33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: OBXVGMw08qUaPiIxfCQ+DNAlV3xXbKEdLnQWzANLbcag9U4DqieD/lfKRm1BirmPAyHMQBTkRQOi+PqlGl28dJd0MfixuuW/SMwTHLwR4TGZO+GSzikx230Yj+7CF/9uh3zUDjPbgHgFcQbNpZCIasLSXINS7bzPNRps4/q1ZTAkHad8E2mzIbskJXydikg3aGoJFlXpARh4efBAapg6iXpg+E80SBXTVxyYkH9XTQCGr7Co1Vom6+msX3Gpto80+wjgEeIH9pJmYagTE1ihaoHyq10taVcvg6fC0AxIIhpoY6B+1Q4EJCu7xk9yYzSLCy/fG1omaDx8G9XqB7EF2+9mAdjSinr3GJyKiCFfQ6Y+bf+RS3ansz4F3Ty74MxsdD99VOluAOHgWklGPdDrP8bdDaV+7G5x3HiYbsYdP6pP+6V0S4gbNzJ/nrCaIvlxtcc/QprUq4Ri74rlMOtDBDyRkSq7MXcsb1CD6b8Lk25jWvlt40MOVigxhYp8lXBT7FeOUFPLuX2or8tQCeqkQcg4qEinyZkmp+nmSltBc4LpSI08fS/GQ090GSMSqLt5iVu/tWOt4ggDSbWq4LE1jpMJXXQs/dSD3clpy4G+1dY9F/vIbrHEKqTBXRXV3xHcNZQZTjNz4nm1oXjfn0xPfJQvyCWd6VBGN8dVwfdQ8vkPu4rkpf+e6k1RKSHqszigk2MuurjOgffqLZe8IDyQeIjH8GjWypftKRYPOR3UaggDlZR5dRs/tFr/jhisvG2Ie0WZcSrVJz5dzZwtbrglUkmZACVXV5KhkynC7BlnQKfohdcKjZMA292t9uCUhlR6Ma1tlqdKKAN/0PoIHTrRuMp4MeDsInACKjOkggZ7JdVbLJMmdBNWUYUZ9cexXNjF48elqwpu3YdZnoSPkcilT0GLOVH8vzh/kgXIn63hn4+5mn1SHYZ7esUvX2Emozb0m3xaT1kGShPlx+CavqM+51z/Z2wYY2fpPDtcFWNZ08LonkVmQdAJrjyc/a81bXP9ntHVTbXp3YoDf77X92tFMGZON/k/nDqDXlb4mCYz6I4fjYaeapsnHUC9GTLgfpY8IEjVc11+cc3tZBllG5mayxQD5E3bk/NZaYyAAy3Qywm8N48dugSkMtkVUjw9D+1Wz2gd/M9Y++JE6iZUhU78AR5TqE6ZbW4HWS16DQPE/IxRCRU6/p9N9FSbpwVdknVhdWvNKAFzovQF7IHuGHoEyNmN1kgDEYwnnZa5K42niRkYfgf5atV09IIchK/ZMSzUqCnKJQu2gJaIqTvXoy/W3Nk1wfEGtw/cxuZb8kUMnIIp0/D/3Woqx9j4B2mktc1AFwfJ6Kw7dA+9ga/ViXW9dw== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3eizxDnOYYoppcNG/vBrFopCEGNd/L+jm8c4squqFVC/2GkXfe+YhqNHPHOkWcWMIYTXIit7WM4Uw6kwd2ayG9bUr2ZmcDKZNdCaYRFduXAtXxmmc2Xb81+vF64TuU3S6QdnwlpTTnIyIAmrhKLG9S8f5JZp1DM+MZLxHawFKtvm9APS3i86oY/LFYcKgM8HKtRPqKaUqiVXhN2R7qaByTE5e6MC/Wy7qE583rLNdD9QwH2ULRqzGppN+L85N1Wh6+HyDSEyRhGgAgZ4+wtrdA3JtB8BVYOrfuYk47hwHu7iWFnpGzxFehaV/q4oCPKqlzHOXJiyQpJt6HJIGtPPaj6/omR8zhge3suBF4Ndp3Fpsqi8Tt3AjKswiBsQXxrct5FCx7t+Jn+2sX1JaNXc/d4NkCorn8rW//Mo+T9ACQaZh4xTshWs12Hj8nNTdpcQf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zWwEzPWyN2KKsoYVZNPCDo05SpHvneb2whSF/8SdBFAn8OAHHxb6Q/VaWAl8nFQLYD4/aUtxpIk4hGYW1mDkJTDfLNw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rhYRglO58dxL1klGcV8VQ1YywnOXgjrCt9Ar0Q92QkAafePBgxIySWrWy0C0YkHCQ6dS8C645NARlsLZP3cgKi2Ki2vW0ENVxERmP9Iz0hh4KeKdKUhmJnUB8iOGZHXU4+SbXXD3axAVfvw7/8mvWfNH3482S517g1VcR7aQJN+IYSJ9KbTqvgXo6EpOwndP5zJtSNk6E1xxv7cEMFoRHMLBQ2yH+UMM/znt8F8PQ+5gW2k7t+lSQSOV32iDiLRQ2C3Kz8rWF22FpTTqA9A93hx4G2qm+/vySV3SESP4zw/c5YtBObQ0BBPZXFV9oy/urtS/I0EN9P9a2MCydlni5JKFEPa1JPdBDCFxxwaAZUZZxgAoyRDC5RN9XodcVzjRF82dDSun91PyhpNndkbntF1MP7p9r2VtNNZPal64oY1w3AJ6GYWXHoNAy1p9/rO11HvJoJSRSQlKbBhRhIyMexZ/7pBWV2F+20PYWej/yimwAHmLarXioQ8RKYIwsAHDYBnja+3gSQADITB8fq6RdkmJtOZm1mQtvMzb1Zedt6xCBHxTQT+4/H0pY75LufkSTuI3WIgz1MZKlbwjzp6AMtn2mU/ETC3/ncMLURxsq/E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46e1499d-837b-4ddd-b9b2-08dcc2e05c33 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:45.6245 (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: uw+L5/rREj/iQcg90wvYm4ZOEEY62aUYOtYjitVZQsgfEMM2A3Aho3UsudAVkfn5PH6XIIxfJq4U6FpNEgFK9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=878 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-GUID: rE9GjZmo35itfnvAhGFVqcBnA_aCbUwk X-Proofpoint-ORIG-GUID: rE9GjZmo35itfnvAhGFVqcBnA_aCbUwk X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8F831C000B X-Stat-Signature: eonpudif3b41nm9c7hw5waypwnndc5i3 X-Rspam-User: X-HE-Tag: 1724354822-239708 X-HE-Meta: U2FsdGVkX1/J/Z9SgRQabIEEQncvV6PYDZOicCd7Agaq8Z7DCIuWX49zNVoJgF907BUeN5TFO/dv9DJYZQ+MdbWf40faTtvlfnVqUMc9w1AzhhboMVhDAMy/UIXGX5quiDf0EzHGKJgaipzU4mcjMEHwGOUy+Se/VNCOJwUz5ZUJMacm0SNMJOjfbQXquPY6ihwNfLECmaFIXjgTs4AH0DH6yDTRVZioYIs860w+GDi+qIYg3bRRPH0P5MPogPyc0HgBFYpbfc0fek3r6JAX2W+iMTvqeQJ9ulKzM/xFtrjl2emFNc7CHt0NNoNwtpUHAH9k7ubsGjrNExM2LtCuXB4hAvlXPSUK/JRUEEi7DgF8/adSjEaj+KqlyDSFjvOw1Jc282ORCizqhV0896FlOvCiC5CTvT9tIpt8G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wEC+r69/KqUOSj/d5ZdDOAW0iaXhgPwDTIvYZh4sC/sVf+3LOzU= 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 ma_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 | 15 ++++----------- mm/vma.c | 21 --------------------- mm/vma.h | 3 --- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 51ab0bdb856c..5937607f6949 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1376,17 +1376,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 */ vma = vma_find(&vmi, end); @@ -1409,6 +1398,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 */ diff --git a/mm/vma.c b/mm/vma.c index 91b027eb9a38..61d51677eaaf 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -1645,27 +1645,6 @@ bool vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot) return vma_fs_can_writeback(vma); } -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 DEFINE_MUTEX(mm_all_locks_mutex); static void vm_lock_anon_vma(struct mm_struct *mm, struct anon_vma *anon_vma) diff --git a/mm/vma.h b/mm/vma.h index 8ca32d7cb846..7047fedce459 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -315,9 +315,6 @@ bool vma_wants_writenotify(struct vm_area_struct *vma, pgprot_t vm_page_prot); int mm_take_all_locks(struct mm_struct *mm); void mm_drop_all_locks(struct mm_struct *mm); -unsigned long count_vma_pages_range(struct mm_struct *mm, - unsigned long addr, unsigned long end, - unsigned long *nr_accounted); static inline bool vma_wants_manual_pte_write_upgrade(struct vm_area_struct *vma) { From patchwork Thu Aug 22 19:25:42 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: 13774123 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 18350C3DA4A for ; Thu, 22 Aug 2024 19:27:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30DE08004F; Thu, 22 Aug 2024 15:27:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C7B480057; Thu, 22 Aug 2024 15:27:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2D298004F; Thu, 22 Aug 2024 15:27:04 -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 B06FD80057 for ; Thu, 22 Aug 2024 15:27:04 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7618D81916 for ; Thu, 22 Aug 2024 19:27:04 +0000 (UTC) X-FDA: 82480864368.09.A940FBD Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf05.hostedemail.com (Postfix) with ESMTP id 1C757100015 for ; Thu, 22 Aug 2024 19:27:00 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=h3wPgmnh; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=p6xB+NzT; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@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=1724354730; 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=XvkWhZ3Ci2y0PBk1VQBRW3jFIo7qKLe3EqSRA7vVjkY=; b=GlkGZUiRKjMVZpvEi7WV5OFiMwChbK88oujz6gPlruHM+jnQyE3ZK0pep+GvBAu4UWVG9U HiPGP8S1ja41P7EvAuN5i2ugWX8sClOk3HeHq30l5t04Swh40CRqcx+Q/5V851I8PiIhmH 5nHXK5hrCCV5817fnjWYd2/lmmZelJw= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354730; a=rsa-sha256; cv=pass; b=psJSPmj+RZ0S5nhygUNGmt2ojCqylj/WT2unw6e/clM54mjo5ahCht1lhGQZNLzRcoh9/U bKjyHZFiRf3h+UQ9H4T+ijqDfCe5jQ78lBLeCT9PTltu96uOTvzJZXZ+HXhb6YTgOvAER5 vGZPgZeKCDpGoOKcMG5kR3qkBKCdN5M= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=h3wPgmnh; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=p6xB+NzT; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf05.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") 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 47MIMXpp026397; Thu, 22 Aug 2024 19:26: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=XvkWhZ3Ci2y0PBk1VQBRW3jFIo7qKLe3EqSRA7vVjkY=; b= h3wPgmnhYpqvv2I3MRo/8HL2TcuGwCQ4xCW8ASM3OEiLRVVxH0KMnqGjbk77JeZq fTVa6rO14UXX7HUjcW4MAmvraA0vKH5H18OiM9gLnaZzWPpCmwuk69yMfBY9XVPk vxHvn3O+4wLMEH2s4+JDJMI3+GEQ4GA1lnFBT3cuokLbhthDNAam8YyBWppjByuv wL+febQJW1RTd6+ImnpOlBmZJk9uIptsFvIU8IJtE/pArVoboX4Hs3XSnudgvfnO e3M/X3H8zJHnTzvuSxQxkizQjgQ7dpzIIEGmCUHHKFV4B6bbYGVHEqJxOxnIhg9i 3KbNV/zZ+KsBNkjmDmGBfg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4v2wae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:53 +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 47MJJOnW005646; Thu, 22 Aug 2024 19:26:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu08bq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZuK+A1jjEVC1ZEo8ps8rQOtRapu6G3DVhkiJMbJPyZsNme5BAetys7anlH9NJtySQYwS1Bn/UgCBxzykZLIa0z1sSv1vyvIPD+UgenqalkdnLcWUp4Pif4EW8ASk4+sXyrTiQPekt2BR36l+7K++OAzEKYn6YtyWJyyxdHGFAiql+JfHQY97RLIhbGd5lDpaKy+FwsCJu757haAh05LmMMemeg9IfyHxDp+bJWl3hp1lgwHJchnwXgblHqEmQGXjvs7afmabiXEefoJhmESTayAg/WIg6mGdE3x3g0QmXF8oQZEK/9J1W6QRyXrlkMDJ/JzIW/OGbbLmO1cc3qj5tw== 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=XvkWhZ3Ci2y0PBk1VQBRW3jFIo7qKLe3EqSRA7vVjkY=; b=WEQbwQ4an2bVEgNdgRoZwVWI3ysFQ8OFd2juciDLcjXUp3A2l/j8u9OKmcMx5ZZHLJPQIH8e9MCybAwyvBiqHs0lsKNmjIJ/mOxr8DnpOEL1hMZgPHBtndC48JcTsV0YDo9e5/SfquckFYwCcZntOqHm0ilW+gLmn0cWGTknlv/93eith91OV1sEA0Qdo/6wabuPgDnmez8K2QavlZ3aGSUcxAgsjCfx8oezHlEJgxzotkuZUEAO9ZvzV+VG79DENqcQR/3w1ODaN6QZE7IdAsvaazqfHI2ruJiBOOUYaeJAftA8SlRRQLGCE8VihY6eZHL8obH6NTpU6vXzuqzQ7A== 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=XvkWhZ3Ci2y0PBk1VQBRW3jFIo7qKLe3EqSRA7vVjkY=; b=p6xB+NzT11868sh2srf1IGUx2gskvDrDvCISCzAuFsw3vHYD+z4Pn76EsJOUvN6a1xHN4IP0FpFiMHJUFsNrtCDTUZOMxM4t5Ing76qsbYTTJfNEB7DkkO47fif9dn827jwf2WTb+yYzf53qxOcKe8ZsWmHG/CBvXJ8Ugmga4ME= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:47 +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.014; Thu, 22 Aug 2024 19:26:47 +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" Subject: [PATCH v7 20/21] mm/vma: Drop incorrect comment from vms_gather_munmap_vmas() Date: Thu, 22 Aug 2024 15:25:42 -0400 Message-ID: <20240822192543.3359552-21-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0113.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:85::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_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: d58c1627-1fe7-40fe-a2db-08dcc2e05d24 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: XsuE6mpobJfU7ReJ5/FqxnzVCXvNdTDqAujXlIVC/t61LcEnkIXQ4rtPsya/PdFUp5wDe/LQ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r/jP5YC7xgEowR7nBw/EQDbGRT5z+TkOuDWDJkOfe3DASRW9hHhuXn2sjacs1vpSnpxyAQsOPyn+wIaue0AsD9bOElLpUiT/wUZOghnF7xaE0gKgS7/zpLtnlwTNfKp/3idtxoi3IxIkDN5oiu+WWHkZRt4luWVEajeejNg8gNJ7Lp8m+H2888j0HQO1mHcBPc+UbYHybuIXbqOZa9RhEGko8DLA== 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)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: naQEV/gr5plRHl0FmA58j9IVqL5e492vKqfNeX7qCirMA9JZhXmHUwDGEvaQ2q3dMhSqaMvHfmGH/YgnYvh/OvPNezzM95q/guJsMGQzennQmFr3gMXnzoEcfMRMVhKB7P+dDycnxZuGivDKTHDCmFMlk+m/ELtiyzPsorP5PK1avZkFGGsrwHYak7+Pn2rowjAy7TDh6zOySHs3JoXYPrV/8g24NgeJEWbINckNq54ZHgecB4g4lN6Q8WxJdx3HI8z5YsvfcNtNBVboyWvZtydccAebXxvAtomRZsbRY2szS3IeK6qtgvy21cHOz1G15zyImsLMIfXU21R0gueHJ1h1YjAovW+y9ilH4q3/7ohJcYrm1Nlnbn1mlre+sjIb0Z4ZS4rJk1uU4ROaEySTIunLAr34RY9wrrRY3yg/ZumrtbJeWZrUzWT/uX6la7psdGeSxH1HsOc5fIN9rgwNN4KG0CQ2Y/i2O7VhWRvDPAdAER++9PdgTUChXGiBHqshjyVN0wxC6CEwMB4IrHW23eyTGn2R8Ej3imDEcXYXzZ1hYEF/23FYLTljW+um8g4iSRdGRRneGoKtFgvGf2JXPyy+2jhMnr/+pYooV+aHkVtLJSsBjrCtiWCzdnp0GdGs4iLV63YSZ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e573ww9JmI+jyEeOODYio5H9+YEfqIARFt1VNcsCnmYUwjoSvUNv5EzURhKT+j3snV47y1+Ia6hSVi1BUj7UhQ1S+WNgRorW2hHLJx/C1B8ye0H/OZfuaYAAsRkUk1mnC+LUN98vag8TDdt1ODhBvcZfkkA512r1updAojoMaDCkNYvw51ko43tMOM5SdyYmD71TmcAd/OCFU8FMv7EmZlTEUBuvcELxZ/7qm1bOyWUZ/7mTr4Ekpgv86qUardBRVT9yub0H49ieI0PLWT8eKzAIcc9t5f3wllkCGTagWtD3nllHIVJkJG1Dr+dWsjv1ynNlo25/q36wJhNcJaq8KQ+CRjurjS3zPVNZu97JfaSBtJRnV0xkzj4B+EkQafBJdWB4lj6ExlroNUNpcATTN+HFln9A4GJjnAncz8JNPgX7wtezgtVXdwRO7UoFgFoCh//6HUJLpcPjelW0LKQlX98qGsJWEgO+iHoCFuBI0H9boiCl+SRcm7w4c6uVUll6Ct43zE2pYYbNoKafPKtOaoEXUkEdkoEjuZyDj1Kgmm/k0WXmDkAcG0j4EqOL10H6WB0HTqowEfptQLQc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d58c1627-1fe7-40fe-a2db-08dcc2e05d24 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:47.2346 (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: GjYeX4GdnQTqSA5SDw4Wk315cgQxJnC4hY2s9ZgfMxm8Lyd+x6zJchtx02W2AuLWrNhD8Q9pobQOIMx7kIiodw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: HPylIhYx-W_f_VHHc4f9KI7XwUhkI9cI X-Proofpoint-GUID: HPylIhYx-W_f_VHHc4f9KI7XwUhkI9cI X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1C757100015 X-Stat-Signature: 9rf19g6x5ny31ajjtjeezp59xo56cgmh X-Rspam-User: X-HE-Tag: 1724354820-870904 X-HE-Meta: U2FsdGVkX19zlSFO/cy75XR/kgV+YnoeNjlH6gxkDAkRcMRFtrAEGkgt9ahjowZzRlkwbGgcodGQ6w9izTPdgOPcESuxThz+mc2IF5bSQsDMpow1n1vRzPaV9R/r82K/JO2o/i6LHjZhIEmUbDWeFLsa/OQQuJWSn71wtvcEjaopiYB93gu3A0kFzqOKzeC/H0dZNX3w66JpFgtnU8+qBplYkKqnHzClKxUCarEHWg0h3DnYfg8jKH0+vQ8lI/vRUpNnO0kanYIVUuAHCM4bn+cPKbZ4pQ4WNN4XOrQ0h0JX+UmrXN1nVA7ncMLzzpq+qaX3UPVbW9hBEMV5dIkIQDxdNcwevaA5YUdns1Op2q+tF1iU4tw0h404IzHCB+3XOgrKKE6j74tLmMJAOI3GFh4XuGGAw2tz2CAw+v/svvqR+FkcZp/3JgS0+aTx7UUi0320csLjEs/vRhywPiKXKu0rJu67hMxX1wO36YFOKivKiJSFYsf/B8QfRLW92YzQWmrVXXylMINv1S9KIjO26EsJHoFz0n8WkwByVb0L9o2Nzw5rnZZt0eG+8sjbLtt0gvAgYL7fESUYa7M/VNT41cLoYqcvXb96KRzhcUFZyAExWwb5+48J3pFLhOAZdQoGrEUm1T2lB33gOb2kt3MllK2wbBll01dZRggzTwNLyo2vJ226PXWKO0d5Bmac5EMxQ8CX4BpVRuZOiS9f0xljVmYOA7rADCH8DKhCEw/KnQrvraSxKz5K+oO4f0tbrJxh9/ew45WhoTt0W29qqxjM5N0/xQPsRUVH1hxkvkx9JrWDE5wTWuD0usBUTv2KrxWnUEV9StgP27nicwDnsWHelpRVfhqzCufuC8Z9c1Oi7DCCt5dCVKF+6LhclFCFGkYDJI3BKAfh8/nTRw4HQLUoPq+C+aSoTXiNxgeA9Q7qwRepnszjFZ45FEI4wWMe07WkDaCuEyXwSoIQzWxQdUY dnzDju0q R9YZ+Rb9gFFrJuY9zpX1e7TH2FXWSqOq/T+D0Cd4daGDrl2jnehamEfGW9wH9AUb3J2IHcBau9Rvs5Bp5fNISMWuKdxCF0olhoz/Nx6dmRCgTzS3H8VTf9yWE3T2FxI2B7sEYtoin1biyc3Hv3IL6B95ENEPRzhkSOgnDj2fmKTETPpg6QHxTk23aa8sRKLxVcFqQKVP1IHRBl09ew4GbK6NKalQ43k107XGR21uOuVewQdF5SbL3IXQ6TMqhiFBC9jCU6Ob4Dw4WjcGSkBjtVXdA31S0mZQW9Smmsly68QibMXMtF9hc/xGnN4VoXpbEJfpKWPft26MnDPyqftI5FAr0jqLdiJZkRkhRdVYjzLMfg5g3HWpFPzjoMil66Mt5rm6AGnQ2kBRZyxmKe9WeUOF/X33ppA2VDvoiqtjTAOMYv8WS5NrcoyPCSq8BQg+IxTxvHg3aBXRYbI/65XMjCNJTzNPbKFSaCITuCoTyrvOqKyI/2UJZwHMRW5MHwf0mxJth3sFPRGc27Sw0tGvl++KyzIAeicJWF8hfaQ9v2FXpY+8= 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/vma.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 61d51677eaaf..ca87d30cb185 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -755,13 +755,8 @@ 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) { /* From patchwork Thu Aug 22 19:25:43 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: 13774125 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 B0247C3DA4A for ; Thu, 22 Aug 2024 19:27:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 335F180057; Thu, 22 Aug 2024 15:27:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E2E68005B; Thu, 22 Aug 2024 15:27:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0720580057; Thu, 22 Aug 2024 15:27:06 -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 D66C58005A for ; Thu, 22 Aug 2024 15:27:05 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8E7A3141898 for ; Thu, 22 Aug 2024 19:27:05 +0000 (UTC) X-FDA: 82480864410.02.C03CE56 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf07.hostedemail.com (Postfix) with ESMTP id 250A240004 for ; Thu, 22 Aug 2024 19:27:01 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AUBtDl+n; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=A2pirFbv; spf=pass (imf07.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.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=1724354805; 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=IvG2WpdeI5OiqGGcNid8Tye85YyH/LiFaaeLo2szEDY=; b=VBVhakwKSUFmklhM9200GmpHN/UVkN9KfuBLS/tUO4ptiNVwGLrIEsGyZqZQ0DvMWUeakV IfgbLFu6BpKrOQ8emJPaAziZSHpWQm80cUMCYjM0NaXX4SAU7h5JLhpGMq8M8T/eUwzBh8 NuGRkXTo4ClIq81C1iRqz9VauOjD8mU= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AUBtDl+n; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=A2pirFbv; spf=pass (imf07.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.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=1724354805; a=rsa-sha256; cv=pass; b=MkjtK8rTMPcnZw24Dfkhd1gNHq0n+pXW/AsWAnhFBWwd7IwF25e5ohAth/L702qSmPj6pF b6f8qQ9wUp+su2Hu4rTra1oav86UC6Ji7hj9TwZPVJRLF2dZmQUkSV36fGrCWUrc6dbWFX /lO215uBb4GhDMbpkfvLW9vWck+0uMg= 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 47MIMVP3026316; Thu, 22 Aug 2024 19:26: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=IvG2WpdeI5OiqGGcNid8Tye85YyH/LiFaaeLo2szEDY=; b= AUBtDl+nWAWwEhybSpDl4S7j9Wbu/MBGEuywQE0pp1QTkX4n6XGU64q1n8UPbWDW j3+GIJ/1gqsnJolFfcbN5gHhyPAqXEVwdRnC405FHS034KzNbGldSx91UfX4Q8xm DWsZxQGmVfc37ZopE5aINSEHpTUfiCnUWpzXeeVOD4d4dMPhdUOlL6tjGlxX6Mzm w5Hqnu6ltWxOYEiUPKzKTM0G1BL96vV15RRsZIUsYrfXyiA78XFpQ5qf/nSM9SpY /V/Vh9CdZcL1udUmnHvvk+Ca78y9YpkWvyQ63uSToEcRMitGAa2uoDqtdknTAthi SN/HRyQI5mnPdBmk7XJyaQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4v2waf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:54 +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 47MJJOnX005646; Thu, 22 Aug 2024 19:26:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416bcu08bq-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YHGbQx7x5ax9Rakl7c43PBXX2MTdZGzZ5K1dcRHnVjcVyQTk2WmrOfqEgxGf5SURjGZNc6egARHcH98rS++qlw1XMFIwKkqDsdR3UIX2HAfmgBAz8r0W5GMRfiRClffK385KtAko3gZn+nnf5LKHNfDH5j1YEd7lGzLeGMPbZqVQkWhQoVZapbzXS1T6ERtuHZ8tYZTwGWx1SNt5gDd409X/9zWno05ngeF8e5lS6a1WYQsZA/FqW8znJrt8MQJ90CeIlim1wjejglZtTkUaXUVkAsXp9+QX8cfLtUbH8cUvH7HuJXLgtfxYd3bdZ6iPe4BsNj52lEn4Yd5YzzXsjw== 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=IvG2WpdeI5OiqGGcNid8Tye85YyH/LiFaaeLo2szEDY=; b=Jj6oL7uNxfwjwkNxGkq0aJqGdawyIMXef1bW6xtkmUejTgKkvXoXJn0Xj/ijSRT75Ot/ANoFAe+ypTHc9NOWp0H3ybaVf2rirzrSQo+0Tob085OGbN4fNcneNp3c7lMQp3KB7xK5gIQs1RkLZc2MvWxSHPmrILneQ8G2y/WQR0GzSz2rJSJ3kK7YozhhRugZep61gCi+dO/Mc4Ve3WPuHH1QwR8LFY+JGluzAhmmDwgskz5rQ7Z6vf+fcWEHmkv8283QU+Ma13iq8jQ/k0QV3BTH7zrObV0aty1S5IgA04gv7qAasAPgFJKrqfhUfbkdE+DhKQbGBoRB0c9tX4v7QA== 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=IvG2WpdeI5OiqGGcNid8Tye85YyH/LiFaaeLo2szEDY=; b=A2pirFbvmtoidQpCrtV7vW6r3qZZr2FoxZOi7ep1ITr9ILvVhl9TcGt09CZH1Y6f8hmrWA5E4EfefUCac2wBvmDf21fAL2YFrQjsJVug0BWUP12q7GxGK/FtQFGEKBkcIpebOzwWcuf3asAM1LOQ7Xb50RmRxKxJJ27f1LrFWcU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:51 +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.014; Thu, 22 Aug 2024 19:26:48 +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" Subject: [PATCH v7 21/21] mm/vma.h: Optimise vma_munmap_struct Date: Thu, 22 Aug 2024 15:25:43 -0400 Message-ID: <20240822192543.3359552-22-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0009.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d4::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_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: da18d156-3e84-49d6-1845-08dcc2e05e0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: BO/B3KMEOczcox1nqCUmH+QP2OQiW/NrFfy/9GJBFM42MzSo5WoNxVz7YgV2KXFk3TgiwXBRUhPyDxrHlgOW1F4dGmXqvWC9SnnNkX31zZNi9eS1h/ntpbaze9xsf/Q8belfcucrLhpCnyZDA1d4bC3Kxg1w4TdMfhCrQFblQSBZFbXQQFZxYtmvSdTLGrD0Lt8DLmS0BleflkYjhdxg6HVXRJfPPxn7qwvXem8nGS63HGfnkajuvP+4pLqT81DG9EtQ4CdJl3EMV7Mg7UpMPnkC2l1ZmIEVFWrr1OoBzX/xCUZe39AynTCoOAr/utXZGM/oNPHBivxn4fK0EZPg+Z+Vu0ASfwWewZ/EApijAquV4xuXujqupIMfcyzVRoe0L5YJRD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9X+i3devu3LO6R1JuFkAquSvQspRWlxyqRLdDR1dKg+SATorBUWTEypnOl65+OfzmUkM0y/aZAZMwFhKzFdXnjgiV1scKBFzxP0cY/bulQgIEswtP3wC4Zl/tTrfsBhIYe9pRNQ2wAhSxpW3VsbByhdbvUevOeMa0Uxk9X6UdmyQugf4qWnRgEW1ZYrGjRDE/Xj7NPM7BUX6zRbPN+s4ZRv1Pg/d9zd6nC5LVnqFs8ooPtHu6NqZPW7hqH4+jljpznBu0iU92srxbNKjeAVmcaNE5blFsPBO4OWNf3g= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: da18d156-3e84-49d6-1845-08dcc2e05e0b X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:48.7121 (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: Lb9kyWt/ku+l1zy0J7UoUnwPKm70khfSMLNjb2Y0PVxLK9dgr5BwSnxCYYoFHrs8abmAW/wOHJ/0KQRrpo5g6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 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-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: iE_tOlJvDGblwnownrLBgZo3KNfdEmuG X-Proofpoint-GUID: iE_tOlJvDGblwnownrLBgZo3KNfdEmuG X-Rspam-User: X-Stat-Signature: 5sxec95zn7wooq3amb9wtmpmub5i1bo1 X-Rspamd-Queue-Id: 250A240004 X-Rspamd-Server: rspam11 X-HE-Tag: 1724354821-879404 X-HE-Meta: U2FsdGVkX18shIISAqmwo88l5u/rqWGTKdJdMPowtaYMMUi9/OiHWd4dOCYypiUB/AEfJpgy0IiI6gRU5OB3i/CG713kYW2ONnkziFKJy1jUUo8D8l5fhaQ58bJH7cP66ignkd/drD6WvLmRSBllNOlQucAVeyRxOMPwwx/2Erl3uWVZPG5xJFsPR+5vS5FEY3AYb6uw4SykHJU34O0zQwU4zxKYj+ps62CtoIGzZkokyv0mz5Ev6cYKflA+MXSaxEtmtcY9dFUcjFozp1TabsVIkY69+pPUQrxp81mn8wabjFHZK9OGNKwMwghtYmeAGqYySQ+0kVMOPArcS5FX2FgkPjspnAS8jcONRnKYPcagSPi9iggo0kY2KSNqkF7YOROAseZ8Iy1izs+I1Fthyj0s14pQvM0qI6AXmKK3oEm2Lzd8Xne8AHSdTo9GC85JtS9yzptSmFn0sS9KZWC4QFHMxD6TTwOw4QhdRBlpeQSsSLAeQJKfiZ7ujWdl/IScPMWXRMl7Qmye8x2FEQRw3uOUqNK2T11TnGsFdwB2El8hBdUvf+n4+18gyaOFOp7M6s0bkCK09p2URPH1gBPp+AtsmGy9ei8GzHpwiO4ruF3ekIt/b138TLvg2ONPrwU3C0D2SBbcZ4EEjNErXqCtt7VY0SYyxn8TMuszRsbPbQi7mFr+LsZ8J9IuVf7bRZ9oH8IDAT3cQ55aSxGVM9f//yqb/5nbCxLp1pLBxl9uTLRJE0xF/oemx60HmanlmKaulwBiifa6nX3zx0EFzxpDvfIB9ClXhG42cSrtcmWLADU1uQW7nltIgthxfXTh5Dl1vkB/6Kzyh+036Afe//PjI70P13ieDnUIoN5+9b4t47uvAGA/2jg5p+b95iEKgBw3JlxvunLJGPwkBJTo+6yekGRPjOgXrZJe2ewP4/VCfnlksjdFryJy5/CqkGJL54YhCurgf78XLUAd18TLLCD gxCUNFZP qVhcMHSE4cPgk+fANjpbWFqbcLtX9h7fQMtik1PsIsbOF7q9sU4XxzRkz1GyhHOmACEd+xoqY0/L1/KmgYBxTvqLpjH8mOzHANYusfFBcDc11vAVMmcN4YJXKp/0tiMnuNmCYPPmu1EpsKyMsO3bxTkvY1bkwbTtjT6DlHz97LCpWd8uoplk6NikeBsnh6HqY+D40549H/sJOJ1BSWZfjrFgOVqIIvbXY6geY7Oirn+KZ3dvbXcXpA5BJApA0AmBEc2MNJX9akSTqUK5MB/KmtxwvlqcYQjwHo+CoN/+XjEVz7UtMZGtmMpWv58hS6VxIfeMhXv2QGv0F7QDOuzaSGZLsNsCjgW1hf4IZH0Kj4bSKxVzO9C7HRRIS3ght4fzDhJu9L8VVUEG/6m3+mU2OpXk3VuOOZvQxsPjLglURrgSzG1ImSex2aKjcg+izlF5J4WsAUMe4MynH6od6KGeK8b7TqMZJjSJlghUEikC1z7j9flovczq/tCuaPmruc6yR2l2DrAskcYMMIg8= 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 vma_munmap_struct has a hole of 4 bytes and pushes the struct to three cachelines. Relocating the three booleans upwards allows for the struct to only use two cachelines (as reported by pahole on amd64). Before: struct vma_munmap_struct { struct vma_iterator * vmi; /* 0 8 */ struct vm_area_struct * vma; /* 8 8 */ struct vm_area_struct * prev; /* 16 8 */ struct vm_area_struct * next; /* 24 8 */ struct list_head * uf; /* 32 8 */ long unsigned int start; /* 40 8 */ long unsigned int end; /* 48 8 */ long unsigned int unmap_start; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ long unsigned int unmap_end; /* 64 8 */ int vma_count; /* 72 4 */ /* XXX 4 bytes hole, try to pack */ long unsigned int nr_pages; /* 80 8 */ long unsigned int locked_vm; /* 88 8 */ long unsigned int nr_accounted; /* 96 8 */ long unsigned int exec_vm; /* 104 8 */ long unsigned int stack_vm; /* 112 8 */ long unsigned int data_vm; /* 120 8 */ /* --- cacheline 2 boundary (128 bytes) --- */ bool unlock; /* 128 1 */ bool clear_ptes; /* 129 1 */ bool closed_vm_ops; /* 130 1 */ /* size: 136, cachelines: 3, members: 19 */ /* sum members: 127, holes: 1, sum holes: 4 */ /* padding: 5 */ /* last cacheline: 8 bytes */ }; After: struct vma_munmap_struct { struct vma_iterator * vmi; /* 0 8 */ struct vm_area_struct * vma; /* 8 8 */ struct vm_area_struct * prev; /* 16 8 */ struct vm_area_struct * next; /* 24 8 */ struct list_head * uf; /* 32 8 */ long unsigned int start; /* 40 8 */ long unsigned int end; /* 48 8 */ long unsigned int unmap_start; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ long unsigned int unmap_end; /* 64 8 */ int vma_count; /* 72 4 */ bool unlock; /* 76 1 */ bool clear_ptes; /* 77 1 */ bool closed_vm_ops; /* 78 1 */ /* XXX 1 byte hole, try to pack */ long unsigned int nr_pages; /* 80 8 */ long unsigned int locked_vm; /* 88 8 */ long unsigned int nr_accounted; /* 96 8 */ long unsigned int exec_vm; /* 104 8 */ long unsigned int stack_vm; /* 112 8 */ long unsigned int data_vm; /* 120 8 */ /* size: 128, cachelines: 2, members: 19 */ /* sum members: 127, holes: 1, sum holes: 1 */ }; Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/vma.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/vma.h b/mm/vma.h index 7047fedce459..c774642697a0 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -40,15 +40,16 @@ struct vma_munmap_struct { unsigned long unmap_start; /* Unmap PTE start */ unsigned long unmap_end; /* Unmap PTE end */ int vma_count; /* Number of vmas that will be removed */ + bool unlock; /* Unlock after the munmap */ + bool clear_ptes; /* If there are outstanding PTE to be cleared */ + bool closed_vm_ops; /* call_mmap() was encountered, so vmas may be closed */ + /* 1 byte hole */ 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 */ - bool clear_ptes; /* If there are outstanding PTE to be cleared */ - bool closed_vm_ops; /* call_mmap() was encountered, so vmas may be closed */ }; #ifdef CONFIG_DEBUG_VM_MAPLE_TREE