From patchwork Tue Aug 20 23:57:10 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: 13770661 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 48A51C5321D for ; Tue, 20 Aug 2024 23:58:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0DCC6B0083; Tue, 20 Aug 2024 19:58:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C20BB6B0085; Tue, 20 Aug 2024 19:58:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9630A6B0089; Tue, 20 Aug 2024 19:58: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 773676B0083 for ; Tue, 20 Aug 2024 19:58:07 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 324F71C3ABD for ; Tue, 20 Aug 2024 23:58:07 +0000 (UTC) X-FDA: 82474289814.03.F93A1B6 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf13.hostedemail.com (Postfix) with ESMTP id BAB4420014 for ; Tue, 20 Aug 2024 23:58:03 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Me6zM/ZP"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=lUAxqbuI; spf=pass (imf13.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=1724198178; 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=3Yqk3S2hEddldm6CFLJnnZQrsowOiWhdMQbQfpg8BiOxQSFQJ3nTQ81N8QHG8o9vbR2sIt Do+RETHV1p5iif61NoCRypoWRmgIn5blviGZy98sRKWZZAd+og6sztwaUpCe/O25HGRJpQ RlM81KSqZgsO6sqFpPxIMUe05VFCZqU= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Me6zM/ZP"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=lUAxqbuI; spf=pass (imf13.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=1724198178; a=rsa-sha256; cv=pass; b=F9jZMYKldd+uuYvVoux6FChHBfVjZK4Mfdwcwc4/DPJcBPV/5vIZlKJJZBcBVA7pwGX4b0 eancO4qg/L14WXV07VuQBtTyQMSLtru8/oFpt9mvJYVtdDycp/AX776a1VxfakLh7YYwqf FAIWJXg1nP9wwy3Z0k2IIQ9UnjSyiQA= 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 47KMBboa017802; Tue, 20 Aug 2024 23:57:57 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= Me6zM/ZPC9I/tL3gi7hWIGQM8VfKqlxm6I7DsMR7gBNk9k8tloSDLVJEc+YOWJzM mXgjBYSSVJIwnG8vky+M8LvlBPSdCk/mjU6PnIP99oBCmvzCDszzHH3l26YR/ZIO eMjpRPitBWGX3tRXGh/ip7euSDuPRpA8jzExWsOLX/82c2xsvu8GolKBK/SVjxUC Hn53d8cyYGYDskTbROjSfdFIkk5+AsK+/Mlp/yzxo1zpPp69pXRDMDf/IVkJ2tjP bI7KvL5DQlpCSOryI7kTWAalY0/r3Z7fqmV1oojb4RAiggzPpGFfw+gHYdWQ6gZR 2FXSN9B5myWDe/1a1+PSKw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412mdsxagg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:57:56 +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 47KNY6L7023532; Tue, 20 Aug 2024 23:57:55 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4154x78fsn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:57:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tp4n/CJyYRd2aY9WcFrs7EMMtyCabnLoxMd1nJNTzweu+E13Smp+C3Evniu4fLZYzHpVg8eihVFAqdsJGc/EH+yLq+rdwW26h22AZhVJL5BxkB4IIJm+wj0HyHqOR94kpP2VN5T597hQIBjxnMTMrpdHBAy+yyvkVy/SJrfFiDp4rFoiL1HMnKAn8d+3i19s8PBGFmFOKwztSJ6B1kU0ySE3En19AMCg0j3wwFBk1vxNsjIyzvuNKFYKE8KHDRS2RQ5ob4cc1iYMWy5DxDmBFVPy7lTgwXB/UN7jazv9XEjwUgfhTJsxHy7PoKqiF3lCsoAkGt4/wQY3kIKOTOZpAw== 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=C0efeCCiJCft2R3dIY5AJ0Yee//Y1CyIg/6pN4cZPQm9GXIJypWQa8jEMKSCDZrkDUz8Mui9YzE2AXisVB5eclBljbx/CTpCPmGvrkToyIsMlh1RPNMLABqmlpKIh0p7m6MtcBZoXoQmJoRx/raZjCgAxtEO1LTONBA+zE6v1BN633XV1ri99AilFnC4LMhC8N9G39FrM09WOPEPdy08SGwbaPotDQXv3kkeVrrnS6dIZvEuvGjW84w/7t89DdK1T4WXIOXHNU9SjKXOMhek5yrR8JLxY+YuiD3uEyhiAlieGZDg3QfTDF3j0q8hKRLjcq7jo6uiV+cUUjCDmkFRUw== 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=lUAxqbuIfJBqgE+7RK2cS9igh+O3CZCVNt6ZF9BInRCoNkLkP8K3t6hY1OV9ifdhj7wj8FvnD3onmHtaUz02UvocrLVt8PiAuE7Xt9IoXcND+EzJgAs5q4NSJ8pxs9eDHka9DzrjeGcLheUk33raX7+hr9mUpzI52pcvDaDTHQY= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:57:50 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:57:49 +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 v6 01/20] mm/vma: Correctly position vma_iterator in __split_vma() Date: Tue, 20 Aug 2024 19:57:10 -0400 Message-ID: <20240820235730.2852400-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0112.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d7::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_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 353a9446-2b49-4b15-6eea-08dcc173e5a2 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: DH1k4puYGZFjcfFEAavWg6e8sMHhRmbBb+mNFeSXi/yWD4tt0sAadRBxVSAoo+ADlWW+nLnpC68tT1ojl35x6yYDkqHLDpwpXwp+881j+rFL5Kme0f+mV8LznTW+QlZMtklawzE+IVKyHCDnCjTA2SFr/bLIqSMZ7k24lhNCMT9HJ4zpa98m2V9Ktd/OcfoVyorI3V/Ss2T1eucxxmUtFl4/lAcTvFRH1KpPcJeKikEdBPc68YoeURPgxsEAr+TJcJ9LHfM+60MYgJhqhPOoO133uU4bmq6PkbwWklfX0DpM+qt3kLqeb+ra5teKMl71CkoEw2BQGOv/Wqt7NGrG+03r00eJ0SVor4eePapWpTnMdeMhaGWhSkDB6BIDQ4SadFBl9XHcGkNs/5I0ekMGpmnGjywe33vCj/eivFMwEG9WN1CnaDACmYKEVq/9paJWedjZyT8oDseymNNBiAVPYrFpBUtiMT9Wi6co5aZ0kyaeJ2eeD1y4EVYlpx6RenAXoCrHTjR2Mzqvg0cy68GjYZ7C3v4UTkG4GSQFPlSG21ZoYkXNMrNeH0CkwsRW7jdGGepUoJAfavgb7RneKmsLMb9botA74qOR6Uaw1Qu4ACkyykrNn6CLvqXW7VBYyWCSvcYSXqCd7DOCTWLUsonSJ9vreJmON+G54kjL4gp+DP77pWBOWm8RkFogsOZQvFh8Ql63hjyWnCFO7BlmNm0WiKNMRGT5GnXn6qwI4sETzgqSBTCnV/KMkMuGoS6dwbdXi0vLnJC8bWAq+Iw/pColRB5yacc3/K40WxTBa6pkfo2Am9bKA5lS49lSAroaiLVYwFZDYXb2g3LBpgk60qVlWklgamfsIKbYgd9IWQmb+jwHZiLQ2je/3wvz9UbCD9FfVyEZHx7buf8i4a2SctqTEvjK2L485tgFjYI/emlX1x+s8qzAa4WTPIUKKHk4eHZGAMVgvSUISy/cPOBL34A/dQ//rA76sXy/wSAEY3kbUzxQFL7ka1oKpEbYiV/JAgHjmHOvgQhJzn4Ok0RBU2h0pqefhY3b/d3rIlwyVVzMAT4xQWk4Ykgkwii/++Ee1M/jM81SdRd5k3hxTZR0sWAEWxlThAZJo1HvPiOcUMNN1hdleQviS8Beg61Cc9b3v1um733wCuFIfO6Wuv0jkym0bD3YRsGjrVU3GmXWAmx5XQXWyhvT5Q8IbUIH70iiqH5jVkl/OWa5I58EBTlKPQI16HJzogj89GkQxSrpJ4d4swlI2IQZaNxuasxsU7jN3Qds41ojf+DVom3ucFOg4jWTzDtn+lYZCTQs+DeWqoLlhrJTEZr2k/RDk4PoK0caAqXzSesChwSlWiABpMHFlUKEsw== 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: LtpkUH/Jrrb/wrVcS54Z8NwmSZaC/IYMIUBd3H6SRowEuYmO3rMYD85GtFQr3jhxn4GYS6KsGXmoD3npOgLeVV3XA42pXm3iMwh2z+EskSkWJ3Iy8Lm2qLwHW0LN6MK7YajL9YHWOK9i2ZG5eTLFH80X5cgKSr+PADBlfeRrUr/ANfxjY7vajz5GPxANW/BxJLB3ypZHgYpEZWr6CijCanMDyN/y49OswcqYHVGO5auQio0MkdbLcr04kV4C10MsA9reQYSRjg/qK67oIJ9y7CJiC0etbI4nNxGpv1p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PbXgCcspozp6mpih4uY4cZ++OLwr54D18P6KiTvFR+va4XU6efmZzVqzl1G0SOTtOPkr0zz61Ouu1U2FEzLbhholKTZ0Bladj3Yd4ouNAY4y2FyADwUXLtJ1pcEIVi7UP29nAFyl+DH3CV13S4SWHtu/MD0nwjVtcH2q08em/WpaPHEptnntGf+U/PldQAbdqLOraQsCMI3BsurKpu89h5uanxhO6a8c4MCcEGciE1L4bX0kuALlII9ujboitdQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: K7oM+dRwybG6AOR9JDqqDDH/mdAdzCaEbZ7I0wnpMXvi53CLSX4RW6GX3Hj1+ORy9ToBSvuxG6Z6HqDBG343n0DVsh2lorxuhNxBpyq73wTmqvrLHGELC3/UsaXTVugpXim+rWrgi1TmqOM0o4aY4FSNTp3J95L8ZkVx8rJQflQsStEc1X5RvXHj+xb5y2KUAVKbWnhN6zD0AWn9E8g7l4afP6xFlF+dIErWHHAuRXI2JG87k2752T/CBDE4SAKi8HTp8k6jMYQ5Aq+dtAduMtXYRlMyTAzaLuD7aaxGc7YN8hYFK+xJWBrP+ClYAqXYSQqVRmdC4pAc8KkNwezxhS894K96MgAxyIlmmzqyMpMf/w7cPBVjvg0RX8x4SLBl///gbBg4DMazbebwHbrij+3SQTEsjqZB0Vl8Il0Xz6HvIVxOg/Ob7MDdl7kK22FOJjIkoiATJJ20VZyS6WfRiueKD4GYMWxhtnDAuk9NevQtvhmeG1KgCAeFEE0hILYIL23aBsMqONdAxzRtNEHnpizn50F2RIuZH7M2jZ3mLvfKEH4ciCr5Z/J5/R2NU4nGtBTMHHm4TeJ0ITJn9R0AhsZHx62iPyv+nizqNyV4pJk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 353a9446-2b49-4b15-6eea-08dcc173e5a2 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:57:49.9065 (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: +XMlbSGQXJegV0dgU11gqbOE9em6V8eV89iasrRZjKjyvm/LMSXMWbB/4eHmaraQSSK08v1lr3AyD75aO0/QCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: Pkly3eK0LM7nZv_XIHanr2QxgglMfv0c X-Proofpoint-GUID: Pkly3eK0LM7nZv_XIHanr2QxgglMfv0c X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BAB4420014 X-Stat-Signature: y3oukj8f3wkq5oh19ipitbqdaa7nozao X-Rspam-User: X-HE-Tag: 1724198283-31034 X-HE-Meta: U2FsdGVkX19z68dCdUKCnHuTOv+jzg0arzvg9Zl0ntx+XDis/s7F4qeVFKxhWKD9QsqaqsSjls7iwPah9rJ8meJA9QhpRDPCx+35UJwb6l2IthBmrH/NiFRN+SIMkXjFgQrjlewldczE13/VpQXdcnOLH/8S9imkQu/sMTtdxruAskl4tLaGGw1Z3EkH4x9FzVUkEBJJa2KnQDebK9LZT0CS4Ce9tuMQ0Vc9k3AyHpNaB9VFYUM1cDuwVRiZI43XFqvis4UhmvIP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ndT6T5ubHH17AlznXqvJa3NttG882awCTjva3WqtKvXFeP/MUCtFEgS2voPu7bqCzyDYP+W4aPpitzWE6gZ8ulOtKpCXdU+iHO+TtKd1/VDO1NJ4tg9Q3iYr5AZwn6LAUOmrk04Uf4A+NMjLnfzR6wcfVEjO+MXH1Drlsg= 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 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 Tue Aug 20 23:57:11 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: 13770662 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 57C71C5320E for ; Tue, 20 Aug 2024 23:58:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2C1C6B0085; Tue, 20 Aug 2024 19:58:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBD336B008A; Tue, 20 Aug 2024 19:58:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A24CF6B0088; Tue, 20 Aug 2024 19:58:07 -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 8080F6B0085 for ; Tue, 20 Aug 2024 19:58:07 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2243C120123 for ; Tue, 20 Aug 2024 23:58:07 +0000 (UTC) X-FDA: 82474289814.04.BCAE570 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf17.hostedemail.com (Postfix) with ESMTP id BF2E540003 for ; Tue, 20 Aug 2024 23:58:03 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nv4quwBW; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Dez7pu40; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf17.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=1724198219; a=rsa-sha256; cv=pass; b=yH5Rsxk4/GiTdfxg/qIw/L5EU7b9+0ZioyNk1X1KbdlqsdlLErnCVqi0xa/vQgUPFZ0kjC lMDHluRkyjZ02IVYXvMwbxKDOE0qDo1pYS4z9mtxU/nGq1MSYrUGA8HFXp3KHC3BbOmbjH P5zLpxs7tWMe5t+PR8360yUAmq6bgao= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nv4quwBW; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Dez7pu40; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf17.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=1724198219; 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=xWblUo7CD9POee2YuAs1Sdp5elrv4nIN02a90cxGFljoIs43c2zgyOfinXBpHEoU+gJMr3 vAWX/cIpMkKiB/PQY7LPeBwBOY5/yvFpLQkq1xfDgQYNYAHYV4ctEiUlXWUOVKNjIcaEiw yRX1kebPxMe8ZjKYWfMf5UbCkWgirTU= 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 47KMBb5f017828; Tue, 20 Aug 2024 23:57:57 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= nv4quwBWD7pYdG94/GKZ9vqqN6RPoLz6xpPBU6kv5jyZmhNsQcyL/PK6vCroKYQy wOo/molDKmTukHp8iaVzEEcVtv2cr7F3vpGXnCFSN/FxAx4P4OU7upsXt0U6Jx0m D0xBcvVlLsyE3AoMuDcV125aSWc+wUrV5gUnZKd9Bh04a6vE2txRP5XAtcQRlCB/ PTN70I4vqz/3HF9ImMUMiFEmT15sFUwiOX3X0NKSAm8I5PtpJjGxaluFA0iP8NMh bwPuEsInVG1nza7bsZlWw744ewJEEWO9zN0/DNDLVx9kD3hJzrmgQkVy5Km9u7+i i4WEely3orQl/pGksGIK2Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412mdsxagh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:57:57 +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 47KNY6L8023532; Tue, 20 Aug 2024 23:57:55 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4154x78fsn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:57:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V/OmLi9P0va2F5nd4IcG02exAbXdDsTBO03FASM2uO9ue1kC0za0qxaJdQk2wx0Hw8AM6whQ+Igx8dElJBfDjuqa1PtZe47+vY+w7ktsCvnHVzQC55PyPtgl3RG6IcmvUE27pAU8ArGAjsxwi6GsRuQzP2IUijptbMi6Ey35lvUr1jWj8jMseKB4QnVOTAQnnjAHJ6Ya52UzoidxqrzImJn2OUVTY1d9zz1KYRsgVJ3l96bSE0hqV8RGV8puDHgk+yVjkDhAKOY1g7Ue2mQeZPbpBpgLpxi3AQ/BZ6JMrtRcI5Pmq5iFVCN4x8jWdfm7w3QJ4108zUbFIZHmWgVPOw== 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=XdjZ1IgTrSvQwfWJB5JRNf3nFehT+KVzrWi5m/iJFs0pXzfQFxiwFKpEmvDM4uBJI4pOgjQugOSQH+KC5SKu2SW0MbzBJ78RGd4DrnaZXclauc+Xom3+Yww3q5SFE242UKOctVr+BoDDJu7HEBfYLicb846UGxxSFiXKwIxdg5WpEmyHRblFGSYZYeqPa7DpBQLtTTcZ62Sk7tHmeT7RzgJTwpTYJ/y2XGqU2jAx1hYYsHKmFPh1Ou/YkWlxUu2qZe7OEUtiRZP++y0CZoGuzzBjE48Ho/nBVniNy+oeGVo2bQXal4/1Qs5k1IAWqidAD0QiI8coPBxOYqp85RoSYQ== 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=Dez7pu40Oe1FtiBVWEkDQA9IVFsMkVi0nD6RCxcjjHQ/YqkxhfgfP4mycBtTm2wQaW4UrYMRaCYUKdExWpk6zSFMFSHi4XQkNjwYUWWBIyIIAsQy+y0tNgqAq54TRIgyQLV9dJeWJY8HGdYA8lVuhWwX79wcJpUNLj+3C7Q23a4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:57:52 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:57:51 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v6 02/20] mm/vma: Introduce abort_munmap_vmas() Date: Tue, 20 Aug 2024 19:57:11 -0400 Message-ID: <20240820235730.2852400-3-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0189.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:110::7) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 75c9c907-2a0b-472e-6f23-08dcc173e69d 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: LKFzCz3SrF4Wc1UIFCCAkva8PqQhG2LZurC3Sqvp5DdChyZkaaRG1uODbNSk5DGHLbYAIXIlGeoCdWn97an0qZ1/M17lRMqCrLq55qxxmuPPLgp/OuzmM+pdVW8/+ov3fJTAiy6hbGr6AhMgMkiKo5fb9ICtbW/nCHSVzYIQU4IHEaUMuMTASnJ0DkWrd2+18yuv9xCP79pbMOV6pME8vmi+VUD+zhJKVIPw2Q2o8GE2iP03go+nGkvgc0n/CIdSzl/u2ULURZOsTbxd+nb0cGr9v3SORLDuPmI2NgPv2DIQgKuYJLSbElcVfPABF/Qt+zIr/EGCiHCPR9wk+lttPjYWnE/p/VY3opd4IBOKBC/Qtspb7+jyqfEmtGbFa8jmbz0WOpZAtG4/S4fPRXh4MaE4V3QmEdqXHbt1x98VIhIZpW0lRSfhG62m7JDeMs402rtunb0FHI9o4CApvp6UY3gdo8N7IBq13mOQwAwlRzit2+BBwbLbuuiptpptBGCb0NieS55/3opFGaX4BG0b53c0fVoBkD6nRw73RQxWwnbFtOzulff/5dSeGG6d56i4BdWxHXpvznjmvc90RDuOZ5UhsFQFLpJfs1tZezIliT+YbpeA9anybjbxf1i8gdTDbcd0rAIm1DGY4Zr8RCtD9fBlRQpq7uUZI/+WCTEuvEDrlZmRUnlz1BX//3fFWaiWNKkqgTcKM1RimQa5DNT4cUcalOJrCKUE9QMO98LBkhkNR7q+GjeLKOWDbXB9BzW2ff6iAYWXw15pyBgDSD7jH14AwKHIZK/sokLx745YfWp7m3MB84xSdhmbShIChBp4o/k+/2iTaht8dBzumTe4GfuxSrfVBpgTCeLKvLlS/9/OyLKCxjCya9DVlSg5vvGlBtQPxlPjzY0M6Q17aDalsbbDUNR/x8/ZG9ZeNR04e1+pELlXLyiJnK7gtZRv+sM+J+ZKVeCHmcTl8SXu2Oc0pdVyVgxkUejI74zIKSx3rF/aFUJjHO3WdrL7CoZbXgcN0efPS1KXy5IRqF4I3p36uEeUj3awbcNNql9MRmOb8UA/veBncu/Jyw4KIcmnohlE+6SMqDMliKsOWFxpA+f7G+TD3ygu6o6bUimWMrvyU9PHBExWg54Vocr/WaQyTl6VCryyxulgn/Wm4iukWLc51b+FjKMOCf8yIFxPQvHmO1LVGLCfU9YOQ4999L4jtSRpAsD464Ze4X58w/c11rYhiYWeNdEOoZbXS9aR3nfHtCFYims1TkL2Iv6fx3xSqWmhbJOiHzQ2ETBDjKMNCzEdkE0ccbREzeArT2cGflVNgBExKYuk6qQ0WCPdLQiC+KgvXo69yeZgHa53AQKyCuRGgA== 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: WAdoOczHvFH2En/0a5/ul/ZAgvbX8GCjsoqw9ssoxqrbQoWiJddgRrX0IeEfRr+yyntId43Z6JTic5cl3AKytDmrM7yr5r4QajDtU4ksn8wtF0FHG3TFZKp3vCERVt+YHC/y5/XYsxkRIPtZh2tvvVzD5PiWeCPupNpJXHXsWOUi+6Yc0t0mvw3oLXWdxaY9yB/e4mwTvXMkkT1tiCJJLEqqqLWxJSLQwPKE+ZhOwBfBD0CNAGJvhBLKStagMA675z+dCdPN8RzuJ60B1fKJpUfxYN8WnA8fUNjHCqfq/fs4qUvvyIViDmRt+VcN/+8X1IQjdobSW0Ew7xkPStusbHpC9Gm4P9q42Rc9DkDL5Wocj8nfZmrXSVGcyAGHOOauXEec0huay9EF+QmxyURyXsBdfuuLQEaVHIQ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vVNlaq+Wg+QLcmQ1WTkylC4nzgrBff1SMHBlfWqVFqU0rBHFDSuJxqhj8NDAtEUiMt+OF+RRWgTMhFWVQbWTkxBAlldOWP0Af6l/rvWiujL X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: MKf4s3w6D3PXoHQocLQ2G92NVArKk1yOMMqzosenk+a7wgZdr3axDXUk7Shgk7N3PC0OcOg9HyPX4DtK6kodcNgHUnNAvwrF/yrZ0Tq8pNZ5xyjNbo2KYXHOx29YXjZjvPThH7OxAIdRziyzQsfkbG6lkxcrFJF9mtCkCPyCSd0t6CW+m/nH8tnqGAdy4tUTmgZMLeGtSRjYvA4skjr8/ghbVKNilb6Qir+/syaN5Uo/Nq4BlW+niIq63Chh3lW2S1oG7+yIGoN2UhKmQcfPJHuomARnLRoM66/3PgSmeg20fYR5ATqRjYmHkUmL4i4TABFbstkXjmd6+NzwuOwqqPB+Sd1vHjEtcjq0QUS8LOo97nRSSaDyItUXItTOH6OPie0vz3uUeuaSV5QD9wK49/+glOBENbPOCjn5fetT3K2WuwQkZYzJDca+BGN432vCoobpLBXQZuNv8lQBlOLEgjn6q3Yb71dD7+274CX7/rqYqCeXXz3uZoXzlLqOdbVR3sgXizHr5YRBZoJyDu7YJXEQtNH22Hd/ZFqvNlBO//vIH8HWR4mhAD99P4pchRwpE0mfJkZcpd0+QmUC/txmlO3S9sA4pu0RHveusFNPZfU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75c9c907-2a0b-472e-6f23-08dcc173e69d X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:57:51.5100 (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: ktSLuLHdDSJEAbZA5LCGvm1M1jFQXlS/s7d6yy6L//GdhyMgxuUGDaY10eOeiGZaz64Z4Usqjc8nNtFuxcHIIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: NTcSUdwHOlOBrs8MHd0DWvugJDpDi-Sw X-Proofpoint-GUID: NTcSUdwHOlOBrs8MHd0DWvugJDpDi-Sw X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BF2E540003 X-Stat-Signature: 34anpkwb55udqy566iyq6our1ikrbmoh X-Rspam-User: X-HE-Tag: 1724198283-308767 X-HE-Meta: U2FsdGVkX180aFs+UIlG2S8ZjWHkmeHoF+scRZnRxFqLkBLZtmLbTcQd0zvJbwg8nJ9CyXphVCDyTt7SzPaDUuYPE0yzLA6kTOu8vXfTbHgFUJB6wZxDh53Xm/0jyxWj89smECHhcC0QOrcJmJxxKPeNgbIEyNqSXlkDeS3SfnXsd0i7luQwzYZPniAx41nam8JubEcBakwGweonIqwMle6N3td30OksZXdOboMMoHORN+ojwoVIvvVOj6U20V7oyC2qIRi3SIWlRpU3ZSLiN/fnbZpEtE5B79D1HShMa0dq33WARQGZLrvKhB7097V5TD2xi9e6/oHv7P6voNqo1mtQ59sbcVOU89hgQfZPuLIjuTfQiNjxJqRXByXB0y+7qgHVCux2ci0J0gMmPNAJ84qFxNCu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mLUuJuLd+6C2vkG/IPEf8rYIc3tN7HGCn3YNaofYewXUjRp5w4LBQWbyiQq50w= 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 Tue Aug 20 23:57:12 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: 13770663 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 6CC0EC5320E for ; Tue, 20 Aug 2024 23:58:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFD556B0089; Tue, 20 Aug 2024 19:58:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B86D96B008C; Tue, 20 Aug 2024 19:58:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9143D6B008A; Tue, 20 Aug 2024 19:58:08 -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 671AD6B0088 for ; Tue, 20 Aug 2024 19:58:08 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 152B71C328F for ; Tue, 20 Aug 2024 23:58:08 +0000 (UTC) X-FDA: 82474289856.19.BE87B52 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf14.hostedemail.com (Postfix) with ESMTP id B38FE100013 for ; Tue, 20 Aug 2024 23:58:04 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=iV48l5rF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GrdPLvtr; 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=1724198245; a=rsa-sha256; cv=pass; b=UfHCOVIIVzxNbMs1tcYjXCXofcMW4lTGuNol0qxY+VkUUY5ynwoKU5X3Ot8kKR8PQSfd5Z Pz4+zBKttJooeC4BzuIXgjjbV4b+xyFl4ZUNywIeVX/G0csJlODAKQ9OipkXje1EK8vZsI LcilRWdh8u23MTYpPPuwunoIi3xzhVY= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=iV48l5rF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GrdPLvtr; 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=1724198245; 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=g8sPpJ02TZA2x/OLGwITVl95mEu0CP0Rikb4TDFJqgQiAcBQR/X6axFkvgIjWGW/7nyAnM ByiySIW9EaHh9mdunowAB2tn8wdMP6E4elt/PAFr6NwNmWZG1NAzWkbcANkkbsczyyjzbD 4WU1ZYRxuhXQcY1wk4W8wdN6chYETaA= 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 47KMBZAm028778; Tue, 20 Aug 2024 23:57:58 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= iV48l5rF4ocf/bbzCROLPZ7nyNuMPhodD62nvz3mNwW/pYFo3WmHEE+5Szy26hJK PH//eyeAz+cvW9iBl23R9X4ih3st9XSzIDyQm86VSsY5N1C9U35vF2srZOq2heIe 66KlaspkivKwLPw9DvPthGNvhB+t8NElRAsA+VBJD+ttVlP1Nbadmkr0cnEJmr+F 1+v11L/TzpTcrcxUHUT578WpYUpkodPAxVyZDYMHR8BWUhETdvHt6BU3MZFaOLyp oVSxhLP2BIZfght5Sw1qWdULzh40YaWKb9JIk9EnOv7x47eGRhgcrwrTrrK+CyC1 GesgvPHNW7XBk6k3fON/gw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m45ebss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:57:57 +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 47KNY6L9023532; Tue, 20 Aug 2024 23:57:56 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4154x78fsn-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:57:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ump5vfYfdkDXcf4qIMy/ALfyhD0pVgIXwMc2AvHS6wqwCC5Ai/7YKOwC3K8HFZLiMFBGaFyPE62zsPpaYjq8awsneVnV8mHTTc7kgrcW7RPMu2ttRTWT/zTnGTpiVarTocgU0Y0T0HhQKg5/AsmVVrzQK5vhK9Mj7CWoZiZB8ujewE4uvtt/oED4+asmpzLF3T4WRp/WCRJnG6cmedu6Wwbv2RMteap8Oq/y0q9i+/crRV9SWWCrLqtHF9Noe802CNlLFQubIB7L4l8RPchOLsjDXlNRIHuqQeNREJi6B7a3kinlFvHI6/oCee3FwPH7gSgQRjxaJuM22f7LN6DpFw== 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=oQNFFNk/HLFr5a75IqEaY8jHxebgG6EDNAoeo63IlErCY/2pjUfzgDqfWl9pCK1rtwZbtUzm3Yq5bOYzH7a9FzMivScRUOy05Kr/ilY6vSWl95JSkRnU9nL48xzUNQdJ/WLgpFa1OGLKQtG5wWAt0GwHpAJjZd2mw24lVn+KVL7/ftM/reOMB688S4SKoQM5vMwA2/pQkGi+8bGiODwm9ATa2xwaDzExYHrOg6uJ6tGO+mS6EtVs2RJ4i9jvuc+Yw36oEurCZKV/JQgxUmWFSOG0h+pFp2AfEpLLuMiVQt035qmUolzzn2GBA2KG7wo6UH7jCWFbJSCzAEbegrvopw== 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=GrdPLvtrG+ipjAWOxzcActXC4g/mSfsOL9ye3jHGCN57aX7+7uGOdfSK/u8A/QNDzAG39fDtmUaDQJJKvk8Zhsj0RY/a6ylPnQ6DG3Fsgagvdhqcvt8alIIf6i9psr7jZp54z4TcbRBXPWbO51uSsZoGPB6nBtXEk4OKclVwwuc= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:57:53 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:57:53 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v6 03/20] mm/vma: Introduce vmi_complete_munmap_vmas() Date: Tue, 20 Aug 2024 19:57:12 -0400 Message-ID: <20240820235730.2852400-4-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0123.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d5::26) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 7145c791-b2d3-4962-d81c-08dcc173e7b4 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: jbU8J7LBKR3gauWRkSXEzvbVpOluRb5OmDqVqYtyCKiZJC3KbPXz9NKZYQ+j8USolP+TpUJN4Nlfq+FhfmlrJ5bvyvAWDRsIPEkrQWr1Bb7hmz9dJBtRfSUs7XJ1ie0gdpPcSTDHWxokJXPATiC84H2SaIkJbIHUMWgTCkIp2x5SPuNdVOUpE7IpbTRlzYKTexx8VsseoNLmo4Z+1tZJ4gkQQpULA0tqQmk2bUUOafKUOndrQXn91RkT0pM9kb7BTZFPKJMfddureN/4r+QriJD6EifzdwbnDZBC6skQa4YEkCnu/vNyLwhroanROnXabdO9rJVY2W3WJTDfcQmoQ0JPUwZyyt0Mldogpa/XPjz/+y9QfxW9Ur8wvr8TnZ4+9EDpYzOu6isBN4a7JqKEB9KtRdjNe2Hj1/BkbDpTXPMDVt/mu/K0679b39FAWQR9xfPF0YIwDaiy4fAXhlbgjltVYTusjqINtb7T1bOaAmOaUzG3dJvA0yqc768kTB/M9Hq6QVum06hQAlz0SQTykfYBbNE1XSJIqZrjiFzFRT3hpcw6RmZj1eMSv1N+cbj7hQYEAxn1BYlU3x4Hq7guREiFa7UIbCj6V6WqP1iSSmKHER1ga15P39pLR2lg5sZrGj66VcJKfFqbYz1ZMzf4+JAtJvV69hk9tw4exOoZyj6EV270q3Yr8QLTPmV4O1U9JAat8ajrlm9sxg5ZCJLArKOL9Xh6AlC0c+tweN9IenWRT5TDRQYaTyv4y/XsyS4Gl3JBUZClQLuW+ppBstertDsCxOEW1P0CQiTSa0BNtd4hDoCZUwT57Jmq2xEmJGTFFSFaOqa4ZM8K/HJVrhwuNG4eb6Td3w4ECfxfzJDtfc3ahcnzm76hBnBSRx9u7cCtqS6HaFBkQaAeOAYrkC1irGzLQLR2llzj0Y7cwJ9VJvaxk6bT3Yi0ec9G5TLy7IFpCywMKgb//9RJpjfT3ycf9hRLeCuro3Q7rpVLy0u33gjqu8uk+C/pgUf20SV2iloP/pgoSsnumC/yA4xG7pLmdGaGMePdcoXGzGwnuW3ctmFlbnkxlW2XogyxH/6M4EFW6+Udmans260c+zpXb3hU0Of4ovR5o8N1OMVHru91i/d9dzt7krE4oJcHRRtsu5J0FGrZZcm7F+VdC6ahZLNwOm3gCwWO8NdzmUrQNSjTeqTapwADFp5ymZbbF4N6XyPwLdxl0kNCwxGRrTAGk5jORkp8oQqpEa4bQ4dDeimh8nNU+rzk89INkvIHX4bBi7n5hA+Coi6lIBjrUaswikl+rNal2PnVbnGKEn5C8z5aH+6+g6URLZtRv5W86xmTHA66gY6Tf84ExsGfylAAXyCA7g== 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: EPI0OwAMW3Ogml7X6pPxJF/0X4QpGC3FN+drUZwhGF596Rgxjkvst/E7FPRGwxM9Oav/uMclm1FtKgd+XEWsU7lM7IFdLJ5DQF5q454NqIEDMQQypFstQo0VfMXLPl684Yv7/pQeS+0iXT0yv3dBH4T8HPta0m09TFaVc8Qx7q5b7v0hVqu8NYqwFR18ghLDJC1ZsEZ/GFjqXvM3/nSq6PosfYQ2nZPQmIIlWWMD0GdRBiTNFklH5Vbnlpi8gFQrwU84s+B9VAX4HjJbS2H7PBIlCWuNqnmCMoJWbNLv89pxZLCmRjNtxTOCL3dd8a+m6J6FlqtR6uzRrTjNSF2L/kjaA+dZ5gHQRyUrzjddcR4C8DYpvA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UOwBjOnJrgLNoUf7TivwjFxps7+vOD/wGY9wuxIRRGn1mbYEH+j5MitPFKq39Tla5DGTHSYJPD9Msnb1yul+FlFXa4SV2qpfMQIy2hjN9gk82QgSf38FzzH4ejZoRLpsCb+XV7/rsILVEf6BLs X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mzs3+hbdvRKZIctF3TsKLwGghy4KiycNr6FODrGhIu9IOIrfKz1decLajuLbfZ5DrTNDIzbwFhooS0fL9quYlq4PLlcjPeUZHkG6JRLuvMYydN3bo1KIM89O8For4IHw26a0aPbpMlnjw2Z6nDsfS0DAGOwO6+1pc1CSNDWDbPcVT53tCFtdPY+X3ClR9ImQLdQ4YD7gPXA9UbOLllb35mphvCHCtsUNLhngbudS0vvugoHCsgbMkTwcx49jiSS0bnbbiirQavLzFEiVG+J/YnrN45C7uFe0eggRInOyvcZMB1Y7vsfCao/xEyUijujj95J5oOqB6rgKHQYI1F/eR9kswGkvSjBg5KXTVof4YdXtAkFsgHaeV+GrJ/AQAE8KZI0P0CqGoUP5Oxu0LQygqI4D5oF+V0nTBiYjBtRC0dXiucLB2YVdrC5RV5Ui9ficpae3Gvv3l92wKaKY+bNJHWqleDGa4dpd7vzF7DgioT7Ag//o6oiDenQjAhPL+uJwgITWHWZDemEvDRxnuGlJdcO8yrxKnTXpMmpiR3Y3xEjyi16877yX5cSXdvvykL49u9Bb0itmwYQLSg+/p7eCMrbspf1ipm+6OUUGh7pN3i0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7145c791-b2d3-4962-d81c-08dcc173e7b4 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:57:53.4433 (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: 5yfTxP7nc2sD0lpKARLqB+Z1ul0HcTEgQGs/QII3vRBWgCULbzcdLshg5vMbpFanU5pWcls0VWD5Lprmq+LMcQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: TKAvJgV6Tw5tr_8J_E7flWznTOJ0muVd X-Proofpoint-GUID: TKAvJgV6Tw5tr_8J_E7flWznTOJ0muVd X-Stat-Signature: 551jx5wubp9617i353w6r1fstqnjhzii X-Rspamd-Queue-Id: B38FE100013 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724198284-346183 X-HE-Meta: U2FsdGVkX1+k6zt5jHgfGz6SFK+ydqksQ1n8OEUWi/d9TGc6EjCZNu1YKUCol5BBfFL8D8SLe14gtD+zkPIRcpvU6QQrBB9vAacQ12Ys8TDQgy+eXvAlssXWe9m1qzeek6e2dambhBfJ+rooUCPzX5vBRqoSPVi+v80vpBZ+KqEGMlRpdSklLl0RfRA3DtZiEPoD2vuIbtKueT81I/p+P2jB0H59GHhnwxE6RpDPnDmPECYey+hp+vGgh9nQQ4PgHRgsjdtC32cZvQO1suwlB7TfPOWvIuYqizDz+ooFFAo+JrfQps1cWtwg5PT+UZx9f0XCNk21JZ1v0cAN1aeHRCDNq71sxm9eoBlzxAA/rAIBDrK5atNTyzYAJ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+Y/msYnlajEwy/Xdp4uK/2Qsk0GKGt/W23byFQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, 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 Tue Aug 20 23:57:13 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: 13770666 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 9F30FC3DA4A for ; Tue, 20 Aug 2024 23:58:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BD7A6B009C; Tue, 20 Aug 2024 19:58:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 546F86B009E; Tue, 20 Aug 2024 19:58:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D2946B009D; Tue, 20 Aug 2024 19:58:18 -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 F21326B009B for ; Tue, 20 Aug 2024 19:58:17 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AD016405FD for ; Tue, 20 Aug 2024 23:58:17 +0000 (UTC) X-FDA: 82474290234.29.2950707 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf09.hostedemail.com (Postfix) with ESMTP id 6542714000F for ; Tue, 20 Aug 2024 23:58:14 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="gHT/UZ2X"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qxW5yciJ; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf09.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=1724198230; a=rsa-sha256; cv=pass; b=z1s21Ytw00TQV18c4rXYHm9s4IfUHQ5IiS54qjuh6x0M7/WRX2MCKndu5eOpCJ5qJ/ZUee QBSOucjVFQ6urIx5z/J64p8QVLk45aWqBbqQ4EP7cYKDH/rYhwv0CpbHbf0LZFlESRa72/ kF8NHQTXbA6QcFduH+rD/NURm0WzsL0= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="gHT/UZ2X"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qxW5yciJ; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf09.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=1724198230; 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=ZowZQ79ZHEAemfQ0yCmdD5Q5yi6DS5YBFq4mFACTeLYj34u6oSO/KcPJU6i5OA1cv0sr4r 1OadgjG9OK2kpejsUHF+YrBWC+KQDHheYq8jObyvLzkCn1USyhXIcw57Pti3+qO+FVYyf+ p+/sff8WQjhyVrl5u8BvTXFlopmW9kM= 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 47KMBdUL016632; Tue, 20 Aug 2024 23:58:06 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= gHT/UZ2XGHPaWbGdLU8kzcYLD4ZoN5uDEjjiD8rKOi2rxKfN3vMWjdPAYOHi7jih 74HBxs2YxYsP+eftmCUZZhzUbDDh2qOprioGbGWwAYw/nVJnhLMNJp/daP4WJ0FW ReblBIMgHyPH3wVBBLRMS7JZYbscCs3ENnOZMCvsYpPTqbBad9zgw/0OoT8a5jQ+ WBsZNTNUnKldRd/gGqBZb4EAhDPfShIg6lBGLHbO3d8zOIHHMXzjAWYl+b2gswSA qIRvXJKuxxIBG+Ya9+OM1Hl+nQ4s7p9UbBa7m38fjdazyqL+AkC2zov5L+0hsQJx JT+mlo02txaDpy5fP6ZKlQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m2dedrf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:06 +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 47KMJJkF040123; Tue, 20 Aug 2024 23:58:05 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 4153u2tbef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hCTNDcvbokyxtxoTmUVE1EmsUfOTIVjxqmelhC/tESDi+fgXuRC+Z8ypxOOk/7JJ6ZA24jOTmx24pYFmsLgsCqOi60cH73ZTtHYK45HpUsWmZ5t9BRTM3I5o6zGjkUg3VtCBRAa3yc2iclyxigV4cG9kjyVN7zT3sUQRii9k3aFC3UuCX1KqyKs+nlKuBamVSv01O0siKLHAWFjoMPJSrqIXwq+Bx4ovgKEpsjlmYMGl5Qnvp/+GAFOjJvLlhaexCc7PJCdpbYAXb3OodDFT2Rnim/8L/F19tG2UNECJgMkWI29jZoiF1KdeKY+vpzP7lwoMP2rGsGGxLEXoolOe3A== 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=Zkf05U3VL8DvDQkB0/d5SBeTmxBtlKEZwiAuaMcPR/9fZKTsHBV3w3iultdyJeZVKcZAqsWjZqMQnQ8JJlGTtNrZANq5q8qAPzuKuomypWWApNEtyG1sGyMvyKbu1IJ+hJPCCg8+Qca2waxjewk6zD9pnvuPlIHdlhZZCkum7lH77AH6gFOqOqsvhCCp89m+ekOPMS4oUxkrbaaGh9fO2kZBhBt3OdYDwPUXtLE3R4t19krNvka2fwMqzw+pEb3Gr4ExpaMBKyuC9kjpMPlhtCLYTgYJwOJr3JRePn9PeHNyJEG4ybgtaf5Q5iylEwqUn7fqnUhiG2D4wHQbdWwx9Q== 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=qxW5yciJnI2bxjktxFIKbxdjq+Prfl6+g42IVofVHkswLr3jHax0KuqJfsSQMlcTrY21uU2Wr8iZrNkjW5moPe1PPQbBjxpwJEX1c5EBSI5KbOwjiOlUbW+TwXa15s7+20kvoJ8tOeri/JD+Muq643rhqZeuRCj7LFFDkuv8ssM= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:57:55 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:57:55 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v6 04/20] mm/vma: Extract the gathering of vmas from do_vmi_align_munmap() Date: Tue, 20 Aug 2024 19:57:13 -0400 Message-ID: <20240820235730.2852400-5-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0127.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:83::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_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 10e1d107-0e20-4ec9-fe7a-08dcc173e8bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016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EbgpRqpi5u2dS3hA78PiV5ONNX2qHsZFNIjfJappuRTajAN73NnigpoCHEppdHP60lfLyIeS7sVJbjBZpQF0zfveMfNdjm5Qt+uIv2ahRPOgp+B2lT8I3VR/sRGpKCBLAqm1suTJ3+vt3lVpxWRWVCMGRp+TYoMjI3Xz3AXcsFBQC+MgotJQLfWWdiXuKdiKVzcvdYmLx95EKUBdy9cA+dDdjs9hsusGT88+ujBwNX5YDveuWIMhCZXqsI0i24CSaXJX4l17dygwYAeuoCF1VRMZKtIcd+jmfNJtJRNigq5BjvMP5/iMWG5h73lA== 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: oPBjHbJ2TgR0t4I45IQAYJW4Ly6TlT43iWi+i+LwZoEHrNDcW01NRJBcEZnhz6wrMGhaNru/6HHcb5x67ebOk80Erq2tUEgFgpw2b4tDkdyrM5dl2r2ssRVOp+grR5E1bXYTOGnn8KP/+vdkeKfeJwojC0QsUYv1qEs0Aa7KKTBF68btfXiz09mWnssuDVJGlysGQUU47wIXt8+FpHilcG2V019tClrMu85WTDnvv2ZGW6y+AVweCPTNGu267V5Go4yEvpgwtmCe5lvCmXHqCLFk0ZkNAHRRH3Hnz66xV72GoAixzSW+pagbZP8aSR9kE+uFh3dmtVqwC1y1BA2VAqItwqKmneJgEIoJQOMsCMuJHZklydbpR8jeh49xa1pkXDd5ftIn4zvqhcsM/q3VBUGLgWBp5NQR0YJfhviu3YtEhQ5JXDl8wOPdzOyXAq56CYnNXgkgrg+2pJlrtgY2s1fIo3HPji9dWq4dLXX+CW2Q66mZpgjTxFkPoW23IMPtv4vhaxLX37akOpLsgj3Ra14sWxrHeO2I+dwf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ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9jJa6pRlhNZlV5aBRPTxkbB52ljIPNxhUbFobRuEeldPLqdMSOD9f+8ZDcLwAuIOJGw6UR0OWnZl0C/FWvWca44LNs6N9tjgHhWC2Qu+E3RDu/jfJkx13WEagP4Itb4WDa/onfWwwLaIgRF/+V2g1nzpz7Ify/YN/FflsIdNcqmSOkcHQiGH4IKnGvpMUMxIr1ntduGePCRSETGNpIdTDZrilcLMvid1DyQyBBVeqpHpdjPOp6vd+5gPIGurlrPDDggMt2B2KY1Hc7097faDuF4jHS1PI+UBBcHiKs716sTyO06DeaJ17xu7060WnsT2ifWuvU9EME+8bUTmIH1hDnMI24lJFSULsnIqnisqyOGUUVMoaoFhsQNQYNJxZLcpYR6uXEPpGVUKq9QJ7zFMY5djKu2d6uvEUo9Oa3OaSrrcxoLiXdZsDaomx54IMe6Fvy/flBzHVcKxKIayEPc30igth4sgSUWnJV8CN88DNlhG9FEYohSn7H6yk324tLXf7xbP45xcnYZTKncXXr0CP+cFMSXLjSwrjJ7ztMciJIPi39JXfFGvQTKVArTEbN4BdZCPR103hymq5aYjNY8VVLhPZ7+VRyu8LaEl6tvK4Rw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10e1d107-0e20-4ec9-fe7a-08dcc173e8bc X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:57:55.0731 (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: en3YZtgZEkPD5kT0UtaNcO5SbtSr2SJNh9m0hu1ZTSQ88n89B7Wna1fZBgUayLhYDHw/bzANkP4iIewm1mXFpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-GUID: wtzRhf-Pg4_hFcY_4eORulCcuujwlk4L X-Proofpoint-ORIG-GUID: wtzRhf-Pg4_hFcY_4eORulCcuujwlk4L X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6542714000F X-Stat-Signature: wn1634spj9f5bwei4hpr9dfksqfim9xr X-Rspam-User: X-HE-Tag: 1724198294-603710 X-HE-Meta: U2FsdGVkX1+teW48BUwKpYSra68l4fnOlOCBOqeMmqm8DZPmbc0k1XhiOk5WupI2j6LKKZGcv00KKkx3JwjSAjR7RpsYe7cTdpsFZ9UDWSYQI0o0Q3OdDfD++9dCsVQYNOtjFvHvDKkXYKKCAq8tG3419jAbBTqKv27EmTgCs7C/pJEEJcfmdcuXVGR83iXXMUx7Ylvmc46KiqlRrQlViMPXYhYKyNbbEYjZPkSL7utgd5B+rkkZWQO297vEDdkA2XmzyTQwL/Xjvuwh9G9kktXc082AFaR+qJm7XPnuLm656oihuQC09Oaa4EaG5dmqrKbM+V0M425xNi+Mdp5Zq9caH3xEHDC7D6yGij2BrXOF0ca2TO89ubPpqIoYg/jeLRjZ1YqBIQJ+oCK9CvlazJD2oW0PvfGHtA7dCmkacVmtHgwgAR+3IN1+gaQ80AxINcKU/DnsyxqZwD+qyi4ra9tzzbZHlLY3je2byvEtHsPXKq7QW+9yUs9W4WgKN8ns+lm8EhDhenCJx79ZoorXMh44NObSpgv/XrEZEsOVkeAYEfasPgeFMPLw8onmNlBFVk6ySvHJvyNO48Qbo03o2muwr8YVW3SzKyGp66jcdAtfVvAE+ubBp55IAlJ6ijREn4hcVMHuwW4Qz2KWm3+A5QHU25gLqEbc7IlNnZ3QNGageoiuM59DTBC9fvVPU/DEGeLuvDRu1Ep6iB7PBiRISB1Fx3slU1zKh4JAmK+uk/08bve/bfmh5jDZ/I7QP6FqWksnT2uKD6OYEsRM2I1j1wnohRDeNmev8pIieBhCd5HM3X8WTczKWDc1CIk9oTtHjNbXSdomir7HZzAjWFIedFVchsQkf33aTywNstajzkQJ9pBnhOYTb/TRac+0nFhfxQAlMtSljVuHQRjan/s/qOOPmhr0YUArxuzwzC/3eGMEy61XAwuOdOAcvQd7O5M2SskSn79ulYCmSxUEPh0 QsAaS8R8 q5Nc5oy8p0blTDlV6QLJicVGjkzq0wn3Wxd+DSywTi2aJb234uQ3CzwY6yvFvyxBQ9FqkfpLP1dn2RvXM13zDrUFExxl5XXuyVTYvLGvfZAKTPsXW9dR1WS/FKZIDnNIAjN7IryMt5NuWIfrelOqIMzecYnIBqDYzY/2cAOx+zCLljG/NUOdFppgeJ04EnsBEELJYZ6sK/yghzPL8aXgrqqyzXWRKvRqItFesrk8B0Sxpm0xvtxK0RF4mvbwBp0cs1Rg0Ou/A6UFR2Z792kIktDZqH79NrHO3/A7Fc/1WgCZXurlEVEd5CA3O0S/8FN1+BgvO1TZhi+gTOMolxBSK3FAtZ6+eiuFttn5OJFulvKSHog6i8+snWiYYgdD5GM+02YnA45/Er03XZHvsWFn3F6DeUaz+PghLd8mXd+YthVo4tfEOwqTgGeGLtrUPJST4P7jTCxcJ5U7BV5Rz021wkTkTVA== 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 Tue Aug 20 23:57:14 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: 13770664 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 5CC48C3DA4A for ; Tue, 20 Aug 2024 23:58:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E9EA6B0093; Tue, 20 Aug 2024 19:58:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 346E46B0099; Tue, 20 Aug 2024 19:58:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B07D6B0098; Tue, 20 Aug 2024 19:58:14 -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 D362E6B0093 for ; Tue, 20 Aug 2024 19:58:13 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8414EA78B1 for ; Tue, 20 Aug 2024 23:58:13 +0000 (UTC) X-FDA: 82474290066.17.4B7B058 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf02.hostedemail.com (Postfix) with ESMTP id 8E74F80011 for ; Tue, 20 Aug 2024 23:58:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FMWW41EM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=dvyCKn7P; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf02.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=1724198231; a=rsa-sha256; cv=pass; b=Mer+Zt6v18hP+P0ic2oiDVo/5To6bAFeN4d8GkAYIIarrFAxr/RQVk0U2CIKJqkLlSbrQ2 TBfQPdwfbWRyYg4tIVrqgae1eewS5Ep9l6YonU27d50znZvE/iHLPsUasu6+SujuFj/MYa WRplZulN8yzJCajSEX9lbbH6WSvpLwI= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FMWW41EM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=dvyCKn7P; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf02.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=1724198231; 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=56X8T/loi3DH4YSXfB6LesmSMJY9P0HOSK6JHflO3dvQ2eDtk1xMAZC23koncPNWF5tDak K8acYm04MYOZieOByrgKxxP4w4Dr71UigmuyUF+jfHroAqubOwrb3Un3GTRMsoeTy4PSd/ TKuY8qQfghEDsUqBXdI2k7QewykQgnE= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47KMBXE3005239; Tue, 20 Aug 2024 23:58:01 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= FMWW41EMAMgYELv+Yrv7T7SfOamffpGVZbFCt+Nev/BVC8zc0GA/9ub36ryyuHPS X57WjyKDt9K5bkk2ia8XgWk2ytqba6G8xNbMd4rAgwP/ciykduqkKFgP1IgSIqEu 9Vq74lUJtiRqvs07lRNUTJXhxVFhZUyQPqUCddtLhDO4xdLk1O05iHFJyq1jhzjF 14oBayeSZ5asgpgJ+9Co75a8mBePSGWpmM2HHVEN6VVVTLufWLjX1Rfyr+vwQ4jw s103NQ2cfLznNNrO8HD24OJYzKIOXUbgG6oy4CXhjiWnLKLp1VWGiLI86P2RtrrL nCGQ/QEjcJZd36cvvxBcDQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 414yrj0mm6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:01 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47KMJJCq040079; Tue, 20 Aug 2024 23:58:00 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4153u2tbed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e337Fl4lN/Q7vg3uAuv8DiybjJUJ+Uj34n34Fcde9vA6yZ6GE5uFVmlorZWEFCDfYZp4+gzFmpMVTK6OFqzHfLfXwIiusfG9SMI8UA0Dlo1TDTENDwLvmsgk7GDAxtA+zVqQUfD2gikBL/wI89n+uSDljte1KmTp//1A/9Ne73SK/O12bYY57V2HVvElFWO3ofSVLaudjiPpQb2/JKF8PA8tj1wfK24yMhefyvw2NNEFdeQS6W+kEhUXOxjiYw2lK4f8qe57U7emsjvIuc7zHn7G1EZBVfDbNPcuYJVpYG3YCNt4+iWPqyKMk/z8tnP3oyUiXsImUVeGg5ZCP8mc7w== 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=xAt9hqAmvH7Uid/ZEAF2IvEh6Inw+e4LZ4gOtSGSr+74mlJJ7UUrU9pq3ktRbkzTFj7JYQ67yljkRmWW4ModTSHxas/RbKRAZ6Xh+sMYzCH7tafJxG85XNpXo+IwZAH3RngFEnAxawrAztQVPmvXlEfnfWIHDCjukYSj/Dus2+MaYT9doh3825M9GfiVYh/HvqNKo+e3uWY1QPmbP3CidvDc6XFJ57wlyMLbhhNAKjaOCUWuMI/Yvk+Vgvb1tO4qQQhHd5/0t+OVwBk2GGwznzD8zVR+lPfDAHb4SZY/sGf2sMTXyrKsS+uuT3NOd7tanVBN6hgqhSTzEpugfBaLrA== 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=dvyCKn7PveBsNQCpLPh5HG/IBBUfks6lCDX3I9horSN3xxwZtQyeGozRc9grGn3xD3DI8+MQJiMRVRwZiRKzuzguIC2EE3nUi8+knKpQGzTIB3fhIemqc+ASqGkwdGjGF7lxvuskooAOdKZwE+sM75yMLiPZMPdjTJpqDx/ihbc= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB4757.namprd10.prod.outlook.com (2603:10b6:510:3f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:57:57 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:57:57 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v6 05/20] mm/vma: Introduce vma_munmap_struct for use in munmap operations Date: Tue, 20 Aug 2024 19:57:14 -0400 Message-ID: <20240820235730.2852400-6-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0427.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10b::18) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB4757:EE_ X-MS-Office365-Filtering-Correlation-Id: e7759fb6-d8ec-4bd0-bd43-08dcc173e9f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: zh7AF0ygk8UwplSDpU7ZyO2iC+5/6YgPO+hx2wUIGCvbkT/1TBeobaZRaCme29c9GAeRWepSs8RdvsqqzDUe25hIecvyHqDkM2ffrJIZ2K0RKw3sL+K9FziFCWK5796VJuIFWZMuihTrFn2/Oyio33a9SO0A0CBVOcR8McvvVI8YowgME7oaglo0iUxlT+zCx4Sb8zDHmnKs0T4zKnCsn1cKad/frmm4qVpAbQvq1X5q7nlAuvPwGTLXk6ERVcmSUQhOrDyT91Zpb4q6O5HWzcv6mIDmTDWIYb8dh0F5nwdpp73jsCCnOJUe765oMZbP2qX9qQAH9IZAUTUkltrWwF1YonEk3BOMtfwm2GklXiy8vXIAMBytEqVYv7/phdx0iBzl1Xn7nAfo+9TeTD9QcpfodNNBf080c8ZzSTyQ4dhu4Zaogv5No8rBkuQgHKDxeuVwxrHwVn38PU4duHG+/OZmugGXykuZH0jKGIRwlGsxSjvHHRddblj8gMdTWLUzMTgECeI3+0+ROi/Wqk8tKoCaOHqj4Hec5V9Pl8Rbr3Z8TL14tnJ9ni8XgnCQms0Dv8toEvpiT9ZDfDmeYTzQzGssEtzW7pOc3wVe7esTPFY6m8+KPqTcxUmBNoVaBfEv41s/go8R0+IvYRFxqwDFvlg7+NbMfkKPqr9XTW6tcPQ7hEgBb1rDICWcdDvNmbW9FBszlTCSAEZ6DlXUdj8cCuWZPL/GYtm/qmzu+EkxLnpdBXn7A31L96SzumJ+VJgiDurTqYShemWnzOMfa0RbpwNDZPPD2UNTS60cYor7jtdE+mIrAQeiHV8XQsFBxsUAKbO3HGjQ5rH/3cAvpXgHVNOyilGhOa9vK5KLAv7nq41b07jbEpwK2TPWvIn2QRaFy++WuKcNyzc3gCoYKJcbORl5Kn4Pp9OINa3L6jZoMvGIfENjO22TC4y1AF/1jzzduyQBVmHCKyxbqB8lm3sVcc4xbTYwEXq8cqoovKqM17SYvBUo3iPlV8B9nn45BuxiDBBucmpczVNTbffEIiJ6yRGpSMaARXqW+y0FU5pvdK1ATtrP8Z3JHRd5Clp94TneKo30a5DcyPFVMoA1qspoolQXE5LSvWjsL+j0tEGEoEBuRyOpGyucZoi908xjYUf9AzuwRs3y1+O/VIYA+rX4cMqQZpqlp9rEHKKHPt1LdPQY3LQn6rfEZmoiqT0NUyBB+Xq43vRZ/uH4trjwj+KZ5fctmqnLuVFv3sJ+BwFJ6uxEjeCn4tXjPJpuO0VuTsPlbYKLfhV7/bbjNIN5jysT25RNp0ylMCpeSyJD0NYqLJm9YoseGrmTnc5BWV1YiNmelegUt933JkWINIXO8Y+gAQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-Message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DfVx8139LV4cSOpTGT3gUwCEs+PiNKU4mAQ3NSDE0w0weGt4jPYmB0W5Z09xfS+p1L7ascBPAcCXy0BAmneH7uDeJhluxZDSJhC/d90RRN00MVTNqzXkHR38JRiHr9mHZ3tvoOi6APkF2w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7759fb6-d8ec-4bd0-bd43-08dcc173e9f6 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:57:57.1445 (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: Gh/cRlWWkbniJEuHND/A38nn2+C/XU5wEGjzrNEsiyZdwLm7U+UYjjLoU7GjdvsGEDauVNzUS1cxxyZ7if8Qyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4757 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: ZcCOpgqyqCSYHzYXJZ-Z_8CQ4o5vUScW X-Proofpoint-GUID: ZcCOpgqyqCSYHzYXJZ-Z_8CQ4o5vUScW X-Rspamd-Queue-Id: 8E74F80011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 55m3t4h4iojxpg4jtbrfzku9t4b6e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ftkz0/usoknNOT+YiHEme4k9XyTSeH0ew9btxgpdepVQOQZPlru0zZJDc5egqE+cCant1UR1kAzuygFWu7GUv2gTVr+jiabIULgzrDlYA9FXbQm0qRAGWXMilS7zM5BorRm/5ScsvTJg1ax/aKzGIluoLBhfhLbClPuJoVTyvEsWWDP0uqFZd51vmRI4fwjGNj1FApTmNPASkssGFhhMdN6gpMbTV/VpOeUzU/iaSenMjB7Vf/lSM0ibYp53IxHWUgUxHYPUIdhLGqFokrWZZZ+dqQs3AFXiuJeCzZT1eX6bgip5LNYAR2fvFA48uGAEVA2A/jekwH0T5IW+hPdXgfz6907nydVXMLVUeApvIID/GF2Lt8YdFNtSqE0DJET/baDskgRs8pdGFLcfFkUXAVCxTb7hiqs4QkewBOJiwSyiy15mBDVRxsO5+GswPU4I0wWtecZqNSik9lbjpmBz60T+/P/pIfrzbT1DHrB9f4/KKH+WVSSIlhZP+XRhSHvn0 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 Tue Aug 20 23:57:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13770665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 867B6C5320E for ; Tue, 20 Aug 2024 23:58:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71DC86B0096; Tue, 20 Aug 2024 19:58:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65C996B009B; Tue, 20 Aug 2024 19:58:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E7696B0096; Tue, 20 Aug 2024 19:58:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E22586B0095 for ; Tue, 20 Aug 2024 19:58:13 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 85B961A06A2 for ; Tue, 20 Aug 2024 23:58:13 +0000 (UTC) X-FDA: 82474290066.20.BBD944A Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf02.hostedemail.com (Postfix) with ESMTP id 572E08000B for ; Tue, 20 Aug 2024 23:58:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mjDXQUAA; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KXtX24xf; spf=pass (imf02.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724198250; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=umj9YQLZTIAO4p/q1uoqol053BLAnZXvnRL4qkPn+G4=; b=kXMSGpt8ftEW4a5Wcwu10fzXmG/5oq/6STh9xnEAKetRi8/CPAqxB5y072w3KLorYru2ud g+00gXzFkB/M0whAFSWUP5LM+rgY+SKFt7IK5uWaDoD84GbY9Bp7zwpuwwdb0lnxCMbO/a 6/vu7DTPHA+h32bBRlZLEjWVbdZLEu0= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mjDXQUAA; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KXtX24xf; spf=pass (imf02.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198250; a=rsa-sha256; cv=pass; b=vVfIUc9//CMkK6vh4ce/YrSb3MvrE2D6wzlAoCTgwQZa2fbXpxEQBGDPUuLCUnDBiBInWE oqwq+5l7VeVPE3K2SNJHkibPErNWSmiYdI4fNtMAQxATIfGYYLIyAPWLWLxD8odYHXCtpm KaDIGjBkUT1zzrp4cneuR3EfyvBNtAU= Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47KMBaE5028808; Tue, 20 Aug 2024 23:58:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=umj9YQLZTIAO4p/q1uoqol053BLAnZXvnRL4qkPn+G4=; b= mjDXQUAAtKxlXA6Hzcuybf5sAVSpYe478Gdo6nM5Ei6lZOsFEqs+SkxypGAhTM8i V1PdLSFcspy4HsISdchLUkzDRX9RkGEKTTe+a+CrhYn8vdEBPhd/uV/ZEod+z/6q wautMDQ4GT08C5YEe9nlccA/FoNJnFO0PfA/KmKZeTrvcvghWHjzz4vyWGM+nJIR YT7jnHdG/XjrQOI8mle79By8JP16tEzMtqhYdYjluYUuXR+rUqeID1HEENEB9VU3 lwLEdUD3ElQiMOta9bFYVYCXdFmlFShmph5kOcslrVlI0uKr/YQAhu2cpsdFBhc1 bLoTZtEsotdIP7HcphaDsA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m45ebsw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:01 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47KMJJCr040079; Tue, 20 Aug 2024 23:58:01 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4153u2tbed-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zSSjQ84ghEPr7NhQ1BgtgGHvm/yrCn6VhQT2TvjAaY6gsfnLEnJgy3PFWcm3Cm4S5W/E1HxZdSQj2KEUByMuJjSiio7XopuSqgrbnzodOWxPkNi9fzRA5RXB85ibQ1j+KT+QiV/gEB9KGvFMurMqxQa9Ea6r/tIGqI9NiLynewcq/8FPvQ/QgvIp2pp9f+J40Dg3LcrBgzA2RnA5rzynlX1zvOq4sk/orJgnQ4lfdE7RdzrVrftrCLUll0q2as+UWvMVVFiVZo1IBEGqvePTSo/YQm6fhwF5mBRbeNJhN3vjd8KXSCgRHdiXeYVVfGEpuO5xWxt2vCO6NGYdcpGSiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=umj9YQLZTIAO4p/q1uoqol053BLAnZXvnRL4qkPn+G4=; b=rUTm1MRUvGpJ16wS9Rj9GAaetNT1nXLOJmgeexvxvxusyaiCnNxLCGcZUMlKgIiREP+0ybeHLxeooKlflf1LZNMtLqoyVCTFmP0NgTF+ppaMsrRojdKZKuvOGiOdkhWyM0G2Wu4nX8ccC3THMC3IZ4DgwF8s7aXY+N3P4056np1qMg2ENdnAx9wZ11PWA1gniltFxQUnOv+ll538CCgmVfaQVxmVsXQhpAjHgjTwOHKrJ/xv99Kau4FXODozQ1SNF+tHHd865trSdooXAS7v5jk2yae8BdhQQmNjck8Y7GLhj35ZsVRu7yYKnog9AVGDYFnXrNqOpghmhyUr8LAk8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=umj9YQLZTIAO4p/q1uoqol053BLAnZXvnRL4qkPn+G4=; b=KXtX24xfgPKQP0J48zpLvRdVvZMetzokGd4CDcEfs4mff1QIRShvG10VVJquz44UkXxsNE/Z7OFBP5MEO4aFrHN63GDIqmz6SMNsPXnZULYSzXe9E1Wd03/YuhCicIRK1rsoMaaonBE27iJVqOytsR7aBx5tBWEM4bVTHRZt40o= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB4757.namprd10.prod.outlook.com (2603:10b6:510:3f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:57:59 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:57:59 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v6 06/20] mm/vma: Change munmap to use vma_munmap_struct() for accounting and surrounding vmas Date: Tue, 20 Aug 2024 19:57:15 -0400 Message-ID: <20240820235730.2852400-7-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0419.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10b::6) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB4757:EE_ X-MS-Office365-Filtering-Correlation-Id: 269f7abe-bee4-447a-c2e8-08dcc173eb06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: bTMeUvEiUtvzTkiDVg+af42A5W9kN53AH3nn6uCghi8k4V9N0uWDuaFiplilMWegGNJKgEwm9jHreO2zEfdKGxBXTazT7+k2Gh+AiO8QK/oNul8Yd8q3rG8vsAW7eXQwNbj+ykGsBWcd0KioQmJPgZugfCXiDX1RtrLge9/y5/S3WRxR/HYsbs7LhWPCoyg3RSfp+WG46+JcovsVoen4ETiAIrK8PdQ1ix9aARN+4lM9epoLtI6pTuBLHrtMUf3M0qnvZTHgsimhI9fV3nutTLD29Fmm8il123kE/HVWMu8zF4fGowgNn2Vz+HTU4LNetmwdAbMVJAK8kQXyEHD0VkaxwQuYXgomjTqQ36X44tQVZPlooCBylP99pMlJ1Zad23XdLJ/mvkCzEwNCbBbp8vHqyBIoNdozfWcL4YnlGk+PqNzoZZjgF257t7Yonk7GcEn5SYzczbm66ljnLNCEyEutvC8OYrlhmXkobc1LQDhMqaEVkRklN2lbBVaIGdkvw89bTI5efImzYWwUtJYbWBOBY70UXpoeosNfF3DMICZxSFOUOUHAnD30ZqEYy171EBdLpXIYrPPh92vfZ6GuTKsJ2rPRC4h+1xg5rHGhixo29f+1m+N6YUsnzhFjcAi25DZFQyr5JTSeVVHqqJFKHIRCLgop6hVKh0YUi+RTTSA6TnISpXb2pCAVcEkvbq/M2kcK5/Pw3xqnoxKwtOc6VGOItdwS8UIpipRAepw8hF3kUk6l0AYbwaVVSgKpf8Ucmxljx+Q5W1Mp7oPuB5T4aV/NBzKk+4sidsQJcjCgjGKGXbTXL73lzQt1x8itl+nJ3JG/I90f3a44Cdxo9K3JH81APgGzt3X0PE2DXMtp2AOCJ1RRSLlMc9yYpXfQT3Rnfd81PKRV6b791tzZDiUHKVztGE4ISbPXnkvZQShI6zkanS/FwtM+OFc80qyFyTgJHnU03S0OycyIuDU9WUyn0keuzOy8xWdcdAT5ofsR8T7/2iVYB73Wf66A5pf7N1RmC8+p/5TUfkN+w2kqAPk/86A/00x5fR4pYgX+6fn0n3DC+PKxx4Uozphp8g4owFPo4GCnwfWD6f7+psCbNN3kGnXhl3WARpLJmT3OT3i3Wm6KjVmkTwONGP8xhiH1lKPL2Hbr7TNd5XsgHq3pqHKkx3kFYYkGKXPvL9xDlbH5eeBsU9oL/2XeMdVkG18sJXNZtyPIdvjWz6Iy6ZHquHGA2sH5EuU2Cr/BydWD9ihC9YHWWUgIzWlyFKLeph94MwVspukhV6q+oA1xfvjf3D1zlJSc7X1oqel/z7KFnKsExgZ0IUIRMVgTSAj0KErff2/tDVXObQ89abrg1rUnnQLA9A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:O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jdS1hPNqMHZ0poGYKl8jr2Sv1/IyVPQzzcNTex6jEWbrZ/yDqI1AdOJujkT16AhzzlBsooLBxSte+H20Dq2q05FEd+W3am+Y3X+2zUhSDPZ39gjtPwnD5id4lWClKvkB0WG5kOfokv9v4K81uTwtc1R+gzDBEXaXOqZHQEsnC++mOskeJgCCHH3IX2M737lDRLFkK2xZRqHX/Y= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 269f7abe-bee4-447a-c2e8-08dcc173eb06 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:57:58.9488 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NaI1HHgF5BbWIXM42sE5dI3FoCB3ZedyS4TjJ0cI/mgipAYE1OIXYuCKFi1jyY6WrpVnV3Lg6GewcGvKuxz8Pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4757 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: e7p5JRB65i7T9U1pTr0Pcr8QkAaP8Gnr X-Proofpoint-GUID: e7p5JRB65i7T9U1pTr0Pcr8QkAaP8Gnr X-Rspamd-Server: rspam03 X-Rspam-User: X-R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y3H6ZjDWawsMYBCFqg3o+od2J3FRgPDkD9pV2U5jnrp5+UPSTnhsGI3IkhFz7vlHwp+f+nLlEm98kmWdlBgpPhu7UnqNYU5+AI95dAN9T7RZNTRfHFPdKVMx415bgQHDOF+9692e5/SRLCc5cvFlsnOxUtwZ0cCblyV80PjREmK7h+suRlCIol9J3JPjbTVDgBDhGH86CPBD4vN1Td6MTnKhu2Agj0Ofi71UFQAzfU4LrzvDWtCKJQjxR4Fx6lIolWgU6xKi91Hein0+2LG3jWESSEMEPTA1pZFJBV8cy0IpMVH1ucjuXBepgNmg9zchzDzoC504ZwCIP8qUC6MFICbJzvOKVP48PIDX7v2weMvlKuLYBombPitOCIwB2dqlxerqdxRNBpfH+We4S293FHTxLrfrghomqLrT6npiWHPnLhX5mXIwqI2XzdYO11hU+8B1uEKOjwdFd3/D0tsT4QPmgJcUjfdSiQWE5fnRnqOJPBGwQY9bB9bDyDnrao/wkTF3TvsPv0tyKilUPQ+0iYLlycr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Clean up the code by changing the munmap operation to use a structure for the accounting and munmap variables. Since remove_mt() is only called in one location and the contents will be reduced to almost nothing. The remains of the function can be added to vms_complete_munmap_vmas(). Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan --- mm/vma.c | 79 ++++++++++++++++++++++++++++---------------------------- mm/vma.h | 6 +++++ 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index e1aee43a3dc4..7b8b8b983399 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -103,7 +103,8 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, vms->unlock = unlock; vms->uf = uf; vms->vma_count = 0; - vms->nr_pages = vms->locked_vm = 0; + vms->nr_pages = vms->locked_vm = vms->nr_accounted = 0; + vms->exec_vm = vms->stack_vm = vms->data_vm = 0; } /* @@ -299,30 +300,6 @@ static int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, return __split_vma(vmi, vma, addr, new_below); } -/* - * Ok - we have the memory areas we should free on a maple tree so release them, - * and do the vma updates. - * - * Called with the mm semaphore held. - */ -static inline void remove_mt(struct mm_struct *mm, struct ma_state *mas) -{ - unsigned long nr_accounted = 0; - struct vm_area_struct *vma; - - /* Update high watermark before we lower total_vm */ - update_hiwater_vm(mm); - mas_for_each(mas, vma, ULONG_MAX) { - long nrpages = vma_pages(vma); - - if (vma->vm_flags & VM_ACCOUNT) - nr_accounted += nrpages; - vm_stat_account(mm, vma->vm_flags, -nrpages); - remove_vma(vma, false); - } - vm_unacct_memory(nr_accounted); -} - /* * init_vma_prep() - Initializer wrapper for vma_prepare struct * @vp: The vma_prepare struct @@ -722,7 +699,7 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach) { - struct vm_area_struct *prev, *next; + struct vm_area_struct *vma; struct mm_struct *mm; mm = vms->mm; @@ -731,21 +708,26 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, if (vms->unlock) mmap_write_downgrade(mm); - prev = vma_iter_prev_range(vms->vmi); - next = vma_next(vms->vmi); - if (next) - vma_iter_prev_range(vms->vmi); - /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. */ mas_set(mas_detach, 1); - unmap_region(mm, mas_detach, vms->vma, prev, next, vms->start, vms->end, - vms->vma_count, !vms->unlock); - /* Statistics and freeing VMAs */ + unmap_region(mm, mas_detach, vms->vma, vms->prev, vms->next, + vms->start, vms->end, vms->vma_count, !vms->unlock); + /* Update high watermark before we lower total_vm */ + update_hiwater_vm(mm); + /* Stat accounting */ + WRITE_ONCE(mm->total_vm, READ_ONCE(mm->total_vm) - vms->nr_pages); + mm->exec_vm -= vms->exec_vm; + mm->stack_vm -= vms->stack_vm; + mm->data_vm -= vms->data_vm; + /* Remove and clean up vmas */ mas_set(mas_detach, 0); - remove_mt(mm, mas_detach); + mas_for_each(mas_detach, vma, ULONG_MAX) + remove_vma(vma, false); + + vm_unacct_memory(vms->nr_accounted); validate_mm(mm); if (vms->unlock) mmap_read_unlock(mm); @@ -799,18 +781,19 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, if (error) goto start_split_failed; } + vms->prev = vma_prev(vms->vmi); /* * Detach a range of VMAs from the mm. Using next as a temp variable as * it is always overwritten. */ - next = vms->vma; - do { + for_each_vma_range(*(vms->vmi), next, vms->end) { + long nrpages; + if (!can_modify_vma(next)) { error = -EPERM; goto modify_vma_failed; } - /* Does it split the end? */ if (next->vm_end > vms->end) { error = __split_vma(vms->vmi, next, vms->end, 0); @@ -824,6 +807,22 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, goto munmap_gather_failed; vma_mark_detached(next, true); + nrpages = vma_pages(next); + + vms->nr_pages += nrpages; + if (next->vm_flags & VM_LOCKED) + vms->locked_vm += nrpages; + + if (next->vm_flags & VM_ACCOUNT) + vms->nr_accounted += nrpages; + + if (is_exec_mapping(next->vm_flags)) + vms->exec_vm += nrpages; + else if (is_stack_mapping(next->vm_flags)) + vms->stack_vm += nrpages; + else if (is_data_mapping(next->vm_flags)) + vms->data_vm += nrpages; + if (next->vm_flags & VM_LOCKED) vms->locked_vm += vma_pages(next); @@ -847,7 +846,9 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, BUG_ON(next->vm_start < vms->start); BUG_ON(next->vm_start > vms->end); #endif - } for_each_vma_range(*(vms->vmi), next, vms->end); + } + + vms->next = vma_next(vms->vmi); #if defined(CONFIG_DEBUG_VM_MAPLE_TREE) /* Make sure no VMAs are about to be lost. */ diff --git a/mm/vma.h b/mm/vma.h index cb67acf59012..cbf55e0e0c4f 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -33,12 +33,18 @@ struct vma_munmap_struct { struct vma_iterator *vmi; struct mm_struct *mm; struct vm_area_struct *vma; /* The first vma to munmap */ + struct vm_area_struct *prev; /* vma before the munmap area */ + struct vm_area_struct *next; /* vma after the munmap area */ struct list_head *uf; /* Userfaultfd list_head */ unsigned long start; /* Aligned start addr (inclusive) */ unsigned long end; /* Aligned end addr (exclusive) */ int vma_count; /* Number of vmas that will be removed */ unsigned long nr_pages; /* Number of pages being removed */ unsigned long locked_vm; /* Number of locked pages */ + unsigned long nr_accounted; /* Number of VM_ACCOUNT pages */ + unsigned long exec_vm; + unsigned long stack_vm; + unsigned long data_vm; bool unlock; /* Unlock after the munmap */ }; From patchwork Tue Aug 20 23:57:16 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: 13770667 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 75627C5321D for ; Tue, 20 Aug 2024 23:58:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A29546B009B; Tue, 20 Aug 2024 19:58:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AF846B009D; Tue, 20 Aug 2024 19:58:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76EDA6B009F; Tue, 20 Aug 2024 19:58:18 -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 43FF36B009B for ; Tue, 20 Aug 2024 19:58:18 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EBAF8A0759 for ; Tue, 20 Aug 2024 23:58:17 +0000 (UTC) X-FDA: 82474290234.17.E99F6F1 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf25.hostedemail.com (Postfix) with ESMTP id A6CF1A000C for ; Tue, 20 Aug 2024 23:58:14 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oAHegXJw; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UtdD9rDr; spf=pass (imf25.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=1724198254; a=rsa-sha256; cv=pass; b=UH2iAlYNK0DMIG19/VoDzaF88LB5k/hM2QBiaEh6cNPe+35xoPvxKC4cktCn95RFsiMtVZ PAavyqsy64prLSMvnYcaGoo+YtQFQRRI8g6L7IOoll4r0IlaXoZxmmxDF7+tjewyvOkODx XETsBm7kk4bF15TMHssN9u6mVtra0Us= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oAHegXJw; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UtdD9rDr; spf=pass (imf25.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=1724198254; 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=PDNDdIK+17zRq4WUoWjBIpOtq1SQCKc3/dZCfu/MLyo=; b=lySbbSKRx3hRYo5OpNhtDA0tTSAV3rj8N6V6zDyLZjUOTtSB1HkONZmMTndDdweHT2dXH2 Ncztpl6Hi/vACvMT/ibXjWXAla7hjCnM4cO7HZUkFm9aF4GQ5MMa4lzYpU2EB4Eczv8jVd q/+vC5Xs3DH+SsHprX+av+xTnsCcQFU= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47KMBXE4005239; Tue, 20 Aug 2024 23:58:07 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=PDNDdIK+17zRq4WUoWjBIpOtq1SQCKc3/dZCfu/MLyo=; b= oAHegXJwpixOVzpL1KfcNL3FPCFLegTqsd2AHfzv17sfC/tlBKI6r64uf5YYMIuD epFqqBCRl9riX0OZWwkcWT7THClpDM6sbY1Ha/vRo+8N0BMeC9VquN2jhInOVlxN o2sq71VyaCkgQsDtxeD2oMi5cF+dPJTf93EuwOVzzy5sfkVohJ3isB3zKAFvscAn dbemQzjvXzBMZIQaKOj4J+u7wwp+z/KC789k8RASrVhWx75tDR+SI0rTJJqKQZ4C qLEZ9+M0WSp4nLmwhSBkZahBkOkKV1bQxef4uM9zcwDfCJLv0F13ZY70xnS3iVqH exN/RbjDQqEwa1C+CX3AZg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 414yrj0mm8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:07 +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 47KMJJkH040123; Tue, 20 Aug 2024 23:58:06 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 4153u2tbef-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aAcQaTJKyGRekAC186wA2b6DXWrmx9RdwkMhoSAfIIIC0jRIyC2k0uRRABxdhMd8c7ZR6dnZT/lV0CATFbQKN1wJCGw9TI30Yopqh8HNrxTd0eLfLTkZ5BST6PmSMvW7zVYN9vwws5s+Sx6UdrrDwI/UYpxMzlOPsRHG7kmsPuhZ1BBkvIe4WaZA2RUa1vog91RcWnGhCObFRiXNaBj62MwcDar29ObshjpeH+6SY0bzRI0XYNcJaTlrumX1t0YPJxN/K7kVTwsyFt329bbT9kBJulV2EWeRqZtxPQ/nNGehC/ZTL+LpmvFB5XTlPh/4Vg+gjiTbpBKtSQUFFvQWLw== 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=PDNDdIK+17zRq4WUoWjBIpOtq1SQCKc3/dZCfu/MLyo=; b=xXhLpbJEJE78RFANFoNvWM9o/l9lPkMGhbmKWcN/udfVsvYWTsGl1qKjcWQb9cvBcjMUmQBfBC66pNZdhsVksW+6k/efPTR5DgOXYO9sMxdqKbkli43IRICETudiny74QgDEY7dsI/5MY0tb8kHb5Ksvy1gwRczZx+HP9XfY+BIy6qOVSxCcEswBxOvHouvqJRidjo6aEiL/1qzM+0+GNP4XPikXXFqKJGRJU4YrcZ1Fa3LS51CSNJmFUiil2zePlO9kaWTLNUCcVXTJZQugjyJ6Ihaks9CYMsnTT4r6IMD2SH3M0ow1Lx/gzgghjaglwoI3dgWZgdcBy4P+JapZzg== 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=PDNDdIK+17zRq4WUoWjBIpOtq1SQCKc3/dZCfu/MLyo=; b=UtdD9rDrlEpXnv93zcUNz71neSFeWfOzf7Bzjhjyz6o4HWeet2n9WhpwXKHMhyiJ0Egp7Q9GrvnsjUzNYiXp1kXY7K9Iug9vkbGa8upN82IY+qpefDf0CP6KjJmCDJuOUL4RkLH4erZe/HY6x5ppq1Jxk8lNEk/+ecKM7tX+heg= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:00 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:00 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v6 07/20] mm/vma: Extract validate_mm() from vma_complete() Date: Tue, 20 Aug 2024 19:57:16 -0400 Message-ID: <20240820235730.2852400-8-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0021.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d1::27) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 14471e0c-be93-4fca-85ff-08dcc173ec1a 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: 1M/5NT1fSs2l5WxbOYqVaJ7DoCP4Hm5q2H3AMcAkLJOohup91HUGazI9QpibU5ddw/OOMGTM0f4xD0xFHtmxLmV0TdiETt8Y776WwZlUkgGmh9umlZ/6Hy9pVdMnI64lqE9jrqZDs54uRAjVHbULLtoUZXB8xNKQAP6/xyc9RsHHxgP4tp2glCXdKQvUNKH1M/nF/ulmKJRCx52GNAN0sd9ksuHfwqiu38hIaoRvGs72afJgUmqcxvpl3le1rnU2FCG7KOOwEM8oVB0eweCFRd6xCITJWUzlpGTmYyABQW89ex3jRewjq/C7LcQXmvVPUF0Yk5hVOThjlubN2MIx0hWUx8JFohmV3ytO4E477XhNL4+YhW8N1p/CYlkFUnv4+aWEI9lzfI8zz+XBeB6uZiNL+CUE2ANyPbYx7bIT6Zi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13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 016ydFlcY+oh70lQV8q/32rVsHSSkN+6Nljzm0P/RqBTt3Ud7QCQoQyk4pnbP+CxpXQVIUZpQpL7+Ix88PJtv4Xmyk5UWGhcZKcbwHjghloArb6ICjxYEb3ANboJbrZ01FiLnYtq2/78//0IKSi+cpaF548/fCoIaMyiSigmLg48HX0i3ozyDo6npHpitxAOO2i2FmwQMY3snKxX3L/jzOkAFNLMaEvgpMIlElKlJIlqhcNqT6ZnbvdFMZZrAmPe+t5YGEJhWNa1MSES4mKLSvvPznvegSjF5QjITYS2vl+uqHhYLahLFpBgtL+8op0Kzyi4GW86TbvnFi0aKtnI+2MbCL56L1H/a3gRXGX4hlIcG2I1xwEx9C4roHGJawmDmp4cfu7ILPkMF+20GZxFNDiHWifxc8AaeUcuIkrDS9GVnDuINDmchWvcdKHdlzU0og/KeezWJziZP2vt9SHacJqDH+c6eueFvuq2IPuT8PCE1VWh/CLXvTsXcrosK0prXzs7YNZb6qGj/0KwbqwXU2Js9K2l/Dh5cA45utr6yngIrbhYdVDyIJneg5Uoyf5Cl6WTcsd5+CIUpm/c7BglANDCvmJZFFyFWSA/JAc4v/+WFXHwbois18N5KOECLt3iCHVPCbpyh/ztePU4pgXn2vCfNMa6K8w2dvjFoTeR2xXsFMHyBERwITFRY3PYfqTKrEsAD4DR4ZZ77ZTBZBU34KTU+PHhoPl+IkZr6ZilrdopE9agGEam0LXO8+mIq7r/NcpzieYaRvKah9jxkpqv3HQcqshEigRpXs84LNgznCwo/ukp6E5Jvh8vyEDHhND5AW9IRini03uEJvVtIYTZqaBmdBpM5b6Jkuhoyr4Nc+cGnTGZr6gDY8jFwb/uSFo7IbtwkQPEV5H7igSuWtIZU000hTTQoaQiff6ka0oJThwN5zFtWarMXPESoMHlFKx/6uZ38RRF+2aODOmyABhkvQ6HjS5Jbc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va2jxAQId2OzH68kJVfJFMM4JwVE3N5SxhAvfOiFScoRhoce49KokmTbNqXU2bqlAQPr8yS50B6J0up3MIFMPf4Gf6rNpL9PS32XlcMA9PAJ1Tis8HaaGAFhUNxemZ9LeK6J2yqVnV95BU5YE8IRI6henluPg1ZFUF+IYV++a+fqS1wJCY+PHlPJgHDZ+Xg44FgiYbNgA/6SX0P/E4UMpO0KlFKyCoUJ1mvZJXrLFJJ/xKIweUYs3rUJY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14471e0c-be93-4fca-85ff-08dcc173ec1a X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:00.7372 (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: WYDfolKE0YHZmCl/CioxMJH05L+34pWdkh9dW1UDhdnrT2VUxeeWa/Me/8+JF3+qYdlRGfMyQKS+SAiN071RfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: CEVl1PdElzELRSizlCLErMBnW45nL31O X-Proofpoint-GUID: CEVl1PdElzELRSizlCLErMBnW45nL31O X-Stat-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2zRMRCv4++4ZmWlW40NXoq6FbZG TTh3W0v/ gjgLv1kaMBiRfbttYzIDVdomE/PEYl5tb/R0hQLMcLjEZLTdXYAOhEdim70DNlxbd2I+Kgnbd+PGKGOgacz4MD7jIEJFEqwg5HY2mU88kZtM4VymcU7ce4oog63zue74ZCpvYhyZ6LSYgvhD2pj/+8d+7uKoAIg/2Qa9QUS2m46sH4FVKHJNItZ63qEVAYOKYDL5U393qAzH5T1518ioFepmz69mHZa4yUk1U3w842NfhTXgutrGShO5Ry6tCZ/+/aAUnR/12i5Oi5QXyA/Hn5dg+pONQ3LrvNngV7J1xvTzNhWmryRZ/g81+PSGLyaFHO4r916yOLtrMudVIf3Esrm+PjBub8jpHpqmm++590CLdpWnB9BcaNHTFgOf6E3aaicFi2WkQV9ViOJsrDCXyBJrQFY8Xz4KOu4go6OmtVUFayQ1D+CfyfEKGdYmzS3UUQsjvyElb5/V3UQh4OcMaeSoc9YoMkMA1Go4MezvVPLeZEBIwgrEr/HeauZb0DabKaF/2/ALr0p3bIgiBiiAbHl6OoXV2C1Y3YKwnkFj6U9sPqbw= 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 7b8b8b983399..5abda4c49c83 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); } /* @@ -1200,6 +1202,7 @@ static struct vm_area_struct } vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(res, vm_flags); return res; From patchwork Tue Aug 20 23:57:17 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: 13770668 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 ECAFEC5320E for ; Tue, 20 Aug 2024 23:58:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 377BB6B009E; Tue, 20 Aug 2024 19:58:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FF916B00A0; Tue, 20 Aug 2024 19:58:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 088F96B009F; Tue, 20 Aug 2024 19:58:18 -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 D51D86B009D for ; Tue, 20 Aug 2024 19:58:18 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9671CC057F for ; Tue, 20 Aug 2024 23:58:18 +0000 (UTC) X-FDA: 82474290276.06.6D76639 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf12.hostedemail.com (Postfix) with ESMTP id 5877440012 for ; Tue, 20 Aug 2024 23:58:15 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Pnm5X5XV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YEZh1KgX; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf12.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") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724198207; 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=iJVGRCxsQA+PlCjzsouDjRGmhZ38YbZGxbQ32H2Ezef9rzp89qpNWhSM6Jb2DoDcbxJrbu TvWl17mY0ypktrHh5YtOheE0Fp89UF2n8RP7cBz1W/g2099qmADznpAqstBKGSwCEFBdU8 GzYF4S/U9hWP4vttUBROOkLpkXxQ63o= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198207; a=rsa-sha256; cv=pass; b=MT+T0fmXq+uGM847LDOHr/qjC427DEqYdTul7+6MbwmASpxR+MuAszE/FLCQUoPUVE4BOj klg7VOYWWNmwgV58Ij9Xz2lU/YsS24DV5d6XGhJUMjL2EzUobcJGOJCxtvRF3dn02AA1cr bSJBzLM/VshXu5EzB3/K98R2ACzfrj0= ARC-Authentication-Results: i=2; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Pnm5X5XV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YEZh1KgX; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf12.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") 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 47KMBWNt020404; Tue, 20 Aug 2024 23:58: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=MpWIi7cMQmivMHPf3/Pmr7r1vB9/WxBvplax7ihq6P8=; b= Pnm5X5XV4KrFS2zZyrDlkxGTHoRnuQlL2sFY7G2j/0Nqb9NG24VMom0WcueKChob 2qVAAgJYvzcZ5cNM1qWPaCtXxXPWvGqs6He4JGFo4GyJ5H8G52176nASFEkmFBV3 DEW5DxXg2H7tdJg6j31NT1+FhsyAPyz/Nrc4L6Fm8v8Z95uxN2Tg79azcnkHvt/j 3odMpDDjDjJtUO/I8BBOW79/7mbFmxDoZOxSB1I8LBHRUe9V1EJMDSDDyhylnMmT sD7+Wv4UbVfSWdxPxAo0InSfI86hGcwtGVZACVaan42uwaOD+pHt2ZIbv7dmw1Td zNwRk/pWYygwGdCkT7KUxw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m6ged1y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:08 +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 47KMJJkI040123; Tue, 20 Aug 2024 23:58:07 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 4153u2tbef-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jdF7PHGespa4a/IVKDr6kefniyRGoGg6qNqcTzebTIzrOkoViTprp5bRRfcj9OckSkZUiwHwVe0z4gYNsM1jr70BaP8kCCeyZ7PbnH1fC3ikvmfHnzXbPQQ3/BVQu0XiOJ9AcNAoU794WGWNfgLtwSL8RKnUcXvuMxFqE6jiHpHMShWFRry1x3EbensNmTwrX5VpL7JBgRaaOSMsqC4UN5d3eNMnz+qllUKKWCYVO+gmyZnSbTW+24TOfVlKgB/jr7FxL+7m0lkt0eoiUK9Rp6qFP/XbOTT0m/W8+wV1/MDo/4WUMrqhOj1/iduef4/OYVh3XkTXZITfWMdJR3zeMg== 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=EN2O6stzmMzONnBmYMhIKPGq8+9W+N941D+OEnEw+ul/gpjmZAFmXiFZhrs1/CVWQtIe1f2ZqhAUqNAUWRxGlVnf4T84VXpFC96Ljw4vvBPOKfBwr4TLNx3tw6lqMt5jgXdX8mcy/Xye7bpYe8wCHoaPLFkgjdmXlXWuqqAY2opHPfXH9cDjrrmrBxNp6EPwPZwsEn2D5ujA1TMgRp3SaCYwfov0/IRbahEsOVmRFGdY6BleYdC2ijESOSZwUiug2tEMfxsMtxc/qBDGVB5L4aYa6814453PLA8li0ul9ZEARfBY1y+UmeJAmWeZ/gvDDn/+P1oTHeFDpOgtwb6AGg== 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=YEZh1KgX3ZA+Z+1tu8PPtdNReCx/gJyRPcQhz/jiyt+WIZ769KjtR6AxbdoqvdMjRc1CNbwY0dsdHE853plnJ0GzGaw/fpxijpktKyalHZl6eBvFtJlLwutfPw1aj1Yl/6VUT2dqSrKNAWx73ENC4MrTTIekmB+7ta6yvAYksJc= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:02 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:02 +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 v6 08/20] mm/vma: Inline munmap operation in mmap_region() Date: Tue, 20 Aug 2024 19:57:17 -0400 Message-ID: <20240820235730.2852400-9-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0018.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d1::26) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bc5c620-27d7-472e-d6fd-08dcc173ed0e 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: kpuNkhYEzdYEhmlNxQYMuwQnjDfTjUpnoT7Sa1BQaih8ijN3wydnpmRgyPJl8RbWT7iHssIBPOmB3qxK5S/GXzfTYhZYPgmWYvLg2VnaAqJrs2mAt+gL4+D8cmpaYnEzG0ql9W4QBSNOPv1voKRavBNhgDUTzu1rMlouvNq8vzkU5XVrQE0zL/MbjZ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Np0oKKzSRqgxlZunOapNhv/6/RrZlsxsjb/c78i193rFCo58p2P2wVDBfdqyGECnhyVoM/CL9wF9mYA== 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: O36XFwkPlQ83TJU1F66dTN54hYduJqH+VocpsGmiePKAjvct+RwxSPyjGFMpt8DecMYgZZgOS2T76RPHGu9LGaMGbyNitMcPy6px4x8ximMrT/DvxrFY7o6vVrU0c4/p1VfybJL3TLi/PrkMjPzIjbjlpe3Ak1yGBaxzrKPW0KX7scvHw6OSBdWFz5mIHCZAWpPbKT2lrks/IaHii9PE6FGJ4f1jWmAIC3HIazTECOuoVlHDWbG3SY0S8BMpI24oRAtk3A3LxLUFVQm59XsTJNszE9oa6TyaJpteMgHwLg7Up1b+C8BhB3KfC37H4k5OQ4+UdaIrNfRGuqqIBE/oqENJ2RhreoSHpob4w12hs3fjBxT4Tf9naAfIRM1H5387qn6hlALlcokQNyYm8IwZfmYvLajhz1Lo7cg6+gMkIKzWodMnDaFpmvZOJYKt+f52O9hAp8fJfMyHNl6N3IuiYClm11iacsbNzBhwqhymrXfo2rngxn/6ooYvQ5XXsGoZbagnUw6Sj8278Z+8esFMnc6PwWOMvRURlxvcpjSmKnIfuiKmQsgkNGRrDBhgG0udGaYd2Iey3BIxNi/SLC2sV/t0l0nKBavu73keDiB23088AHeaIOC9PPcvzlSGZTQLbiYZa1oANG0g9sNlKSRGSnQZ27iy1mcbRUnHdBx56EGh3lUQ4f62OW/7jjfyGkqkdQnXy3gkiehqBScgttw88EB7KfEbfHpUOmpExfeXSRHjLR87rePpBWARbW+f6AfEtaBd6rszvf1E8d0l4YvGDGwxLxJE9f3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1zq87nryR6hjt9cquYQ7kggdaCSDYWIXmA6xKj27lTXPjZ5rpyVM1WOQU5cLQGXZPz4RuqCCKqrmuwQPS5y/68oBB//UG+9+zs245sldtJsAoY4Vy2HcKrDGvpVkDofKk+MD03ng3B1nCHqGyK6GA2rGekXi6dLAm1Z+U2a1MZTh093yWMZ0agQHcLWV6Lak0m2Bg6vi0kwOmL4kR7Iqc/TN52z+8/UHklNCpuPvCxHU/5nTUL/bN7G69/Ba5GnjJmaWqgexTZ4e6XTh3/QXlRnPImJHHSiAQs207FQ1vOdRQYsKNiCqrJPBfQS3QulBO0Xg22ZYUmC+kL2QGR0aOILezFIYEv8wWou8Q8FkuK5yqZQdD/QzdFREPh9EQAGYBH0ifdo0gbvPRAAE1SL7/V3xY0cxWjO1KjeCorLAzQaRiAnSMjfS0SaDrinYc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bc5c620-27d7-472e-d6fd-08dcc173ed0e X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:02.3399 (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: zGOU31m/hrJUV7CSmRYtfLdND9U2Jg/ZR8T1fOB6v/g0FN2B8JUd8eARJq2YD57yDvLdNyndMnOVTn0r5iY2Wg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=925 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: siyvEitxUJgjuO-g00DHOC-mBaJlVNYL X-Proofpoint-GUID: siyvEitxUJgjuO-g00DHOC-mBaJlVNYL X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5877440012 X-Stat-Signature: nr4bk9yb3w8sx8ebg67ggqwr4asq35pu X-Rspam-User: X-HE-Tag: 1724198295-938924 X-HE-Meta: U2FsdGVkX1/mIU9bOFEGZTDvMcqJw5HNF8mCFFN+xyUR6l6srr36rv6acsSF9bbNdnfA68Af+sj+ag2u/v04MTPXC12/ArI5zyjTTcx8C4tuGHyPlYuJmR7z5VxZxHYPV4rdyXXhJrfGf+BG6UwvRl8AFqdpxBDxCKtsd1vE7G8dP5qmMis+XIR0c6/Dj4tMi7HEU7ofpxFPNHh2NP6WRaZFqReDwsjAtNqsCb8e4biNN18Ifqmxx7f6F3F0DyvSMkWMSxPnFX/XfyDrEZi/vE8PRZBwqQxQIyN5lirl6nTV69BTVT7w3hoh0/Q7bJTB1qLoypect1k59drR6VI2VJUYx2UFrgbhSx5ooqG9CLHdFxbSGo2Ob6FEyjXSZ6e4mlu+kUXWysFpoGPFj1lp/Fw2QXJ8t5nEUefPu6urg7NpewlcHrr8reSAzDHoPogkD75AUNMbeSzVT/Fb3kCtv5b9fwxdntBysIagoiQ267cHwAqEBY3Klt2qJeAcKZayddN3e/0HVhg56EUO6TgzFFpO+PeyJmQwQ44THOKQwOEJExtx9EFaRBxqYrEURdLb2WXRJuQS33vCNVqkhBg3LJdYgEXdlStnbviT0yTvs9QPip8NsmCLEqvuzwdTzQMfDtDj2YK5uIJNilij2BL0xe+Iks8iWQ8YZKZz8vTljjVqPUYncvSXIPqUAjXYhzPr+yAGSB2zPv2uQ4pOfRoq0X0osaJlEDVtEfoM/jZT3TMmAf94dLebYmo6rzjBPfSiJkCFQrko6Do6misfELWL0DX9kHDnAq/fxRxouamNnfek4lP0bCLBIJIBx8sTXyotTLQVDmYGytKw/uBWABJhcbLRql5kKoW2O6yaYc5grnwy7aUPwJAVsTBIpQe9zg6KGX0/+ziDhO5vmFZR+58hqTlpbuRsXvT7f33/jCzf+Urc8L3vHgwH1S1lfgZX6SILiuecppG2J2sfNvlNliQ 5r5eg7yn g6tk9mj6Luhd0yjV5OkuAk2teavjTj7B4FyDqJeg4qE0AiwABAAnMGQpgFt5j3KxRXlPEw1rHra5eSC2XPamQcacBmWU2i2tsEGgJi+7q3CrDPAEJY+13qtVJAqWMzYLFKrf9EARm3oEzekwJVR/+TNs+6jjtNKUn3qzZzHEW7NuAWCpjSCbKc4Y68IWEjIK4Fspa2/FN07OrBKOLTqDVrAAFzzmWPGK+7sgIBVw+MWnplxTI2mzdJ6FJ4zyJRfDFHjIrHCP7JFRvnZaeSFDyNIoFDT2gwGPRzt5Mk4z87bxSnPH+ymaT+RywJGEmcZDXHKzl3/Lo0Zak999sayoowTAgAfCUhLcp+LfwbZvWorMFs9bFB4pqQWUIYc0CdAMI9UmPOT4+pfapRrp7tUVT/mv3oXMS221ebvWoiAGOVcx+PgKW+xJDnxYr/yDBHN5iHnpWqVD8FMjEZ13jWRLIMD7ow18Qi64NAacFTOP6f2NbdG02jBK2nbBbl4w4JpAP+2+hyyzmIxbxtPxms+6q/k5b6Vzau5yOMIwz3JAUY3jC+C8= 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 Tue Aug 20 23:57:18 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: 13770671 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 C4611C5321D for ; Tue, 20 Aug 2024 23:58:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A28866B00A0; Tue, 20 Aug 2024 19:58:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 989056B00A3; Tue, 20 Aug 2024 19:58:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 741196B00A4; Tue, 20 Aug 2024 19:58:21 -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 4E2CD6B00A0 for ; Tue, 20 Aug 2024 19:58:21 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D7BAFA0753 for ; Tue, 20 Aug 2024 23:58:20 +0000 (UTC) X-FDA: 82474290360.28.22D1A2F Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf11.hostedemail.com (Postfix) with ESMTP id AD1F740025 for ; Tue, 20 Aug 2024 23:58:17 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Op6NbzJJ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TUm45UZy; spf=pass (imf11.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=1724198235; 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=cnr2nj+i9KRBLtVAPLklyAzG/es9lZr+TlO+DI4Jsvc=; b=lqJbxwKhjDgBJESSBz7rP1dQLtxVa0wiswzZscDqE6c31qU6w2TSywuB4cm9Q1f3s0jPuI atoupkFp+NAMFMTwFyPUCNZj7J7PE7UEIZhnD5W1iJZwoLuiuBi5UxnvWg0ave1RYSA6tl YHHZT7y63a3cKab0qFqA7X12UTCpefI= ARC-Authentication-Results: i=2; imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Op6NbzJJ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TUm45UZy; spf=pass (imf11.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=1724198235; a=rsa-sha256; cv=pass; b=IpRn387ox7iDaxmlVnJyjtFY52+Ex8hcvV0x2YxJSgIi27Eh3vCe8J38N2rnnM6cesE8xM jhf7BVPDvTGNgRFW9kU+oK4mhdxqIekJHAKL2DHdRaEql2ubj5CPMdzkCxqdzGjaZ6smRZ 2v1rKaiHn4OjR2K5ZajNEZ+QErogd1k= 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 47KMBlJs030503; Tue, 20 Aug 2024 23:58: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=cnr2nj+i9KRBLtVAPLklyAzG/es9lZr+TlO+DI4Jsvc=; b= Op6NbzJJlGbeXK6uC6jcNk/RVbAfx0gGyMHCQiftRUOZnha0NGHILdgVL/98uaMT iVxreEVplYymi/H+xwOI9USBezCDiQoDgc8sMBhnwRtku/buLp0O535Sa/QQt5TR mVBpt80329u08OkwCT2QlZ9699hRmhn5jnaDCxjRCK5oWUZqUFGFWHaz9EFDpGQh WQ0ao93SxzK14yygXLI/6iUO6aFGDpoRbHl0Vgos1rDWc7hzmHctnviJye/Scz6J tnGznO6GBDrx8H0SQCnfWj20xK2EeUXvmIOr7D21K9buw47PBNCn5CLSw5XoYRCU 8D362Y9T0VP69wwGvb3pvg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m3dphed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:08 +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 47KMJJkJ040123; Tue, 20 Aug 2024 23:58:07 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 4153u2tbef-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OVOB9/OA3VPv/2bdWgxlZ5+FrByO0iHHJrnXeLADVeYmkkyBB/3cRGUrzFjCmWnlbm14kYedcsd59NeaIpf8xKQKHplJJs7TC7klBgZZ5bRMW+RpdRNIRjAWoIpgQ5SQFgP4fLT4plnskuCBxBcFdXX6dutmPH/E2rzBw3/Y7oC08z3uEK8vU0Y+9b7PRMOsfuB+hkMuu5SB2tPr6wnf5gOHutB7epxD/J1KoQda3YyIIxaAouVjm395H5vKw9ycL+y31fMzM2GjqlY0llnTZlgk2VCW9hM9HeLBrSER6hq3JU7sBrzhSju3Bcc1CBZhpmOYBdvAQt/JBAeZwy7XDA== 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=cnr2nj+i9KRBLtVAPLklyAzG/es9lZr+TlO+DI4Jsvc=; b=ITOi7LXiIpp4nrGMMrUetcbZ+CJswZmRLqe1fcfyoqrnwJFCymUASYOxHqDzUxft/zM/klgJQ3wewpCVFZUNEP9wEJk4bLs2SFx6LT8KshGKjuamhapirSFFuPDssFMDcuo6zj2aFpuqDYm0O6omINL9ygUeaVFkuhzbG5HnfUQ8GgNC5xtcGa27lCmd9uhpNsJ8vhg9tO+Q4DLAtZXtne6o3sAfd6hd46rVi5OLqO90tmQ46NLrnu75xv2CrVCE55iFYIr4ZrfUUCHESrwQvChC8ovUSdN1ZS35nSVgI083X44EzlgZJsTHvK4i6Hnh8PeQN7ezGIe2hCXNChCoDg== 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=cnr2nj+i9KRBLtVAPLklyAzG/es9lZr+TlO+DI4Jsvc=; b=TUm45UZyxCxOsd7UjhKMWpdw5Sjvf9YktNGBoGFrWSI/zH4JXTx/RgaUdSWAxmvfHCX+vf/3eYgeoRrI6ksqks4m3y3rHWDUopVBLXi1BMBxPmPdMo3pwqKRl5NBj/MbsspgpnVMJplWkcGPqZ+QCB4y2vc0H0HOsBl6OgZwkQg= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:03 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:03 +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 v6 09/20] mm/vma: Expand mmap_region() munmap call Date: Tue, 20 Aug 2024 19:57:18 -0400 Message-ID: <20240820235730.2852400-10-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0419.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10b::6) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 44399041-e5d4-4d4a-ad9b-08dcc173eddd 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: XGII6FHdPFm8WNc8c0Cyjgfw26jpTqNGpxKf+UnCMFRfG1HmALOtpVdMC2gMmQtuG6t1QCmBqvaodyj1cCCgEOCbGK0xeomOYgZw0VNvKOTsWFsgqal0p9+RPU85c2oLPQtOIftlFnstjuXXZtjFPjrqutW6WrAgoEFWnZ/X4/Z/OSoFzxi1Yi4LLMhiPq0nLw7wsGgCDbfFDGPU0o5ANAmJKh3VIaUDUcntbSkWWd63V5ph/3UxGHkjelsYwMezpiBSdNjVg9ikubc6lqnnJikR2n++M1EjVQjc94+EV669JpANs0I41kABHHTA/b0kCRvDRMwqwcotX7xtZ4K9yx6s+4xCDTJrBdJL+FieMx0JQ2DnNiTNDVrp3KS3O/QU2Cymw0vdVdxb8VrU3XvQu0lBQyeGGiQRWyrF7jboAxITMOuhhcHuTUnramaKvqhbqJlu8BVVtRQM0zCXb1vFdZR5VUce3BpvGdpGAowwIp1LCrGIyWDxfPCMDWw6RsT08C8yZbyfLWi6OEplhzqwV3cnHU9OkFTxUSNdeCEawdke0XhoetXUlR5UHvwQeobDPXAZKoTQtqGPz8fs5FAVylTvFn8R9tfFaXnErD69GINUgyz+c2cvbE7bgMvEBsHSF1ErnWNp2phYF2r5PDYUzB+HwWumxSfGTBT1cc+zanwxUk8MHvGahXxHTI5BFmx7GIDpqxMxhBGgPW5dbtFEBHiXHQCbSEZb+qzASav5NlL5mrK5w+mQ5YLvhd0ZVPyfr/4TUFlOf++ZzpyRR8h8VS5o7DY7F84U/Xaje8g36KMdhTRCei60nJHmF2tfTl6xr/1+SCCytUbad8dFi7sv7XbZc5tPyJNe+ggiTrceTC5Ikt7eIIdU1wADiK+GvsohEHTuDPQ0dusSx+VBTLs2zzu6vkurIyI77sBY3sl9HszlMnHZCtlkJ7zqkCKnytwrPpkEaTrlMY9yzMEBN7/UQSp7BCVpYNxl62sFWHq17aTiuc8TYuBUaHDpPHhYkLzmlaqV4h2k1G17aPOy3eteSicY7YA+8PyQ7pXNl9pD4bQKO7KivDvllCURRMtktXLgIqtNuhZVs+VX2aG+A9KI1GsOOnuJ/pdaC9ENxm0rGdM7jHA2foOgNqrN7q0DOb98CNgjUnNTv26aB1PPSy45cSzTI0x8nKrtsmGwO1wNTRdR89BfQQWwNrP7Fuv4V6rDrRAmjL3Gu4XWZ6G0dINUNqQr9i30T9DGTkSl/ooTAD3xW2tRPnec8SSTGhLqqQ+qWObkWyYulsZt/r7lP/oTKhoM712fwcS4ehE/lb4Bmabu2l9e9zTiS5T9+7R7+yLdVac1ryBkFySdR3y0jWHLUQ== 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)(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T2rjmF68kG+fe9cNLKZihFC2ntuiEJtE2+8g2MuGQZmnpZLnaXf2k6Si0+EkQ4vi2FK4Y4/MYeUtWQcTPOTN4O/sMZuBnvZIlpgbyb6FZysRGukduiW1cUdfEMWqIOa47mzwolXoZg9HXCBAAgvmAI4Su3Dew3dJLmtKgBdD03eGwzXBpybtxE+f5ZwbPmkldr+LYxKw0b+yOV84cxMm/ifJ1DJNyCyPwoNGIhQ2hr5GdURYhOZesgNCuQQpcjINzrllSesYO/7u3wsGrvyPKbROQQ44j8E2+sslnRV72C+9CeitaPXkkQ5IBleeRyR2a86ysL7CqPFaRqLmUBIdBJuc7Ln5fGuXiII/06XyFV7wCy6g+A0cD+TGLsjvJc7zLfXnQGmPmycPcnJl5HEphngw/ogsEZnb5lS9+LMdrmjzsWhZV19odF9iF+Q7ACfi6zdYjrmN92kcCF98htBRfDO8hUUQIpX91wTDIcI61s54AQURhDSnCK3VGNYF1wMHHc8qciLm13l96t+bOX4S1Vi1vwaUDY7i3BytIxFYQyAn1WlOGm0weT+8XH2ndO5FBiGnfKDSTw74F2XJYMGKFlLz8bY6FydoWxvLyyD8LGJRQIw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: iYhTyZ4X5CofWp27hMTQmA+21HupxKBPvQ5LX8peql6ulxg/oDm+mTdYRUuHhq+sq10MLyTCnNg82b9dwkKamt/BE8tz2+deU8UthHZYND2QkE02F4cHrIRbw/IZb7I07nfNsAoAKfr+am1LAfr4Uoq2QP5qJqpQ6r20EappTYgnBhCS/JDSjgQfAf2ry0AImn8N6DcJg5kfhgsoJsuOUNBXcQchOxINntLixj4/xcA0vmidBUAefzYn0izB2ORTE2dfN5f+ToWUlPZna9X7W9zH3BaYUdZW/MzBNzZ9vHihHjWrR8Nk+HjpWDeUQaG83XPknQ68VoBA0RKcjzPD1D7vyeb0OUcs6tBaeS4bT/WsvEPBhajkKuLH9ViINPUg+9A2boFM7UWFlA7Cc++s6nXvy7mARZ7DbCqQDqG/gpz5QLCPABDbBLAjTBOT/sS93cogdCinI/1SyiKSMSvHGbBbxyiW4UHaY1uz/lf9OnTW387SeJdGVpv/c6ZOZ5P1GPSfrNqx0QAPML4UWHoSEqcqjHCX9m1maRNYzkYhb5G3OwupK2m6R0L7NlIWwN+0K9nZ+Gf+PjdRsam2qzvv9i50Vb7CnuIVuIZSvHybkj0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44399041-e5d4-4d4a-ad9b-08dcc173eddd X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:03.6949 (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: Xf2P27rkkfbuEZh6SmNmdyFgNVFniI+rGDrB/Nel5R1zWr0YU5OWlmFbOZhgMzCu3gb6RUqGoy683AnYjS7Eeg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: 5P7WM8SD7g_jBwQ_ST1Bdx6a7XAPn53R X-Proofpoint-GUID: 5P7WM8SD7g_jBwQ_ST1Bdx6a7XAPn53R X-Stat-Signature: 8uxuxz1om3rxbrbccueyu58ty7y9cfoj X-Rspam-User: X-Rspamd-Queue-Id: AD1F740025 X-Rspamd-Server: rspam02 X-HE-Tag: 1724198297-454693 X-HE-Meta: U2FsdGVkX18YCuPOn8H43ZNBZ/mFvJIoOWOJR0wAi4G4NBDM1q2hSxouHlfXwUvyyEaTKvBI7AnnPc02+YIOthBayD3kqZ1fc516pTqxJz2WQDFYzdwMUMSSkybXmlN2cO/OKXAGqilbPmsiA8/+iXTgXfbR6kJvPlvZshKcJT4V36qb14auwrnxTaWSwi749uRHKH/snpCPnNV6/WqLDVD1npYR+DL60gw9m9lufy93Ko85dwFLA+HUJbIFgiHBweolyd54xC0/abRs/rWpOFQSYn11y15LJgjqmbGHW8kPcEXw7ghAkBvpkZWyZpbXMDq2dGNg2LyKNDUsuASsYxYXBlQbKyXnPqLcdPZLObMCSBPofSnwGTZz5sq5ECjhQ0+WbBXgOUsmpeDEa/2cQAPCVz1e3UOKE3k9kSt3JSwLrgeqMp0XMlBrs9UD3etGzElddL9EAsSMKndgNc5eng8eyBRmFLP9HZHQ9K0EQLJB/wgZVhaLNqlH61bS0dPyOQGph7MGCWiqhwu27Uu4vRjW9IEEhaSs18wUmUEQIr+lz0ZSYcV9EeSDHBOfpXsLp1oDx4/maj5b3fzmSZPBW1jAtsJwzbwV+rTt021RCRtA5q19d4EeFcw70IY5fwq8ajY+/pruT++zJE1+O5W6wlpNModR36YFCt64xFrHTwyhR9M8k2NfuvJebEKPK1TIpSSPOk1rBhle8/zunTo1fXL1oP2kPrIGNPwcCFLXohFU3oJvHM2n4JS8McnyEHnsR7FWxojtiBPiMR6fDamU6QXCYuseXMwwPCsw0HYsz98ASe+rxPfrTCQGAZ83dZpV1uak01tdfFIJsy9pAv4nip1aGQFe59V158WiSObaJUOKBt+2CzAtuRO1phdzlxCb9cWWv/VU8wFzAWYQ90l9RlrBFHVo78Fcz8xw54EOCtJh5kBQmtewhMjyXP6SVJIHIaTisDnBF8D26oYnISq 16HgoTkN hzYhlYEX7H3jA+BuVDhKHwpI8kj9hlCy9GXxO/bUbP8OBVjRhk6wOVRVEkES1zT6FlpcIKHetfLnZJjJAQ0VOO0f6HdUIkwXDddOgujpRZa96cw3VK9JiLIRXQj11C9gYRpJOfmQ0n0ljUkfp7ZevF9S3BHApBqT2shPdHWqWHbjyM235isPCiDYP8ciWxyMInb1BaZY0lNH2JMS7lppbVNlBVtdCpvQxBNlZaEU3qmZdVLPIFyjc2yNKrfAcHHqxWKXEVYp0s6rSYok7F8yKq4nEjFRqObZF/+Txxs/ITiGfi72VZyoTHR7iheZzMT2OpDcEu/M8KLGX6Ju8L4Eibb+uZHf8TontUukV6JcXVDNRqlGmpSZ53f0FUsCq7aC5JolKldIqTWEFLXFBh3as5Q80mOzU1ommv5ERcTphhhgVoeSvM5w9eir2YGE78KvZ20KpydRL1n3kmaWrwWdvYCQ/kg== 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 5abda4c49c83..2840cbaeff8b 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; @@ -747,7 +720,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 Tue Aug 20 23:57:19 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: 13770669 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 B9FD4C5320E for ; Tue, 20 Aug 2024 23:58:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 791CA6B009D; Tue, 20 Aug 2024 19:58:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 718956B009F; Tue, 20 Aug 2024 19:58:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 523D66B00A1; Tue, 20 Aug 2024 19:58:19 -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 19A846B009D for ; Tue, 20 Aug 2024 19:58:19 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B7AEAA0761 for ; Tue, 20 Aug 2024 23:58:18 +0000 (UTC) X-FDA: 82474290276.24.1EAA826 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf30.hostedemail.com (Postfix) with ESMTP id 6CC448000B for ; Tue, 20 Aug 2024 23:58:15 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SQYC+3Xd; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=PStfrdxn; 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-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198279; a=rsa-sha256; cv=pass; b=o8buyp3N/uQxA4QroBr+hIJevecpcvhQnMi3JHKy3QTS10UFaH9jN5y9+JHhKqraR8CfNA USKPaa3ZtjOk3stABuKG8tt9eItXycOtpl56yFvgDKsNiaSrghiKlVjXCVnAy7bqULclp8 ig25Tg1l+0cgMiWoUPNW+NkIRupDjgw= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SQYC+3Xd; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=PStfrdxn; 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=1724198279; 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=tuulxpOjQUJ/MDbodMRktF6LFgldzTminw+CzgLFNt4=; b=VoyAQhlsQi67I8KTDYSWrNvzwaaG9NJ7YtVKj9yyThaHLkkYN8O8D1mFDaidMV1u2syvUB 0qOGT5CxhrIXmXDVESCh2rY8E9FB+40bT+6fK/BUSnIseBqq5wE7xusJ1FD8BBOdJjFsiF Z1q9qY0FD8pNwaisu5XUohxkPwU3VLk= 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 47KMBZcQ028784; Tue, 20 Aug 2024 23:58: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=tuulxpOjQUJ/MDbodMRktF6LFgldzTminw+CzgLFNt4=; b= SQYC+3XdhFCzjR3DhKO9DQI4Bm7+KKTPWGqRQc4Stp4I9QvLFjChUhiDe0C40Rh4 FaDTNyf1mPXLZBX+Bi6RnzE9/eWapbWuHXBNZz8MD+4XxKgU3dEUNf6nxixaRV8e jKs+QzFnre/rdPKBJNyfgqeki+qYbDIWNY6+tTajidyrwihBkXIVYFShP1p8arqN LZ+YauprXADgKxCH8lPXmzZxkumP5IJEG7mpjKJbUR+Bql7cN/yKprjAWwu6x8dH FZzgOHG1oJyQMyDqjDlLoujwR5UPCxispF2c6Z3DGXwDbNcEZV2Cfxypel4/wnna IQrdk3eGNHxkPngLK7ydSQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m45ebsx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:09 +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 47KMJJkL040123; Tue, 20 Aug 2024 23:58:08 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 4153u2tbef-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KoDTUSWq1mtsVU2Rt1pn2ZwqSYVNMxAm2CFE2ly15+p5c5GY4jShg0Ff1/4VThj/Ah6gyWphVN3WXpCXtFN8IBOdk8GK1Fq1dMOq+905wj8J9PwjUYIqzwurMj9LIrZUg//CWIZl9Ope26Ynis0B0SWDFi2461/ci8XcY+RfrXpqHn9elafY1BxMqjLo0pN7ycBPac3Y8FaZwD1SYGNUMOA754iStysEybyHdLOCHOP2A3OvdYBnaTIx3O0sbXBu80Rt6LEGo7KvvRWmUCc9fzKkLcFN1+BpaChdZF5PzSrCRG+7Z0+6crqs88y118pRf6/MuCoDlZJGWMi2m4MFvg== 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=tuulxpOjQUJ/MDbodMRktF6LFgldzTminw+CzgLFNt4=; b=re1c3PgmzWGobx/kECMU8+5N6AJQwIhYfYmes/sjmbfjXx1I+/MRc42aXwHSYjypflcJFmDUAjED5C2fbyxVSHE9iWOKmHtjtIUZBUbUukpl06ocTCQtxKOT5e8mrkcu7egOTlY726WzTP8rGjPBftLekSUIhQqLwTCxVzxDnWs3rkZ9Kti6TDB0s0RduIowCbrWzOCFToCz9lRD4I5GESc6xhQ5rbZvSqOOMOVCRACTzHAoU1pO2ibxbp4XpXaFMddKyftSbl+KV9ShF3yUayclwb13KbxKv6/WOWHXA10MBQwVJt6aLIeI2CHcl1uLPlCKSwUIgLRV6s6AvfwI8Q== 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=tuulxpOjQUJ/MDbodMRktF6LFgldzTminw+CzgLFNt4=; b=PStfrdxnx9//J46IOJECopDeockL6boKG7RvP+Nrza6SqcRsEzXqNfNyuSckQurrAQO9CSWbGOcC+Z9NAFpg5Ay6D9RaFHzMk0K6aqrUqarcTvY4irz6RiqROWBl/JWjzPuLGKnga5NiXQsiuYkreKH/sothkvqaCuJC6f8iwrA= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58: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.010; Tue, 20 Aug 2024 23:58: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" Subject: [PATCH v6 10/20] mm/vma: Support vma == NULL in init_vma_munmap() Date: Tue, 20 Aug 2024 19:57:19 -0400 Message-ID: <20240820235730.2852400-11-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0095.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d0::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_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 545667f3-03f7-474e-dc4c-08dcc173eefc 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: iKuVYAVbdvPOGJe3DkMMAFK8b5x6JtguAJiqI8ykjJ5mshN1o8iXRBgUvFBOebODql4O1tqVQPjbf/xYHCVrk8FTkRNJ2Evt2qIup7QUsNyOoRzPN8U9OuABE/8xf3Qt+WCSUtd2U5Jwj8ssk8wTVzXQ9t+5fCto2rRMsMS2BKEk4MmFYcJGH9l6Gc7HCmf+Rt74xgh0h8cI6M6hDRPtrO79T1xT3J4GqP05NKphLlvgqSAZ1YTPn1wJgRLR2qKuSeKDEI7CoXQ6+Mvhb4h1YU4RGv9JxIqQWF1TZnfE9yIh3+uENQ7a+dsP/8AKqtXOJJbzmdxuV3TpF3xCNoYNPdqhs/CjQCUQzGxY11EA8w+QP4nm9XJC/H1nKA9+SuzQkek+0IrtCmXduUVZ8Bu2oMydfJojbrEQIlMPnRw8LIeYRyRTpOgpgkUvAYVQDKmvRHQSrav/Lak87BdvEGXltliBrDkLUUE3Zke/sCbOGPot3PMpVyxlTuPaHF8zz1E7+PpHrhVCHvtLhzBLm+EakKXcfkqjMeka7FEZ5w/evyamXGxSezWxaVgZ8peiQOD+tEk1crew0bkdYvfT7urk81o2pzE75mHplyGS0titf1NDkI0cP+S+WXceLZWHCfziv0T61FkMCbaOnEyzIEzJhjzMTF9ZI8TngELc5h9dy6d1pWXLuzEFvpalYYTZuxB8NanFnAgguz+AVD9oNBUjEGXyrcWM5N7SnPgE/HFRNn2FfQqj1CLIdbDbt2hkDjY3SK2YgtXsVF2WgeVFAMfNhtwrprkIUImH/x0qFeXHztspe+Hj2Iy+lzhwEOb0x4JD9RzoWlgBf69tcOIKFjMIW9us8fuSaPI/Gwc6afhgxXNKubTLWbjXo0CGuj0Oj3O0Be+N3rZcWRM/JRUNBSM9XhTmmMEJshsSZ1XbNAU8IzlPilJPIYed3hO1DbwEoKEa9q2FaOQdATZj1D18QHersiVlY5fl5ZeGscdTn6PwAdJTQ/zbVCc7e/Rm0rcNISqlkdQMl352MaeOg8R9C02Bq2XI1v9TYA5V9nQ1XdVefE7cA8eC29AhELGxnR/4ohSp32PGbBJmyobOnt4E09EEHzUS+PtXK+zM7NPtX0UQmghIkX3ViArqFGgrPx+25YtKM4nzdt3WRt6Irgx2Xk8LE0aeoY0egY/Eg/6mCXZt29tLTWJycB+qf2WCyeRCA5P90k7LvGu4+R2y94ItJ+Ga1Ue39i+eYWavsTLCre2lh2JlLxwPNXk7dI0r4egHtmTi9DP3Z5zJDrdAXBzoDnn0WMh6ZHZ4HDb4ofOdjWTz65VdgtqLPu0sRdvTU44jT1wZg9NFNUD2xvTTlrhYUhA2Ig== 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: 7+s9NrA9p5HFNNkmVZvbC7dR7k7uV27cOQDAT8kRwEne6TAg7imNzUBax9z/c2TnN4VeUld6H/TkFb/DhLYd9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p/3EfA5Ah3FtRidAEJUj5xjcAgG3EFqDlNVzOLDpSWZ9KfpvMtsYjOq2e45roFtN5+pSsdg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 545667f3-03f7-474e-dc4c-08dcc173eefc X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:05.7708 (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: FNeyK9Yh+3H/YsxclcvpDVdGtdaVvKvb3RmpswcOEmRe5WP+OdaZxOpwGfPZdWSCUYJT7cmHSVpt+R5YJod1ow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: aKsVfAVlTN-wXA17ZlCCbXFiZi6aSPOO X-Proofpoint-GUID: aKsVfAVlTN-wXA17ZlCCbXFiZi6aSPOO X-Rspam-User: X-Rspamd-Queue-Id: 6CC448000B X-Rspamd-Server: rspam01 X-Stat-Signature: offhsauyjttghsuucpq5hqu4x1ammfbd X-HE-Tag: 1724198295-500904 X-HE-Meta: U2FsdGVkX1/ewib40UM5rYyJuxoAx4Fbe4VnmcT0643CTh6Lyadkcj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mquM4DasFjPVaAUYBPxesBscZ2WaiA/3uk8i3sTR0Od4HoHsgWTAmcG2JmrNoV0Xumult+n4Hq9O1ry8CfF3gPObO/VbXzBjSyvc/C7dt7wECU850WGlIUdAO8CwxHSxsdF5f1B/w9Afm4f6Z9HJR0beu2/DTjNbWPzMgl8NE9hWMl40Ix6Ak81TzeM1LbA6X+8qrV1z0siqAz1M1gEmJOJfgM75lnrDai2vG8N2tHumdEYMaVrpY1LZjEBusq2L317DlLJ/j0p77E7Kq6nbHTXy1wKhmcLK2VpNZSrCV1vZKcBw68ddUoZOnLycKVztcd8saquTG4llKjSKoWDdYgJoHM9Bkon3n7hpcrznXSQoijrEkfXpRCDlVmQ4T32bQ= 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 Tue Aug 20 23:57:20 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: 13770670 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 B47A4C3DA4A for ; Tue, 20 Aug 2024 23:58:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 917D66B009F; Tue, 20 Aug 2024 19:58:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89F526B00A0; Tue, 20 Aug 2024 19:58:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6583C6B00A2; Tue, 20 Aug 2024 19:58:20 -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 31EED6B009F for ; Tue, 20 Aug 2024 19:58:20 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DFB72A074E for ; Tue, 20 Aug 2024 23:58:19 +0000 (UTC) X-FDA: 82474290318.14.E9D5B35 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf19.hostedemail.com (Postfix) with ESMTP id 94B691A0004 for ; Tue, 20 Aug 2024 23:58:16 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=kpc1Fwnc; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=sTu1qh0+; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf19.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") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724198208; 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=/kF+vqo7I9bVt8ivw+hZvg/8Iz+49RUF+0LtjGzT6d8=; b=ezxoHW7AaIgKIde48hjzxXogTbUl2YjsTLhz1q5rAavw2sRX+tOprN3j04WwxBSEMfDH7Z 0OgsiB3rLRez13TfuWAITPgsHpAW7QXtKSDE7P+Hj5rV9IlNQ7cUa7Aw1wT7Un3HXrnjim S3CMJ36WKo1m4x1a6/Xk+H3rIGptnwY= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198208; a=rsa-sha256; cv=pass; b=IdJ8phHPl0Nv/ibbHmirhx7tzhUS9n0YkOQw2/K+hHbtN1gRq/yfhPfFX0GMOrGIJQWCLs HsensnZUbY3PVcgpBela9qsK3f4SL2ToqnBR42Gmu7o6dmwOAlEec+nDejqvY69qRDiW4G WXmHLiIE+AB9YWDIvFB/pypXGJGgSJY= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=kpc1Fwnc; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=sTu1qh0+; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf19.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") 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 47KMBm9f020641; Tue, 20 Aug 2024 23:58:10 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=/kF+vqo7I9bVt8ivw+hZvg/8Iz+49RUF+0LtjGzT6d8=; b= kpc1FwnczDzqhF4J6n6TiMHzJ0Lt8tAg0s7K634Pr7ugX3JO3dB+kcYd7Gg3D6Gr UoZXumdh91wJxd0BUtpWjAfsHgXSQfXzacPatPp0b4N9MhsFXk9R03XoKKAOtehN jY6L4OVIeyocAZiJwre2EDXzjgUutqswLuNxMEZKWhqpHvVezB7Q6v4iX5uJFqDW +T/sxxPSfe8Vg5dor0nAU8swTfYAevUD3Axlpu0vq1OGqJN9gAP53UKI9hpEQb7u 3rYda5gthuMZm+P5r2azQSmjvwE3srTKGQfW8BpOk2Q1V7dTFibs4/fyx31vGiLl gYczfq0DDPVkRgxjFp5z8w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m6ged20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:10 +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 47KMiKu0036831; Tue, 20 Aug 2024 23:58:09 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41546yhqxp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b72HiDp+DfnHL9hwBnlvz3961VkD38hrAkmHBo37WRiSsGaC38RB5M3FO8WnSp5SQ8pjjQMcQ1mtxpRpQv4+YYLhe+Ub6F/yG3UgSgO0XnsXJaLUpo5OaJ7h1F+Vn541FVkORnBv1x06d6VU0pIv/P6NxkyBtPylWe7+T/2abY/2IMJrTroi1zlEjWZg+v9QyNW61m2++8oWtd9VM3QbmjAyJZ7KoQI0zGxGbu+Vk9ogFp2o5n312WeY08ElyhL3PUYQRESnD5vTQXR9iQQmfA60JArdAlqkbHolM7cAyzXaARuIlfvkGDXNaLOVkDm9Xzhf8T4FFfYX4CO2guzJUg== 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=/kF+vqo7I9bVt8ivw+hZvg/8Iz+49RUF+0LtjGzT6d8=; b=Q1jBZwGGcocFcDENxio01LOnf8A3BdZ8/4J5pRItH2bbAdbL/soStKHh2FCEBRe2OXYCIgKs58PXwjg9+HMKeimpTbUrCg1zVWAlwzRM51ivuvxj6lHWz8D7mfSn7Wyybs1idLw27+tTAsCkmWVACcCq/7D4HR3PJGIAt6xE9KahNqi3uRsRCiArVdZarUVYxcG2fGP2heO2J/FOLSW0BILWcvO/svBslFNB3FMDDaaBIrpfiBSkCei71FBI52Jc59uasT/wpXHFxWs3Hz2qwSj9oyEWEIvfSiZYhkCK4HrJBk0wj7fZb2NNsFuTHdtBI/qITo4XchdBo9J7fnB1sA== 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=/kF+vqo7I9bVt8ivw+hZvg/8Iz+49RUF+0LtjGzT6d8=; b=sTu1qh0+aJ/DhNMdCqH23sxz+XAotidlw9LBUqaZCTQ3cpD0WCCBjyhDmgnpFdNNGiK4Aidyg7LqpHHhOU8hxInIFPI0HojxZgfctCrPxNXwv+MfYfXpLR0UPUYjNmlbomHFgzOvzB3Px/5ebX09+77nkMnQumuOqBM97PsP7iU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:07 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:07 +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 v6 11/20] mm/mmap: Reposition vma iterator in mmap_region() Date: Tue, 20 Aug 2024 19:57:20 -0400 Message-ID: <20240820235730.2852400-12-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0391.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:108::9) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: cb6ba69e-b179-4660-135d-08dcc173f01d 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: ZDwf26jTixkqPxA287NL3hWqipzMnnaXtFzOydyBFP2k+VYW3jjdrlQOK4RGGWyw9yhRgERqcRo6cp5Qv/thpbSCRh/nlrSjsibCY7kJcmeZztJVX86YhxQXnAbGtSkxiNjqYW/+21bkQCb1fG8cFPQ6UsXd/N7A9Ak3M9VeuKGh61ZOJE652vFg5HF7thw2LYYoUXmYhPiUoEJJWZeS6PwsDjPkcWAiUH/6zocnJV7vN7Zp/HggXF3oKWD0bcfbbH/6i33FEW+l2HMiiqwuxttiUZI+wkELWFPoS2D4McbwGYMIMZ+FLcrz/SrLDL/ces32L7NbqyeEQSEQ3YSVxuDz+iuRNJeWGHaHJJz4rr7revhLzGScpwwalooRogGeHCUBwGC0aKXMSb2V41Y3JuM50biiJghfggCklaG4X6g461MLb8XtxsU3SY+9fPZ+6OqrV+K2ALVkZVls7ZFfCy4g7zwH9ZmjV/Icy6Y8H35dHZ1Qw97w7tPyX1Y/k+9c9QumrNLtOzUQMj+rdpMCtkF9bwbTgWNvcpF8AaiJmwj2z/rsJSKvb5G6OBkhKsACc+uA9UHgS9F3AlprKH74wMlUGW6Z//jm+r99eHZwwj2msmcTV7qf2jXPAkUuPrGaIg/ZMR5T1DXGO6oXnf4ZCjAWVOOgdEUxgC9gEqDa8gaGNN1uFaaNJtF/m9UBVLlUE2+Ajq/8I6MvlyIzXdDLPUVFcZImcwEpoMZM466QRBQCtjatm9ZF6+c2LHAx0r7otEE2jhJHXpif0RadKy3N7t2GfyTWqeQSEpUT09Lzbrp5lJLTgHsSPb1wq4fRFoGnD2p5GoI177cwnKXPZVUTOc0x9jyyNCd4bwDDVIn7UMDWNbKZ4l6rBBUnFQl6RiAE4Zj7OdEwRazAjkrEQrF+Ix8imMKF+1RmVor+5fMbwtVKgQY7RQT5lthcX436pokirdHnwGWSLYP7buhWwBCsc0PTH4YfQ5PT9D9R4LRKYYgX/hfuhKS3xuUI9pFWyfAWhc8oBBMFUxsDSm9SAgCtaJBKiGPiZZ6p399dLoDf97pARyZo5KwwUWFCkKeVSq++olDobehyGEgrRLqxG1YFlflx4WGl9wWgXpQuffOXx1XYOQP7h73TTPvX+4viHnzlQUTCXEmaWULXtUfR06bU0Q4igx99+8DKF4GE4PSrfNLp7TA1XmwYvYBAPNqHXf+oEYMV+NjEwOIQBJRKbZiz5lMvO65hH1WgxYUk1vOkEmaltgKuiwo6UQO46hOd7uMptwQ1XPhbOKLY8EOLjGDQj4ZE55alFb+tKZYUydJL4zQN/i7DuhguA6sp8+hUMe3wp83ORs6Mna1aS4YjGQHXig== 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: 1y3Ur1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WqAIO+6IiuLzInf4Am0k96TrEHBofw5uwnpEwnzJMDOZvKn+OWdzhz0iU9Wq+i4v376iRGOGOp/a41uw40CuOF0TvaxfevBQLthUd52HFYN9dbadPWNOSUPtDoIQd9BPnuSpJoV58qTxZbqmq1kuHuEM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb6ba69e-b179-4660-135d-08dcc173f01d X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:07.4763 (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: 44TB+bCAWQBSmm4aeAodMKm7HEfJ3aY4EUNirjI9gV+Ilv09jCMpwG/Oi/ZqYdPgVcAeCxlG0z1xpH7zK567Hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: MORbhZ9uJsX2wbPTYmwHqrh0LQ6K_kjC X-Proofpoint-GUID: MORbhZ9uJsX2wbPTYmwHqrh0LQ6K_kjC X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 94B691A0004 X-Stat-Signature: buhmfxdn5yn9mzji4e1dy76o4e9gapws X-Rspam-User: X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//qfN51WigHRSqi0IP4nmCHKcznoTClcXbnU9EiatyQThAeYFbS22Of5FgnUEGid81vt1oZzemHs+box8x1eGf5Q5Hbl/h9n9xB/JTbMZfSCxO9piZabzDK321fE7RGKLuPbNkwp2YtYo/drBQG2BuIisH4Lf9mfU+rh5Jj+v14lBjWUc2ViIfYaMwApjAHmkuaAo7+DW0dJ8Cq9JONR7YskSV+TQB1PNr7cTEjQHEkZEfmMVxFDQ2Db2mJw/I40cGkl1/6H8uTmqwKnuGJr8bJYYYEyqT6uYXnAI2AVKFxhdABj2uMFta6gg+RyPMy0J0mSgmGT8UufyJxfIuKisLaV4pHJd91+MWJ+rckODqqwpS/vxO/RP7hhwDl7/iS00XZ/RssLhqEyclj/Tb2X/KGm8LGFfffHqYi7wOsBlm7EWVp4Ku2X0SlhwxLGkZyn3H3YNgKzX3ecOyUNwbtw== 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 2840cbaeff8b..a8d716c39db2 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 Tue Aug 20 23:57:21 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: 13770672 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 107FAC5320E for ; Tue, 20 Aug 2024 23:58:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF9A66B00A3; Tue, 20 Aug 2024 19:58:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D5BE06B00A4; Tue, 20 Aug 2024 19:58:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B61746B00A5; Tue, 20 Aug 2024 19:58:22 -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 8D3156B00A3 for ; Tue, 20 Aug 2024 19:58:22 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4FA241406F7 for ; Tue, 20 Aug 2024 23:58:22 +0000 (UTC) X-FDA: 82474290444.11.94D3E84 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf14.hostedemail.com (Postfix) with ESMTP id E6D4D10000E for ; Tue, 20 Aug 2024 23:58:18 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Rlxd/xZY"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=kG926isL; 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=1724198236; 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=7cM32KTH1tzc1Ltl5lH6KrVUwxyw6BJXIXdnd+YGGaw=; b=7/5aBQrZxeZfTX3m9hXg2lrCrbSnOZFuQk4/Ps69sN1AX0QYodzgEEMTsajondwZaiSb23 0tn6GBOYwf44FNXwl1+PVMYgmVD70iKP8OYhlBvY9rjjsFbAKzlnWINaSIiXcF1p74CoVY 1B9jc/o+xmxevKL9wGzlNik9oLGE1j0= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Rlxd/xZY"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=kG926isL; 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=1724198236; a=rsa-sha256; cv=pass; b=5pW4VT+DRVMOeFrfXmeOjmThiec/QlXdzIcRHvnf7s1EEPLuVaIlkpwX4lE33fY7rm3zJl hyRdMBYbPIOgZO0SavYw6MPln7HsUFdcIF0H8WJBIe74tV401wUfnxVeOh3J6hkxL8NYCj 0FpriDHkQW8M5P1uPDaYkfbQL1DLCoc= 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 47KMBa8w017785; Tue, 20 Aug 2024 23:58:13 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=7cM32KTH1tzc1Ltl5lH6KrVUwxyw6BJXIXdnd+YGGaw=; b= Rlxd/xZYuzMLfy8/iaTIsS1PnzvH/+g0W9WdXD4HgsRX9MhE8DJUPz/gK673Im3j gn3YSlxeYCVxK1PPryzmniwgV6rY4yq7SjhIshAelgcHtqVfj8maDk8Qt6cAKCnl zlD7TnuaMOGBEYPtvjfmyucfR80ERnzRszPwFuqRSy5cGs7wGSDGAok7Vg7LEwsy Ve/ToE7VyeehTP+2N/ysrCYzmtsZzE4hjbL6f2qztMeIKv73la1IHHKgT7vRPjxC +c2g6JdHNR5aYlyoynlNpyu1h9rNwTxfaXimPKWh7NRLQphSk+HMYpI9ix3YiDiN uJR1TWTWQK3AnharzUaViA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412mdsxagr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:12 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47KNi8oV033669; Tue, 20 Aug 2024 23:58:12 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41552xg9rn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LMAoNH2tquvPaVaOCTQ0nvCrTJFSha+a5lNZHmubMGMMDihwCxnkIaVFIREu0HgGnKeRS023EUZC2xQ9WaEnnkGww9SAauOGXkw9Ye5DfYftpw0b//bQt/lJPLXEh/1DgtqxCepC8iH9hWFpRq2dUG/DCojfxpQ9TAtRgYPlD7NL+n3Hxx0E/HtWnl+LjZUftOsLvInzs8a2JRU2/dW+07hUY9eAS2zeBfXznkmUvQAmzBh0ok/40RsEvot5e0aYG5vZjqFT169a6b/nn0w/6n6aycC6u1SKV21trfyioPJopktHxce2CrIRGBSJwSwFnyBAz8EahJS8j+sTfzUx7g== 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=7cM32KTH1tzc1Ltl5lH6KrVUwxyw6BJXIXdnd+YGGaw=; b=awT5Ib24lOTaJNxVbTuuO03+qZjUBLFW09XlKuKL5Ks2Fr1lAB7kweLavMHSxWi3YMivc8x1dSxbr9SnFaWTj03bDDODKUmqvvfYGLvjxvxBUy9HwjcJCQ5Eb8mTsVWkRwsaYZaei6Kw6iCXxgqTh4XyPPcl9H3LpIl17+5Hu0o2N670ok1Es2gETEZgmkY2hswq3yBRSo0G4xqu7Umra9iwemsoBNy41nnPL/1bWo1lEHQJ31e9yKb9p2YqJGBiB0oMUY+qZbPJeMdGa/KRKVr8psNdleOGDhf1RBecbhh8s2UWyp+m+NAxGzayXZqatuaH93/AqigygJEzBugoBg== 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=7cM32KTH1tzc1Ltl5lH6KrVUwxyw6BJXIXdnd+YGGaw=; b=kG926isLG3B3FxbuLf+r4EvmZ5ZY3e/ZtcTFvYWPKNtXn0Nakcx5A9qwUS3M8Za6qo9W/Yev5uBKcz+/cq/F8Q5bHxxgxTbqGZyfudHZZ6tyP9RMhZYcBb26o/+gn8lF0w/MUyVvtV3P2zwODbwqg6QN8GTp6KPNnXRZ7R3rNWE= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:09 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:09 +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 v6 12/20] mm/vma: Track start and end for munmap in vma_munmap_struct Date: Tue, 20 Aug 2024 19:57:21 -0400 Message-ID: <20240820235730.2852400-13-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0479.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d6::19) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: ddea7f9f-7a1c-4874-923f-08dcc173f139 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: 7j+YMejonpVEeOEqS8LZwMX3AVkiEaMcl1vMpS0cn4cXb/t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vXpUxxFVbpItFmoa4kHRTAQe2kUDAwmUKATrN9pbNHOQJ0BY/HAjUVKVWonHOnJTz6qiYR7oaAyKiYRt9Qsf/YRmdFFFXlbl84stIW/f3c8rlquehPUwWYkt4f3QD9xKOtvOfg+8MHc7k5pVUujwdc1DLg42OD6H5Fm7VXGz2sURMZ0oqC8Jsi5O1GPtKaI8P0H1ozqIuq9c4d+9vqzyqUF/IOuXoR27O+o9jNoZMyZ13U0KNMA== 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: 0y+Ng962avDhX3eMS/lZObwmq83V8wK3ewjlsd9qRVb3Dx5zTR6iJwWX3WIdUMa8jHl58grdCQmketaB1EC1DHDFfPXziHtzezpseb4grI+K24Q59T9h2jN+9gP58IPh7xJ4T79MRKIsxC5XW8xqm2MfE5uWO9fIAX8e364fPMi2skJiLwu8sDwrmbRQLDfCWxDi0jSU58hxe3s/R645zwkNQjWv1OfQbnRgJrJV33TLXKLio2cJo3Tn8ZfayKUS8vai/fjTXNs+VsoTscT91TYvWkduJqzZJk25SZy/zrLuEaruov3CZunJm92wgF20obzZomkPdkJZUJV/ls/suE2vO1yfHgSC5tMO/lQAB+K7l34WK9NVSo3UdFAI3fMymDUlkd57edYBhhDtqZis7ufXa0MMiBQWZKNjVABv99RFHQGkaQeVfjoQcOlrbKAQSixYJlZG4DyziUdP24acea78YwT8SINFc7uOAe8rl4o+6d//l3bxmeAM0oJC0gPUwO5WlEMzK8xvDKluDRFaesQzZjYRHkZERpGwfrqSsRmUQAtNzpoPL5e7fxY7zKRzLWtA3GKnBNtHABwLonum8HJa3vh3sFFi7nfmjNv0vR9xa0BuvkubIK1S55S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gYS8Rr5j2Iag+5jrw7iUEk6mZ4QiHIvZ2YSdGh+wtc4ST+5lcrGgqlxu9+3gDRmqq0N9ASbt5KUzT/TCA1Bp8+p4JrYHJrz8WATpOZqicLg+aIeWuQn7gjn+BMKYre+r+7FGGd5dm9X3fV9ATqhwe5CGcRt2GfLtB/X/CnLSwkVdYb4Xh9VK9b7Mi12VfDcML6/4N+BcphgvJR3EyXKjI0sSCApUrfQi4wNnZZkg39hc+FTHdujBqLJqLgJ1m39ZEb7Rf4Ju0QwNSQ72EKCvJi/zU7eLBVDmNtWB0wTEKHAhRqsuNOiDK9dKxihsB5p/aAjbi4Svt5ySD0eUTRW4zJmdXs60iqIt8JPQqWvmOI6e3pUzLJMYntwUApECGup3hmSfDlcUMdLclBTOZ44zFVxUJdpsgKbgX36ESC6qe05/wKruq1HE/KE8RTA0EIWQZRq7OWO4ZI3jNfqXLtVWQ6WAJ1gFBsC8Vf3LdaXVzkjKNIBr1RsVjFYVLGorHx0i5bmXaJ03sCfSoEIR0ifpAd0R+X0W8gkIvUTR1LSNdAY++Jy21rxcqqM1xUXWZfKbRJ7Eb3J87c0VK5aq0BZO6eykwl33hWO3zc5iQXjPLW4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddea7f9f-7a1c-4874-923f-08dcc173f139 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:09.3453 (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: XeUF9VWnElqMbuTTrEYl2AuyHLyub3H4g5RtMn+Ki01UVCtzr/vx22aJ62WCQ8f9Hhapdiq3FmHdHpjk9Dd3mA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: bvT6GbAxtERbTNSWLz5XWoE9aZzQewGt X-Proofpoint-GUID: bvT6GbAxtERbTNSWLz5XWoE9aZzQewGt X-Stat-Signature: twsssxjex4jskniorbumpt8s164psbu4 X-Rspam-User: X-Rspamd-Queue-Id: E6D4D10000E X-Rspamd-Server: rspam02 X-HE-Tag: 1724198298-279445 X-HE-Meta: U2FsdGVkX18FeUnCRsSBYjma9fPPUeBWm2T9tobnSeplk0zPThgPWsrbCFGLNMpDNed/ESFdOmA0huvIAxOUJZzLTs4j/xp2XgQSD7i3H3KxPykFVBBMylAa1GMJ8WNFRxc57967ZBDXNGlcBFiILNdcRdEIfULG5MoICCkpfi/WqAjcK6enFczbeBZH1H5KMTgVC2suO8t3X3PUSkSqRfx3cQCkierZJYm5S0kqFtgmmFC+zGdHDDdbeM8zXdQIANjCp04ljrRbD5XBWrjks+3sjQ0mkv3H9LPvalGuafQuL+6skK88ClfxQ4KjilvqwbYITpP4eto/kLdUt6zbZ802nAqNHwa908upDnKae4M76fc+Mlo9ku8FZQgTQbpiahseonOSD3mJlQvY4Qeu2OLGWIv5InAo+zwhmAmqudUU+d3K/occTVtH1YQZEDOLTUqONp8ppb5LeXiDFA8lB4Tda6GzyVf6EVDG3YifXk9cg1VJDtYFVrP1jIb886JcujiJlL0U4VQKlUppOhM6CNH+FWAmIBH8z9FtLyqEN8BuXULKYY+u51Kr7j+oz8K9cawALvpCCTUElSfvBaer73Ufs+11QnqMNNOhqCQEN78JgDIqu8TOjisWM1G4CihzeVsCNMcHQ1XZ75xOXmanSXLlWs16LixOthpCSbMZ/wlCQoblZ1Ur1OWe0OPRZ2Bb+LVV5HXXTTUXKFB/jRKy0cJJQCuPCrhO57iifAB9Fxak43br1RfUmYWqUCxQl1IuQw1W8Gv4klUEeCskX3eNwTyKAUjPByw8OQzf9v+G3CugM8722yNw1ZJ5jvgJg+xuaa8wzmsHc37zRvoc9wCWTlLlFni1Sv4Dh3+/YkLbWzs1YmzSjtGI+iaT1Bd/b3Hk8u2R/jpC1NB0m0u8JZ+hyBjTyY8nW6A3QMNArEI1HNtUPluBivQdwNPnq6TADziy1hSqXUxwAAFlyXJBElw ayuL5FU9 n2l8hvPdkmVZoiRviSqWP1pmp74Z3P9/aooSoEENJvPpABZhd+2KIYvYuHgTPnNeinLx4NgJlLdyACXiZOoqCPtr5xBGzv/e1CZoYurIluHiJqD7WC86rYEywXYgxEXmHRRXNzVnafSZTQbrGyaz878CE3rKi2GOMu5BRk1n2TWdmhxj8+rtVgTsVBppzVIVmUix/BENuzgDEzbPk4nTP+V4lyTFbJK4WTA3TETJLT7fn/exLbGgzOroP6AGR8lGKmoMrBYbctZriQSZShZS9JT+t3YfG3lJryysyp05k6YwF80DtQtpGWXAVfrZNBjziHAs/lDMCmHCB9dlaWP+o0Sv2avUVbIW83GMFF4PaU1NNt7T5qvjDqXzyNDenYF+fHARSU/E5CcEDur8GPkC/yY/Wn28rKbiIRwmXOHB4g9qOafxgtlAgGqzmm7BNiLGBYz+nQc4J1h/Pa5b32VzY70qw0Q== 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" 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 a8d716c39db2..5ba01dde52e7 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 */ @@ -741,6 +755,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 @@ -808,6 +824,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 Tue Aug 20 23:57:22 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: 13770673 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 2EE3FC3DA4A for ; Tue, 20 Aug 2024 23:58:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A278A6B00A6; Tue, 20 Aug 2024 19:58:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B21A6B00A7; Tue, 20 Aug 2024 19:58:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B4FA6B00A8; Tue, 20 Aug 2024 19:58:25 -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 560FA6B00A6 for ; Tue, 20 Aug 2024 19:58:25 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0EC721605F1 for ; Tue, 20 Aug 2024 23:58:25 +0000 (UTC) X-FDA: 82474290570.12.E91B7FE Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf04.hostedemail.com (Postfix) with ESMTP id A421E40006 for ; Tue, 20 Aug 2024 23:58:21 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=feJQT9lm; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OtDRbanS; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf04.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=1724198243; a=rsa-sha256; cv=pass; b=JSd/k3o8G4XdpCMFj0i4ncsGlDoMi2KIkw3wh+57STmkTfrSJ6rM4Cn3vq42Usha2iKGzy GK2Sno1BY7JQ6keD+NRHMIgYeeV1IE4z2byC7BYUTwWmIBqtybhj2Mx0C6tU+PTbB7M8Gf 0DFoJ8BopvFYFb5Aubi6XH/5JmN+/Vs= ARC-Authentication-Results: i=2; imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=feJQT9lm; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OtDRbanS; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf04.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=1724198243; 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=9tEwNxjNGC3trfidDDdxabxW9yBYLd3veiUzYxgKkUk=; b=xcKUIxFwbwbtIDnsktrGcBSwK8MI7cWca+/70fqUh9sXwboKuSlCMcc72BO+4qLuVqVZng h6QKLtMrEJgp3V8YkeygS4RhF5y9lKpR6OZ5mmTg1BQDelQPUbaMUvN9tN9dMn+i7fyCJ6 41lahppyiXZvyGHX8ZxL0B/7TIjF6IQ= 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 47KMBvvu005187; Tue, 20 Aug 2024 23:58:15 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=9tEwNxjNGC3trfidDDdxabxW9yBYLd3veiUzYxgKkUk=; b= feJQT9lmBfiCQdltLIOr9H71Tbb9D5W1WnPGkmfXh/Q2O0d9d2xPXWLeRRHVpUEi OnnEKPIoeaTOvNsAfhjNcFjK6a8drX24UGxMSgc6hgfvK/A74VVsI+iaM+rBtkgf zAA+D1gwb143wEp4AXGNopA/wXO84dZ1TluSyVULlPKrD4wAX2Nzz7DqWedHa6Ri k17OB1XkPy5u+rZDyZg2/0jKDkwoiX0vm6agN+svTzYFFMStciAAo7eNVVhoqX2v LeST2Fnd4LGUWMaqtHtxx8hcc8nZEWUiy7lfGi0Wfj0xXzJGMw7ua8gtQJOOlcBv badeWHAL0CbS009QyHvGrA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m67e8qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:14 +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 47KMinOH037575; Tue, 20 Aug 2024 23:58:13 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41546yhr0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oQvz2JufbVaXr8YWR72BQs2E4XGMGdeWjkjD+9KTP7PaE4T3jvEpIlaLDFsaCeC86uugbzn1KxS7X+ABVf/iKcDj3o8+5VOvVafTTVadvAKN+fq4wMlSognzOjCj2hEGAnjJ/aMH+GaWr+UQn851iLaPscu0goQR4atsafg9Vjp4ttK6SKGTZZ9cWQOA4+BjeAnTKe4GSHbrVJTQy7zdTq0ZJJeNPXpyhC1UuQaNGOdKkTfgH0qV7MwLgEEBVxOc9I32SLZPmasU1HNyyUF7vxuU8JNqwVDsml7bPzrXWq/krfRZQhx7X1WfhTcHyFbV9CyTSR6H0L762dpGmpsM6w== 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=9tEwNxjNGC3trfidDDdxabxW9yBYLd3veiUzYxgKkUk=; b=DTMI2XeKF/3MF1CtaR2P9QlXOq7bO7C9frnFVhRjMIx/i13w+xWdz/KPG2cdMGpEFvRlVjapf7hBFbzBnCyjiiFNyMS6tC4+rPN2jOUKWwDpTddCNGn+0EaDBps7nImb+lePXRpsPit1yi/5Yjng2tL+pvnAD5FrA78WcamMhvh+uvlYfjkewr9a+erQ3EkhmFKVjGw+ytK7CRYfddh/HzzN8MjCIe2mpzvstT333R+nhbzbKMrORKyDEfo4YVTTyyJMBqBMvqjVzKgFbj06cc5rLTA1UscSARo72EvTGUo3814lE7mdOwaZmFpPilTSNnuXWJ1yOsn1wXbxV1TIhA== 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=9tEwNxjNGC3trfidDDdxabxW9yBYLd3veiUzYxgKkUk=; b=OtDRbanSUvjmIz/LX15uM3q3bjopkozc9dVs3NIyBDl4IicpJBv/KfHEUsCbwXmg6ZT+sc72KICh2OrH/qYKnBzCx+Rn0NdGKq0ZyTmnnfq0LnEAkeCE1pS6sh3nnHVc8TavJjQkUWKjwSvaMCOSrK+lw/mD/SPnvHVq5RujSMU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58: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.010; Tue, 20 Aug 2024 23:58: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" Subject: [PATCH v6 13/20] mm: Clean up unmap_region() argument list Date: Tue, 20 Aug 2024 19:57:22 -0400 Message-ID: <20240820235730.2852400-14-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0320.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10a::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_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 72dbf3ef-7f2d-44cb-5824-08dcc173f25a 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: NBRhYgEja2dGfwRuyZ3ERSzaNQ/Mrj/8/RAuUNh4lrgtkmKwexMxO/aM1Gq66NG0WwQ312YuIbC5pBxi83BgrRG/azl+ydo/5zRAeg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soFSjX659BVnbZA1ZwKouNOSv5GX1+muoGOESCDC8HWWnq7ULiuZuX19aqwt7ZI3BsvjKW84geu2mvl9OgyZuhGY0QxgmwAP6ysP8R1Qhg3I3miX5f9ZAOUPD6EVNtUFEWvp9C7wJukKGrbXY3Q5GJNJ/xqRHgBv3kbbNpEgdsdTzqMB6gt7A7JB+1I1ZOQ== 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: VB2WvdRVax9cgc2YPVbJ7HxZBn6vuVYHoMxioBHrWbK8E6Y53hq6+Iz9DhBFZ3CFje+/4lgeFtsk0MqQRw0xFXxtTOXkqv1XKsI+0PKN3QWYiUYwq3fMrr6W6pn8xviGIcoIKisExv45TdmDQKsrxvSyqeiOLihzb8Bapjx6pgJeGCz/euZJ46jVgyF7ircnCZlkuBvwcqevSrQRsOVYC2oGsswu0AczaOPPkcLrSPabq1D9W0gXTtrFQXAShxC5lsX6vNhMizYkg2coYT4fi+0D6MwqWKfrW1VkYopC1w9DAahgUzsXzYNzqs4CGJ2CXdJvysxVe5VVI9457Q6AKm9oVdda54DFqdo/1903AdO6F7+waLsKvdcChDbcM7KftfS+H2Cf3cAc8epTM/KMoUIdtXhHlV/J8N8J+K7gIf4sezcFpStyDNm6U1mqz4HPNasnsYKPz0HLeVzGsOd44EUV2G7HRdaoZPL2duBadzsFeYViMnCW3C3E6HhKveY0JthorLmreJQ0THqYR7PZjwckdlgisCG9TJnBGaxjV/8IT/yWS50sXGfal02S03tV0uIiTAGcnGARrCkztA69Uk0SP6oRDddipXNVj/OGTxoB4PniIjlDzXIgOVJ9k5KHotqLbfFnujvUDor8jxzM+/9xbswZyU/BFu5Gw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WDHNvnox6OiV0CZSEypy+3cVvkO4P6XhvKWdcy2VP6OP9pYf/Y6aecbI7vwZIyt66iImm2vSYHCn7I0esJps5kQuk75i0gTTY/mGtgPBUjNpgzRyg2Lruc3WdgpnXpCUwgt9xcQvfUp6nat6uHR4E1Q0Ryo639dKqvZKf1tub+cZFvjX1Pqlg2BH68SrKfuU0OSTpg6Nl9flMaXzzt9UQL+VXYeP1CHmZPZviXTMLmLKC/a5kz/xyTd2jGQiXDISgiMJlj7hM5u1bH8IJHBQkP9i4Iz4+lRV2/sKLXn/cWLZDixN75QWySv6Aw4B83TmKY4nsy5/YKcsnzyk2pFk7iJiepQou2USA8Gy2aWxC8/q1v8o2IwWvADnOx7b0VqL9+6Dx2weDImvvloXnNu8jk+c7meZwzemRGaqS/ZiMB9RFSEBqA05O6xR3vRMEBvitRVPMgc4V5N1pwZ5DA3rbYZXu4GgAG3tZo6QbQa7JNlicp8qRxzBVOabAVWmQDySpowMpck+sTUWBd7lreznaP4Dg4zo8aD1MRWQ19gOT612DdvAX5zJc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72dbf3ef-7f2d-44cb-5824-08dcc173f25a X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:11.3421 (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: 9w34LRFph3pUA+/Ft/DbM2LSZheZAqt7izAvYf6RiwoxLNaLMJAWVxmprGvMnkQX5rWkSt/VfKJaHB73IXwJSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: rlsHmofMYRIYAkEi1rr1KqAbo80L70pT X-Proofpoint-GUID: rlsHmofMYRIYAkEi1rr1KqAbo80L70pT X-Rspamd-Queue-Id: A421E40006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: bwxtoh4op5uhst1mwzme76ewb1zjoqjh X-HE-Tag: 1724198301-413949 X-HE-Meta: U2FsdGVkX1+gYh0YkHS2Efd6axq8XuDsRk+u73XYzG887J9x5hfHYq7+CgeFngQQt2g6TJsY+JDrSAF/hpkkUClIosQfzufbROks+dG5p7SueR4zQA3wsLS97JjGGUOcRSxPl+8RL26DA96b8RTpXUveFdVIaEJvvuUqDKfXmphUFTUf7am7wW+MW/kZMrCcrn42lUqoXF32yIvaEMYwY2DY3tD1dLwty2Jv3zm/G+NDWJ0rva1K5dYso8p42gqi2gGkAYdR+2Tjv9TqVErVF8c1yYQelCx+KVpCoAAc2vMnQ4oAQ3MmUHcadRomvLi8iEVbYvUs3qWEcLvBotCi4W/jy7OgVfx64VKcdG3u0k9bbuxY1AmB8Whz6BuB8H3KdQXoPzXIlwho4c3Ju3+UN50YctRaDi4qHs0DbXkNwlFF7tppovaQnqClQ8B7nJz9OPgvaCs9eM4sM40C0FeT+eW1FcQSeOXbjMBBBjcUpfzKzHrdrHzqfG1KdiCI3WnNYf1MQxz+ms+gdSXEON2gya7tOBIs/Q17F4loHarGRCpqTDP1tFtyJ4cQF5XisnHBfDHBR487GPZoGYnnRT8kQ8iYIVbrcr+7+kNWmoTlV6qsIcSiPD2fm8/7U25F2W38KJwDZh7T6H+1gJABAlQmP0L6csuA3IbiYqs9zBxNPZys38EKjUCwyYAzc1ST1c/5zYF+ZmGBVrLu1jLFr2sPgaI5gzayzSSLvL+ENiXNgJNuSZTKQkL1FccVcema255Q1Sy81GcXZbzVm1L4zRREXXDxkt+qRyqHFWBPCGc/xkrwFBRK6o6r5jCgAZoBzkn/Ay20zU85abmy+skmTd9lVhHXS9NdLgVTwxLsCeqdHRzq6tZ68FnadPKVKRfLSGJHZFwNBgJxSdtwBG527KFlObZRXW40cifLewi+1Az/jYB91S1DEmMqFuVWlzDgBKJfGnspWHFCXgrhxdHE9Tg GFhrC3R3 9cBTkcrzT+ptDEFt6HgqD02Dr1JB8qzImxAXRiouYsEbn/L0N6lTcLh9I+zhSGJjo2EGWSnJdx8V43NCtoI0k9vAHU8ivlR/LkdpsUwAHNMmxgpSOEx9NkeXjkwLDFzVTCN7nvDrxH0G4E5mM9bwJYm8uvy25htQKINym1BGxTU8y1Y2UpehixSaCFjOrOS18/uX2HhAVuZx8EKTz1+BU2dsZSt+uxup5B9K3+pAyE1xhTuGOP+IvgkalAYUOzELO33kAu4R0xKYB/uhacZ9svqMWxvX5MFkvnESyhNpLo/thxLFA0t++jdfXydZtpFIrM0pWOgIBc1ltDG/Hyzv/u2Ytth35McQlJDPhuWL4/gBwtms5JyVmh9E0IciI1/ThBoQWitHVJELirmQoazFrIYVtFHu3uuu0WYZe3X7v5Du8YSgDW9b0NZT9Ns7Y3MKIIXuFm4R+YVgvDTXHB+zmKoHNF+gNRhB5NeaN7bAyAO6GLUgQfJU6JOser8NF4rs7L7BQQSfBGpi84A7i2B/vksYOlXRWSAzpYCe5cAmRXUKIUf3n/Mam5QaqaQ== 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" 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 5ba01dde52e7..7104c2c080bb 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 Tue Aug 20 23:57: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: 13770676 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 CDD08C5320E for ; Tue, 20 Aug 2024 23:58:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57CB16B00B2; Tue, 20 Aug 2024 19:58:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F4D16B00B4; Tue, 20 Aug 2024 19:58:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AE5B6B00B3; Tue, 20 Aug 2024 19:58:34 -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 EB3086B00B0 for ; Tue, 20 Aug 2024 19:58:33 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A64EC16065B for ; Tue, 20 Aug 2024 23:58:33 +0000 (UTC) X-FDA: 82474290906.20.E4E060C Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf02.hostedemail.com (Postfix) with ESMTP id 5E9D28001B for ; Tue, 20 Aug 2024 23:58:30 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=iKKYPDuV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=LmA1o+xd; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724198231; 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=mYzjgcT0Ns/K/MAg9MEWqBBmmk3U8iiO2h1IDlSxUIc=; b=PwVetmi9WpHpvHcyjygGcvF1my7IZHOEJXQVVKE09o9zYTYGAKTzs670+XyVeLo/IMHq4B NQFHiDSgjbRHdxVHzOblgMtPbOBdmrDMMz84jGhRSL5J2y0hqh8QKE2gFHCcm8JacpHRow wwV3m/DG/DzZ4944vK2eyeEKJd8pZXU= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198231; a=rsa-sha256; cv=pass; b=ktUadQvqjOONgbrbR0pRSIfln/p1D4w5tlb/G1ccJM7WbzAAAkfMHJYD4OfzebksiQMQK1 dBRMLEz5HzxvRnfhIP7S86pWtKfWvh3YaqvXPdSeCDxwL8U4sAr6uCkd6RfIdWH3xtyHXn WShe1whML8LOtj9oLb1lD7pl6Iv8xiU= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=iKKYPDuV; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=LmA1o+xd; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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 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 47KMBa8x017785; Tue, 20 Aug 2024 23:58:22 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=mYzjgcT0Ns/K/MAg9MEWqBBmmk3U8iiO2h1IDlSxUIc=; b= iKKYPDuVUh/iY5ThywtPK9elkPNQ7oyKpg2ni8+6i0uvR4g8YD6hPg2bfSTO5Cop EeXgNMu3U4/U36AjlEfUkyo8OZDESOa7QgaIrzKaS7mSLOqCP/3ubQL+d6pzpafH yjYH8GCLcOXMN++gFsTQEOJCC0FAuOQ0xT00ej0WJALbRSggr3TxtcysbMXbzycc WxeTr9/q1iS9gbd+zldVW/qfgJiIlfKQTn//j5tTvO8a2fjPe4OMlwHN12flq42b hCF7cvjeKdco0flqQNDuAsjC2klD3FiZXw6lfYCYXn3zFp1qS3HnZa2VcqoualFq i8ASFdJrW71OiR8b7YiNUA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412mdsxagv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:22 +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 47KNY1IL023382; Tue, 20 Aug 2024 23:58:21 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2173.outbound.protection.outlook.com [104.47.58.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4154x78g2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x9oFZESBAcTYwvBCqdW/klrXpPA46IM5jSm6LdtIFVOGTAGX7FBJFksbbdXTrUBbsJOFhoZjxSAML9S3uHLQ3GECv8QYGE42NDNLJD31bY7lDNvhFRkthZJVtshPtWJuYeRPYqEmbhIZ1OZZc9orNjybEHFtgrKdClQPv+hMrGkfGN9yhFJkjt9JgS+6FGXOKgVTfkbAhFyZbNia978uGvWxDnJtWykWcBwe6OTASxDpMa2vEjwX7ELEZNfMUg2Y4KtNxHoUOSzaPiP1KeNQ1kk1nQSHP8egUeLNTvyVwB3K9tYHeI7QmGueZrC93tUxlcX/VXSPbuP5VVjqIaXI3w== 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=mYzjgcT0Ns/K/MAg9MEWqBBmmk3U8iiO2h1IDlSxUIc=; b=AbPLGEi7Sp3ha9QiBJ/SX3vIVhq1pwrS6y1z/dD2ER3/GM1ci9y3zxg6QgID6IDtaA/VfJyYjZY2F3B+HLSrAL4BztfckuK/IX1j+dSxoRE1Vf6BROmrq6AM3CNeMLEXlNdyUSaJ4XKjD3SLMR04x3AmpXW2igJP3TVmRbDvrd/OTzm11ePGVWVfR1sEKbRXvXSjIuVUInh3QBzydAF5Fz5y/sJ3fyRn6lqg+9Cu0h63vhQwrGfH42xr0ZvQsRGRqgcOxUpTXTUW49hqLR/g0hQjkZFoU+xibXP+aAmob9OyWu55a1W2XO4yC+iCB+2CTnWid/lFehqqc/vzMwgBdA== 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=mYzjgcT0Ns/K/MAg9MEWqBBmmk3U8iiO2h1IDlSxUIc=; b=LmA1o+xdRRBQSOapHA91momzxQgrJLUZtN5a0VaSc9OfBrs9MB9XcIX4ldyZKBmvMJaKIic0C9A4kyPbVot3i71/GECykuhyVMOOLyLJno+526hYgUjoLWeBb+dJgt+X9JBSzrpDMRZMH9Z8koJwLAhQNfy6+jUIhZsxCEegdCU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:13 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:13 +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 v6 14/20] mm/mmap: Avoid zeroing vma tree in mmap_region() Date: Tue, 20 Aug 2024 19:57:23 -0400 Message-ID: <20240820235730.2852400-15-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: 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_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: b38d223f-c1c6-4ae6-184a-08dcc173f397 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: itD2Fxz7dhWw0R7hN6ixg6zot71s570PBZ8upV329AeIhHSMmRM5uCkB+rLJw6xiIIx0WgxXTA/lFiiBT6sZutnvVigvvPP/veGlHNJ+28vgNJEAGU2vEZgYtV9uP1EQL1KuaWDR2v8qQ3QroIWkFG33xLugzIuNN8sS8QxdC9R0evlF1uvAEC8OlZA6yf4R1LFaIVjzEeXSOd+yxvEIAyO/45/41ohOM7Wbt3hwr9PcfIJz+ilbX7s706SkZ89WreiuqUFY5w+QnQeOdgiio4xKq45QUsbmZxYjFq9OYY209AvKfldf9OUotZMo4HSMLyzs6gkpUz+UwUCOpoEk6Y9KZmCUMepNBrkTX5mNZPfoG1G17fJsnbi9x50Mwe2lMPPU3Px78R3JvnraGJOWHykl1L7ykzEaKdedg03m7KKOyGkuNyR8bLqrpGIwIjjc26oFHZd0Od+1m/0MbQF15HUID58OFhU8OfCQngBVvVcyHu6oHAhU4FPB3HIuRFukEwWFi9GaPz7NlGFCDEUY34AVCNwO1lBK6j2jZoo/GLffiGb/ipGazDN3jRCAZ3afERJQ6Nidj24D8uJyXvRLjicldQvapaUtMaeo0UTyhMJRACeIawWhvo8QmocXzDiqH3qN2bhiwyuOeOcdK5QHbFBgGqgwwr+CsSji8EzVQzI+FNtD7lK3Q0jJgEQJWQSuqW8FDxakUgVNV+PU201P1rHWo1mC1qHTvc5jKf0Xc49L2mdtCYXcgC909MEh5Ma+tgnAr4w8MB8ny04H9n7ItSKY7qJHrhPUwomSDG/Kct6a4w+TbJCrDyDaXupEVAt37bk98HOGQQlyxwBmfLV+WKn+N3ZeH270tvpiIEU5T6ldZnUCsTyBTDabmfg8rwBxnj4FJKSqvP7dcIP8YvwAXdIKs2hJmMvX/i5EU/ib385dftHbpDFo1aH+88+46P5xSmWGU94tarZP7NCO8YgZqzizfnAPkrHrknQSb/hmNcRvWF2Oi8FFqkYSWC2AgGuMglHIYOfoJ4m3Bq3ybVgms3hDFdDxhMPfTz5FJyJl5zAkncoG2ATFj+Y6zstmlzm2GB+M0dHGkEVkUwwoSKgDWDtrscBIMSu0IK0xxlN80rhBkXztDxak2Ly4gc2xs9l2rLDl/1B1NtRBgTNYWFEer9ovjTubkZT6W9DMjLP5MYRxj+MFchNXavOLyjE2+Wy2f421/BzHVQu8nMgdZVg2DUPOarFohjtI4WodXgWY3uOLaCfjEtBGO7v61akJLMXvEaUJeALmm8kK+qniYttH5dIxnVvPavOxoD9Cj6kAR5hbeHR2nJ3eLaAkpC+FuuAvsgdqMzRejlmVhefIozeSsw== 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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bb9DqpCBMokc6BFQreydjXTlX6Eex4qFxA2DVidm1XL5GHmqzyf39cLb4ozxWPiMUmzejb6YHLlX6Rs6sVnLEbXx1UKqimzZ/62iQHQxl/omMKeodCf3JjAj/ShxpXwTWdRoqkmsb1xqA396E2/trbbTbBK5j9d0girQZ8pPOgSVW3SOKnRbqLDJc3sELu/bu/YJlMlfjtB3w8Iy2K1ZXTYGFXh7l+YI1QPv0GsELAZhk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b38d223f-c1c6-4ae6-184a-08dcc173f397 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:13.3296 (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: 0bWYXsm/64qDvXDyjwyHso2qS8Sr7AOqu31lRV1Yx0Ynk+ge4rJ6GWo3VL7tDraGanp3RLULN943Nx5ZPSVVFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: 3nXwtLY0qE24pLf4hlDMjb2XR-FAZO3m X-Proofpoint-GUID: 3nXwtLY0qE24pLf4hlDMjb2XR-FAZO3m X-Stat-Signature: a435krk97tx6oy3497cjgk37469it6ud X-Rspamd-Queue-Id: 5E9D28001B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724198310-937234 X-HE-Meta: U2FsdGVkX19QKY+SRFG7c0snLUpwQK1iNK0rtOCc6VXx8ElbMkpJe3voNdv0rTdBR3qp2cNNO6im2e8nSjdKaodo8QFCXShM2fPEuZP56HzcGmRpE1vVthHjGwyoCNSggE8Y2miA8z1ee12noGNZSqPfnCPuniWW7r/85I98A2tuGQgRoPlU64a8XKpRPCeRETXDA5P4kKIVakUAaSb0MgrkdsXgeSXSQ0tdsmLWiSsBiLtZaF4FKmAwnRcetkyu6vjA60kvwPPMF3FczGkekZKcIRlUSlv/lyCkyVniSp8gdhjx26gKdcrTHRlu1aK9+z8gQO7CN30wOuw/3L7u+TML4Se0IGOwtCeCRjRpZNPz20TEweQp09yisUL8OYnma2sBfkoGGdgtMbxVMTWkOAff4dX3WQCr0mnn6gFzmptc5bE0+V/w6Hy55KD7YFhyBZ6H7F5IOf/i9C3sLwIITzCLzdDhsfGnrysP/1WYyKCK3BdqdVe9g7VzV9thgsDgl4JdoMV9A2t+J6bA0WmxuMJuYk8g/QUBrRigCaKg0WOApeMn5dZ6m2m5U0tVbExqZk4bwYzDqwa189KYXEgcwq1NQQB2TcNwBD0p1/kQpOM1/81r3JbffExdgAlagv20IBu6r/bsXo8KB95V1vM7cbMdZP+1FzCeFgQlHplui7qj9+ITavMpA5gRO/MiaOyBhZmX9/R9Wh4BUDukkLwoLWAGfByBGYF7BGTEjI1cyHGNCivTMqXuGEHOQ7dNmSIbqD8x6fs090sc70yMPKkKerKzo4BDwq5z5znwdZ0evfHGYnZkZNGFqzJ5qhiulvtH8PrrqEFg8wFCoHgTNaxLrHbiKnuyjeqFPGy/54TNF4vXpCWOcVcANyOQGM3J06kXewg5ICYZkiuxWkq50JicHYXMxaPcbhqtfMlNEYuTYiIb9gLrFcHk7yVa2AYNZeIXEO1/8cUnBIfOXxauuvl fBs8ba60 euRgQMKWtLOcIm66u5v3YkqP3KEEx0OxhcVoiowi3hVD6Hbn8wrG4Kz8SJkjU4BI3ca2RdiI2i7BeaYwkZPg6NKu2p8xdmGRRnw/4OWuiE3rV6KVOXrrG7SUS05BWuxO6vZ5gaPVIShftGfZY6UIkxLRMzO/BsGG7om2pVnTTfIPjXySY2cQNonYstUS0dVtwduyWsL8P04PpWBP0r/HxpzUD7vmBtmlqbVvJUzTazv3WfExazxIHB+yW6hw8qIrCjIGvycRVFYHFZ1Vo3VHC9YrNonXtGVqU8hrNXzeHhpl8/9RXAJndOcJIIJi8dYdn5W/WpK7GxDS0mtXNqd/R5eNQV7+aw58+8vn96kl0Fzf2hqcGGcWadsUSKTi9DM6j5jCjbAySL2/ILeauLfhOcVZhUROkt9l9GaqA0b6h7Q+ytsk93Ap8w5naZU5RjMJpLtPF2aivMX46G2RPNgbno96R7x7y+Whc+PcKnD/Fsgd6DjSNeO8kFyEwoDQOM8bHpo892bVGcA7v2NwBeJLde+LRkw== 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. 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 7104c2c080bb..5b33f7460ab7 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 */ @@ -697,7 +722,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); @@ -849,13 +874,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; @@ -900,7 +926,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; @@ -1618,17 +1644,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 Tue Aug 20 23:57: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: 13770674 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 A7083C3DA4A for ; Tue, 20 Aug 2024 23:58:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BB386B00AD; Tue, 20 Aug 2024 19:58:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 93BD16B00AE; Tue, 20 Aug 2024 19:58:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A35C6B00AF; Tue, 20 Aug 2024 19:58:32 -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 3DB1D6B00AD for ; Tue, 20 Aug 2024 19:58:32 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E71E1120696 for ; Tue, 20 Aug 2024 23:58:31 +0000 (UTC) X-FDA: 82474290822.27.188E10E Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf28.hostedemail.com (Postfix) with ESMTP id AC8E1C000D for ; Tue, 20 Aug 2024 23:58:28 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=a5708ec1; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=tPcfkCGT; 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=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198292; a=rsa-sha256; cv=pass; b=hj2yPnxwdRjVuCXzfeXrnotku8HGLzMP90hhkmnZ6UBT9ePGDe8CPqCtHxhVPxdE4E+bAl hcT1niCAXn2kQtMCc20/RGpZdvNZLmPkf8qQ2LZa0TZt6MYMM4CxuCRn43RKUbf3OlF9S0 +5BB4lEyiYkAZlkDMd1DuEq5hatTLVg= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=a5708ec1; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=tPcfkCGT; 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=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=1724198292; 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=CKnNlRY4znAwLGI+HO8zfHTa/X/PrK1n5BdvPU67AfQ=; b=Y9tbzPuqvIcNT13fNjLM+5QilNUDIjJugZCf5ttI8wftgF4EzfXjA3oE+QOt5B0IfwxHzl 978Pqj/O5mpf5ErMTy08TZqhPKGAlfe5jB1cpuXr/vBDV1pqfSpqD9LXoka1fDDBsBVXz7 d6EB2oloATu7UkfMW8cHNt+6SgEkQV4= 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 47KMBdNE016629; Tue, 20 Aug 2024 23:58:22 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=CKnNlRY4znAwLGI+HO8zfHTa/X/PrK1n5BdvPU67AfQ=; b= a5708ec1Qe3yqZtM12mpU+4kXUhqu2ZYNjA3jgP5Ar/RgGd2j4Odaggxr7mqceeS woPt1m2da6yrT5wDhMIYWnRlKFHPtouF6OMwT8HIC/rJ5kf7cI7N7aeG6Qy7abbt 5wYd8D4oBpXsqkspt8WZ+c8yVmzpDh+RXAIeKI/OVVf7h8DE71OkJd4dr1HxnmRj ZgSi1v7bYzEQaiAqrtXZz1eS7mtjdZK4QrqXd00noNZMCa+HGRRYHKD3foMJd/hx M4bitfT0/4y9T01eGPSM2g5/HkAeHP8b7AZO2CbevGMyQ66kh5KDDuZLo8ktkBfz jMhVvBQfeDBvdFoZlbi1jA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m2dedrn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:22 +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 47KNY1IM023382; Tue, 20 Aug 2024 23:58:21 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2173.outbound.protection.outlook.com [104.47.58.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4154x78g2k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uBSplbAc+CSTHuXcB0I6DxgEX6BIWq+4gIw8AMDJe0J9uqx/jX4RIaVRGKJjsvQY6VMiMiT/n/h/r8mfl/h0P17YoYxOWNPE5H5rc563L9FiEcQYYkKiaWYaO+XdwVty6OQxfoYv3U9o0ScTMxNM61PFWriMA7CVMQXtSCgRQtdj40zdOUe9jOx67FsRIvPoTYaKTa5WSRjGyqOg28Y9zVng+gXnBKqin/DWJygqXVAtofQYeCrdN9ACHua4ar/ubFpMLUAUPhlE77K3vD0183rr7IsrUfRlMiVKEbKVC/wGylLwC1XXtKQ0M84dDHZ9Bx+vpHeLKaW97UPWpxwZlQ== 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=CKnNlRY4znAwLGI+HO8zfHTa/X/PrK1n5BdvPU67AfQ=; b=DkznyeLukdbgL3kZHbZpJ9x+6q0LcHqVSjv75yK87NzWcRQPGSt2zd4oK4rsDZsHQsPJqDvl7kdKCGEafsVUmykb19J/BbNlbvyN+weUidSNR4qxIdY/BCzHxl3wTOYYoIa4KkpMYrzAnrutnl70LxU85gE9BIlCeU+aJpji7Os6sHp9cTlOL2bFLrjlLmB55xVAC033GOV72awq/qneiqjX2nmLS/Xd2ZzfClKNlWlqb/1Lzxy0vUrCa/9dEotIGTqFZxpSG6zTLecO26zsE3rJswtGRycQb+RtlyfIQX5nb9DC+IZDf7MMpTmJaVwRT8lGp4jjet2b6gquwGtT7g== 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=CKnNlRY4znAwLGI+HO8zfHTa/X/PrK1n5BdvPU67AfQ=; b=tPcfkCGTfJgASJqKwvZjfKP6gcScWeXNEB3FqgzWiN5NEkF9oxSQpTtUhN3LurgegfygY7X1pMdBBw7Did+ueqXItxnZpXWpUhJb0vaE8grt6jWRHx+sRUmuXoe102hNN10FMSBRp14TLae3XFvnmn2uRwPgObaUtTpc1zmvT94= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:15 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:15 +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 v6 15/20] mm: Change failure of MAP_FIXED to restoring the gap on failure Date: Tue, 20 Aug 2024 19:57:24 -0400 Message-ID: <20240820235730.2852400-16-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0167.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ac::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_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 839c3e95-7057-4593-4400-08dcc173f4c0 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: AHhK11IlXFH75vDVFqqoknAh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IerV/F4ip8wcpFH5udrxSaX8F/IDfld6X3ZeEdN/d70zjtD90/alDsYTqCDZypuDxg/HeP81bxD6yAn+TOo22JLSutWvihYq7R5exFAsFaCiou5Kr+XKEBLPQyV9n+KtUqW99WSWpURTJBaPoG51GfZ+9g/q+0MGT3KDcsTz1tsWnioxZMrOaK6wUFSCfomZkuNoicXp0aNfKwWXSWDPqmuptRv+SoAzZ4bRbl/0RFZNXdGEbs7ap6xUGphApHZQ== 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: Z0b0tsbEOhtmBwbBnzILMekcQkVCtx2JW40NHGuSA7gOnDmP8aPNrtGrSk7jVmU4qFnH3h0Q/q0ZB50ppgInu9zM9TW1M9q016leeDiYJnxRB1jdrs11zfTNoqDRyCZ8LSs4y/FYsL7RDP50Bhjz9rlb05vPgG7cP8THlFyiue5AkpToHHGA76PMzSPp90lj0lmhcZ0RVCSOzS8Q7wnmXAozLxTqDH4QX2TnOmTrskNOPxACoj1Ws/UIVm2VC66q6Mp1RWDjZyt9iSc9VyR0qmywnvR2HJyVjq+5pYlsrQidOqZXEr0v2S9DzycZhlaNjBmdOiPIKqd4IT0Q9IvdMqVR+f6VhDH72QFJPB/I5y+xgmAa76je0ja1PmtWOegicTkHWbHagL0TIdQOWPz0L7lwupR3Tz2HIQhKYNZq4ri2W+xrHhYd81WAamHvkUGb1Ghj3QIWYMqr5jnNE0Zh3hnXQ1iMNyof9BmgZVMYi4F1S3e9jzqaatTNxYoRvqGuQmHSw5xvfmog0GN6PHI9MwBWqKCmOJzC1/DwHlRQEuvryUWj285Qsf+vU5cZYvRBNCVlZT5/SkzD3XUd/OxrAbYAw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essageData-0: bp8G8DoKUvdURNZ90MPNWH8rfQoxBxsgM8PuRcNOf03LyJZEljjPWssoGYCVYSckVmEP3znSeUyPQxb7P8S7Z0A+XptkASut7RZByIaqP4eUnOybYbyfpZlC6MUZTYjOlf4GkGdF7LmxvqFdmDJWqMw1ebxOmnmSzZJGxJZ6pglDzJjy/4vi3foKSK25GpGPipQpMN3iK1M8llgTAilRLtSouSsoOyGnAImzsehJVC33NcUu58dyiUgJNwRWSsdhtG9F9dTbkogDL584wxQN5XAh/XqdPIB/JUFf/XuqOZearctl+hMC7123cP30T4xZ1Hf35PirXTVdqapYtxNW3OGgRrkGHnwygmEU6YEo1BgfAE7GJEeXLPaG8kO61NVlZDXVnG0A4nYm8uB1HykwBv9xbORnBkBnjbtUF90+wZPb+gJtdCsWz6yKtJwoyPPNpX2QTDbjHCC3OFcnM8PMAaqa1QRqsjMT1d6tOgiW0bPoEwlrpSHgNZu3HCKvAQsI/Umgo67Pv/XNfMJotKsbc9ZcANXC8GWrkhLSvs4ZOlNFm+pVIFrQIziFIwrUj/LbMHNZQkSmSUbE5dAjm+bmk8Dj44PL5kmUlEKKkAlkS4Y= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 839c3e95-7057-4593-4400-08dcc173f4c0 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:15.2705 (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: RTM2EuopIMZr6lm9K28Hc99DiEFC7UuHdOju3QYn3Gz2F7FqhaCZbFrd00lpwm+Oa1hnmzmdZoWKt29JSARokA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-GUID: TPsk4msRKmLbfgiSTxbGDVQbfhF0-6uM X-Proofpoint-ORIG-GUID: TPsk4msRKmLbfgiSTxbGDVQbfhF0-6uM X-Rspam-User: X-Rspamd-Queue-Id: AC8E1C000D X-Rspamd-Server: rspam01 X-Stat-Signature: ehawpdwqmcbpdwo8h3iojs6hqwajah6u X-HE-Tag: 1724198308-509038 X-HE-Meta: U2FsdGVkX1/zG2XWDkEJr7X6f8Y1exDECpkNxPigno4SqNNjT5ELc6qs8MGLdgtfSKoFRSXo5Rk/YOrIwNff9LdHy+XLcw2nCcE5PCMXw9Ze1YVytvQ18khzFHKW+YImu2WtaZn1vhBnqwnokyVkhmFLFJDTZXPqB+oJFvZf1OcL9caqdA4+tf0Q7WwfQcgxv9SRdKALMAy9wyJAUKxcKmxstobc0yLGbabtBLO+P4RnzsZOlmAREqEjyUv6e4m2FyeJR7KumjusTM/X5Pr+VJM2qlMEHKzIpMk4zoFiCTGKEsDwYDH4eVMvGf4xuHmyuN3z1RKU8Rdkz4VH0vyz13F2KQggaJA/TiXqZb/TePm8ydHIvvUOY74cn+7FTvvFJQAXDSsFXUEekkvvHdy7lpp4P07biw+0ih0FBaGB7likq/6V7DpyrD+wnX1FyiiOTY0D36NdzpitXo/ZRfkVpf8hMgtVI/D0/PxuKTIgmX/zbaRJC6aYUE41bMT94xi8K8n+UVO7bn06qDGL83DgyQqoXNp22Kz+CTH2lYGGBb2Tx/GFfQ/Iq772DSWR90qmTecLNsUEWvS4vxOvLePMpl1y8EWrtEa+XvFI5EwRbVM52xQrhC+WI23uwcR24TGNXLRTGpgEolWI/skOwpzYnWpxKXWfE868UhZdC8v7+Z3ropTfIxTMlXsUJHKG9NKs0CXOtGgu9KvZlgfAbshEJMUPW21awMi/3slTHIs/13Q2erDlIYN0Nncr1vsB8ZlppPsLE6rsleZyS/F8t2AJStVeC/Nzc6aveyPe8wVqoa4knZM8zTOiUSBhLnSohdBvKiAjFRnwIP/+pLJIkDxBvXFMFvy9k93H2UASTnAIWM9FnkH2Dm0kfOlgDHj0pjnTAHLI2kgZIMVlyhrvU6n3bmib7lzhjxUNh2+XAhAqy3U2/EUxx09hv6VD1KdjBkiFPnebOTikn888cC3OPYi 9T3+bTA6 YQKJuGbcp0YB8WySuH8Mr/u4KxqTy33SmepTgotMT6kewmninRbHgf4WY0E8K7l8vIhahhNVIpu3bomdvYWcAUEECEYXXUlvunzDBgCCK7QRnVDdNfb5oPBmIYyDqwDEM5wMrD0gfaJYd0muVVOVCbdQAr8KJsgH2G/lKNr75lvOkmKz3i6ygBepzdTOpqV6kkaBndw3oczEE8nkYNmETpv1KY5JOWtDBVWhO61FzcAyp9LrrgYlawzHRGcMD15j9RYpNj/TwFpE7gLO+k0fZnN7VKRbs/xeTb6bCnxd+rjDD8rabzcpftghqaaf2vrqmCit/OrnqKkcujJUrPYjTytNSPjvJ+yyBvQTLpPvBQyd9EIoUUtN51cGTju6PTow+IkFjqhfTcwvnYnFdVR280+Vqi04nlPoUptcnNN1I8C6pFKlAW0yoFLbbIyoLi1qEhmitcjWVg5zRvIsAlgYcXvcO0q5gNAEUXA3bUom7YKou6Uz0edwv3FWQ7w== 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. 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.h | 62 +++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 6550d9470d3a..c1b3d17f97be 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, vms.closed_vm_ops); validate_mm(mm); return error; } diff --git a/mm/vma.h b/mm/vma.h index 756dd42a6ec4..7618ddbfd2b2 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 @@ -136,15 +152,37 @@ 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); } +static inline void vms_abort_munmap_vmas(struct vma_munmap_struct *vms, + struct ma_state *mas_detach, bool closed) +{ + if (!vms->nr_pages) + return; + + if (vms->clear_ptes) + return abort_munmap_vmas(mas_detach, vms->closed_vm_ops); + + /* + * 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 */ + abort_munmap_vmas(mas_detach, vms->closed_vm_ops); + } 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 +335,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 Tue Aug 20 23:57: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: 13770675 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 513C7C5320E for ; Tue, 20 Aug 2024 23:58:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 484D16B00AF; Tue, 20 Aug 2024 19:58:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4311E6B00B0; Tue, 20 Aug 2024 19:58:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E9AD6B00B1; Tue, 20 Aug 2024 19:58:33 -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 F1C776B00AF for ; Tue, 20 Aug 2024 19:58:32 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ADB8114070F for ; Tue, 20 Aug 2024 23:58:32 +0000 (UTC) X-FDA: 82474290864.25.9AFF6F2 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf19.hostedemail.com (Postfix) with ESMTP id 747461A0011 for ; Tue, 20 Aug 2024 23:58:29 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=GD02GfOG; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AriZs7dj; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf19.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=1724198251; a=rsa-sha256; cv=pass; b=SRi4s5tldFXuB7awF+SjIe79sGUoEYrzR5mcL7MM/bSSakMphnwzQAPfn2UqxYdu89yAx1 leL75kfk31hVLwftT3eAI24Cu0Yp8BAKnY6Yskmxq2M9fWDbDBmXimrT9s/jpJkxOdcO1L K4dVDDU5HlO3GlQvNAE0wsobRNU+Mu0= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=GD02GfOG; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AriZs7dj; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf19.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=1724198251; 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=XE9RiA4eVXF12Bs90znzCWWMvf9fN/K9WnVIKHwPxHw=; b=hLeqYIASHLQe8nRihT/RdnlfczqzeTCj9yf5Cq7GJXFG0OUNBKKOfiVvbsKNF1zRpo3sEE GGV6T+ItbkkRMDfSj6plh3/kIj0cFNLcaHXTN+Want44FzdJAmcWrFnUcJ8o95vhBAx/4B rsctyWotzx7ZAJtOIEgiV58xYkVapPo= 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 47KMBegq020565; Tue, 20 Aug 2024 23:58:22 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=XE9RiA4eVXF12Bs90znzCWWMvf9fN/K9WnVIKHwPxHw=; b= GD02GfOGlOWUzkBAicZBuNYkHZH/nbFPmswsJzwd9H3rx8c72V/jhpcOrN2THXoZ 1A8Zyim4/KJr69QvJ3yAoZ8W7tt9U0WdYZ8o8bC96a+pwsNZeWC/jPnzFaFAp/qB ewmg7sqKG8rLFAsYncsibCXgfDH1ve02RguZicVXIJsm9OsiBTEDJE/cmB1e75fl w6P+RggLOpv787RkNG6HMMJwH9qm2R+Q6Xs1c93pmFx/Q0QzGlKdLSXDBoAIiyPF wMWQ+UhfyjAE/2tJ0YXVJ0AN6GrDzISFSnaCk78fgTwVNkjSBjIqkEfYCFpaJZdD WrLarrDysKoFOQZgMpr+jg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m6ged2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:22 +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 47KNY1IN023382; Tue, 20 Aug 2024 23:58:21 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2173.outbound.protection.outlook.com [104.47.58.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4154x78g2k-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dK2W+Vr8R2kkW+XfE5mD9d8QMP955Z623vAO84sLQFmO5GAUP2XF95zsFa0QOq4Br78eUkG34aE8RWkgqncqTsMtVJjAAlRtV+OoI8CiDhEfFGYNoEBNKxaDIWyIAWc7buRUZff4oiyRyJzx1jKv6a/Aqc1plTiPpRscGEwE1G8jCBt9mA9iQryLVcNlNuJ63lQ52U5AnZjdAHNk0kJZN1ZMz2yFK6iywJ3xESGLm5RQ6tJoGYa18cWis60bgEehlXKS1S9PpvFMd3nikqy0G3w+UPVUPm5YisZeX5/tyciEw4h1UWwrWgEFF8D1zdP97qpxfbQEZ9KYrf7KNv+QGw== 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=XE9RiA4eVXF12Bs90znzCWWMvf9fN/K9WnVIKHwPxHw=; b=MvYLqV1xii2hTiRFhdMLHLgrXV1vmUql1V4jVfg6njBeMPDp/FPc8Ic6RRq4d0GdsPxXUxAnfb+HlOtSsDapV8BZZ/yYrZ0PLDKPgHHo3y8rYTfKSaXeaYGza34L0f0gQ6U0daNSX7heT6Wqf7CYA9hThW+VR9BRic5XbTYsuW0enxoTo6irI/MiUn1QuRgK9tsu4/0iTXLzySAFDPHmrs3UUBClKQQoCeDbe+sv67dnsNStccFEh7g4JQvOd72XbjWl4bGOqMvHQFzAN/5LiQbQLZG2wzSPa5hY7RqOu7oRxKRrDFKeBgqPItjwdmbthMFl57UeyW5hqutc7GF4Lw== 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=XE9RiA4eVXF12Bs90znzCWWMvf9fN/K9WnVIKHwPxHw=; b=AriZs7djrwjUKla9m8HYyAkwnQPylnBUtu/HVpthldQEDQIPvdc/KbE8F/o/8/3URO2FbPqvupaDH0219wLerNR//8+RH4dSgcA/Puk+gUCdW7DVZwDwt5OzsWZ5tNbvZiIA/plJUd74YjKv+lawRyCasvO91JaqGHhatFSQLKg= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:16 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:16 +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 v6 16/20] mm/mmap: Use PHYS_PFN in mmap_region() Date: Tue, 20 Aug 2024 19:57:25 -0400 Message-ID: <20240820235730.2852400-17-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0048.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fe::9) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: d7f9b360-97ce-4dfe-62a1-08dcc173f5af 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: Hyz89Ck8ydcrWS1ofl2Q9g6LPAKQy8fez2P9Mi0XSRYZdCqGrNWiuNqQ/xEv0JIfLM8aJKN2MA3tl83VtSRKFmtr9NCjD066HzZon3PR+6K+XeR2ow405zWR+XNc8w/6B6PamFv7Zj49Knx68Lg1TuYgYBQZnLoBLrS3fb2i3sI5Xt61wrzElKhUrcDQ4GoT4SNjn41/jkobVJBRNWX+MYjYxl4cm4c8wi74Xgzizg8PjPm7S7xnZs+v9PQPJbnFj/KEMufkjVX9aGlmKDSxsvFp7KrlUFqZBCu0QvNIHM9/Y3RNVFr+Z5VF5bLtWA/1Bcl38M+c6G34jj3EpRcUJfXcTk00P9Bc+UyJLBlSFd33fGiV4M3HuShIOsVAWjGpFuPUVSHTTCo2VmZLmgVSD6gzqkKuporCXXIQ2ITb2X3sGPOk1rwpIhQD/jvbkekfFKjJzboG+1WTDWhUCIDM1cD5V/m3UXTWKBIgtfhekLhg4FqefzsJ5q/9Le3vBeQ0OWWyP21cDxgVWyrIY/YWDmZx1zDcjsRUcNlASidQdrSy6z3L0kYfP29EWZIctGS5fkDI99a6oHMzczJDPpkavmU3Viw3AYDRqNqW8npoJMyWrcP7xg5Kwfw2iC0CnV7XFqPD1xoAHrw1Ry3kwojtM1Lq0T54PlMZrMXC/WdqutCAXau8SkQl3EGB+IM0QHR21qYd/HtctG/88A7aKDcoed/KDlDdq1HTo3N0SqMDxdElNVBKEZOe0xGsjbZXbH6vvSjPa9j7EiUxvPkRQondeTPFiFX2anbebM8/xC43fPX4+5lJuPbvuyrfJms3DEDdtxA9w3mGFcK1WjTfYu1Xtzx2qHCRBQKmQTpI5CZ20lMDudV3hW3IemscKHPylRWx35LLGRKg7NHSwMcdVUNMltHDoopLf+DRpYVxRLxKiDLm9vCymzIEQKxYD0wUVndlGBv/AH1octMVYnXL9C8ULnGC5H65q96h/TaSqq5Uz3mv3NYyx7azvUQHke/guOwdg1DD6PJvNmUhJTQoFXT7yha3LoLFhvs3VKrYPDQ5JpZDn33mn70BesEcMqAR/EGi4hU5rWGZ9ztWp4n5gaSg/5ypu+O6kk9SlWeuSt0JNK683HqMeuhgEqelsgjTKfw7MxDLjCLmRnJ/wedbI698gsZAY4qKAVi7OgYNIi5+ZgxzydwsTR/XyGbMEbibDBlUkkhi2p8+zBAWzMXVDqrTa9fsqjP+PyT+aBejsRpaUgd6wTlDTZUYkBnS0qM+ta8TM4YspkbkKoKM9HXgnGx/b8zeFZ2sntvvX3enouPiKj4wKsbTZsDQwKiYpFkkH7byNLrpCIihthWH2V941tLT+g== 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: A8SlSZkEfKsDUJaypYaaQAuHesjaS8kFa/gD4Beq9TZ7gfKGKyvGliOp0fM+7KJOXyGZnzZyUd+jp3rt0hzWVT3eIgsvfTtOr5CyN8sGzLxbPPo9EtPRYEDnC0wRvO8SVlGjCYkeI8cvZPQnPc30n/XLxFKOMdoWECnnl3811Y3Jlhi/GQSpfE6TvpC601umtQBjAwl0dSac/GYA0+ylq9cnD84e4mvoUohuIXySQ1Reie+4vzs9t5Yykypm0TfKNvDViidWGC5Nxc/K7+BKd/48NuaE29S7/6GGa0FilM6l18o/fO7QUyhvJoH18ghIWx9JvSzrvVlcpPjoV5q7/6r8SGna8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RJVh1t2dxz0OsP2PXDAP54nJktmyL/SZBhcRY0zKHHI3HFdZgrCIbgznNBMHk9MhetSrZyxljhQElRyndUOVTQ+yH5KzNiH6aGZa0kP/E/ruyddzqXORERw+gEcGTAJWonqMBs1ABJ4rcDMpe/rBmnM7W+DUGnMp/GkLhr7JwHWBACziEUO6PGuLkoT5pDP5FhHW1nc9oDng== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: IUTA6yyD8gm9xDXrtN/UDhMtXbjJyJB036CxW7hf2XccXpwV6hCsagAHUo9FipBXSz0JmRbEmqoE/6/jGgD2DFrG6qSFfiZSgJ8B1bIa8z9jkpC5qW54HGWvN7WrIkTpWq3CWCN/QFhu9Xm8LjRxbZ0gx+h5dP1jhKNYrZDq4t4TxkvFc1CNdocznTdzP7j62MEbG6QnUQKEQXnPW3dvpTXs4PsxbZpdHy9A8Ffc8G2/notozWbFi7FMVOXUd/fQivGlG0s82D3lXWbeEIBWJORWf7n9Pqah8jUOkUNuj8W0UsWpauRTzJ8z1+NxT+I2VvGQfIOaU4cxR7j1XSKm7TQGm2LTlDTJjAsTKCFOa/rEvCII15qvxITGg//2kJH8KmOvadlyUitx1DhUyN5Jt8/0n1YZTCjOcu+6AG3tzQk/Ijk6oEHinBCRhyBNrGU3WtXrqXnz+HlCLvLTzVSbtBF/jKfeXX0Hs/62L0CloKgVDS01z5NAvKGOYhofMBa5p795rDaj0uitnnJ45bqiLwVtepfq3NPayW+wO2dHA6ba1m5/uPwICY5oPZuLCTqyp9KfwsvTcsajTsDIiQM1bis6KqKiNWmAuO3ZWzP2Woc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7f9b360-97ce-4dfe-62a1-08dcc173f5af X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:16.8089 (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: AaUm9psfDjXDP6FI43q72V2I44Q2UOk1pqTnDGbQ3mFSfdhYwXTJ6UYxYxT7PWB/Vhb8BEwz3qON9bSwtvfdcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: 6cgoLUxnxlgtrCxQ_6ZDrGV5xShNyGYC X-Proofpoint-GUID: 6cgoLUxnxlgtrCxQ_6ZDrGV5xShNyGYC X-Rspamd-Queue-Id: 747461A0011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xqsgnnwgcufo8h8gxe5akwrnmx5y5gck X-HE-Tag: 1724198309-25509 X-HE-Meta: U2FsdGVkX18nppTFSjTaE2Yy6xnfDMonJ/M7Ljo03quea7G+uSnpJ2WcI20T93Pel2h3qfk9ebDCty9PEzGSKZjkoShur0D1ReArwwnL+imoUyo+Do9LI8bU9TB375c5EYJD3oV1NICSCwQeXMxfM3+UH33P51MvyNSbnIkWsu5flVmy71CyW9wqoTxIFxPkSduSg/M/YVKyXcFFX+yYiJhd46BdymWeNt1DOAirShoGLOy5Nfu+3Zltu7MmrsgIKO2hUyoMHxev1lXuinny3RAchPdVXQL3xIqiU23NbK4YBVI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2/bIADoC0qNsdawn94lIaDEmokygjthryNOKbcNXJHARmNnHJCI9QAWnm8uIDzcfi6KVPqtN+rV2yAN3kAWytNLzChkXbtUySv4gZ7QzizE1j2vv5F9UD98AK6F3yu+uR3FTCq4bJHzURG3cgpwttRkIDoBwvM46c8WYYmDJehz3Fn1eA= 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 c1b3d17f97be..19dac138f913 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 Tue Aug 20 23:57: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: 13770678 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 B4F02C3DA4A for ; Tue, 20 Aug 2024 23:59:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2DF76B00B3; Tue, 20 Aug 2024 19:58:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C95506B00B6; Tue, 20 Aug 2024 19:58:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C8656B00B4; Tue, 20 Aug 2024 19:58:34 -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 5A81E6B00B3 for ; Tue, 20 Aug 2024 19:58:34 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 24C671A064C for ; Tue, 20 Aug 2024 23:58:34 +0000 (UTC) X-FDA: 82474290948.28.E5C833F Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf17.hostedemail.com (Postfix) with ESMTP id C87F540008 for ; Tue, 20 Aug 2024 23:58:30 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SPDSiMuB; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=PIzNBwH3; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf17.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=1724198222; 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=YdZVOBe/SNp5Gyamos6vbsGOr9rKM7FOBCFAvFJ838I=; b=AG46TtUy6H6HfXxhem5CVBfcuGSDrb+Tvvx4AbmQ9xnBTKrrfUrrVmV+OdkaDmFlYREi7l tdvqiDjjoIm8fQ0hq80Nie5cpSsi4Ly2cphFtjOu/2b6pSfEFlVBw+xvF/3qYeX03ovBQS FyLoahDMCU/tA2rJDEvT0LEVIEqlJrc= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198222; a=rsa-sha256; cv=pass; b=2NkbfLD1OetTJ7zkzC6BkSwj8zEioI4Hhghk3/aOq+VGZBt4qxMrOU0wNOCEcnm3uGVFLK 1Ll/5pE26arCmNwhharV5xBV6L1Ypukauee/0lhGO8H6j72t4n8ACoKTIfXkeeGwBKcEj9 FHyk6HtbPDSEVqVCn+kG2rEnRZwdbsU= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SPDSiMuB; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=PIzNBwH3; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf17.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 47KMBXLo032213; Tue, 20 Aug 2024 23:58:24 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=YdZVOBe/SNp5Gyamos6vbsGOr9rKM7FOBCFAvFJ838I=; b= SPDSiMuBVgmFyZ1IIa5G7NUixs114aVSUM5dFdjecLs4ZuAoyCI0ciHVUVF8J3/o yap0kVUd2dupyHSG/xxkhEfKMb6FCzDhJna3Z5KQsSvIq1f6oz3lfXa5DLmMrimX a44PIc7kwWPaIyIN/aKan2uA+tBN9qeWr70qjdBeVEU8duAvFIjyeeUir5wYBU+g faNaXLMw2FZYwUPfrHhB6QUXy/e+8oK9FfSUUBOWpFb8yb7ElXResUcasntIm9mE 9oq4ckKJj66gf2EdM6Xhje2s7AEV/X5iya3Kq8gFaMZDnO0arzj/S5iO3aJUuWy7 uUWbMbQ+38grf1EP+p3TNA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4uxbks-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:23 +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 47KNY1IO023382; Tue, 20 Aug 2024 23:58:22 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2173.outbound.protection.outlook.com [104.47.58.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4154x78g2k-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZaTl0iPLw7vGliZ/7FCuPPXs8x5ySunuuJMlJSZNpMV1u95CsjDGoTl9xvitaJZf0KXC9P1vHFDYC2JPzLX52taiUhJ55M0fdvLmtT6ASQyi0qp6MaQ796hQ5VDjM7aqmpxtVri0PM/5AbLiol9W84WsDEVMozvUCCOjUB+LT5Xycoy+Ixwp+9uGoRbLJjOV97sV+bSQNzpt5sB4divv+Hiv9boQKUvorpF3PbyVnZoNyfvOddaGibwHsckLzhn7/r45xVPekMLFLt48Q29nmbBt+PIbYE9gn0lJTTPvp/Q98m8+r5u7n4fbYiXuBU9NTBgno3yIAzNz9cLL0B3IPQ== 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=YdZVOBe/SNp5Gyamos6vbsGOr9rKM7FOBCFAvFJ838I=; b=vOmFC0OeJSBsuEURv2gkwmuz3dhdXTZ5r/BWL2oYHtVHtb4Zw/LMo3Auhr1RAw/VoXKfGbi4uD3LkOcGRNmCkO1DxzGQJiilY8arI5uFDrAwtNIn2ToyKxK+MOiXnZdSQJTrd791gj0XJFrFbFeY8H/Y+H4Aak7l17kwpfCQXMEgRdQiIwv51sQQ54Ti3VXcOiYwU0x/3yrK5qGpre+R4lZJIZ3ZQHxLSF94+6Pes2T6n0i79apOivDDP32ONYptxZg65OgUvSUhkRbpRnl4ijThUXkVfL2vHoMA8IcyC/rnsis1w+CoY9s698GQadsbjv5Y74TgzdGm+eGio1MASw== 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=YdZVOBe/SNp5Gyamos6vbsGOr9rKM7FOBCFAvFJ838I=; b=PIzNBwH3yo+MMFouS+WbdBsRIMZCxZ8fp/rC7c8nSgAlF2S5/JgjN7AWyV5BnfXpQBGEr6uMTzscstO7FIUDBMu7h7TSYe+Z5J9CrVnC4jFLfp3hDo8givgMANnPLZg8M4zwEIeoH0bsvRcpP9J2R1ZfHmKaGsyW3peaBx64Yho= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58: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.010; Tue, 20 Aug 2024 23:58: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" , linux-security-module@vger.kernel.org Subject: [PATCH v6 17/20] mm/mmap: Use vms accounted pages in mmap_region() Date: Tue, 20 Aug 2024 19:57:26 -0400 Message-ID: <20240820235730.2852400-18-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0360.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fc::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_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 2193816c-a38a-4e79-1918-08dcc173f6b8 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: ugGUhwENs7VZ9v5D1QMnsLcJLeiWIggF0i2Usfsw8eKN09fnAJk7G0gniWkA+YXDci4OtdBVkK3LJSugKmdEZGnRz7N39HQW1ynm81mVZFBjbrfP5mnZo9xHn99lA3Vkq2Q4yIpf5T0qEu7TW+23sxiz37gRAAl1TyQpCPwSVSuXAlv1l8den6n5FJCuG3fLqXXoPgyNjvpVPvEAmo+l31aI6Roa57R5kkA4qSAtotflgoOw6sHhgG+vl6puckbQxxqFYB5YFhfhgoC4LyXNIex7yuJe9CwApvpTp3eN5/uVb60nFyCkVfA8y5VEm0Psan7Mqw6FMpc+GYEDmn6mG2A0xVUtXwlb5Pc2akxF17jusaK4rTnIgd4GDskP2yx5J2EamhYXeHRBz3Hlsml0ZVRkSrYvb7zCCbL8DzoEp981AjUdHyaiqsqJFS6eEOQYydC+eEcW76XIob16MYU6a5O+nMcQf4K5r1jupw+y5XDnKGf52INU2OBxFtPcjXcm9dmwu+WsgOL0om8KrF0KpV3/fCBxJFkSRReXeHxOB0XhiwpXv2Dts3mCLIRbD2Nce4wMtJ551Na8o8dGTvuNbxLNw4gtpDQPN6s5jgXNmzR42GJ6PWX4qUmJ1EyCRWSZuA7EzEgHIxOD3nIfNDRgAMZ2yOvJwefDV9oAkrmI+gI6njjebz/S/X2EozaCv0/02onDPDMZoVJZFIjW5itxmkKLLQxvrOeofTTaif198HoySwzsM8lRaa6zD+FyjLBHURhx717tmzpeIWl1Juj9ESaYP1zxqx6A/88le369qU3ylJ/5pJLvbUd9KMhYZ2d9AWRNb41e2PMMX9SBa7wBLvJYnFon2oAP6cbrw0PC+N0NzNY/tYp4CtX1dWZEV+zbFh1nwUJOlkoBTb1o3siuvjH02Hn4jITmFbp338YwdHkh/GpvELFzjcliR751WTt0FIJ5iyNVo1ieFz9uKH1nkSGPHnuD3mIubwaNeORsqBDydUNe3kVKBwBXSEVH5jh1xYjQCYuAt1FG8Xda1Z1Lpk77ggDuTQEKueYNy0oElrw57Gf+XgszmD439rmD5gnK2vLmcTBPwZt2T9ERXT5d/rU7sSSBD37dT0/jPv6CexiNqy0bDxMEpi49oA0aWx0nvh8kBUOWyt+AjryuJc/05YTG0txDBHHm0UAmG6UqdZy9pXN7hScsbD2n5tPs8Mj3gwDz0gS371z4yh4wiWAutAkgjx8gRvLDZpc5RpCnk3WJuxKoxauOCFTTWmWIfMZfAmcgTFFSljKUAaFFTRytDgnf1N2UntMw94QB4ZqcyRq5Qe5mUz41PaFww6VWmrkADnbfdvFoQZFb5kswYdZuuA== 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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UcI3xby8hjlNwFS6pti2GNQT/EnVRh6ko+NVlU1an6tC2QoUKsoGVkjlXiUOC9//db/rO5jRRdG9kki0pnSKPfdAaQUD1zxcUIvPYdhBkYpLpCrDYISc/L7oX0RPkHttrU3veU8IcznW59tZp+D5A2U4WIvFqi5VNsqmx7uKfl7WuNcE5e6LcEL3lKqR88= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2193816c-a38a-4e79-1918-08dcc173f6b8 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:18.5569 (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: 1Jj2PIDkCJD4oWjXiw9tY3lMwC/PRFLQhmHvo6ei71lPhmto05fKv+GIhF99984VGHU2DNGJfQryRavaVBhryQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: ygTRTKSU41nIUsQshqcdOFq9RGQOWhFt X-Proofpoint-GUID: ygTRTKSU41nIUsQshqcdOFq9RGQOWhFt X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C87F540008 X-Stat-Signature: 97to4mq6joxswksgh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6BKTctjsBZzEEeImAED2UG0Om++pJqMQQi20SMgeK1SoISS6sCw2GBPuMk3uQMHtNvgV2N9H4G84nFz/XMcD8n8LLM+W3rX97rgFdqlzazt8Dlz6O6ioIkjnHYZCtX3tPYPz7CUXb42duhTPjLVkZs2U7qj/+Y1aq0Oz1dgToDoRxEChnapm6yxg2gBl56zjo/BbNQUOoCYQNa8ZiwPPqLMUWSHvrYYpE/8APVkDeDcrFZfSaOCzTZ1+L0H1UzltOPtE29Hc1k1P4U17Nb+yfef4zc21tIYsV/3iNddyUPkCvTksYd32OLPF0UYqTwpEeDq4++3tGGLVUxLRoD+UlrcRfqDkTOlhjv5YU7WCiHD2FVs5RM31x+w+NVhF/JAGd0loy7502Rbp1Tq0ZgwFMOaCXaZFQuYYw1knrTDqXEyqAh1CYjdIYTsDeN96ognWYPqBUrA/tdKSwJ0YAjviHFxH6fY5W8M22SAY4Ow2t/oPCUjyFF6rsAt2QbNJoNFFJEILVvJ0NF7ZXmM0HYWhHsQuFAcp8Mbn7OfR5y1jICsIyeeCJekSqXB/DZDMIqI/jn6Y= 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 19dac138f913..2a4f1df96f94 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 Tue Aug 20 23:57: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: 13770677 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 7F1CFC5320E for ; Tue, 20 Aug 2024 23:58:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A50356B00B0; Tue, 20 Aug 2024 19:58:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D7EB6B00B3; Tue, 20 Aug 2024 19:58:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 569F56B00B1; Tue, 20 Aug 2024 19:58:34 -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 1EF0A6B00B1 for ; Tue, 20 Aug 2024 19:58:34 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BF598C05CF for ; Tue, 20 Aug 2024 23:58:33 +0000 (UTC) X-FDA: 82474290906.14.B7BE63E Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf23.hostedemail.com (Postfix) with ESMTP id 782EA140007 for ; Tue, 20 Aug 2024 23:58:30 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ZfOvuFj7; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=u8eB7jhT; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf23.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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724198231; 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=EWVcmdCv6OHRg79PF5x6IE9evbHP3bBXy2AOJMFbKk4=; b=I6F6Go1s3UVo6voFxBxM1qEmIwz5jq1TmuemF7PAn7a6XEuiAjPGIHt0NFzXflsPjJtyDB 0c+rHqcECBhDGF7qExMU9eIGWuMPvDKBWAXJ/lbzLXyRFOcliB7z62uZ1oSTRS/lA6Wbym BPbqq4XO2n8gZGNOSOgk1IYVFHt9mj4= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198231; a=rsa-sha256; cv=pass; b=yJ+hwHodHcTq8NwDWY3Z7Us9uOsjuj/RxeXoBD4x6llOZu3rBlncCGh6GrwtqRWNn0+vaz ZyZlJQudRTEF58SzVrI770P0fQbHAyJhsSt7vnNe64b9tmLWxmWsW7z3cs5WR3KlGm1Wz2 6owmIH9fEKrso+sZHSKWE3vHQ3/OKK8= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ZfOvuFj7; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=u8eB7jhT; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf23.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 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 47KMBcPu020559; Tue, 20 Aug 2024 23:58:23 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=EWVcmdCv6OHRg79PF5x6IE9evbHP3bBXy2AOJMFbKk4=; b= ZfOvuFj7HCqOPafvn7Jzy82ldOfAyAEkajQq3kualkObP7E9F1dlFmCX4387hEOC Pv9J8cJqg2xr1nCHIG8dA6TENsSbIapjKsSOGeKRlQcaVt34xlMSdrl+JRijQbG6 LIEPo8i1ED/5OTuFzWbAXPaV5fP/WcZ4UF4/Rx061SI1RLZI+wsxthCvMaQbF7Lp yL57JBm2SQkz+pK/Rbaz3mPOcvvOk9Vq5GzBk72c/zPvTlwwpsBmBRMERSlOFAMQ mvVQveXlHsjXiclcYF/JWaONm4k+9Hk2jaO7IwOLtNt6KRoCfvba+SRKTcW7LJdS uFAmudKcHin0STBXCTDw4g== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m6ged2b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:23 +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 47KNY1IP023382; Tue, 20 Aug 2024 23:58:22 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2173.outbound.protection.outlook.com [104.47.58.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4154x78g2k-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dZRMpb0YAYbfZ4cte/6Vm6erZVIAaDLgsWPOVnOtchx+vdMJVkK4uys7suAj79IyP1NP0bvukYr8jVBrORwtsfiyw+1HrCZtdQt+8pX2kMaN0qIqJcFkbBwm9SR7JY2FLQLobE5b5FqC+NtDvJ7WmySNC0nkmZCPa4kpmeF03Vue8TlnhPW2nWfJ/C+4lvKWeuBMaO+vUtAAB9zfn+1YxsvcsUa/hxDoBuA4BZiUx3J2Fyo8tk9SdkTPmU4vuv3/w3ocagDB9BGaUHfcfDyX5C67JPVsiIToxLczRdal+NkKseW2nFwke/VkR6lvhhmFgTx8kAU5hOOwkb3BOcH5sQ== 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=EWVcmdCv6OHRg79PF5x6IE9evbHP3bBXy2AOJMFbKk4=; b=E0gnUvgHi5uN0x0lK6QMgKxuhsPTWg2XYd+9qrz/zjG8yC93OHCuxiC9gvParyqSQlnSZH4oJk42ENIpuY1vM55lnu33iNbaF+Bz6EZcOI88Hv+vZxdd6cdPJo5fxKKCqoDdg/emfK2IpzX5yZG6ArFP6qqi3oANOYGAUO5LI7IGAJrbRl1/K14cZwm+4ayEnvbuL+WqtyCDV6xsjKMguwsW8SxofdVE3BDS6OVYMWKoa6pGwHUC14gRmVbpKrnFqG2EY4PP4sEZjFDrR12Fwj8i0QKk1+3h0A5hT8AGU6YRk81cgphf1tFdiIKdaJrdzUzUOJlhaO/+sbO3NN5PAQ== 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=EWVcmdCv6OHRg79PF5x6IE9evbHP3bBXy2AOJMFbKk4=; b=u8eB7jhTVMV9IWBXU8owQjwY/zPUIEwmpZc7Ky5WP2YfSbIFhmCeRemy/7+dL86bdOkV4+ONzHqJ2Upx3yt0PvtLuMrnbxVmzbQbT5+I2hHiphB0spN2+Rh64GRQJm2b+WKa0H6WFGYJI7DCYBAyR3LgMHRN+UqJimUHVvm4emM= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:20 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:20 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" Subject: [PATCH v6 18/20] ipc/shm, mm: Drop do_vma_munmap() Date: Tue, 20 Aug 2024 19:57:27 -0400 Message-ID: <20240820235730.2852400-19-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1PR01CA0112.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2c::21) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: fa6d7fe5-eae1-4e3c-db54-08dcc173f7bf 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: 6LVwbIafcDc0iNlZ21x8fKfjDJRBzf/zeZRerIw49tZ7LMEiLdN+gRYimnzMd6pxPL55CzTYqMJgQOOwDcmvpurJNNE2qQsZJ+B4jmqP8CCVvHe5tuV2JBxX4wAs4dungNG5UfEygtdRWzbragJh09wLnSCD+UNBwo0Y8hzWWQ2IYJAeA0RNMg4w53JEnGV5ydk0t3+KsthMutiiLfW4JDy21FRCO9XvayJMiX/xGn5KUkoJyIdrPuPcdkSl1WG8UPNgld0LeCQ9Ty184nSPVDkKciZWkBh1L4Rh9sGX7BA7hekD+7EyUvomFa9WNFaGo0JrUQJO3N6Nr0H12MQ7gfh2d0FysN3ckcwwd5RZEVvSrEkufjPOJaQigSerhzTkXHSWh8xSZDdp2iN6EGNh5nHdTtc0uxpLTKaUJmEf9pduMRRhDSDBJ+mHJQWUI/kd/o/blH6Bey9UC0Om20dfhXz9faO4Es+D/YDN8SPRyIRAFtAvWE2VX+y7NoKyGe8r+RC7vJNBwByFCsqhoAUnz+gyBVVqv93Vt8dNtlVLseQcTH5lMJFU2UUKW36X0Mdt6/zL6+VV92zCOY9+cJLKqBBqSQtQ1ELIqeZyYsecAoqZW/BRWLtzh1HQqNhU5yea/U0fGUY0rhcBbEfUm6wRj9zWo83He8CPhgpviNrBB4TvaOKxJPS+WYxM9hJ8FyncJdv5qfHYJ0rmh/B8fFnvTV0iDmPxjQWU46JeVaVONOAik2joE3DwKn4KidEgxstFECtFNYG9Yjq03AOXvtyUfSUsITX3QB0a6vTNI7/2/4XrjumWxS9Fj6ayOI89y1S9tU7MGjYca4+wePrngg0nqoyHDhbxX3VPnjCkM3z+iEmuluYtbWJwP9Ed2grx1TnN+mmdAmZx7CYszoeS0Wv+JsuBU9PIrlTPIEXb1nbkRkrecy+TKRCLFFwO7RSvO0YMnOScQQBFtNQdwA0fEp8FavGttLxFh1OvmfYwSnZMD6hFxz1Jyx4mSHLQXpvWJ1ONXaFEdyVY4zOQhBNSem0gIFsbYwX7jsTIFjsLIf3vB7duvkKgUs+4Q0lXgSSVTJa2LoupxffNuLYxrpFRN/VD8ULQLZLrztB5WOQme1a7MUTOMZrQvLOLQSE36fOMkF7XopRrxgVu0nZSN5pa26QfsBhuxv9k2U5/84Gy644mn+h9m3aRxyCz3R5TvlH7NMw6vUonZbvIo8Qvgtk4GH38F8yoPUnKws1O2Kb0QGRN2fVyTgnOpYZBxpcSah+7tezR3rzCC3roORmObk9HNKfIvcBjINu5u72m2ajdDfsUV2L7T2Fil1rgGigvKtCDySoPJ3Z6mZIgzSKEqG9ZZzdHHQ== 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: LsDsvW6MO+E+enUC1RlBwf/1+4AXmblDSvnDJab0lb74H4qUdwsYoBVf26C3fcvMT3WGxVFGa7ecZlpVrt2SzH8q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rfE40a6DNt0Uv4XJ6UvMrDpqnQ5EFUjY4uvTC50Z3gwdVx0tXI4IYALtFdvia+bL1jSI98JggbjEuSWSfEtPv0EQtHHg9hcU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa6d7fe5-eae1-4e3c-db54-08dcc173f7bf X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:20.2922 (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: bc4rtpKYqnS+aP+epn94VL04fIP0685pa011VtzUQ1j5TZ6ZgiJwm1QlMt4cDp02HRTN2S8lbmrmQJQXzJJRmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: tkW86oKwPfYLhRT9IJ18ca3GRDi3ymhj X-Proofpoint-GUID: tkW86oKwPfYLhRT9IJ18ca3GRDi3ymhj X-Stat-Signature: ahzkn1yemc4ggxhkbm7fxfw3jchwmkmy X-Rspamd-Queue-Id: 782EA140007 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724198310-361715 X-HE-Meta: U2FsdGVkX18OC7EuIc3q253+7l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NiGMUmTRmc7mkXJAVNjOQ+YaroXETu5FkbO6Ci30yCNJtUMQyyXoM97ofV96WwSw0I0Fi4hEkOUbXPY28hFvt56z5w/t2wfgcAfQ6pErsYQpB6eEAm1cOpCl4nS/xUDaMZE76xWP3zusUurgiX6enmi0AzGwpwibO8mlY1ZUH4Ym3HmnUAxZ6NetPjUeaPNnQ7rJa3uvaHfM9Q9KlyjegCqMjCXBiNHzYR0v4AeGYJjFF4NLhvZtdzt7RftQFpNS3/BfwbXQKPOCh6D+Yu3KcbRRPxO7aURt1KiiniGGZyizrlrPev8upiAXqQL/+cglBuCJbPmmAmZ2R8gKmHa74duF+zVimaH8xvqv4ZhuaOfy4G1v61XxP9O5JbbVWuPBEHCMplX7b75RWcuoN0mAQw/FnDg== 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 | 29 ++++------------------------- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index b1eed30fdc06..c5a83d9d1110 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); +extern 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 2a4f1df96f94..49d9e95f42f5 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; @@ -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 From patchwork Tue Aug 20 23:57: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: 13770680 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 AE05CC3DA4A for ; Tue, 20 Aug 2024 23:59:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E94A16B00B8; Tue, 20 Aug 2024 19:58:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E1DD26B00B9; Tue, 20 Aug 2024 19:58:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B85BA6B00BA; Tue, 20 Aug 2024 19:58:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 90C556B00B8 for ; Tue, 20 Aug 2024 19:58:41 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1D782A78B1 for ; Tue, 20 Aug 2024 23:58:41 +0000 (UTC) X-FDA: 82474291242.27.464EC25 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf06.hostedemail.com (Postfix) with ESMTP id DE942180003 for ; Tue, 20 Aug 2024 23:58:37 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=B6wRyGX1; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZBh6Tzj1; spf=pass (imf06.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=1724198212; 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=sz4HyiBxeYTd9ERWqAfMhOMdcVpivHhrD1PZOvJqvI0=; b=6QqIuf+BxWPKYuyq1CED9dkdgJCviSnf86sVRKr6EC6rIgnDQ1OWxTSPvmgXhAWAHoDq2G kjhcvXxStNa1T0JTngbAfrWPvmRRgeZB1Y+uCf+061D0usS4N82SpS/UIEqqLpTJsg9olm atbQJyotnuZKWVXh3Ok5NdtteNMKfDI= ARC-Authentication-Results: i=2; imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=B6wRyGX1; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZBh6Tzj1; spf=pass (imf06.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=1724198212; a=rsa-sha256; cv=pass; b=o5VMtZxSB/RvcwgpkOpQO8AOvVXCJ3KUG6ePQ0kgwvoqrL+XGWLjn3TIlMHbWnLVah4FhC DYohNiUbZ2TBXMq/kupgZZGyo3sddEog9IOh/CZOw+qeXOOh65tK001pGnby0XCv/GEJEB vjUBT2ugUZeNBc97QQ+czpQxIVsq//Q= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47KMBh9u005273; Tue, 20 Aug 2024 23:58: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=sz4HyiBxeYTd9ERWqAfMhOMdcVpivHhrD1PZOvJqvI0=; b= B6wRyGX1oFmkushSpBz69lbejw6zWi9F3GuNSAesoiC+hAXq8sNAeBUsHXEveC5W vFGE8tOZLxQeZGnQoyw+lKWnuiFPAvRBJGBrhQtefXHQacYHhPAaC8QTWd9z36vD w3qHqsIZS2fzC/irXNO+IqYtkpRL+JMaPQPk2umNlzFI2lc8j30tNCi52FFNmZsx giDGK9qISH6uL03Zb7jn1VtxeDFTcJ4MbPh0qZWhRMsNDIUlSIbBwsnMG+qkfdNX FURi6AqqG7TWDpVLDsekletuQjgz5N+OK5oJVkahtTqsf/EMo/TRoxDyfZ9Xhm3q M8nOwlqqCLWFvOKvThV8Kw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 414yrj0mmn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:30 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47KNi8tm033645; Tue, 20 Aug 2024 23:58:29 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41552xg9w6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SxyQklxBVhCEDU+InWmTM5Y9L5JyILYnnLhtL+unD8znIrI6RIkuxDNU6Y0/0TMNd+eEW0iGBrNibnvRVB+I9Bbcl03TsD0lWwT5Et5r1meoDRz2e4SXLCsgnKVMc8VFSQe9ubh1W9oAmj+U6H6qeIUo/+HDg3YdNDOFZuuNr4BIL5NX1/iti5Jyon0D3a3wI8dkkyxV07qRJiXnHoEsFUHzycC2uJC6j4bz6cGhcJl1AbpZwJEN7oHXj42MLogPrc5JSqBJ2JyWR/+Q0Ue+6GdAyLFibBNFHSbC/73i/kYNBDTd8mySr/0XAf1aUe1OfJCqxzn8E8CfzW6kHnUxpA== 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=sz4HyiBxeYTd9ERWqAfMhOMdcVpivHhrD1PZOvJqvI0=; b=N6G0Ujbu9mPxjrojP7cqktX2RCFs052reHb9R2Abtb3X7KoCrg32rkaePkkhfQacHO4i6SF7F3xygEerRq9LLNDOrJF5QDAo0vuI1dWnGBl+xhBm7reWE7SiOkJVH1zFJ2l7sMpv46yIZmmKfPfUVzv/RPLPpoUK0VEXKa4Fk97nzjqkiY/AovcNGVCsmpC+MNa0WiZeWR8KkTv85F4cHsLu/3zteCTRlr70PrR2G/vU+uzfTOqh4746Z/upmKQmhFUbgNcSCfEqkxZVwKLNX1HQZiRIl6umjkHqDPDodcPo4vGdrLsa1rRnJPe/CfY4y1OJHD0iMwWWkL1lA718nQ== 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=sz4HyiBxeYTd9ERWqAfMhOMdcVpivHhrD1PZOvJqvI0=; b=ZBh6Tzj1BdpfjZDiuitejV7o4JCqqu+AdQ1vrH+GQBSF1ftAi1o9kTsFG8VTqopDTicTXCO80WE03AmcnbpuoxcR/0epvPcY+82QG0z2ust/LHhfbDXxp+AaXzLkDBEIuVXPfc5DSMJEMZgBklC04q7bwv23Rh+MngceAoW60dg= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:22 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:22 +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 v6 19/20] mm: Move may_expand_vm() check in mmap_region() Date: Tue, 20 Aug 2024 19:57:28 -0400 Message-ID: <20240820235730.2852400-20-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0040.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d3::21) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: 98b71778-8145-4b0a-8c33-08dcc173f8f6 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: 6HB7SkiB1n5qDLyW4+LIc9Ipsj4udKNexB2H5htK5LN5/xLxdZMsDtb45BxrhrUEX/S54gdwp+J0Lgg+RTX7FyL4jWv7gXGEUmLXimGUAHJ538nhyX2iNptGBupsngKvBKGZxMmYvDIhniv5XquOG8aTphpq+awxdojMrtllEaRUFHV4mMmEbAHMIm/Cb9F3ZN5tWV6OfEhF4ENL4IoMjzdBnsaDDag3eyXqYNAqa858XjrVKgud55l0n5V+G2uHh+F8niHw+wE7xedmUwbC4qnMQJCRx2T/GcbMX8WbQenyVh5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.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: +6EcUHwjgXtSJWtT59cKAimladhc7nMKyo0kBjQr2ucYmKZNTVPEAD+y0zORJssR1eDPF6o8iU085WK0tBL3SN2afbUGOlERsnjhxy0EYVFm9+1+ypnfkOuj++5DW1BNh7AFacRzFNH9DmLxv1XAyMHXRgYXOHdysRuN66qOdwq6yZiCAQuhHVUnvxkW+4vQxplQ9OF72MCk+DvFTa0dMJ4gxAHASO/D6/LyevQkNfTGeUkVtsgijP5VfZ7K4qACd52xx/pxnQ1BlKFVgCCX0Ih1UuVT5HXBvkRMhb4dcULwkSqJi2eu/UY/rmDoX1b33VApwTmyzKOJODbmtIBWXGpt8P2BiVvcYao3jNCgEeGSMrkXqPKhjgdEB8LsX1ehORSgBDLukHAyDz2kZFxd+9OQL0JZ5SnMispSekx4Su+z2Ofvpukf10BYn5aW0cncdeZa+2O3Sdn0F4cX9rSDbr55T4IBrNuDlw51kZTPDdJadO/ysQImc2FrJ/Ii8gRG5+Qd4iew/iSOH3/GIXoz81ULCJ8W2Ccv4XQy8LBN5uzMtOU8ZqrbskDdkkqQm+wWz7ZDIw4SmmV6DdlAqWuA2hWetbffwKE8q0jmxm+ufv1zZZCqMQqpDORu8g2NmGRDdQ3xMm6Yue+7gmoZKt+SwQQPIPON541rxTIyUScr3Lq0aE1Bzh3XrKL0CUoLEJ/UClEyGxlMAz5B1bsT3ONr4di4rnPKgkto03P3mPnet7EHjh/HzzDih9W9KBDhwuPhiDtA6b/NjgToB4Xwbdakpb6s9EwppiEL7NLgkN2cEIYJJ38t5ePUkxpyD/Aul8yXMFGPzTAqmDAHLBwntaIpljQgg2tZ3zJZ/8CI4fzC4yWFIN9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L9Gz1V754Dmyk39d3p2HUndvV81ZcFjpZTR5dkxF2h326gRD+xVQoYXZbygolww8y92KAWdx//2Jzk3aJOMit0+6EhB5i60BnwLHv56fgBa8rCO2MEZwo93FpBA3xMZXt4eM681Vrspp46ch43yr7GEv6nX6HdHZBU7jPb93tT4QJ/LtXq0q8sL20hO5OfpRfUOAI9RQoD/iTBjpwnxF2WzVXfn8EKFV4MJ4lpgvfAnFsb1QuQUnjuxLDECcZAyxNYjOcaMPSNjEUtpl7fCfsmt6+kElT9rTpQylSe5InCECf2aJ5qQ2QyMBnaxmlNWW+SGS/nS5hQVBvMKdkJVGo5p2tPGo3QIjBgE4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98b71778-8145-4b0a-8c33-08dcc173f8f6 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:22.3318 (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: /XQiiJghoykLaBOqlzxhV6tXQRwUaWFfWPmzbymOZbbiwfFPM0a8kWhUACMM2wJm37FZcDXBdrJUbNvwdub8PA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=871 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: _mwame6VNS5XRcoMRfGcjQwjgA9wF9Q0 X-Proofpoint-GUID: _mwame6VNS5XRcoMRfGcjQwjgA9wF9Q0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: DE942180003 X-Stat-Signature: oaafudujgoj4b94higfp4qhyzzu3uo7a X-Rspam-User: X-HE-Tag: 1724198317-350598 X-HE-Meta: U2FsdGVkX1+4hpCADqtMws22Se2Vy/HG6LxVgAIAvFDn8KOxfIFsVB5GD4eCJVzMyDREIQxriqEJ3aRnl/XQ95eEbe3fK1Y+j636lhvvKslFeHURe10fpG0ln5eRivhqmXeKsqkHIQWdCn8e2b0I7hXTDUJaCSE94FVLoi4urMrXUnXHTUDUaFELvdqu2g9bTV6Bz/j4LMlCoJDpTJOyEd56gwXsDM6cbqGeG/mBuK6lYntsXKiNefwwhaKg/h3koWq8WpeMv4rtlikVzDaouAb3xMJQUxoY34BvpAnPSAv7UuyjvO5uO0lmjMP0IWZOdUUod1epBdSTV84oypi5f0W/4IxkZrMxpiPp6SuMAdiazKzSPHWa27TqLrrSDB9llKpjWMXp/CcUC8KiyUwvJrfQrUZp4ah/7OzSjovo+pmWv5SeX+B9nZPnQuORabJEjVqyQiWQH1xCuVQqzT6TutGku9D3w2xZemqlrT9EM3zxnjR3JviI3gWqROD7nkh/BceE9MnbhrmTmOpF1tIvpaeC81pOc+8C2O/yJI8/kHP2lpMYLWmuKJKAo1fwFo9i1aYCgBCNsd9uTwHJ4FNty6uWbMOW8QtIwvO3Z1lheqhaSJdb2bAJOyeoeyvPGWfgz17C/AL395mITinvyxbA6y88Ik6mE9qguk2ZtOXlwZmWQr6S0ia/cCIb79gGz9RX40taOFasEDwcgRay7qDXnpcvJseywL/TnGDx5ixgsS5mfgc4R1r8Adh9X4p0c1+nLK6JmG6RrpR0DDBMqISAmYx9R0H0wEXXLXRLImyXtxXz8YVFZm000ms+9senIKzs7s7l4HqdECdDMUKELKEfyC7+X+T1XrdkFxvZde00lx5BZ3+oimP0GXOajNWJpxF8C8quJbOU3qdW2bddVyPvxRHzBKYYiltRPEsbVu7rCV/vMy1S/VLNSKjORvs4cOdwX4Rht3XStF2ca5V3m6i 9HpScAdA nKf+e8/w01MUDAghy68Af/M/jiUFcczOBBu/gpzvdl35BEAy2AP11UcRR2oICsvzvvfptWBvjuzNQUm7/4v1mN4XtuZDUTV3g+O9VfiMPNU1Elcbuvf1WBXYyLBa/uu42Iy1Jb3FjckQTyRr10IXSDDDltFjBZ0q6V374E24ZFn9g0FkcTYeZv4k3t3GBnDeVNi08CPJYtyp974HWyjRqt0ZdqeXdgTuPx9LK4/rySBYcH6IlhgivPXTCzVmIJXyBqjR4z52uGd45Sc6NqilqJt/zQXAu1gaaz7rlbvuaUWmU8I1XzpckLX0N1WX0VFTr/ZUK5EC4eyNtp95gPLzeRhTtyiGC9uwwD2H6XZsrDNDYAxnaTIalNH0qE6UOiD8Q0RDlb0iMVVqsB5wRS98U2x2ONc2wgBGaSkyYnquFYof7EppQKVFeeOaC9g+uR+tNrJgxLC73oLs98sVL1A7O/V+jili9YthUEdeHHCo4FX7KOaLcCe1qbO+mS43C6Ba0LjvD 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 49d9e95f42f5..012b3495c266 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 5b33f7460ab7..f277ab1b0175 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -1643,27 +1643,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 7618ddbfd2b2..f8b4d3375a5b 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -305,9 +305,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 Tue Aug 20 23:57: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: 13770679 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 BA8CBC5320E for ; Tue, 20 Aug 2024 23:59:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34BA36B00B5; Tue, 20 Aug 2024 19:58:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D4806B00B6; Tue, 20 Aug 2024 19:58:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03B066B00B7; Tue, 20 Aug 2024 19:58:37 -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 D14036B00B5 for ; Tue, 20 Aug 2024 19:58:37 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 84487805FC for ; Tue, 20 Aug 2024 23:58:37 +0000 (UTC) X-FDA: 82474291074.08.5A68918 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 1B308C000F for ; Tue, 20 Aug 2024 23:58:33 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FdbP0w1s; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Q9bD9RSX; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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; 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=1724198234; 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=iJjBw8j0sW6lJf741suOdG87104nAgRAShghgbnodso=; b=zUJltwQoizau3wwV8r79bL47G/Dk7+RpzyAqH82CJbmpW7ZU2cYmmPW2qzs78H/fiDPF/N mvre2XaO6KPccVVE3Le6fAekKEe/0F8jTwj+ulbFV6zy0AFtRLgWUL5A4TAa/nIHtj5VVg dThcdfuWPaoC215TB3q8JDyK0/FtA0c= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198234; a=rsa-sha256; cv=pass; b=EYnijFneXyatLeiSTI3pfrVONNK/3lEx/OvttBWjgMegh2VZF3tLVF5+2XSaDY3lZsbxOf hl7gpE9fJHQAAxGDG9qofZ2vvLjGpEEKI5urxarI615cHtvcIGdKB6g2RrWvqZHzc3U+WP 7eK1Yuhf5PTP21rLSYwzsgYRin1lAWg= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FdbP0w1s; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Q9bD9RSX; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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; dmarc=pass (policy=reject) header.from=oracle.com 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 47KMBegr020565; Tue, 20 Aug 2024 23:58:28 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=iJjBw8j0sW6lJf741suOdG87104nAgRAShghgbnodso=; b= FdbP0w1s7NgHmipXSIgejy2+kijlnRuiG3DPnkXrfL9itDWv0I5u/xSySKhnvuxh ip2Xiy1XgKNogjgineTXG8RvGsyXI4xqIZFHUprrUXI6VuB83Kr4k3i9I39U1ceV p83iNHN6fdWz0F4icdYke50zRIU3s3T+SuQkhH/6GYYFCHxfqgAKhx5xK0/R3RjL rTMjlPq3cvA3a4u8R49kyywl3xOovSoOpOA1x3IVM6CN6bi4BlLAvizh3EH3y8bB 1bZuqkWp78cJwtFRd0uMvbWV1rgr/BlwZptZux6ZVBSyM8Pi3iNTsey7y8IDIT4F F9ev6lJrw3mgZ/lcxwSgGA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m6ged2f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:27 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47KNJP2r024574; Tue, 20 Aug 2024 23:58:27 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4154qdgtc3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=k/XO1AmoD1sI4ruT6bx6yU5kKLLYN2jEh7GhTwpV0859zUpFvR/1fikRqKn1xkPhlzJSk/vrktomzQiKMDJj9Hxn9T5N0pxCb48Qgp/I+VZevCma6eaiuLk/Imhvw2eu4QKtSuXCzSR8cXvRsA6TT+8oC/rtO1+FYbIhjhUB/ehkquT3mjVHRvCyCVHVqeZ6cxPaEWR6GD6+YEh65z8/o0R4Hc7UFevztB2OK2a9gXzq4f036ekr8X36wWU9B51km8CWWo7NK6JJkqPeYC8pP2xXyzv8jO9V0ZS5f2/CwOAoaYuAh3lGLTObRN4jSHUYDU+jcTxZNqA1c+TGJZjZvg== 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=iJjBw8j0sW6lJf741suOdG87104nAgRAShghgbnodso=; b=OXGiYEWuxqiLlT98C7MsyDDhjrxjynsBimMxb3qLkOe8auduD5D70I45v3RsgwdH+F3kpzRuVTu8jXzs5g2YLN6AK2j12Im85pQ1Y35jaJIwYl50dJCWzd4UN+Xyy4b6S8xkv+XGZ/QeqzEtTlwAzLHvOryNeG/5EnhrAuUMm5nkks38SE/TxKYs1G6nMwvXGUmfjLhbOSwCG6yNdkgDjp1vg1ZN3H2ke20mg+naiPhvejoz/tto24MlBag52wQB0iYYNJa09Ng9VzDaqV/k4VrGIT40S0G33BDmoe6VyukWJuqFUPtuuzF0bFA8rMwKJkSIwqUbXh+dlZ88B9lTnA== 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=iJjBw8j0sW6lJf741suOdG87104nAgRAShghgbnodso=; b=Q9bD9RSXssMHIw+zysZVeL4kgOft0rI1az5UHismi5plegeH8MCSJpmvqxkGLxR4bohXF/7v7FPZe3d2sT8AgYYE3fDXcHU043Yyc4MH1DMvtzyiB9F0HKEJTK4qyOJ9Rwbs7ph5h0tbQElU6MlpUYAo/wAQHYX1DEVH0nt3kUs= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DS7PR10MB5053.namprd10.prod.outlook.com (2603:10b6:5:3a4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.12; Tue, 20 Aug 2024 23:58:24 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:24 +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 v6 20/20] mm/vma: Drop incorrect comment from vms_gather_munmap_vmas() Date: Tue, 20 Aug 2024 19:57:29 -0400 Message-ID: <20240820235730.2852400-21-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0404.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:108::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_|DS7PR10MB5053:EE_ X-MS-Office365-Filtering-Correlation-Id: 03d3ef11-70ec-4be0-2605-08dcc173fa02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|7416014; X-Microsoft-Antispam-Message-Info: yK/2bZUkEsXqN2k4RIj/7rx3+zdI9UJhpP3m+asJNy86XqKaBTNxAEavWdBXkXNvDHeLJJJNh+QwE3CH4qMvZrjrexQhKl6vMa3t6JUIFes+tR+M9i+iKmHJFRdG1RbS0ZSlOrWwcwzz0lInO2+DvQ3/VQrO6L+szvvM1xv2X0qLCvHHNmU7oE6tOBtrQ+NpZK+5z23Xadgdzu10LZs0lXReCSHqwJEOXPFiHTBgFt05NOndF0viQQFQCpqNjRcdjq7aNjyQW6RKGGLn/xaJ4qORA/UL2JlS495S/pd+rYK9YY+4XOtr8Fza7FXIh1hAZZrOUhfH5jv/spvR+YUCZxb1uIGcvEfN9IAHygUQIpLsDAFAy2nhiJRZ2gj2RQsnsON2dFQxaCLFn34gMCKyyHKBLQQVNAMBuE/FsDR0lDyrMkSNzD8ctMS0LylkVzQAFqaoe2A0Kq/SvhlG/l4Gavv4BGGazVNj2gUM+6zaFcvZl5nM78wZBpHGrL3LT/h8r0/lQWAAv0yPQWOU696lgxV4TZURl1/FgWOLoM7z7fkXM9odGg/yf/7RsDHX8G4NDuLrmoAnMWKQwpvb5eNJmc8lXPjXvb4yVbrQIjETj1UtQZ88GwsXcpv4h6riRkZ0dzquIIz/YHaEnfuz6M0SYGz1/N/RsJcU3zcZ45Peku+g8h68/K06rn2KkKNuzzHT6GIZThAqiDauXAdTPGY2x9pyFB5iwSjR6mIh9xwGCy6xgkPRw9wZzYZAjdjMWsweUha9jeXE9T7TV9EwacEU9XzlxYqXmit2iunWmi2lwLTf5irRGG+D7ScXvwUV1ZGzafa2go10UNS0lpvwCOTjhNLz7a2pzhX2AdEUcrufQYfxxAI9YM+7JOs//7v22KSNwJ7uOv7u//UGfA8qHJxUTztCiCxMbh44qQ/bUPv+UocsWVmYcZF2ejVjzkiIR0iUisop+SSXuo+w2bJf24mHXQ6+wxyZiyrLwC1jM6/93EVdSAp7EHXjJyHgqeVn3uAH8RH+jkXAVrvoRjzJPk314ZYLvJFyshEGn/6AG8CaTIrWRZojYpVelrpF22Mll4jf0VdXAAqNexHavamqk+4/1tEs2BUHd0zczcjMYdDMT8k85Mgp+usWFIMNA5P92zRZiyWxnBzJpYM0sn2/eXJ0WW4oKObvO6ED7rCGQjfOPadk6k1yzrXNc8DDcfXj/DhMzdQW5b/eu7VLGAVzx3Vvjt7wwNga9LT9CxLMfCz3ghjrv2zfdV0839EungO0DHbtZw9tl9lqmciZaIWsOq+A31pdmeYukdIQInggiP/aamkTl2COjjH2bm3sMhys1DCjXjsU2OndRX+bc/OjmnPqCg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z84Pliy0AVRBi2cqHEncXz4HtIVydwfNUUeEFoFksnua2RVkzHPomDbDRacVCaG859oQhZEFBSU47YO4rIkK8YUchxyVliOkqXUFjr+/JlBah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b18AVHBXaroHojxsnaAP6iU5VJnfvQK4tEp++gAbu7kFQ4DnGko+jaU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03d3ef11-70ec-4be0-2605-08dcc173fa02 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:24.0882 (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: 8GzIeVWKMlfxIO4RBvPQoA4nfOaAuw5izPpLF5y6yic+N9P34jjKzpcwsSfX1Ojrl7BErq0meQYUTdJBwL8Wzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5053 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: 6KvRuAjfHFK0uZofFfzJPmdMpM_q-lAl X-Proofpoint-GUID: 6KvRuAjfHFK0uZofFfzJPmdMpM_q-lAl X-Stat-Signature: 4wx7sxqg1f6fdqfnc4jnarkoa1eqxhfa X-Rspamd-Queue-Id: 1B308C000F X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724198313-954090 X-HE-Meta: U2FsdGVkX18YBQWJs+5iZLX5PNoa5AcH2Kb8VOVxG4ilQYet3qFGihC3URuiTlWb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O0Gxcjt9MWLByb1oUXLkOAYzp1fmPIM4G+HbTvTiZkMK1zczmED2flzNqikP6/U5DTht2T0XxEACsvsxed1+JOmU87yqVBPd0GNC5Bouw5QrMlzN7jT3H+tges0gzoh1jY6juEt6A1sgn29k/gMdUbMpp741O/IDHRdrb010l1AXKSjrBHgjz24cBGa53E8N8SsyKwSANgaK/wzvuypAGu/blqjm91WIYWFcgXsOytfujJywdsYvfpUjjfhd+8UGzfW+EVL0L7ZcnomFGto6uYJUDYMKs21OkIlIXKL2CbXYABP2ass46HP1ujUkgRNZI8RzJ51PiGgIRiVpUpjBzF6usQqBoR2x8KLQLdsxT++1EO6LpBWqbHVX+ZxfbWE9msdnQuWYIF7AWzT9Fk2HzY8qmdfkzrMjoYmqlg== 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 f277ab1b0175..dd064b0abe17 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -750,13 +750,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) { /*