From patchwork Fri Aug 30 04:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13784181 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 30454CA0EDB for ; Fri, 30 Aug 2024 04:01:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59A436B0085; Fri, 30 Aug 2024 00:01:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 522AD6B0088; Fri, 30 Aug 2024 00:01:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 374EA6B0089; Fri, 30 Aug 2024 00:01:25 -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 14BF36B0085 for ; Fri, 30 Aug 2024 00:01:25 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BBEB141414 for ; Fri, 30 Aug 2024 04:01:24 +0000 (UTC) X-FDA: 82507562088.24.12698D8 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf13.hostedemail.com (Postfix) with ESMTP id 838A320019 for ; Fri, 30 Aug 2024 04:01:21 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SzoZ56Te; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=doMnEIvS; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf13.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990408; a=rsa-sha256; cv=pass; b=vouVOI8Py2neZiGpCFsRb0FIezwGG8tbqhjYtOXyBlpJvYev7TiTb7sgPR+wvCNbSvyoqy NPsu97WiV4ML9AsFHxjsZ92YXOM3Qrfhu9XW1rEO7jgGuDvEwbDK64qIAhOV6db5x3Mwv8 NrHnBBRjHV6blXlVtdw9AyxFd5YYs4k= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SzoZ56Te; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=doMnEIvS; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf13.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724990408; 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=xnnEJ2/bs3ZZce2Wvukf+vvIt3CjvelmbfYrktlw+QO6p/BkXt6+uB9t+i9CmUPK8vYfuz CbGDY8LoYmGmPn/Ss9NKOy1SNxHFg5jJ8fEMQrS1i8kTvo7FVL6sVPh/mm/8y83EbQVXcK KPjbei/iWgQfhea2j55IQkp4MVCY46c= 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 47U2fnwk000993; Fri, 30 Aug 2024 04:01:11 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= SzoZ56TeDcjmyiefwjGSMryqu7MQErLbMdsOW8GzGZwOX4bDtMNhxqyyUtGFZBQ6 C8Lg1HHOuhEbesQMRsKSOAUTwrz067Rjgtj3q8rOZz51lO2T77WAJh72QP9hy4nV zHvLr5OQheNlfNspNi3ueDgxkkgQDD0ibd+1dCjOZQHVeVrpHsOo6IPSwE4FNmv6 o7wdVvvXmholE5B0WJiyfnYMf+kK3SOVSDS24BGkC0wYTd187KtD610QBfY7CazK YmKw+FMdVZEUZ5fOd5vMZ9zzkLgg/WkdiLtgXzSUromS1Q9u39fm7ntBiPRIJ1tW B66iuhZdTX5aI0dn7zlwJw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41ax0grrgv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:10 +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 47U2Cu6V034855; Fri, 30 Aug 2024 04:01:09 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4189swukex-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wXhVpMwjWbONTYNn6T3Mau0KxOUK2fXthg4FHwxbDK9AH5GKfy4RC1JzSDHhmiGiLpXZUG5q3xHGNVkTxjjSGglvIDE584SHCdTvlZOduh7wIC25P44yE+z8vtuTxLypDrblDlmDATfgT+F/MkXsd1rXqO7Z7V4wE6YxNky3RolUc7JhpoF0phzcqzoANlwAjpR+PGXzhkNEQZhJdFTQp/9KHtiL/9MD/ksXBgVfHcnrT0i2PhvqbpBAWXzuRRS8a5Z4El3apXjoWWv5Atd5Jkkli5mSLxDNu3jPhIN8FreEjcG0CI1O8DJGn7vehSRu0oTnv7t8xzrGmuHYS4qBMw== 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=CuS9pIJDhGy3ddwvsPR1KPxdGhsUjYkMZ7kFWctJDhp6V70nT0IhhauLkW2Mu4AE45M/UE+lzu73nNZom2fvs+vTQ2BTSFch5vOjtPSXQf00HDo16eNgKLD87cixL18QnWizUbmFVEr3A61snDiZklOVWoAANweLsetat5ZJ5EfpRH/Y9/wZxX2WTqrAxYlczA7FbJnhNgXFacgj4RqUaSDmW+ux395AZY384mAx9czHyBweq7mtzxr6BtgPeYHk8aVvAYB5PEoqqzWN9grKhUtpH/Ehs2/TiM46DlGBrNaN9+AdI4pOmWrKLNPcUa+zYu4wXMSYu9SA5pAuSaQACg== 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=doMnEIvSHBC3dkgZa1CTq7gC2Etx6A2SKNHDGCyDIer7hyLaCd8aKX8ipNZ0PGTW1SvLACnZCDm1QMt/6aT7Y2t9up6olBQcAUADyf3u2ixmWgQwWA3LAyoqpSMafM8rt+2HlJt+GDAXkS+8k/rPEBZ6THP2ZaUqgk1El3P623E= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01: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.7918.019; Fri, 30 Aug 2024 04:01: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" , Jeff Xu , "Liam R. Howlett" , Lorenzo Stoakes Subject: [PATCH v8 01/21] mm/vma: Correctly position vma_iterator in __split_vma() Date: Fri, 30 Aug 2024 00:00:41 -0400 Message-ID: <20240830040101.822209-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: 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_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 4599cd62-f987-48aa-1bbb-08dcc8a86068 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: cdi1d+3b2GiFa+Aki9HeSVO4uJSmuhVIduatZgXJ+ed74BQeOkLwPS4guWaQS1vR412SAIDz7YAz/lZKHmHKIwHc24yG2bEd357pDe1IFb4JuCpWk6OCIXHb7sG/YOlAsOiQipXbJB0q5ga0an0YanQSpOx/paqoE0grDGQr+I+XPQceMjZZkSTICLf7TDQxg/hYGSA8f3tmKpYBpxt2XWJja4Uy0zBj+CUqkUyKXernSoI9GwkF13UVy87mODr1g5rAhE1Y235mAGqOzKZ/4DGjm2daoDQu/+jGW31kSxR985lJGOU7m99huiOX/GW0WnDA+MsLlMYkdLd+LqJRn6ePi0HUIs9LK17A0IddIQgxcR+pPZO4TLWjccnINIRYpABmquPWDWdWHwDjfzDOqdTJsXlPXF5/3EBvL7WEmo7C2TTVaTfk6OUMq3SP2Kd9G/B4xIC4wVaj92uO48CPJVwD3eVLNILL1t/O3JdxHP2oiAXkuZPHlWyYeHbrZLYLLQqDnIIdacazevW8Zu7D8CeSjxxRMRhoSJjgctXY/jww9eIfRCE3ryep36fgf8P+yjO2LUS7xF4C7O84YKm+/+sX+aW7YmEjIiPWNc85qFow+g+c6+irt20rYkAKSAZQLQa7PEbUOb4o97AdXrbQhLAGHJ1ii2l0S00vjSQzfLTuuYYjesYhk8dzpj4FG1ueo+3WjbOhlqEVYTWWDWMuvBno+S+hoJ9A/J+llB5ANJRQnDCr5/5lASIf9k+DkbJ9qFGA9ontHZFIHyiPmACj6g6YwkXjqAvcxxjT3KfkrK+5ZyEsutdQikLTjQ8Rro16ekaTrUFSN+VpEcAHpcBwebaGKIPrMT1W5OuAj8g/NEg7eC68Fv+gTspaqR5p1Vmewfqi3LFjUGhsnGXYhfWkscKmFMu2KQTIbnJXUvPTc+F1m5IyXBWl/ahKggZk/fVLUJYDk+FzksqrmRRvRwrnYQ8uLKvI46Hp92P+RCJwWXNQeQz0ves3m4JbjFgEsEkL/NME2c0PE9D+UX/eMHhgtVjOR7FHnwf+ws3EEUAvYW3xjnB+qp9r7h2uF1P2/OiRNzM3DH6N3sy1DaNxYQE2UbmhZqe2KCQsXJK/SnyfQ6vhkXdsTSi4w5WlgHcueHqc7fD3xA6zn6rGHQmrsPX266R6MQQzxXMBarRsPUadvXhakFjFfSKoZ/aKn+2aN1GIYe5PVPBoGgJ5WcywGhT/tPt19Sy2n6DLFA0qqo0jXRXO8kqsPtuo4neiYuGilszUTmCHwEzDhXHAPLfgV5VOBIhgKlpGZ3ThAWIekrcftkJCR2AyhwmMnuC/jDIMAZOGT/Wv+mofeXKJI0do3hiwCg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z4q4is07N4vxl+rj/O5sIbPPGcuI6Yvk2wjrfV5CQO6wCw8j9ENEswoLrgkfIbThVbKnVBMOg9NpTCCL2yEOaaMxcmw6mMdg7y1CrfLiYw2hkScqFgLCj0Oqf4alvbo90q8TS8u/oV1skZjLJti+TZ+HGVJyF0hjmndX0KKmlgYVWIJyMcSRTEAj3zK5n52e1bUndrLd2D15Eowk9fb3x/zT0JUrvLUmnFr4USLxHpO3GhrXv0t0PxYSqFYdMQGZFM9Kd8MoXbW5iENCk3s4i/gvkz7fH4KyhU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GOb9eI0U4fWCW+OzMcIkDhCHvfKIV4qF1uUKbIqsvaItGW+IvrNNdlZ2arKoKrhVSSySahvmydQQnZzOJsU84KdQ8cJ2xG3VccG0C82R5SnJYYTs3S3Zz+8opslK4UnLMAMJkh580vlcqx7jF/yzihjvfB98pdGzmQh0NzV3LHdVM7am1mzfjqQUr9u4sLHa2h62oKtHVlzlmTbNBx6Guz X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: gR7uJof7Mk6dSMRPBvRJkABPXZULKGV0eSXf0Yd+LOniw9/sFOjtJQX9okDQyTtjHfK8eD6UUnhH4irHg31M3zvExs9+DWz3nTceghRxhM2AorYmmoJGBM4ARScmheT+1MG3PXawuHjNqEPK5eDycgPNch7H0tubUMtILhpGQwZYVInbkw2dRxpCeKaHQmeYRw57lWno/qNsnzQUkm/FNjw5wk7Vus/rXaP9t8gBZI8dmBM956m/PjUKAyZdNHPCMS1Q2lOUDTY+AGvD3YKIwHaRI2h8CVX4SJtXWhUJk7ddyANF9zG4TuSkNUFhMkUi+q7o8GUzbehT99Ag6P5LO0qm/B8zdhm0/qgHpG5cKMAA3BLH0oqJYl9xFR+kLiC+b9fVvcOMGKp5RPH12LiJm1RggAjLhbdUWLwrl/khyBU1dL0nGNm+89T3GQLuU/S5UDhE7D2YqWKv5Zfc8VGuEKCFBHCMGunaTgSHRdXRD5GfFD2JZga+Uj8gcXMMRFAm2hp3no/0BWD5sN1O3cG0335bNAUKSQyjGlhlcI9u0OzlyZM5QU79OTnrVH7oSMlQzi6WogLssGCJoDditDTkGH9BKQ/FLgY+XIvaJbUhk8I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4599cd62-f987-48aa-1bbb-08dcc8a86068 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:07.8549 (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: z1dUxOCqWeCZHSUwaV/lazS62WN6f1kfK6QFwEZuoxKShqxuyKjDu8vl1ho5OhtYYrkPjSfocLxgx7ZtTE/O/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: 10gfR9VdhwdVEU9Jc4MIXMsiPYNdQyJY X-Proofpoint-ORIG-GUID: 10gfR9VdhwdVEU9Jc4MIXMsiPYNdQyJY X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 838A320019 X-Stat-Signature: tr3yzpg5wbx4kt76dziizi4bp8ewdcg7 X-Rspam-User: X-HE-Tag: 1724990481-340583 X-HE-Meta: U2FsdGVkX19cjwPwfzqpD9zWky/HQ68rOODcbrX697kodCW8tct1wb32VxEYlZSCzG8ewuJZ33hUiG9+C+QCDr0EUkDo9rKQThsIpve0YOX1/nqj+ik9Wb+00AXnmxIxm4F5eN79NDaKtJeR5jFV/xbG74/dnKu8JAItgtsPsmzz64ywWoijkDMTQeCDczfFsPVDfbY3iPeVwnhemJqh72XZFCMlBn88ToXiq/Ld8Tc0eAT4ZpwSmK5tueFFk6/0aGfhBHKK7R/n4yNiwosRv6hAdQPPlSu1dw5EfoGfuO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PCWu+B/RgICcVITG+708BMl0VF+2rsi1FNn+UXXeN8KVNTu8RhJZ8nE+wxia4UmwJ/VF5WJV5IVqgIG+SEGpEGLEXPLCPLNBjI7PIzWLoO1U+UCnNXbOG4klKoCuqF1qk5o3EBCZ/28+7WCcmlCmOw+A7jF/q+KZ07Pn4pgj4OABROZqqaFbbfWvdltVVwZUIwBkoMWrfYPF+MgqvjaPFLLHCuGPx1c= 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 Fri Aug 30 04:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13784182 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 7F268CA0EDA for ; Fri, 30 Aug 2024 04:01:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30B486B008C; Fri, 30 Aug 2024 00:01:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29D8E6B008A; Fri, 30 Aug 2024 00:01:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 019FB6B008A; Fri, 30 Aug 2024 00:01:25 -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 D97576B0088 for ; Fri, 30 Aug 2024 00:01:25 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8AF5D1A070D for ; Fri, 30 Aug 2024 04:01:25 +0000 (UTC) X-FDA: 82507562130.24.1199341 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf11.hostedemail.com (Postfix) with ESMTP id 3539A40006 for ; Fri, 30 Aug 2024 04:01:22 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=eC9zapJv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OIwSSGNT; 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=1724990437; 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=5JxiFe4/y5ks7yVsrhKE0QHduoawmB6OjE3uwwcM5AHaHEym8J56WOFH5lJziLH19O+ZMk 5MXTBTAkyg5KCXHgys+dY/VAg4oPlGpyqGapkkCrLreMImSNBS+2e4CENGAd7F0XeioiQl E4W4G+n7g6KRqjLkdpcMR5lbEMIYvY4= ARC-Authentication-Results: i=2; imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=eC9zapJv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OIwSSGNT; 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=1724990437; a=rsa-sha256; cv=pass; b=vM/e2EtOpYmVp9TQq07ovoj699zDCql47JcL63+uxtC8y1HO83GnwwQnGz3X0trV+TUVoQ vXbrq/TQ1lFLW4507jKJdZskPvzEUHSt9cFESFmrjQerLYkIb34gIuaqtGR9MZw3QekXLk +oprJhjnbasYp274Ig9peIMkBI80L84= 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 47U2fiFW001321; Fri, 30 Aug 2024 04:01: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=WZRaFvqKhmeZGOgIn0cNM+Fo1hKAtKZhH+jC5oCYViw=; b= eC9zapJvxyW3cugG2HVSrnuBJ6J5m68xK8kCdiDrbfV1hohw4vMmlLNkYaSMXCuG gyHj4ilkSr7fLDLKng16e27hCSSDBXw3c+fvxZJr+4y1hUqsu42TbvpXDP8Rx2qd KhSGCG3WqDzIpY/kui4fpFevlcMorojgPjBI0QlZWzM7ijl+yC5orvFmYHeMlnz5 3XiX+6cP+53cW8KHZS8oYjrL9wgI2N9PoepiXXMjrTMNMHELCX30AFLpqeEjVCGp ia177EqKs4/ckE92XMCHlcB4D9ivmqlUPraLQqu8l6S8MREkiJhTya6Vr4x4nrOl fP5UKA51w1U00s+l0VgGhA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b25qg882-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:13 +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 47U0URNe032483; Fri, 30 Aug 2024 04:01:13 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 418a0xj8a0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xFnQqHYNEiXLZ+XpXpRWAa4icArX9Y7CDlrIgiLC70cL8siW+JwQPzAvUslgxLtXHfW3/M/4LUvULEdB0uaqP5UI7kp8JLaPTKUj81PyObrMghmxMMG9UCxK4hFHsjlqUcZqHvuVAkhDCMD81S0zumfLfRpA3PgRHKpXPrSYw/vhFgNxvtS1b2HAmp4DSqhrxZp3jCGONlXzVraNln+s5Ci755pvAIi6raTUqTGBx+fYWuWxi8wdBT1pR21KPCrZ0SzYIgYF1dsabYGX4PCqOIqvAP3VunvFiZSknbIdXVe4vAQ/1JXyaEGhLHp2rWwtiqP+f/C61GULc9+QgVXGRg== 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=O/2bRHgXXdT7Y747TvCV5GpUh2FYnZa0t2yl3lipRDdvlGd6Wkx/drC2XJpVpOGTg8RHoP0RmJz54qsPBIzNXhy7mCda9Gr3MEYbF6kSTr8joVOM973v5yCQ7/eH5eiXJALNEO6xZoaq6/lMTIqa1E9nGl+7U1ezQGng/ZDFiyadJ4KQqx4PunD62yvhyJiGXerxpjgTv9gMQAEqh5uC24Bpkjx9GLe/0T7ya1iT3ky9blJRoI/sytIHxeSB6lemwThIu0D6rUBzSPnCvf1rTXRXb54pCHcbYRMphJUp6ltnpOL1ESiyJjuK5WAO4Gu2KiFCv932vypWy4ghnyBR+Q== 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=OIwSSGNTN8NtAmSI/XdH4HeUbYJe9By5V64xPS3Ixx3EXCOGucJ00QsIBnDmrFN9LE/P5FhAFsvn/3Q8nD/lpZQ73Vg+xodc9EynkWs0x3uP9u9oMh7rKPqzV4GYAXpRXd9PjwiLh66QuftRjAeNHd8qAw1C/Bepc3kPUsLL/X4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:10 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:10 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v8 02/21] mm/vma: Introduce abort_munmap_vmas() Date: Fri, 30 Aug 2024 00:00:42 -0400 Message-ID: <20240830040101.822209-3-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0057.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:111::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_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 5906c6d6-d9c7-490f-cad7-08dcc8a861a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: pSBls0z6fsGqUQzyVkFUnFpiFrIEgb+l1SmFKMP+vxuV7K679DBrlmcRBYbTStnzlKm1MI3P+wxX3gcCapZIG7TBrlshAQIyvJz0EAkoyL8VUCo7zwU6EpbNKSkdSTjSg8zgd+yK6Fqf/WK8BG4tDF0Hkp2dKWXyH5pZUTPYr5yPDPCHxamO3NIHLA2XySuo0P8EH/F3laib3Miw5fVoFacOjE9BEnvkRJHQ+rea9dm7xKDJsnDC75NurIEYNdu3IcsEsUIzk/S+AxYOPVWrS5UM24AKFnYO5dNRXSTI4qROzLPAujlxla7KD4e3cPRtVvvR8M2O+Zg3hDDHkFlC+RTu13IKbdcyd+u9HXOMRTFn4AxaRzsP037VtJYbvzB0fQbdWKK04+KKSfiirL7kl4/VJhw1zXk90InDH5jr74JgZr0jzwH8N1sCJ1wSZa/53kWBDgM67XqzQLGoKp0upff7fis1Hk5VNzHUJAihqMDdU5HW8nAowuh+iIj4DxBppgWT5o/1Oq6AMwW25gP7cpUolkpdqI1E+Sq2/yVeExiOxr06bzEokGU0FmEp8KXVZrSrHM3XtiJya2Pq0ysOe4GxTrxsgk6VIJIPTERqqiG9Q7Pm8gkNIQ3GI8FFMwi6R//auGhY50MwUGkGCN73rhKctmVGkdSfW56Ah5fZ3SNd11TQNu9ubYLzetV1dYaFoMnzvYK6iNF1F92r7I8KgRPcu4KPo4i9BIthV49lrsUXU5Ol9zkM4JUijjIbdlSYSUCCSA2KLTfCdwqUAAExGvy/J5y8roTSXfuCHx38dNJ/3DPEcne5KKhlFJ5o2j08Gb7QOdeL7pUK8B4niaz/9lCADaDoHuNc+K0YYrKr2Q9F025lM9UXawmaA4jTh9J1yuj6LoQMzfw+XJ4aa+lFl1l5rK38KfPhN2Hg8FbzV4AfZCIklbpfSMLcEEHueAeIEdLzIwXICFEq0dbRGzy6LVkCQQI1k6lDa79tfWz8dsCGRyxCX0v5yZTDOCH4NdkL/DjbOSnPZ9MQWoVf9NR52xeCc8y35f5nMKxQSVdu+Tfbn5+M5YgxU3eNmV77vJAr27jpKcCTK2AP60Fi2ZZU2xY2TVUBWZon1fYifHFZgmHjUNo5fOPmMTTWFPRMZOYXlH5gH7B9XuD8Hgme4d/kMvUXtD8qXDwKWerZP+Y+GgfjvxoeNOY6VyCf9xBsiHsF6jh4rj/VwTqlYUulsEWDJ+UwTYBmXeyxbGHwlka1cZ3gvsA20sbdrTMLu1NnEhuB6KJomJqZnGIz3MercGiZLgE4eL8zeiMkItNKVj45Xw1MIt1Xo5ZylyjxlTkIRzQ78SSl9F55H4OVi8SMRDglnw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J0yCsSBYJfGuPp5iE2ASZdEsEfVSUvPo70gzw7JTvGiBuL2unqdHok7cSCukVKTQLYBDbWlmPJDwL/FZcMkeuL2GUvXAOrNkx+AeGSvvHX1JYqiyLapmYkpVmFa/NbTFzABcI0EMzKkGyf6/Y7tcueieENhUfqsnHiV8/ZSWmqn1CnB66qsATD4mfjDUps9K07jbbIUvVqYgjQ/5ajGgEl8btQUmdwXVpclesoBBFWAUypDZjuvGuRVdaIv9Rjxhs1sWT5sVw5AijEH9wbxj0oKMhTuKAkqe471m4zeQAvY+9rfEiz/prJwlKtAzb9AlOJKXNK+t/Y+CD9/5esaGrHcUPCnVxB3V1xOBI4k45X/wNlGfdX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/Izhi09uRKjrSgen3ZqIafkf+EZhK4st25Jw5POfawDiOxZdbYdxMly71E4szGzR8fGNh896RaxNHZmbm4kcjqibI/qYOz0zoEWAfYpch0Tqn7L7Ax786wd9VjnYNe5mcvvEQC/9HhCDTRsZAyND X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ez4DOe9DlIf4igwCLTDkxB9OGUcTimFVqt0aoZ3AW8DhUpjZaqv7uFRUNpkmoDutUqYrl3G9dfMvxTbJNAw9s9RJiXyOKOqh9Lj32LK3ot0xx4bJh7YxE8aCsb/kpwZPKqDayPH8FdF2b7eXehg9mubi0RQA0DhJ1Wbwq0S8tFo1KSvrSOK/Yz2E2nqW+MtlbtpCJev+TsKpjVv12RXV4Y3ohfZu+vI+7Qmqe29clIHQMgWdoDKkliiwZaA/YIDVPoCpp+0a17rqHSWTrmDPi5gFClzo6Jgc0CR/mrAnyZ9ZiZ8l64Vvp2ZWALiJgQ2TRRxBhjaqf2c+6+EEPVt4e/B1WUBDKwE2uNsOSRmUeGT/icKZgltXbLqY5cI0MMv3uF2ZbOI9yZw2iMvXCbE4krN+qLjAnh3nAu4rgoNp2W3cojjEpg0AIwrivaghvPYL34E9oHCPNBj0+ZdWQUQ0FI5Ns2XPiNrm1ChCZsMp0znrZNdcHVHg5p7EO6c6lULt+ODyRpcU+UhES/VsWU1SfOuiwcHbODXfKv/vtjgDBT6Vzn+tWE3ZP4irhboI55W8uR4sr3urM8IYGWV+gqlZ7soQ+RBlID0A1LuLY/Xorvs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5906c6d6-d9c7-490f-cad7-08dcc8a861a9 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:09.9452 (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: KF2yrXvr+qwy8QC0lm/7KWQv58v43QT0K6MmHMERigokz3rLx2+ProXNKZdwh9j50iGLiLrG0T7sNQapS7mllw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: 08MpBUmu_sHQCXsvpvdvRka9Xf9--INf X-Proofpoint-ORIG-GUID: 08MpBUmu_sHQCXsvpvdvRka9Xf9--INf X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 3539A40006 X-Stat-Signature: wh46ep1xkj37r53wsxximdxarqs9rrnb X-HE-Tag: 1724990482-2708 X-HE-Meta: U2FsdGVkX1/SX0bsM2x9bWM/dWLp3yaPiTSfQesKinMLkH9xdYQ8ad9ECP3XLkIjBfkquKXiQbHdTgq4YSJN/QIx5TRc49zB2y5E2U5i2XJrUnlvfbIZcBAX8t5pFDaWHykXITqGwMxU6kWOc7kY9Gqg4GmIbvEdkThPwxSq4WsVoEwwYAPZ0n32qthrXWLE5XHbm7lG1vhsdrDk8IECvfMzipHqYXMzHj0wTdOY5+GDnZgo5NPesSYw8w7FgyqdZpvLyuAmDCyJHPUDEtiAWpR9zsEMlfCnfXO6iqJtlJQI59oowOWDgHVzuw8UOTDHzAo6U8yi89WeAaHClrg2+WareFnS8QKnH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gy75yYFZw3692wfGb02tyNF0V2AMpNR7yrpELaT+dy6li3DzqDmd/aLgy9dDNUpBtPpwytPXNugbxBQ9ztUYBFLeKp9h9SPnpPr5SqwnWyyL29qral3MVOjtvMA9Cyy6eGrTVlFYiEfDeYkOURM9Pm5ANjhAfhmUDw== 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 Fri Aug 30 04:00:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13784291 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 42EB3CA0EE1 for ; Fri, 30 Aug 2024 05:29:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E4B96B00BB; Fri, 30 Aug 2024 01:29:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 793F58D0001; Fri, 30 Aug 2024 01:29:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E64B6B00BD; Fri, 30 Aug 2024 01:29:00 -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 3C7566B00BB for ; Fri, 30 Aug 2024 01:29:00 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9A6E7141473 for ; Fri, 30 Aug 2024 05:28:59 +0000 (UTC) X-FDA: 82507782798.12.AD397AC Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf14.hostedemail.com (Postfix) with ESMTP id 3298F10000D for ; Fri, 30 Aug 2024 05:28:56 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AQjmBPQX; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gfJWNYqg; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf14.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=1724995647; 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=PemY3/TmC00kq8+1gkGxHkyYfoXNhG9eM0sjGM448mSjvzFPkATTUzbHQMnExySJwCCdoA A1yAnKwL24WMdkck0AgXERlc59v5lJgidUSBBQno2JfE09N9P9ay56umrx239zhKWzxzkk Ac5bnHZnSrEPeL3LaCvuBvq4NnAXw4Y= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724995647; a=rsa-sha256; cv=pass; b=kq48eBueNYklB3P/BygZF+BfoUSgb3Vgisqzc8HrNYXTUv/OOEe/ueKHIFhq52+7DtT/ef rWTHpgvi/Fs2ymwiJ10FfBOvsewVUE6TBq5/osT7SiQqAKxDb6HZ35fepIPYL6MoWE9SXU 8WC0jwnU3kKIUt3WWvU59f+ZxF6LNhY= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AQjmBPQX; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gfJWNYqg; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf14.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 (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U2uL9G019681; Fri, 30 Aug 2024 04:01:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=INR2A1cBDUV4GAxtVOjXNUJPR3TPHjuX5sIyohpW8AI=; b= AQjmBPQXpnbQBV8qZSKKb0F5gMq3c3RqIDjJuUwJtY9Jc8zWSqzrzmgq60sFkqUv DQTiyZoKTdg0tFsxWKxKG1jeWB6PKxAqtLxyvJmn8JGrG83S84WHEKtug+ogL0e5 CiCck/4YSwP7LiSU7eTiSiSv85xTB4309rkWQnp+IOmvV7HFArKACEpPldO9biol SVoqpv/dEDdtirhJRKTBFhzpBqk2ixUz/hf2DiRL4pimvBa4T8JPU4QB7QUJuAjU /TnvdfRC220S9zFeFxR2P+99ID23aE+A/c7RCM3aTFDtkZqqAtRQJ6StC5bhjGBk VdoIfsx50c2Om0JRBt4pTA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 419pugwrf5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:16 +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 47U1ZDJw031876; Fri, 30 Aug 2024 04:01:15 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 418a0xj8bb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UIRIU8OIhCVS0o0GBPg60MfNCgmHafjhradbjClNoYTajyHVMTBz6vBgNtUzwroEDIuTPwrQ0jqvIdMlYwz2OifX4wbBhb8M0e05Isipm3cewdhhq7rU2q+5RIlpYS0bEKxx98FGrLWpJ+bawea1oVhKYNS+yxQYzgnHtPLRQafT/3A4StBR26Bjd6s7oI0wMMIcUPKP4DnIcd3bYT20AGZEqWIeqTP40LM+NIw+HGRx+m/NeBkyIpHGL4aju+CN00K8gClzfZ7/kG2hGRAQhRvmcACvm8Uc/34zz2VQvrrUh1vQh1wnpcgLmFABz8nA3KA7QJUSzs7OOomcnhXQqw== 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=Kh+2W91I2zNTpdZeBi1cLszIzjGh9TEA83LWPtzDEbBlxWZBPb2vkDYNAOiF3cl6x3RUgr+fn58ZmZ2DeDkVa10loKQrEkKlkvhi3ok8gcqG/G9e6h2hzj4aKnaS9yJ7M8xnXc1xLWCcDedbu0FD9sAoJBhPRjCNVIRDv3oM3tfJnAZkur2+Q28Q8r5RGNfL2YnybC3TxgEdcmrJ3gqtluS0AYTk+kssz/6Q0C70vA85qLChbmYzbX2Zdx2zjyMrGo3SY5jTQntZ0WbvxXUVElKSAJc5Ez/cdox7cPu21junPPeF4NwgigM7xalqvMmMIpmGj8f2mjkPrnETK5CCaw== 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=gfJWNYqgpZwI0YzjigOrS2fW1nelLWVbRxvSTeZKsQDpB1P+jelRsjswo1/WOeCEpUpR80ay50z/ClXrWcMLOkGu5S08BR9O0Z0yi/PXHe2t7AnyDQnozbGCGZ9KeM1q2OU3yC7y/JuqhXiM0oZeXyz/WYp2mQWr2slYfHmZemw= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:12 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:12 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v8 03/21] mm/vma: Introduce vmi_complete_munmap_vmas() Date: Fri, 30 Aug 2024 00:00:43 -0400 Message-ID: <20240830040101.822209-4-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0331.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10a::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_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: e0359c68-95c1-4b87-fd1a-08dcc8a86333 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: spA5QsMnlwpTykoQjiU/HcKXFsVOPTNJLbVJgYBBIRrhLO9aqi0Xl6h/Iwr1E7TRbFDwxr+Wks7cMxTQz6oegCqS8Ejcvnsty8cBvgrEZLWZaMlviHrFrE6Is+7bNsxeKBiNIxzTH/ndehBkHZok2K+6egWeSffkVaSi9PNzt5Kl498Dk98q4Wr9TUlFotUrK5JqxwbuXPD9mi9N6GcFz/gp1SsnE+xusyEEL7703dLzvT+UAayL879aUe8JhNf6hJO2SUizON3X1s4AQUu3ngnZew3eK1DOZLGhMQUf+KuUT/Yi0dX1Mew9Z8HxYE6Mpg7mR26g5SCkSdbJ5zsueRn5pxtaNTjMAEwi8DDeTTW/BtT2OxaVDCe00Sh3B73sp8rkH9EgJZSh+N5lyJ7Lets57XHGrrUalXRWlVz05NBrs59m8o0D9ePvQh+mZbsdP5ZxBr0NqwA3u9lm7f+f406KGU43b6P2A/aMkg2YFhRIJWpkJTG4CxkMTXI0yoEsnAIL/hZ1BNTWJP1FqZvJGQC7ORmOZUfOB9opsk9oZZbAbV9WNTSAVNjagvluI7JpEG7Ek+9JErnV/eelYWfOfvgU1KqbSNHh106e4kXssUy7S9MSROe6epNChLqlC8nWnMMzsTlFlBblDk45Lkf6X16ovOXjzBzepZOpRERs/z7VN2lFD/8Ls/tJPbyH4reumwfL1PsfQlxscH0hzuDfvFMKjOys3OEc2qYzkEVGKBjjZNndF+E87HVHOPyTTrRjLZaMaf5bBPgVSF+BNDQFy/zuzpYm1IRE2gjSYm24dYB2jdpU+/j2jucfbmAMNyWjem38ZWDP0kAlMBy6OONS+J94KQow2kWS7pojG5ZoxiIqiMPj1g81jWzHlsk4SP1agFUm6fBw1CJEfnimhTUEcXo3+bUw6xcXHLUrNz8Iy6GdVVNLqLKrsRKDVvtDakRfwDiVJEZOyGOkSVDqUM+LRjN65o7nJBkOxA2fjpImdzBtKkQ6IC4ARtDon2FFnpnL/h2vG+qYUI/XAedFE4dpqZr2FwXDCso4xzB4Ebe4aVrS6tjkgK8ATKO6m66uslnQ5nUN1FhZR2FbanV0yKEUrRQKlrFUPYN0MHsQWG5wqWLpYJt4oflqnGyb9Z6CrdnGhntKbTbwemaVHGcIPBGuzHK7jGVOfe55WIYgS4EZRN2eHfxkM4ck63bGEvlcBjkuT0rzddELxi1qfeBr5lBc4lwL+Vluc6OKgaD2xodXX5N0II4IIId4ECJ/eNjnOjFRb8M00K0Ndt60luS1QU3d18lTZeN/96EAWLYVJwv8sPYe3js/7KdgniAlW7dDRhBC9KjohWuiKtYAd6P/rrB0Lw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HIxW3ewT2VNYrK8RKE0IVO/cXRQd3H95VQ+jyhgNpsqUUkQFIwgfn7HEpE7qUpR002GjBtyMjnWvAd3E4lPJEJb+/Epv81uSJ0XVDGiLqaAcrky+DbO8bwvsyX3vtSVm+g6FzsT5OsUs803e0e5ibS57by4D2hpioKcE/phRbYlEDgEC7TNab6cFbUNfsgyjh2F1PjZl1hOIkN/XTebQQ+SQUL0Q6q8F3i7tdtWEmP0PUuDl9jPAM6Gwwkc2q7E0uPFZjAIYXl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anG2yF/qY7ckF504/TxGyCGtzOTaURoV+5Ojj2TsFsZysCRGfpUfuyBY1acNJekUNy5GYw6utzSzdPZ7uBNpSmoWdaf+4MhVQa807hG8sd3f7bvECrEYSR6HTsana7l5KkDdggRCa7WH6I7alilg1W7eQbXwaMw+o2+nK5BPCod+qlHVRN5xoX9Gz7KtUzgJFD9nc03Sb4fZdFQQsjzFdx4aFpQ5enBZVoy1T1d4CcX15lP4Vuqk6G8I9/S3kik+H6 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: a3LGdxkTbUhk1emIywXOVp1QlCdaBB8sL3iW4gAjS25VWF/5aybL9H1wFc0cMh1O/5Le6ZemXE5vR9IXWj7CwKwb1MO3OUz1+svD03IFUo2WSxlAbhx0tQrNFU1TTxP3tJ3m1iakvRI+xjDOSSAnlCtWOsSmaayHGqgLjgNr7u4HrokSbLFLkjFginVOkGfoIkm8rCqC98H2b0uC/cmcNbX3RBz/+lbWahxCpGHgRmyeRmV4kRgjCpgEVAygbNfLPlrc3TOZctwZyrOHeaMgOe1gGf663d8fFFPJtOtfKzhxlgjIvp2KZYhdcUgyrJW+xI0nS7QS/2uZ7Bvh4rfZSvgF+iyFf1L0S9JOKNv3FuPJ1dTXRku5q+VG9KnXtKZj8kCfsG+hwX5/daKIzx6HFwZvpzpvFB8/tOlUyD+n0RVjHUU7tukuzZp++hXxX0/c+h6E2DOdPZ9AvEWlS6tGFkPs0PF3IaNOgB98tfTPtSVxXQgO0mU0WY2iN3uFyaXDTLkE48nGcYG3WGCnwhFZOFpkep46sBFTiKw8m8aCBP5p0yasydX2UTSARBRzGx4vD+gr7E9n4aQELfiAkI18ZU/zwtVJbseO8fSYQgQ/Wo4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0359c68-95c1-4b87-fd1a-08dcc8a86333 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:12.5056 (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: vzZ3R1P9HMI3La9JRZCLl0AUhfJrDGwsDCVlLMiznT7yfdwGOsc7HJ5e09mhJSbru6/vCM9rTnb7QltLcL+bjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: DtnEtIF7t-cLM6Qf9quFrHcgnz4hQKEE X-Proofpoint-ORIG-GUID: DtnEtIF7t-cLM6Qf9quFrHcgnz4hQKEE X-Rspamd-Queue-Id: 3298F10000D X-Stat-Signature: 8j56geprh3e74pd7m48a1j5q7susugud X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724995736-182536 X-HE-Meta: U2FsdGVkX19ZXkwrceQlR5vX9Y1iJoAJkSSvJsUcrjmbIkxyfy3tmFvpmhR2Fyvp5a6LhDL2CkEBtve7q7DU+8r138hLyIWoRMkttPWfRhrmHsiv2HuXVCLoyv3TpCPDxmybImqIu4c0JcFzhugdDGdFfLMUjihsXf/UuTHMDpZ9dmKhSYGocVNmpPTaLkH3teMluWO8HyjCzfQTnbIwcM52nDWxmfoTY+VshMXFm+DkXNgBFl55rZx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gjecACp44SrqsoqEh4mKyGGwEdmMHuvB+mHC8VfBwsvgU8DrrqoGmL/8Pch71wGPtWC6CR73C0Uu31P7avlBxAT/lhRo2qFCFElxqWlj3C/kKusJxyfrP5+rzOA3lqfqctiuAgqSq3vlYMuTM8/Xa/MO3cEmuiMbulzCpaGFdQifxxT5+xMFo3y/k46rQetSgEwbjp0faW3cDzNeErgrblXTIUVy6fJ+PdWFy6lRLGTu8LvQYmiv9VdeM1g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Extract all necessary operations that need to be completed after the vma maple tree is updated from a munmap() operation. Extracting this makes the later patch in the series easier to understand. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan --- mm/vma.c | 80 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 58ecd447670d..3a2098464b8f 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -684,6 +684,58 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) __mt_destroy(mas_detach->tree); } +/* + * vmi_complete_munmap_vmas() - Finish the munmap() operation + * @vmi: The vma iterator + * @vma: The first vma to be munmapped + * @mm: The mm struct + * @start: The start address + * @end: The end address + * @unlock: Unlock the mm or not + * @mas_detach: them maple state of the detached vma maple tree + * @locked_vm: The locked_vm count in the detached vmas + * + * This function updates the mm_struct, unmaps the region, frees the resources + * used for the munmap() and may downgrade the lock - if requested. Everything + * needed to be done once the vma maple tree is updated. + */ +static void +vmi_complete_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, + struct mm_struct *mm, unsigned long start, unsigned long end, + bool unlock, struct ma_state *mas_detach, + unsigned long locked_vm) +{ + struct vm_area_struct *prev, *next; + int count; + + count = mas_detach->index + 1; + mm->map_count -= count; + mm->locked_vm -= locked_vm; + if (unlock) + mmap_write_downgrade(mm); + + prev = vma_iter_prev_range(vmi); + next = vma_next(vmi); + if (next) + vma_iter_prev_range(vmi); + + /* + * We can free page tables without write-locking mmap_lock because VMAs + * were isolated before we downgraded mmap_lock. + */ + mas_set(mas_detach, 1); + unmap_region(mm, mas_detach, vma, prev, next, start, end, count, + !unlock); + /* Statistics and freeing VMAs */ + mas_set(mas_detach, 0); + remove_mt(mm, mas_detach); + validate_mm(mm); + if (unlock) + mmap_read_unlock(mm); + + __mt_destroy(mas_detach->tree); +} + /* * do_vmi_align_munmap() - munmap the aligned region from @start to @end. * @vmi: The vma iterator @@ -703,7 +755,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start, unsigned long end, struct list_head *uf, bool unlock) { - struct vm_area_struct *prev, *next = NULL; + struct vm_area_struct *next = NULL; struct maple_tree mt_detach; int count = 0; int error = -ENOMEM; @@ -818,31 +870,9 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, goto clear_tree_failed; /* Point of no return */ - mm->locked_vm -= locked_vm; - mm->map_count -= count; - if (unlock) - mmap_write_downgrade(mm); - - prev = vma_iter_prev_range(vmi); - next = vma_next(vmi); - if (next) - vma_iter_prev_range(vmi); - - /* - * We can free page tables without write-locking mmap_lock because VMAs - * were isolated before we downgraded mmap_lock. - */ - mas_set(&mas_detach, 1); - unmap_region(mm, &mas_detach, vma, prev, next, start, end, count, - !unlock); - /* Statistics and freeing VMAs */ - mas_set(&mas_detach, 0); - remove_mt(mm, &mas_detach); - validate_mm(mm); - if (unlock) - mmap_read_unlock(mm); + vmi_complete_munmap_vmas(vmi, vma, mm, start, end, unlock, &mas_detach, + locked_vm); - __mt_destroy(&mt_detach); return 0; modify_vma_failed: From patchwork Fri Aug 30 04:00:44 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: 13784184 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 9370FCA0EDA for ; Fri, 30 Aug 2024 04:01:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F11F6B0092; Fri, 30 Aug 2024 00:01:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1799B6B0093; Fri, 30 Aug 2024 00:01:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E72C96B0095; Fri, 30 Aug 2024 00:01:33 -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 BF26E6B0092 for ; Fri, 30 Aug 2024 00:01:33 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4276A1C6167 for ; Fri, 30 Aug 2024 04:01:33 +0000 (UTC) X-FDA: 82507562466.25.2ED68AC Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id EBD98140008 for ; Fri, 30 Aug 2024 04:01:29 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="S/h4filP"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=y8uxUca9; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf26.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=1724990390; 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=4QFME2tTREHjLVCMxQPlLoeuuJf1PRO7hekWo2btQRA=; b=5WqdrW3jTmZt6dU4tMBkfeLBenTTHHmrm7jAKcqrx2Tl2Ep85c+4MzRwqf2qz1Kp4fos8x jU455FomzXI4gI94JIDtusPLe5mkihQe2rSHKskixpIL5geGE7hfyconJj/Uo8zIGpZUUx ua3bbkCkO51eL4Sad3tcmm3fhzr9fIg= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990390; a=rsa-sha256; cv=pass; b=N0GIoU2g6fLnYRpKMdPnMpbbxcyBLDHY8HhwYa9e+4SoPb638LVmk+oH6hnDyqhjbYEjhb 5Rfd3qlG9ej4jxpGx/4vk7vYltxRsLN0bq1M5RnoIOHpCKXsEHI1QctYOcAo/N9avHQs7q wNLGdb9fccfA96VXGgtEEoJBOAa9z9Y= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="S/h4filP"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=y8uxUca9; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf26.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 47U2fVGc001103; Fri, 30 Aug 2024 04:01:19 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=4QFME2tTREHjLVCMxQPlLoeuuJf1PRO7hekWo2btQRA=; b= S/h4filP/JPtHj4IDEBSnYXQfBJ+HzatKgpAJ8lsaAoKc61dezT2oyF0b2lzf9wM lSDfpi1Ocly3hKIfsFoEMOWlnzW4fZHScfq92Kbg48ryxqzAVPZ5KHbmY+1TBl/k SBM2rPABgZyUF3j6krkvG1ZQl3Q7mx8NPnLIrtfdKXjj92DTBHfoWO7HPYmmD0Av mKGIGSqhh+klV42Q4RO10T52Y9NfyxnxkLuFXGOMGg468RsLlUtDIBZzJQEbhpyX EEDxRB6LRJoYUoV/zv7/JBVoLg9Zu1Zd30InsLNpq39Uv/k7J/UeyQiGGar69fLr c/9BK8hSKYTOG0IIlCR6Wg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b25qg888-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:19 +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 47U3j9da034714; Fri, 30 Aug 2024 04:01:18 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 4189swukkp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U5hyAmlBoVlmTVrIGb1n0TcZiXP5aY6D8Sqhx/529d6UUHO8rs4aq/Z60TLE21gI/8wV2ELEQ9XnZH/ns3gcPxTIv4v6X2bfcuAK2xKR8QLv2elhyQjqiN+gBsibUNArnxXgSWrI1SAtcWOHsv3DRqrDXbrpUSf5OYc4P8IyC/+Ljvm9Ycs7JfjUWAmXlPFhRoou4LU24xKJz0efCZtGLr4XP4Sj890sLG5APKkOqa+5+N5z8fPqIVSvteyodlVMKU5b00mGTbr29CRCQenT6KCMn+3+ESLFzcEzZcocpjc23U7XMFY2BPSrM0NSfjw70BEY1UTExZHeZM4Nfxk02w== 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=4QFME2tTREHjLVCMxQPlLoeuuJf1PRO7hekWo2btQRA=; b=THeDQHs8CwcCIi0GJvZ0rvQqIrOOTNq33KGJNvrUW68QQ3BK+EQdADCageuc/WNqg6XiaC0G11cv+OO8YWkJ3YHdC4DCx4I8axgtlCmlbp1L34X1rmt81Gs68jOLlm5tdEC3fmLgQVe0RP5Casr7/GWSn8kgnC5pWZYQv2mIpQIPYT+yP8bcm1GFlu2XhXJiZ6wUWYM88p7GhqLpbwX0YHoeO2O2Lwyf/K1oWcEhL72Tk5F1wDozr5taoGOfXI9gVhRZZR5lE9AAkjiuommKv+h06nuwUpmLwdxVkAcrv4NBGGoMnrFxjZCQMupTckUFl4GB2Ky09Zli5/e6jzVH6Q== 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=4QFME2tTREHjLVCMxQPlLoeuuJf1PRO7hekWo2btQRA=; b=y8uxUca9zr+Us3L+CCO8b4zMuqVyRlS1JmFkXWX2UT6bGMuUBBVKy/GvSLGvGNuVimFENmBgSBFZ4aQDSWs6G8aaDzi5puSyyNSyNjGpLi+BXLuk/pYzGOsss941tXy+MiiVnNnAoTo2qmiz4cUS3ctvHZFtR9rcfT1zkIfIiQA= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01: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.7918.019; Fri, 30 Aug 2024 04:01: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" , Jeff Xu , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v8 04/21] mm/vma: Extract the gathering of vmas from do_vmi_align_munmap() Date: Fri, 30 Aug 2024 00:00:44 -0400 Message-ID: <20240830040101.822209-5-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0098.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d7::15) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: f207ef78-dd44-4761-ca3f-08dcc8a864b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: J2iRrcermSVJo423j6bZpJNHQm0LBp1D9kxVerUaW0/P5reA4M0er//+3gIfTnJmPFm9eWw6haZfKGZXsU2VvK1TIgN13lysTQySlwtwOV4QD/pTSOUDoQ2KRkynQTY52FoRHCxtesZRNtOSeO9dD41d7qaMWoyRc7SzEmehXf2Vk8lMYto+XYWCfhBmYv4FVPGub6ehKlB7bHsOCBOrg5thN7EvSBuD9Xcqg4KAx9xpyWKlDtMkIvSOfeIYHZJEKybLNFa6dYTGILUUpojTY8J58ZZeUb6aODdbOeyeYs4uaj/9F5n5/30w/5JLoExUs49CpmaP2acfDHL+c1ZcWJZaHFeWMhHGyoqcxNAtmTQxD7iH4BQqRHSigBficbbNRuAgjVpitN8wdxfLzM5KraKAp84F2KJc6RyZpXQn5kwiNrUL3kcaULnvC8WB6SDiyNKrh3fI6A+lsnxzfXorYQ8V11HGY5O8UP68xNU1GlkrIddXpIUlKd7skqmANwckmlOaRl3xIOo9LnpZ6oq4m+osQlp66jCC3VAtijmUqss/P7Iknq9NkAPyw5c1d0tzJSSncyJox+gpvCybnJ7uDGNN/Ehy00tql23m0PNUNTsjl4O1nleIBjvvyvbPX8Y1n6GTKZ6mHRXJ+KvMIsA1TrLr366VY1TFNYAwHI5e5C56IHIC4Mp+AbwzD/cxgyr0eNXEStOIpguthUUfMqPcyejq0Sh95KSFFHOTEmB+if2r+FGVG0A2+xnFhp8xgo0mwa9wTqds+5fTUoN79kv81IhlcQMinfU+QjoJppdAFD+y26vcZ8jVMaJRmohhC6j2eatLWlNnrg3Pbkwzd6Vm1/Op0co/6SGslALOGpcEHD+ktyTEydkTRCJw0kypnJrnTrvYpbIDrJ8dKL8gTnoms9s4iwA4AJ3cOI+fj6X1i1JHXQJnw3z/dHgHbIVqxixC5UEvK4ARbOEijvC+0ckaNPYuKcOKq20WmDZDKmauHv+CGB1kPOiLZ8ToYAnrSjEaC6hblB7zx39YEHZ8eUAzPRMKc+G1dGnu8s+BBfgrJXrSiRqKfazOXaMnKzqMJMxYq0KrIlu+SOE8uiFA6qfb1K3Nosp2woaVo/6GVVARsBURzQI7L+YpALD39OcqCo3W76vRaD1aakJRGV1+vLdifn2NYPj8aW/+gY86NxCCrnpjVAwrQExHBU0z+wCez+GwAL2RKLD6a0Vif/Ve/JK1pyn+Fvrg7CgbHbEqhjTGvJ+fvNbiOtneETL8uNaxkVsqxjtO3bGGvLdBC+MiyGRLX2oksOZGOhoGuEVaHj1WDJn5DHgDcU2tfodst6TBf3uUDHYR5diqnKzH52A5khjS/Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vzFAxiuXGPiPp8JfL3HvUzJM2JWWdVsjCcehpICa39MFVP0U+YdOoM6e+Yss5+eIDHLghKZqxKqS9VTWZKj6sfX1ZpP947mzu9/nLdcijKPh1hqaxcGcFbZxGmKkhn/yA9gYgUk+TnjO3D8XmDe5Xr0iH8fM0QE9/rvYeLF7txIB+1q7bNKZUUNHVIPbQbPr0gOjBHDqUI6Ve5PwxKhOORq/vNE5n/Rqwj5LdTYedFdO9RwgAWxEcmOPG/VS/ZL3qi1fI0iOA9bN5+NLJW4Uun1dMKBqJ1HkXwZ4vioZxvmLaAGn0PUfctFX5EizYNr1yxIY+1NsCSioGkazCe6lH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v58uUwGtej6009af3y32PqqUEqnSPA/E6qOKnrZ1bRjkXBjpMiDCCl0hvQ7VrUIsQ6BUKLLBN3kMcu2TJbcKn1QZo2KjJkOEUJKUgK6vh86uF3+5FaWtnAbB6iy2cHe1QMIvFTfiVZhN/hZG5uJ+0hofnmDOvtOcU8pSLqeTdhe1nlWET7PM2MJHd7E9WVyj X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: fXkMXPzkZKOP+9foxrY0TqzvcJibYe642g+9MQamNsSEVfZeP9Pb9q9iZCu5XvZxHaNVcRW7mgUuaSLZ3wnkhhChibKY3z0af9BQD2huPVKQJLOdFoZTD1y7PSiOOtNbXlDPr1RLELasFw9VAAaHH6Y/iUOkSKXGSC84gMsRArR1YMj2ACa6G2QHsFR9L70N7WP2yjJ+ArG9gsKjYCs3evfFme/SpPRmLRQkYMHAWhfJ/ekRTMfCkgvlfwYWAxozwZ9a/DIMQ3GzuVps1oE4EyJRtQi30DGnANADLWI5FzQ+q8f8wCVlEnGgo3YDgfjps8NB19AE1jSyoLsUviEffq6XzXOFi+SHIcK/A+o5UwDG2EeK3a/fn8MwqPYArdCn+PEkqq2yimN1ddDSe7q8y5/XRXIoethTEvy0E4nHQo9NOyTGNI4oK4Lk1NdyCmTS5NK7lCRQdUFWLuwKu9MD9GT41LjVs0UyTV2CPBB/vdUzCeP251E70+tfCU0/vdiaHwCMZSZ8yKjHbENlUmfbMGnhohxyw4GqJkmTiEioRb5ZaJ9sDwaKFh4S9LdjA7FfuI9yvIsNrTR1U6zGvdumFlpknWPO0SGtCj6UMbXW0TY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f207ef78-dd44-4761-ca3f-08dcc8a864b4 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:15.0302 (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: Z4qMCwGCKah7mLdp5PqYo/F45zNZjcA/3vz/4ap3wTI95rO3SqmD4jSnEPUkQEDKSS4D0auLrWC+Dtvc3Jn1UA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: l_bESagBN0mp42CK2JuMkFIdv2_bzF_4 X-Proofpoint-ORIG-GUID: l_bESagBN0mp42CK2JuMkFIdv2_bzF_4 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EBD98140008 X-Stat-Signature: 51qftoiahyqreqer4rfaqssax3sowryw X-Rspam-User: X-HE-Tag: 1724990489-337104 X-HE-Meta: U2FsdGVkX1+ObDIYe/o0NTcWGe7P39gNtJKQ2O39Z3Jeda/bTUqKvAyFgv/tbHJYvSZBb0JNmeaUqN4S01QcHcCshWHZhocs4+RllWNzAA4pTN16MNn7mTJ2r1SsxdWlLRQNBF0lSuwKqvSvArbyUzwXsO6lc1SVR9xcaFW/cmh8ZW+emeWFkxio3tZjweQfuvFyFEioZtJxwvAZ5h+Oi9MsJm3dwwf3tExrhYSSbs4/Ko/XUZBWtWFgjePYJByJ84zgLZ73kpfJb9RtiMqz3FkLqEQPHTFMW6yv+qT1JXOrWV/zC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S8r92yDXNk1hOwqLW1m0SVPifr5dZ+WdZ8ZC6MD8xQp/VpOvWJK64iX9Q+P6ckrRJS7Ch002AXXOuozp3ARwVK4NXIFQqgpseAmIuftMSyEihMp4YJLpKEGMJEB16r8QaZRZjJKM3XF7J7QtIboN0/0Qd8bFPm++/z/6yTyRLXPJa+t8dAT85pw== 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 | 95 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 33 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 3a2098464b8f..f691c1db5b12 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, -EPERM on mseal vmas, -ENOMEM otherwise */ -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. @@ -789,8 +787,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, goto start_split_failed; } - error = __split_vma(vmi, vma, start, 1); - if (error) + if (__split_vma(vmi, vma, start, 1)) goto start_split_failed; } @@ -807,20 +804,18 @@ do_vmi_align_munmap(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 (error) + if (__split_vma(vmi, next, end, 0)) goto end_split_failed; } vma_start_write(next); - mas_set(&mas_detach, count); - error = mas_store_gfp(&mas_detach, next, GFP_KERNEL); - if (error) + mas_set(mas_detach, count++); + if (mas_store_gfp(mas_detach, next, GFP_KERNEL)) 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 @@ -831,9 +826,7 @@ do_vmi_align_munmap(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); - - if (error) + if (userfaultfd_unmap_prep(next, start, end, uf)) goto userfaultfd_error; } #ifdef CONFIG_DEBUG_VM_MAPLE_TREE @@ -845,7 +838,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 +858,48 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, while (vma_iter_addr(vmi) > start) vma_iter_prev_range(vmi); + return 0; + +userfaultfd_error: +munmap_gather_failed: +end_split_failed: +modify_vma_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 +907,11 @@ 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 Fri Aug 30 04:00:45 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: 13784188 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 4460CCA0EDB for ; Fri, 30 Aug 2024 04:01:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD8D36B009A; Fri, 30 Aug 2024 00:01:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D12556B009B; Fri, 30 Aug 2024 00:01:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7AF86B009C; Fri, 30 Aug 2024 00:01:42 -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 67A8F6B009A for ; Fri, 30 Aug 2024 00:01:42 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2D09140CC1 for ; Fri, 30 Aug 2024 04:01:42 +0000 (UTC) X-FDA: 82507562844.19.401A120 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf19.hostedemail.com (Postfix) with ESMTP id CC4AD1A0013 for ; Fri, 30 Aug 2024 04:01:38 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Ko/UW/6V"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nSjg6gPb; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf19.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=1724990409; 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=U2YvcKwGePCmxbcIx/fyjPP4qSdkHYCXwCKrh6Jw9fk=; b=1qMsGIFV4beG6R+VGToWE1taKn+s9f9DoeWsqIC5Pr7EIvCKlnSzWZaYzj6adPZYf4FiLr 2zLAaz1tupY4SFzpxXbDDwA7FxT7WNnOPz7KstmaR8J/IOG7B3zE6+moq/FxXm8RPUO/a7 hQc7kJDG2JYygMHE1vMEN8YJUcQvSUw= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990409; a=rsa-sha256; cv=pass; b=R+H1oxRda0Edqh9Ax2ErU/FAZoPujmHL6rioYMQ1LoWepUaBqwpd53GtBhycqlheSHakau U46nLPXdreiMfp40EYFejEVQxZJydFCw3jOHYUBC5fgE+4azUg4qogMOOjGgVS9T1o5KQS TvoZg7j6Zz2NW9mTAUa8cKozLO9+AbE= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="Ko/UW/6V"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nSjg6gPb; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf19.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U3LAZi021755; Fri, 30 Aug 2024 04:01: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=U2YvcKwGePCmxbcIx/fyjPP4qSdkHYCXwCKrh6Jw9fk=; b= Ko/UW/6VpgrfGTy0RBnPr2Cn16neC5oudnKBMmyFnK/YpnyY5csQ1atfkOso9LT5 efS0e5XSUfOfnMBt814l3Em8unjlqmI2C2uXdHpsWhffWomx1ShP5TU/WZ/RKBa6 aLTwrWxyTvVUdKBhU8DyycTsP5SIjIC5sJXP0CRngqi5r8cCQ4HkSncLgv6v8kea 5keEztCLgIGXICqG+KTNFr2cMV4DZhZkZqehDRnsY6TI13w864RhYPBBegQCYKmZ Ce8/UAIcrMoNvnN2hsuUfJ4E4aOFEv2dUfp3fKRjK7VXduxh9X3ttQXx9onQQVyz HJXUislrJYBHF+7of9y72Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b3myr582-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:28 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47U3jJaL036502; Fri, 30 Aug 2024 04:01:26 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2swm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UbcP5asReJOpeZ032lgN084joZ6FpJSrQjwhhnIfQeF1Kd4szUaoLPsmeGBKHb9lEPAH04DFUvDwC48rOYoaDdjoPv6Vd3xrR25/TQBPrx147oJURMk70YQ80uS0hER9HKGgO2v5HU5yfZybX5kYx3UPXCNNUHVOiWTWBpEyi5v3Ujxydk2w1dlKD8arhUlH/nbXEoJi7yXdzmqhqqwHalp+dlaIORxa8rBRIYXoHnj2zBCqi8n527+2tHsNGDPx8GACiNW90lwxuybRWDnntua1+EaDV7C+rKPyDjkuRO02Q00ZP7jSSrltgvl5Si5WF/XjjKQbjSoJ/6TeVKzsUg== 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=U2YvcKwGePCmxbcIx/fyjPP4qSdkHYCXwCKrh6Jw9fk=; b=nTnix203VT9VVKwKxVySvDUoAoy/BPp8iyn0JHCURKdRkiiVG6wRjzusFK1gEWp/brXgvsYPXub9LAnJdqBY3HijI46ixlAMJ1lZtiz7/khtnfd4F9Y8B4UH0MMLaAKOx3qKcOnTvWrJOv9uhpIDEfm3cJMiAgSJ1jQgl/k7GEZ3QyIGhECNy48a9hfWdUi4QHIJAKnA0GYu6DwFzT2l5Cxv31xEVWHYetoNUvtA4u2jLv4dW7ueBHb2TjULr5RyV/UrVFufpEblGjc1XKQa76xICXMfb1svAxAVo2KtRIOusSid5Ic8pYDlwysydF9QWnYUbokvE9Eh0JjZop1wFA== 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=U2YvcKwGePCmxbcIx/fyjPP4qSdkHYCXwCKrh6Jw9fk=; b=nSjg6gPbll0zN4Xx5a1qUtxnVp32vZFeUZDsJG/gkdw+R2hAQPxLRFCwv9Aqr9ztWLqbNkdKWD4zBjFeYENweceDcJX5Vw8foDmG9ztbSXA1n6qKj598/PYJXGwKS8jgfk3LXtX2xIMnBr2qdOKJCpPgGzcuTqfoGoN7uC6Ol74= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:17 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:17 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v8 05/21] mm/vma: Introduce vma_munmap_struct for use in munmap operations Date: Fri, 30 Aug 2024 00:00:45 -0400 Message-ID: <20240830040101.822209-6-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fe::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_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: f251c220-45db-49a0-583e-08dcc8a86646 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: 5L4g0gx/TkS1IxSXmI4czmvnewFasMREi+OmruuknktiaH8sc1rxyZ46mUuzyvQ7513iXYuvZgxNBBwzIqkPLl8KPgZEzYUtfmzeOXHRx6KjdvXguJDl7SR9kJwoha3CbdxCeIquGJUMbRP1vpRZtujeGW9D66rNrmDxdqCXjN2dHUUOORXG5p8flkAR3RsRWuTNAgrn4W1tTS+PQ6ZL1JwPo/X4MhY0CLts0KUce6Q3ubG7u4EbmxkHr7bx/zi0ToFJXFKb8DXxy/amvRlEgmlkOqClTYWRPo8oI6OZ0R281BiLVm4bGqX/oHBCMirbWLLUib9aaxOfDJ9mkJKebo4C9KFbYqf8Ap/T1NBQYIBCUZ/VN8nrqUXY0wl9uzHDJCu9Y0Ui0XYWUBKEFx6ubUzoen9vMlvri6smtDAAXsnyUeh9uaFz9MnjCM68myWreuivqnYTzV3ljMKC9dLn3CoqY+u7qv+r0DaqfNHdwAy39RvHXlh//Z1oFXZnqYLMqnV2Gh0MP1FBbJDzePsDaNccBtCLcBRe9bhPCvKFHGMAHOMF3hnX7VAr3lzhrkRygL7d0QPsJPlpNXAb1D1WhaeIux9QkYAYSA2Imj067Nkqw62We+EdrBi+icqSg9dau5aCYLiYzjkohhpBBkMog6Vnb+bouUToC3Qmo8bOpcLe7e7f4tcnkRYRa5fSD3uB/macVRB5IvXb0eisIIbU3YdCUOW+IBi5E+R9m54Fv5oMR/JwwyKCiVE7FmOjpXIL5EQ/gCzd52fpX34LtzpAASoRIX+6K3opobLT3lC0ODi+p1OuRgnC6QxGAzIYykbqe47PnM5k5kCiD015dzW5pFjBRJo86tTS1f5vwMQr5pkei+C5ozXdrE+aK+uSmqeGL3raLRGXNSHnw/LJIJLZHc82oKYl4BXhIvlB28L+pV59wp+veBIWYZmDZbUssex3UXkidc4kbq8m2WyVgrGdVWvVMKSatwrxdI4DEfL/XHGyROSwFd86lpKvcfzkK3aGWo1cXvUJwLzfVFCUb8mi1T1S5dvFtQlDSnfRVpOUM2bOaUJoZyWiqc6q6edc0+6R25TWvD46x7YH8eIbwPIt+CLappbzy3OmBkVh99tj4PlKSvL+1uzBcI4zshHjcZbeLRiCsb461zg3ZEF7OghW8Sxa6WAmombZt/9Fz0dTMf0vcakUE8b5PtZWEKyJ9vTO748LCNldslmpDQGQuU6bgTwbioJNePPGG6M7DgZAwGWNDy70E+srNYLI4vo9y15CaQCTFEvuCnIc3Rt5YnSMizx8fwDD1anzhXiVYhpnyVZpBoZYVk8gyxnOLRmvdSTZDvUoY8UDpk+mZPEAD6nhQw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yqmThh2VpgfCMg2JmYgzuXahXt9HQLSDgY5OPy3+pRF6CruG+B/MzWr6psqmcNvUCtVU3Be5rFYWfQ1Ay8xHipSjxT6R5sjS4jHFI1ucXxozy9UQ3F7SSgYjFd55cY+Q2OfNr1QgZDpHtZSB0uxnI40Ql6F/3MW8L5Z3Yy1SjVLB1T+yjbRCQLVchrQlGuLGvsdxpqzqcHlEv9pLbiYziZY1kDNtOSDi1x/xIeIEGyviLryo3UABK2yC2WhmGLyY64EaPWy1Xdpub+j1N4INZPDECPzP8+6oFGpyhW+vlhqFIZ1e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j3Mm6nJGMusdDTphx+S6YxJPnvhTPksLs75Iyc4Xv2ZrDngafNJqaFZ6KNKXCfATgi/dnJTFGoxA7sJyhQoRbt4AAURcIGO5UMdhDOO0RzgYZL+pTIenSXgjiZIlRqKH2VBD86rsoPEar3NACDXrerAFCjoJMFxaGJ4LUWpM7DSBPNQRxLVyIbVd1mdAHbxIQwoTD47p X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: hukItWkbqsXc6w1YiD6Eye5ag70SlU7YdkaC1+28yq2lwVwZ1qQSfwtGQZaGgYLzNnCUfOhirWmWVD9aEiHOqCtUBqqa8pym//HxCySJnriS8S0AhNW81g6KqOOhvWebUKYk2MMyT1kqrqj/dbqiTi6zWDVpkqx8kOC0BTRkAa2XG+yEmei6IC/MXIdQefGj+cSWUUfER0o3KnulBB9eH79nYfQBufcDhXvn/s3SUm5NqymN67WonGoLQ8hb/y4UqmJy8RQOqkCpCWP7uAa6EJJW72DCEot3UqjpzQ/OIF2u7BTH+mPKpdA1j7+dDRYz+DliUIHqb4e/wJX5Y5Ph01BnyQfMFbhYTMMoPn1h+eEs/i+emV4jHizpfzuvcXlBHhaiE2gDoelRRbMrTl98kWyi63lEAbG6EXKvVsIFfM+wkEF5uSnbaPpadPuw6aHFWLwZPfEmcm2hPx5MjxyVguKSlfC0gkU6z5CbC2q7OxS4xt1TWzXelHsFWPIhC8T36UoipiX45P2tLS+oczhvzSQTjU/zlGoAO11+8LeBrdRY1PzQwgtxO8iEkS9Yvvkxdsb5fRF0n+WRUumc6ZB3h/BPv1ZqTHUAaZTSDUmnxNQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f251c220-45db-49a0-583e-08dcc8a86646 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:17.7382 (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: jhBvNQLSm+4QFz4jpUAJVR8jl88NqNHL9rGYTbRnhQbCg9so3LIqucH2sP635Tz9ck14CuVjFUhvSDMdyMs9dA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: 0Iy5k441AOmygkUK8-kHZhCA-bCtgAIJ X-Proofpoint-ORIG-GUID: 0Iy5k441AOmygkUK8-kHZhCA-bCtgAIJ X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CC4AD1A0013 X-Stat-Signature: bqfse37wdwxadmi9cixmgmj918qbyasy X-HE-Tag: 1724990498-401783 X-HE-Meta: U2FsdGVkX1+Py18fRGfifOhrtE86AiThi765vtMfMaDigmsIX9xmPXHg6cAwSpoF2D9rE/eWmLS3tChyoGj9HchHSTLgD8Bg0MK3tNWaIqvoMRB3HgY0TLq8Id3PGN1dSkcNkC4aLXennwzVnaFFFaCBZ7YPp00JRAe90heylZwkwSigXSLVdos5HfEFo7ErU6mbBwEF13VYW0dEZkRijD1o29+lVUG0Cj+0ye02+vmqEsWGjs6PcT3XN4YKzeN8KhNgVSQSJtYdHqNBETYeuyE8Cws0gqHPa0A9rFPqk81hNhi+jHVeessA20MICRC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R8Qm42qh4p4D6ilyKhab/1ujSmNd2mAMEnkNdvKGrO2Ij41G6rSfMNyqjLhaiiZ8nZXCwW1OmxEBI9sWc3+7ssvGwAkM8OM6rHPRLqIew/eApcFpVrNQbH6/oBVLlhO/VkRP/YhFHlME2ifE9NS15An/qh9HTdcD83h+tS7J9i1eYhJyj01Js6vrlnJS+NyZOH2YCL0G9YI1g== 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 | 140 +++++++++++++++++++++++++++++-------------------------- mm/vma.h | 16 +++++++ 2 files changed, 90 insertions(+), 66 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index f691c1db5b12..f24b52a87458 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, -EPERM on mseal vmas, -ENOMEM otherwise */ -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; } - if (__split_vma(vmi, vma, start, 1)) + if (__split_vma(vms->vmi, vms->vma, vms->start, 1)) goto start_split_failed; } @@ -795,7 +803,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; @@ -803,20 +811,20 @@ vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, } /* Does it split the end? */ - if (next->vm_end > end) { - if (__split_vma(vmi, next, end, 0)) + if (next->vm_end > vms->end) { + if (__split_vma(vms->vmi, next, vms->end, 0)) goto end_split_failed; } vma_start_write(next); - mas_set(mas_detach, count++); + mas_set(mas_detach, vms->vma_count++); if (mas_store_gfp(mas_detach, next, GFP_KERNEL)) 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 @@ -826,14 +834,15 @@ 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. */ - if (userfaultfd_unmap_prep(next, start, end, uf)) + if (userfaultfd_unmap_prep(next, vms->start, vms->end, + vms->uf)) 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. */ @@ -842,21 +851,21 @@ 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; @@ -892,11 +901,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; @@ -905,8 +914,7 @@ 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; clear_tree_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 Fri Aug 30 04:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13784185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B282CA0EDA for ; Fri, 30 Aug 2024 04:01:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96B966B0099; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F3036B009B; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 682BA6B009A; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3D2DB6B0096 for ; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B9A164141E for ; Fri, 30 Aug 2024 04:01:40 +0000 (UTC) X-FDA: 82507562760.29.14C63AE Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf15.hostedemail.com (Postfix) with ESMTP id 5D45FA001D for ; Fri, 30 Aug 2024 04:01:37 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=aJ48e43W; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="g/lJOcu0"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf15.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724990407; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Lu6AtId3bBP2dooEzmFt7N2rgO4+X+ZJGjHwi2y0j+A=; b=UjtJ+BECVCYHco2uCTQvZ4UqRdFvhsz11Ggvup+GG/qBKpcs8GeAGJ0M4pyscQ9GxuTuan UARGvSGViX7Clnl3rL3Ps8o6KiKPuh9aJxH+l8PzDGg3qvEqaoszw1/z0v37yI4P6HHCTu jGmRaNRM9S7Vgr/qZxAK77G+FrS7Bn8= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990407; a=rsa-sha256; cv=pass; b=biiB736p+/09BoNrE867OWZnb2l2M+EZ7Fzo/IxR1VZwPydjBhjt1EH2zdPmWhbIBniXkj uIKwU6uv2ZQff8oTaV5el1PycRigbz3nqdkxW60RlJaEfPdVxIN+YaVGTgin8c+yg+Toii Ml4h+T/ZdtsKAN0CPKlEuIn1yvOmOjM= ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=aJ48e43W; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="g/lJOcu0"; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf15.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U2fVNw022839; Fri, 30 Aug 2024 04:01:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=Lu6AtId3bBP2dooEzmFt7N2rgO4+X+ZJGjHwi2y0j+A=; b= aJ48e43WBfbdc9S7ChqawcjC1oOPRRsWYWI1suN4NpKPslbHNf9gK1HP735Ue2Wh 5xotbR/2UeAXXeTbugJaZPbuV8ND3+aM9bj4RTwuG72tmmyr9pMDuJ2UocdE/o7P Tq3f2eeGOWsB7tM+04kRxZfm7C94NJhwtGB1Pr1VkshFO+faudfx6h+KId99RzHD jb2dz0rwk2+jQocgo3VLUytlMYAk1DspfcQ9RjA6fQhvI7pC4Kvj1TEl0qLQjh4h VJ7zYuDZkE+dl7ay84J6FEJgKDVMZNo9+/nGVHEtvtsyf6IfuaAM7wgIbOeN1/Nv bcdpQtH+cGOufGxsw8pung== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b28508ne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:28 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47U3jJaM036502; Fri, 30 Aug 2024 04:01:27 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2swm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ERTfAd5OD4ZjXTg/2oTC/Yedei2Law/mkdb/TTx3lAyVrhgQVNYlB+vENXiDyr+2KdatmNVY3zoyQ039lY4j6sP5pvJJfIHFyj0kCyQZgO7Lu0LNL5tvq298C8GzBwoGGncdHknJ3FEawfVHU5tN4bGMaPR0FgoM/FerKlZTq0k/4FFJ1xOuEznFARoeefbaPbbVSwg9Vva4yE6CP3mgFcbpuPQjaIuLqQyBLJDmZLPKubA5fc3aZluqGPwlSpLHSz5CKxF6hkiw4ALA+OfcQdpFo0EaHaf0gJzztqy3Ah3Nxju7eeZs/njCaFEOVQA1Z+9VsS4pR7og0DdxMvf4dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Lu6AtId3bBP2dooEzmFt7N2rgO4+X+ZJGjHwi2y0j+A=; b=nniIUiTEk4Ma2VQ+684FvVLsMHYvYRHxlcPtVLDJUXZ0NqBXPnt2byapqhqO5t02nneUnJtHcsOZaDJ2LchtB1dzRw4TJPVfXv72BUse4ArDNm5GVEiBV3WCNatdw5taATOWnpXUwY4yDN8ExHYlyUprAer7t5gLvSZcFuFKTkVWV29MGHIgYKHbsLpgYTZWSGFnYqv951+g9AvydqthEG6Dy50er+9o9JD8rHfwjb5xanm5nm2O+R0/KCUpyngVPQHnGBAjf8cp28RIAvc4f2Pzp8vkpysZzsZcpYOTbFF+Prn7TdNe+RNPqO4TKs2xNb7VEB0KbOSIfBzZ6bvKeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Lu6AtId3bBP2dooEzmFt7N2rgO4+X+ZJGjHwi2y0j+A=; b=g/lJOcu0edZeGzEzW9LmDW6Iu0cyTo9fvIhoU+n43/LixiEbqx8DMg+ZyTVscNa2OrVDAmtGtIO/GwutJhlGh1Nx2wgiHHcQV/Zt1ixZsXr8hqI8N6c4olgoETey38CCQHVYIBjOzzdl53NxsWh8cNJv2/XmfSPgg0Y69h7GMiM= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:20 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:20 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v8 06/21] mm/vma: Change munmap to use vma_munmap_struct() for accounting and surrounding vmas Date: Fri, 30 Aug 2024 00:00:46 -0400 Message-ID: <20240830040101.822209-7-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0046.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fe::14) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 575e3351-636a-4be0-b1ce-08dcc8a867cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: IpQjrzZWD/pgrLcHjNFdaP0J546FcdRDD/ETHYq2zpKsV+lGXNQt5oeduQzWfN196xxxa38sjKGgB9KKMKwFStVKYbDg+ZuRINrL2nU8Io5fhJBL/q4481rsClLpkwIxuwk6YWERB3FdOf/l+3nAjSrz/wg72dWKTPwmp8fGu939SWJMPISC0s6Uf6sUJcu5TfyOiDujHrIA0w/dyQ97iCborF4fxga2FctQCDJcfv6BYHgifXsLK6U+/JQyyWYLRdu2tsp3ZEViWxobVe4FlisOSEaySKZE8HJkdrSoVKafR73KCXW5PHXMLQFyodong4P0djpciXcUyUoan6DClJoFFGMos1BwnyUVVkSKJpYiGBfYaNa2+vzojEuusA9cJkyFTUwGh40q9KXn3+g9DJYOKtBUKvQHAzDmnB2x7yAA2mN9dieBswcFxSTUoI8KGRv6fCGTCtelxerImm7lnMxE8+2QyPl2VS8gK38MQg/z7UMFbHxwbGxu9niZ9xEljpp6Nqicf5uowH9NHTntl6rN916NKfvSPnIHG5xSXwMYOxl68EH1LiTIhRuh92OKJFI5OfC5/yB3rBA8vv+iF/KY5TSd7irQrX2w0gaNYAqmJhd9tW4XY1bKdfJ1w5ERc3u0khWE3gAXEzmSP/arIWYEH5Fe8e3136qO8ET4FRrmTyTrZQuQzXX99287jHXNX8W6/ldfVSLOhcS7/IhVSgRvUGMCoiKrvPieOT3QJnIRiCtEKifyBPTAgxU8kBE8dU7tE6CetGloVgDfAJcDtA+wjhUJtG5tZ4HMxB5nWP5gaSt1ckmVWujbAJmTunphNT98hvX7SYMPyfF6H9vtOgrpeNWbOjNVzABvFNYDl/Lza6Z4WSCWwsirLtW4hNHgdlaEuhLfLfJwGju4akvuYsA/C2/cYvmAAROiY+xcuQTKKnqbTV8mGiZhNEFzpKl2VY8t/Om5+ROowEqO4WuHi2va920PzOg2ky0NszEM+kUKL8d5kv9HEo0cmd60ptQVP5WzTtF6uT8Dh0BwheUNL/gIxIfBDzWakearjpHmNH2yD3tDp+eovQ+AJXRNN8aw9OrXdlz6i/JjOInlvxK1bEBeOuvu0eiBKyyZWMQ3BOdVIM0IZ4Spms0jFgdUI3cA6ZeLFg1tiZjXith8oef4YGmh8Y4iJOOeNHTKiOszxgvEat+38KI7XuW66CkMgeng2oYy3W2MVEexwDJp7cWc+UQjikPB2SiKHCMzJybMHIMXcDaqhwhJmQr8Cr5Zg8sA9BHzipNkVbjya9orvBBi6FsnD76cp//01tUWxm7Tj5FMl3HBqUdqXMSW6CTCRA6INM6tu5FXlOg6aFlkZdrS6w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lIROTDVWHlJxRkEDAkcSFkqBBnQ4wJK11wBAAsdISKIqzuLlFHL/tC7vSio+DcZbsnEoL/nc2MM9UdkDHzJ+gZuGMOG1jk5EhqNyshcbeE4YdIs5wA2Cr1NDJXA7e+izulKUS52G0mFpa8X5t6JBFl7fKecy351Rv8ittvf0c7AkmGaf5ypxNT6MLlQd5KBIvRnYXYs4SSFBnsmAEmP4uZfEPzLtYSfkM2sOoj6d+cvBIiuhrSPw6AiGnhhliH/wojue56jsbJePwIoKYdAIPJQk71X2XqPYVBcS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IZILtLj5Dx2RtzX1tidnWu+wpN4/R49cyWlrJwvCwEAY4bjlLSHvJNSOEtVfL2bX1bspCjs4WUm2ofy+CupYvjbfVj18lInY91NL65qteo8mGfC9Pw6GGVgflSLqOZYaFSXvMt6R99fiYkOGcL8m19WzEQqYuJc5zxuGE6wADA/uKmF/yRg9bnLfkt/CglGUN69K0dUtS7ioqfU6XbSUU6IOVX/Gc4RpQG X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: xcehb3/PNlst7lu6wYejJJlG6X8LOpZl+8VgvrjkFQs3vvJkQnPPf6PnDDrabuqwiNaxerr08nU51bkMTQCQzeAqNJxXFKHOJloL7Tyjg/FrBOxgefIZxhtYeF9VQRXqsEL/yqWc4vNlBCoqiqx/SnxRILJ5YkKQu0d3JdBxHzDYvOh8e6fCGYPm6KQ0dJlwmQknPYnHzHgSoR1vIZBzNtN6ZjIZfAaBg4mNE+qatd+Jb31bYoL60MuPM4kwJk6abWdXtXhaX3CSi631dij+7zJCWtmJsbvn0oU1hfKB8HuAAxsZFe39GNOyVsM5TkT8fW+W1Q4yI8tYOqpg9jzW701X55BIs5xsZ4tpTrD5BoJHyfWDsCC3tXnHD97iQKdmzNxzwciqzFgUSFrfNOEnP4LCY/ZsWZTJiWKb5kLOPhDV5d9re9YMwCm5cIHqDZS3RIR/K+2m/QT7zZx3TcnXcMSlUPqoCsWji7bBUyEzwE4JIWrpQczcR7M3dBWTgPwrvxzbZfEVzLfsbSb+yidNHcs1XcElhNBCQ8g+8vrkxfEtfcnbOTvccUuYC/isLXZ8ZL/2b8W+cdLFz+W8zs4iO5Ed/xvT4MvLb0K3ks5CguY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 575e3351-636a-4be0-b1ce-08dcc8a867cb X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:20.2381 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lSK2wP88qjL2baUazf1rBfe+V7YPObaUATZ48KooU7SQ3e3kLAoBBjo25z+k8sT2SKxMcAnGw6JL679cEP0kvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: s1TuJUxGpeLi_9DLnqI84Qp9tEc4UvrV X-Proofpoint-ORIG-GUID: s1TuJUxGpeLi_9DLnqI84Qp9tEc4UvrV X-Stat-Signature: 35weyatemzi97wddwgs91msen4tigwgy X-Rspamd-Queue-Id: 5D45FA001D X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724990497-900943 X-HE-Meta: U2FsdGVkX1/tus/pteTIo80HR59FQMWGDLrgX6zeAafsXpBD62xgkfkG04hxplrJoVeHHUEQidGbtKCXMVmGk/daAm0/IqeFBJ3pJ/ZoPdASmeziS40c0bZ89CnEQeyuNzQwNBC1UxGXiE4UwD5nDDvimcDRI4rz+wwnr7LhyVmFhjuSE9s0NqDZV7Dm7xqZc3jXNToxuDuSmBhMFKJFBEgaqsnlxJY65RKv9OEFOaa3MsArd4Ec72ET8D4+WJpi25NEL2GzDljffdTtCnjF7kbUfdr4V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Yio5noi0eCrWbyELnO/QSowmt8TxBKOSum3E80pGSYVnKqri8jQD7KSDX3uTAovCI3uHjzKyUgvGPXIefni1Ms3wAVizuOwMcTQINxe8Zvfxgn/gW8LikZIk2wUt6YUuS+M+k1YWOmEXQa/dobaSETrhuGRph5KcuaJ7nffaeUDv2nxGcWyf7f86P8pyurPmEeJIiY5sJ0EKmdkYzoMLVLi1TO7YYe4g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Clean up the code by changing the munmap operation to use a structure for the accounting and munmap variables. Since remove_mt() is only called in one location and the contents will be reduced to almost nothing. The remains of the function can be added to vms_complete_munmap_vmas(). Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan --- mm/vma.c | 83 +++++++++++++++++++++++++++++--------------------------- mm/vma.h | 6 ++++ 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index f24b52a87458..6d042cd46cdb 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -103,7 +103,8 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, vms->unlock = unlock; vms->uf = uf; vms->vma_count = 0; - vms->nr_pages = vms->locked_vm = 0; + vms->nr_pages = vms->locked_vm = vms->nr_accounted = 0; + vms->exec_vm = vms->stack_vm = vms->data_vm = 0; } /* @@ -299,30 +300,6 @@ static int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, return __split_vma(vmi, vma, addr, new_below); } -/* - * Ok - we have the memory areas we should free on a maple tree so release them, - * and do the vma updates. - * - * Called with the mm semaphore held. - */ -static inline void remove_mt(struct mm_struct *mm, struct ma_state *mas) -{ - unsigned long nr_accounted = 0; - struct vm_area_struct *vma; - - /* Update high watermark before we lower total_vm */ - update_hiwater_vm(mm); - mas_for_each(mas, vma, ULONG_MAX) { - long nrpages = vma_pages(vma); - - if (vma->vm_flags & VM_ACCOUNT) - nr_accounted += nrpages; - vm_stat_account(mm, vma->vm_flags, -nrpages); - remove_vma(vma, false); - } - vm_unacct_memory(nr_accounted); -} - /* * init_vma_prep() - Initializer wrapper for vma_prepare struct * @vp: The vma_prepare struct @@ -722,7 +699,7 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach) { - struct vm_area_struct *prev, *next; + struct vm_area_struct *vma; struct mm_struct *mm; mm = vms->mm; @@ -731,21 +708,31 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, if (vms->unlock) mmap_write_downgrade(mm); - prev = vma_iter_prev_range(vms->vmi); - next = vma_next(vms->vmi); - if (next) - vma_iter_prev_range(vms->vmi); - /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. */ mas_set(mas_detach, 1); - unmap_region(mm, mas_detach, vms->vma, prev, next, vms->start, vms->end, - vms->vma_count, !vms->unlock); - /* Statistics and freeing VMAs */ + unmap_region(mm, mas_detach, vms->vma, vms->prev, vms->next, + vms->start, vms->end, vms->vma_count, !vms->unlock); + /* Update high watermark before we lower total_vm */ + update_hiwater_vm(mm); + /* Stat accounting */ + WRITE_ONCE(mm->total_vm, READ_ONCE(mm->total_vm) - vms->nr_pages); + /* Paranoid bookkeeping */ + VM_WARN_ON(vms->exec_vm > mm->exec_vm); + VM_WARN_ON(vms->stack_vm > mm->stack_vm); + VM_WARN_ON(vms->data_vm > mm->data_vm); + mm->exec_vm -= vms->exec_vm; + mm->stack_vm -= vms->stack_vm; + mm->data_vm -= vms->data_vm; + + /* Remove and clean up vmas */ mas_set(mas_detach, 0); - remove_mt(mm, mas_detach); + mas_for_each(mas_detach, vma, ULONG_MAX) + remove_vma(vma, false); + + vm_unacct_memory(vms->nr_accounted); validate_mm(mm); if (vms->unlock) mmap_read_unlock(mm); @@ -798,18 +785,19 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, if (__split_vma(vms->vmi, vms->vma, vms->start, 1)) goto start_split_failed; } + vms->prev = vma_prev(vms->vmi); /* * Detach a range of VMAs from the mm. Using next as a temp variable as * it is always overwritten. */ - next = vms->vma; - do { + for_each_vma_range(*(vms->vmi), next, vms->end) { + long nrpages; + if (!can_modify_vma(next)) { error = -EPERM; goto modify_vma_failed; } - /* Does it split the end? */ if (next->vm_end > vms->end) { if (__split_vma(vms->vmi, next, vms->end, 0)) @@ -821,8 +809,21 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, goto munmap_gather_failed; vma_mark_detached(next, true); + nrpages = vma_pages(next); + + vms->nr_pages += nrpages; if (next->vm_flags & VM_LOCKED) - vms->locked_vm += vma_pages(next); + vms->locked_vm += nrpages; + + if (next->vm_flags & VM_ACCOUNT) + vms->nr_accounted += nrpages; + + if (is_exec_mapping(next->vm_flags)) + vms->exec_vm += nrpages; + else if (is_stack_mapping(next->vm_flags)) + vms->stack_vm += nrpages; + else if (is_data_mapping(next->vm_flags)) + vms->data_vm += nrpages; if (unlikely(vms->uf)) { /* @@ -842,7 +843,9 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, BUG_ON(next->vm_start < vms->start); BUG_ON(next->vm_start > vms->end); #endif - } for_each_vma_range(*(vms->vmi), next, vms->end); + } + + vms->next = vma_next(vms->vmi); #if defined(CONFIG_DEBUG_VM_MAPLE_TREE) /* Make sure no VMAs are about to be lost. */ diff --git a/mm/vma.h b/mm/vma.h index cb67acf59012..cbf55e0e0c4f 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -33,12 +33,18 @@ struct vma_munmap_struct { struct vma_iterator *vmi; struct mm_struct *mm; struct vm_area_struct *vma; /* The first vma to munmap */ + struct vm_area_struct *prev; /* vma before the munmap area */ + struct vm_area_struct *next; /* vma after the munmap area */ struct list_head *uf; /* Userfaultfd list_head */ unsigned long start; /* Aligned start addr (inclusive) */ unsigned long end; /* Aligned end addr (exclusive) */ int vma_count; /* Number of vmas that will be removed */ unsigned long nr_pages; /* Number of pages being removed */ unsigned long locked_vm; /* Number of locked pages */ + unsigned long nr_accounted; /* Number of VM_ACCOUNT pages */ + unsigned long exec_vm; + unsigned long stack_vm; + unsigned long data_vm; bool unlock; /* Unlock after the munmap */ }; From patchwork Fri Aug 30 04:00:47 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: 13784187 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 03F86CA0EDB for ; Fri, 30 Aug 2024 04:01:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79D1D6B0098; Fri, 30 Aug 2024 00:01:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 721966B009C; Fri, 30 Aug 2024 00:01:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39E7A6B009B; Fri, 30 Aug 2024 00:01:42 -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 148096B0098 for ; Fri, 30 Aug 2024 00:01:42 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D10BC161385 for ; Fri, 30 Aug 2024 04:01:41 +0000 (UTC) X-FDA: 82507562802.17.5509C43 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf24.hostedemail.com (Postfix) with ESMTP id 67355180004 for ; Fri, 30 Aug 2024 04:01:38 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=eoBxXIZf; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=B2CnrSi7; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf24.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724990410; 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=qcbtKtfIxq4olm/b689TGnAJiG25veUzjpPHk8GV7Ec=; b=xrNdM1kJANV4c00pxy7bPN+Yx9E4Wc1ZOsWU/NXlAUOTHn/lbIIqKVqky5zdYqvtXxckNp WkUr46LXIYw8RobZ69M3eP+Je6yKCkYO11PylL683OB6zHFzKGby8EJdTB3m/V2qTL6DJM BDHoHYWdxI/tjfFWj9DXzedpWfyyrcI= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990410; a=rsa-sha256; cv=pass; b=FyqWGlcfrz/ipDqgyC9vZDLcV7wObvgiBdMLjIa4IvfcNaSNHszkWrTOszi2xFjsTSscmO Y6FdCdCC2aXqH3J15wkZYdKiHEq746EjuhKyTojy/iobZNkVSsjZVrNXoDztm6j/Spv3Bg b/d5KIReysMRW1zO6YQYS04tGJdFAkM= ARC-Authentication-Results: i=2; imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=eoBxXIZf; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=B2CnrSi7; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf24.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com 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 47U2sFnH011046; Fri, 30 Aug 2024 04:01:30 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=qcbtKtfIxq4olm/b689TGnAJiG25veUzjpPHk8GV7Ec=; b= eoBxXIZfHcLuq7W3rWNDhOgTbnFGo4zguWfSQvMlKFSs0j+55041evrF4SOG3am0 l8qvOlPOq/v5e2QTPXCryMlr1PamROtbRfO6AOwciXai5QTgR0zsyQpG4TRWaub4 wP3hvGQMDWh+FJy1iMwkO/s8YaI2IBba66BDd87z6QaBezN3ITHHoxzr4C4KHiCB uaoCzljkFTvfiKks+5apaBozc6rNLlLZkjVQKohKx6hkhjsfVx5oh6aww7SoTlma EY/LDx5nYwb+3AX5jtEqJvyDWUJIRSGN7cPEvewK9WU5aBObyyH6a7AbJNR1reAn DpOa7ajyagMydKGKnaYdpg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b5q3r1v0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:29 +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 47U3jJaO036502; Fri, 30 Aug 2024 04:01:28 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2swm-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DIS22csqf24vqBmp0XwHNmP2GScSXJGudmDOWN0n8qlLzOAOo5wfq4aIr4vnerYwPBTkKqHqEH0WoNh/F6yBjIqKoRgGnCa28U37irbwRwWJF96BUX6LvuisENAF+TIvfVR3G43LPiJJpEzGa6X0lGfWz5azaOHUS06vvc9Vil74CsHkkIiJB4xHZTCa/Hblz9DE9vZ6tUr2SbdOKK4O2SsWJJWOyzKP7Rk7wXKcbDnMrkB9xdlGtqOGaxQvwJZ0PebVGVPI+B9RogHoZZer+BqlQoy0XgZAm3ymKFL+fpQ0rSjDrc6jICbrZoqrEXoLGZ1hs/yfdkZdQJU7sTIHMQ== 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=qcbtKtfIxq4olm/b689TGnAJiG25veUzjpPHk8GV7Ec=; b=VnejNvfIdChqt2PflrIXlm+3osTIrlqoeWG4GyUwaLqr8VwQ6snGf9S+Zda5hNJ+GSbSEXaJYqPuOesNwluC/XPEOx0rANvo7Kp77Rd2HaoVXEaEWq2Mikw/45QhRVcKDMeJNk5ouNnvpStfAVX6TMWTd06AG9A1nTycAfT9QpYzkjkb54rXI57vvD5KzqcqKPzBuyF2JgPDW5p96G5YKYpriYc+H40CSlPrjt0x3+lCLos3ksvRDU7duv4v+VvkyJUP+/H7dVOZNOHDL3ln8GwBVKwJDxj14md62aDhOfsugPZkKvVbViWt4umi0dkqSm9bhn9kztUKzdsbFN3/Gg== 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=qcbtKtfIxq4olm/b689TGnAJiG25veUzjpPHk8GV7Ec=; b=B2CnrSi70A9iRAQGEXQ9TxxBBZWuGkpKKzMoNqE5jD0YMiBpuXl3HbO4ZlqPdMLu1iIC4XdKbcJYwGSNnkGs+loT7wqRNP/gnLq1qa2ZlVpy2jIURj7mTl4siWFxSO1Pux8pDi7ITQ94jbXJTlwr7Np5m0ULugyKbU9EQcN7khc= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01: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.7918.019; Fri, 30 Aug 2024 04:01: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" , Jeff Xu , "Liam R. Howlett" , "Liam R . Howlett" Subject: [PATCH v8 07/21] mm/vma: Extract validate_mm() from vma_complete() Date: Fri, 30 Aug 2024 00:00:47 -0400 Message-ID: <20240830040101.822209-8-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0402.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:108::14) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: e5e05b30-d771-43b5-afa1-08dcc8a8692e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: rQqyJZVIXPgM6TH+KynG6OgYB/M9gS+5JZXq9NYRIFmzzlVXsy8JNxR03g2kbfefrfVSrtTQIdNsiZ7+pxyMf4KsaWuZOf4JsHYLBBGZtDyEOf96tfKF54Ahxk1PXEP2fif1TyaeOVpdiDUbXv/wYNSLiR0qLOPCB8B6/uqo+VKh7G5Ya5UoCLmyDE0eCtdBsDyzQx1d9g0H9JrFeaByhFJKP4dyCtOc55KSYLX7Ca2Pltk/yRzo9yFlr60L9SYDkhh+yiPaO46qYuL1o9HrUzKaQ50xjoCwwYISiRMgAplw++g0jSE7zn76uShbLmQPcN+gSQRzhmKYDBQ8/j1QmXOLE6QAVW9PK2MzUlmfPqiuYrdpvhPmmsC9IqlF5/0q6ejGjlH7dIvzknCL5ijE9uWTpGgPbQSwKblduZBUSTPKBykDPC/YP6Xy6RqePxm2BjTOjcdoCx8SWGxeJjS8zwwfaXHpoA6ks8u4nRNj9ojbOhHmwqzExlzvC+RHY3JD8pMef53Dog4fMoGDSf9HM9MXMobgpJxU1x1yVJl6rjPulrgpH8534/U9ctHmMTb4dupQWuUxgWewiH/EJ3wJmT6Gp6ZxNfkEP8t3IhJUkyuEd1KEj6mFLU2+T/D49oBd6zgJ/g2RWjZZnYEyVcdXxVonSlmSB6tZZfrMZsa7o5yYk3G6vRCr/RE6cgveGdRwQCZ/B5uUgRllCpO577X+XABZkbXrT8hLanxPYxKXV2KTY2hn4uB9SHsjFAsHjP3nkXqyiRSSlMp8ZFxPjcejCNpluXkKBy+gdABxh1H2f7PLC3U1q55+w6GfOkyR3Ct7cTeyW/LCfZRKJ4gDOM7O1weDW2LilHZUtFCeA00aTLLCHDhy06+zQF17qShYadMVvOnom8h3aO2EmqK+F9SVrjXpc5kUJxUIvBs0uxZ50D/nwVNKD8qXPE4MgPff+8qQEhbgBqHaAgYzM+o0UeUE3PPa4jy1OiDw6BYZXxFd2z2opdBFowkWiLNdJ90cVv+GAPUSAz4/3kE4Z3LuGelUuCbW+sAH3Z/n4yV7OsR5RJA9WybvFyvu+TMA5aItU05cEwGP7qt2rmTZwGY9hXBkPH0JYuklyBKI39eAQi4bh0VeHzhSQlv0ctKj1wzCipffCtVDBCMlX5/TVCfq//BKkivDUHhvdACimD3sGcHAxK+PFfZs/2xAHYRZK2Um1829zr1/ZDclm1kvZiQgrFKf4ZeZEgjBjDhzygNhn0LOX61Ct4JVqQkRGGMNIDSCRWSgE01ogJkuF8DHGqx7A/Tm9rhoZ7Xyxvc2C1GL2ytQYev67k+avgkspax4+wSRUmvso6JcKfE/lqd5XLigk5gvVg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HeDzGEHBtRS5CSGEOnjyA81AKQJTqe07S+iaINz32liLZYQlaUjyLQRlljhw8To9H35+uZEd6cz26Ak4bHnqz0hHQXryDi62kUWwURgfjMZ7UHoU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F6oB7e+73AhE/1as5w4TWRWEAUBa+fCMLAg0iNdheRLCptfpj2U7uBTgo2i0fA6DlaMqrb7g9LXmj70LBbhEHNxJKfvimW5sROVdwi9KL4G1Wm3Abk7ls8y5qdKBVG2r5upOpvXWNOiJsgZN5LqvqWtDA0f/OTO8axaCJLPIw32flxRK0z11EDfq8S+2vaLbFIepkbsj/NvRXpZus7iaU6R82nlCh7hUA7oc95YZebFodaByk4cbv9vOjdy0LPsxT04AOvwYIQZ7U7NU8bG80oM67qKXSWeLKS8laf+RKAAk545MA9YuGpVfXFk2ajTt1w7DCNXRTdopip+8iCnP/rRdm4GPRKmVctDvBLEWK06//60HMfBiPxfDWtlvxOAI/z4PPYzP5VekURdHgs38JlvdT6/o+JyzWBw89Np/5WxsjC4ozoG9P7X6A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Q1ow38rR//SOixmVX3pbBmvhugsRWBarg3Jks0zgyAVIQ8YOvo90Gy8mYHMUAkws/LGnoWb3amN6ZBi3Y9lBhzkoBW5dlk6PkLGAzLY4lEKwKLwqK0MU/8Dg6VWMb4EJ39tgTmzV8mJeymgmaBDUWpMhl0blZU7xjx9A4vKNUKwjGGXgWdZkFeUvlJGK8DfeGSTfA3U7/MCaxh7d+c3fRckgI0LVt3j9oKBVQ1E6THV/oemG17JFnefZZWAxlQTxY27PW4KLZTy/kFv2RV3Utig6Ial8yTstQw2QDlGDNdVpIQ8As8ty6xTxTWSy2euzwWmv6H6nJjKWZiMVvIzpaMoFlhysd0Fmuepw3ruEzjtQzEhZg2F5SSZ9gRP915b4wIK6sLsX0RUUazcDNwtXKgVbyBGlCMborQr/EbsyrEOImffAdZPftNf04wV5lwRom1iiloO+5XsE2PxlycdjGRRxdP81Sh2bZIHmtEeuL95GiCytckEh2doJi2Jp8ZZIyZtElx7c0e6w/1G5/L3rXxfag+X7OVolvQgXjDxJJsrFw50ZsOAJvtPvyRsj6k5HmosVWOyxVnpNuGL9vOraZtrCpp4GpXXCWAKmovvVxaU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5e05b30-d771-43b5-afa1-08dcc8a8692e X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:22.5751 (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: 20Yh91gk6me1Rd6JJmRz1mu8iqPQStn8jo69ykN/m5PoxtWYDl55Zj1BMi4SIaJrVPJodpEbmFBGg48SRO255w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: aVRmbWihzATOceYqtw-yMmMBmxgWFjMU X-Proofpoint-ORIG-GUID: aVRmbWihzATOceYqtw-yMmMBmxgWFjMU X-Rspamd-Queue-Id: 67355180004 X-Stat-Signature: 88sqyr16m67s4pypzphnnukkpyzurp6f X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724990498-665059 X-HE-Meta: U2FsdGVkX18riXvY1eGfgT4Li6v5hnzXJb/+dVkowVsoY7Y5Gyt7+An+QxQC8CL2yohlwj1JkIOlHDdvcH/+oKtdBaX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XoF8eFTJ2Kea2BA/NSyYiOX9wdDYfElwkjiMuHGEflAV1Iurmkij6SOuzkR1EL2oHn7Kl1bNx2ps4zKEqn7XI+0v3sLhJtqzASVNvb8CFMnGLvBRInkvXEFdSUIqly2RqpnBZ4zKOCfKjIxN6Vh0/e4CoADf887PQEqmGtSz9GVifJ/n1N0x2lJgdO7ZD1+qac72wCNo+eDHPUdhFV9KBmK9I8qnQoOmoxvdINPucbdrkwNoLheARnAfTl+46rrsU5skQhhUjJtskqkwra4ePTMKrAoNA9ywcNmxv7p35DxIH/qr6SVtZBGmSsBc0TBDeY7wPypPAJv6vXLi9tIraXFFMMpYy4pgjBwx28FEn7MBUcSdKR6SuMa+xxU4EmKdqXAZGT/nLQy6T7hgHwwxtr5RT0zU3WQWRuK8Cnzwiasy1k= 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 548bc45a27bf..dce1cc74ecdb 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 6d042cd46cdb..4e08c1654bdd 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); } /* @@ -1197,6 +1199,7 @@ static struct vm_area_struct } vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(res, vm_flags); return res; From patchwork Fri Aug 30 04:00:48 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: 13784186 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 0046ACA0EDB for ; Fri, 30 Aug 2024 04:01:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C79C86B0096; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB3386B009A; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 968776B0098; Fri, 30 Aug 2024 00:01:41 -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 61E016B0099 for ; Fri, 30 Aug 2024 00:01:41 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 124C041414 for ; Fri, 30 Aug 2024 04:01:41 +0000 (UTC) X-FDA: 82507562802.11.F1BEB01 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf16.hostedemail.com (Postfix) with ESMTP id A9797180007 for ; Fri, 30 Aug 2024 04:01:37 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FPgBEyoK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=eesjldRs; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf16.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724990407; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=G5x2B6KdF/l+leREmzG9b04kNGdPYnwroP/y6Yjz/QA=; b=LqFfPJr/6iPUVynPoXn8lAYVN9pcAjcanCI7OrjxRjjrvp/nUMuug78aNkrXx2Hp/JbUxT Phrhst38R8F5bmzACh++O1CXck6yVMcbxyHP+mvARHBOh52mA/FRU0l7lNZ+ncc+K0mZg5 /5l6fTTEmHOTmbmCGmeaANXIJM/o8CM= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990407; a=rsa-sha256; cv=pass; b=TgElPrjM24CN7gaK0aaW8YoiLJQClk0oFMBJXD4GwQQkfEyK3++irLIjrMuaSCfAfT5+Ub RS4eIXpY4o9i6fs/AUScb1b25/EHtFin9WXy6UAEyonOHP/SlY8dZcEOgow3R/4SVqcArP UaNtl0Efjxt/xXyPcvYM2mKe7ko3Myk= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FPgBEyoK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=eesjldRs; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf16.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U2srf9011858; Fri, 30 Aug 2024 04:01:30 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=G5x2B6KdF/l+leREmzG9b04kNGdPYnwroP/y6Yjz/QA=; b= FPgBEyoK266hI6RaIii69d24LM1Z5pC+vEw4uaRmDAd4TA+++A+mJBCr8wk5LQ3r MKOmnmGP93j/ZLrOI7xaymoYviUOT+5rNljovgD81K4wOOIsykCLK/fSO0cjFgX0 fqSa/LzlZ102I9QjarDHYuV+wuswADkfReyXEg4nIAXgF7/jKl3yXPrZQhl7dK69 dDPOGgCu8K+723dzjvHRantGMEVYEvG/70DuodYDJ8IKrU4393qOXMM+XLT2uwvz 7qAdQJETznetUOj6a7FY/ZdO88FuGFKc2RCoTvnjjWitAuZnI5DUSa3LjBG8z5zu ByxhLp1OQ3MCPnqSCQ1kMA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b5q3r1v1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:30 +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 47U3jJaP036502; Fri, 30 Aug 2024 04:01:28 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2swm-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=amDI/iHlCL4PmHybMRaSCOQw5tKfczKhM7k3IVp33CxI1f4X071oT+UpouewJnubUnnRDoRtGCPETXsgdrHjzgkVem0xlcDXNmZvBmmHRG+VH0SPjDx/mrN4fA3DswEscaQ0FynS8xw8UlkKBL04OFkkxwxIOvsqDcAu5r6emE+pjOT7SxR2LZgoNoiSW64/7vIGCOgBW8B4wjLkSfj2sblVq2Rl8XzysSPojUHWOsgQXXq/ZXXftUVWJlQfXGVQrvGSmLbLplfc5/8is6EsiVcqLpwxPv8zhu5xfgfOM88YugDmzdbtIH7Q1dZXbfN4CwmctQskrhx418w0yyvI/g== 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=G5x2B6KdF/l+leREmzG9b04kNGdPYnwroP/y6Yjz/QA=; b=R+xUvc4qEfHUGf6zmTqi6It1bbZtzJiixRHVOOmWRKY2J50JtKmVnvoyzEsc1HnFeV9qcxEao+msLnV+FxuhiZfjNALJfctSWkFbb8uOol+5ThWkb6MT0+htG6B9gSWju+c0n7C6VXlvESXcKV4n57hy0hiGf11fRYsTwKCC673xLIs1XDKyCRiG8XDJib4HexlnffVDQPEyTHjRMC9BPjgeFZ6FS/BxJwenBHHJH+Fgu3FqQCKsvAm7FwpFxGkCfrWpHEV/XB4bvEKqA4EhtJvtvW5V5COeYmPhstPajoaX5UD3M+Z906i8eBYXHYF+jsT4AzF2X6YR8h+ncrtOew== 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=G5x2B6KdF/l+leREmzG9b04kNGdPYnwroP/y6Yjz/QA=; b=eesjldRsMR9BDidWbZYoTk6CM+HJRFWjMB8CIJ/TrB3lfakvFsQP0GX++UqMu00hAqzwjoM5xzHNbUq2eZIFPuRB/+U9q7A50lgiv3n7695OLEdgSQ3vUQ+xzLEfG5Fd9wvH9h3ON7fW8O1E4o2wgcLLq2nPEsZi19fE+icRnBg= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01: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.7918.019; Fri, 30 Aug 2024 04:01: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" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 08/21] mm/vma: Inline munmap operation in mmap_region() Date: Fri, 30 Aug 2024 00:00:48 -0400 Message-ID: <20240830040101.822209-9-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1P288CA0031.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01::44) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 99322462-6b0a-49e9-0da4-08dcc8a86a59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: zdi5fsZWBtshPrFg4lh1DRSdILh94vOoXBnrOrD+1P7Nt3GjxODvP6SmaKrDcl1BD/reETz9cLgG9R89QM4py7rt4z8LS+JEP5xIz5zepwvnO1Dg6DqP+YHY7gzjkD2pLfCQWdZjHLj4ajS/yLJSb6wj2N83YEqCIRO6xhaD2U0020Ztvuwqo/vpHwxM4I8/tyUpSTi8AEWB6p3+cr8ylAo/SaFb+ZE+8KLXT6dCh+rCiFD5K1Tt6IiIZ4CXZHpyEmZIAWSmrB4enLrDq2yOD2euLxiAy5FIxUeMW0q25Z/Q248Ko9cQtVTYzhtbPIAafYghIFiYkV+Fdw7Sw15Euw9EJZp6UIRn8YTiaEDMae6Xl+l76dtCnsYHPTmlv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prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sn1m9z/CzIccL7qUR8FyR3R2fXBxZvdvPTgsjEwRdmU48T7E/jJbFGSGK+E89dcEZ40ROgyuEq0Z/mV0FlWxMeBm8pMjEIKCfKDthjZBOjja63evOnAkjr88YjYVyRFjh1nLSxObOCJL9zmkSBOeeR+NYfgyDMYHaoqD6FHt/w2txrV9jndDTmjvTQr6V/GJW/xeF1n0WT6hvmcUsgrF2AjrCNuGswE8pxw93gwEnKYUqaphEo66HiyluDKiEM90pXSigFSZFu8VoXYMVQFb3CnfmJiFK9lAWYnc0x037X7DTBGRSZtnMdVm6qFcKNuDrXA3fNIjRnbCfhxslsGFnwihJSJx74kZZYDaek303d9EXuou2hk72TsRawEzofsiIPXoOvcicqDHU/5qNccpTawhmphP1w6debxlN6kUnVlcP9tjRXlzI02TL3+602Z4jPIX7adr1bF8oh7Cs/l5/2KkGWvXVwNgpDGKaCdnPmWD8OJ8hjecWW5DePHqm/pIqes9w5wPOCQr/9uRs8DQ/BpwHi2nWGxtkIah5GF8fplK+WRi57Lb9TDoL6zrW+BIdCWhe9YqiUpXaKeZI9U+CA/FIV+MPUc2/XCh4x7OhuQsPotoDtLW8oEWog7isBgERaFERz0e6qF0t+so50bsYpXsaihNcJ8tdlABwtmxWw6fSE5XZpvda5EIdj5xHTMZJoTw/O+KS9Z5Uh8XCCYoGQURGff07q3s2GcRCsbu3NPlkCwliykhd9Ztd5kVjrZaXNtf9Wag5ict9hwYePhpDIGaXaH7tRcZPJxlIRTQ77ceoyCLi2ahP1TPCSRxOQm1uUx3AluznU6SJwOJ4oMMAkQdC21AR0zRFyCilOQpdrbZQ98voWYeUkfB7/j4GuNfzy1ec9kBzrfLocFee3zrUosuUOxHER03xkXWUU5G3lkVB+Z1xbFZzmQhZ5jDDHGgRx+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OzD4oStQhJ+IwFHN57fInog4DW8OgY/+MhE6Jv3HdL2sM3zrl/GpOaC4P9MTaucE+Ym66xlQwoKdnivfKhlz/FSlCLript2i7ZSlcwBURWgUu3aPjJHLpFHZsJ58Q9hnlQJ+lso0Nq18y2hoAjy8avRk7PLqJbcyoEIaFFxTHAIDoJ7s50Kt4H5dxvHMpDN+H+tb4pXawAlE9tztEs2Xr4rY/NWXG6seMmVh51LtgrhSoGHf7AW3oG6GRJp4zuj4FKMOCb0gWixuBsc8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99322462-6b0a-49e9-0da4-08dcc8a86a59 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:24.5268 (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: p7P+praqS4KVKW8aL4HF3Mll3nI13SaMXtm483nlhD4BoI6XSd9R1B/JFtJAYlT82O2w9azispgaXs2DuZ3Wxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: qWbMrd-yMzxYTgqHDsZnajb4gbBE2Axp X-Proofpoint-ORIG-GUID: qWbMrd-yMzxYTgqHDsZnajb4gbBE2Axp X-Stat-Signature: 7oyfkuq3z9uazbzrse9jymfpwqghq48i X-Rspamd-Queue-Id: A9797180007 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724990497-314109 X-HE-Meta: U2FsdGVkX1+DQFgDnN6E7+wnf2qf98PPIbwUwFP61SmzlFdSQ53oRd/ofKqv5w8RXPOscNeuQTxKVuPNdTvomlKThWyMIVHx7HBbRlpfI6l1Q00Sgb6QwjZNeYDBPmZE7TNyba/YynP2Cr/JwgbuSgUNVNPlvrt438dYUWaskJUVtEhTahJvucwNyvzx6TJTc33esEwjHNQkLHL6XqM1iIJSnTwuUcpvrAbfB3UYkEeQo+HmjFTG5gJ1QrehkqFtCVdgRPEFLSjYhAXEenMBGGpaZbKV2cPtYu8jBus03goZFHkDyqypOTGN/tfsT8G3mFYX15E006QOq7OZ+j2YsaKlRWE2sQey06UfiZ/pBMjVvUVhM+9BrQLqjrCvaEBy78Z4vaCnmhcoa6nrvFXqxvn3RThu2C8WTp/E5mUpc8DBoEqs2/+/pkrgOqXXV2/wyJElMOYsokY2M2qV9Vdvvm76bQcErsoUP5fL33dnDWNQqoivMe+mDtEcLq6K7kirlRDxhTBGtD+IKsXm1350gz9PMrmMOb4O2E/o8CRamRo533OqaUa0WpFawFnILr0WCgurOVpC3OvKyI/LvEtuGeE115eUeiAlmGIW/73IuKoDnVLusU8FCMigO9mlFMKM3aA4VlYVAKnEov/d4JIMb6v/NhsHRqryjXsMqMhca4mUsX1A/Izb8hP9ZOFFDrK5cqj/HonTXpB3cfDKFrWV+wujQPn8ChHwu3w0ZONLuiorakDeXl4JZh1aG0b1u+JDP7I+R8L4Pfgw2dzAU0FFfl54auirnmlq1MB9ErHP3L8GMRw+GqflK+uQEscQooM5Kqf8XQjN5j1wNz9niW140vEHo8xl+EClNA+whe+KRl1s6pG2FF2xRL9vFqFGXb/oLvGW9DMQPlj2f8NqNSxzM1rSIO5CnwyK9sbPhT2Dnnvx8/kPoo8hRlfqj5wU5x6C+IRqlphNUy7jic7Sfpx kLO+WKoU Rl5GQ8JGYWzbP9fjjISBdY+GFFAIFVvjD62qR+/e1Mzg8KVmOBWOqdvHtNG+6SPXAktahyWRgWqHc6YZzvKwXLtv0Foakp4TYXUqi8WOVOkRQgse9jkGGdXGUzLhwZo//nwBNjrhqd9NGJ3PIsUxPrvXf3hY7pedXZ2loV/ROePJx3Ues1Zm+mr+JH76i2CoqEu1Tmhs0xtwNtQBfWAu0uyLjaf8lY/jOo3s0JBQXRry7o804OpPAThd19SzYmMbyjWt3fG0xlNMBIE1VO08XPRIrs12zm+a9gEYFuzzYxnSz/zzE1dmXNhYqyxicQwRLqyvCjqAtITBKbmy/5/2kFk3jq+lbf/PGudHsqW4jhF75JUEUNFiS7z8OzQ6Ejcy43/eIuxM0/rOaVc/YqiDSYRNmXPZVJJqNnggNza3Ny7QeOMcsxPwp6g31HPKHyV8/bvbl+zd0LfcrhwiqMRxhw5hEyoAy7oWN7OklE241B5qblCtXnvzzyhR7BXZGv0CQGxktmqD4C2Wn9Xz0qsMQ3W6oU9SYbjxubuIGPUbPMc7r/uAkFUGofdd85zyzQFR6BICDMJTRCZdDQmq0lzMu481yEVgdUfsDOT77iDOQTTwBDAQ= 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index dce1cc74ecdb..ec72f05b05f2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1388,12 +1388,15 @@ 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 */ + error = do_vmi_align_munmap(&vmi, vma, mm, addr, end, uf, false); + if (error) + return error; + vma = NULL; + } /* * Private writable mapping: check memory availability From patchwork Fri Aug 30 04:00:49 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: 13784220 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 2D3F2CA0EE4 for ; Fri, 30 Aug 2024 04:31:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA9DF6B00B9; Fri, 30 Aug 2024 00:31:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B59746B00BA; Fri, 30 Aug 2024 00:31:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D3BC6B00BB; Fri, 30 Aug 2024 00:31:31 -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 7A2B66B00B9 for ; Fri, 30 Aug 2024 00:31:31 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E0EFE813EB for ; Fri, 30 Aug 2024 04:31:30 +0000 (UTC) X-FDA: 82507637940.26.5220E17 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf11.hostedemail.com (Postfix) with ESMTP id 790F340025 for ; Fri, 30 Aug 2024 04:31:27 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=U2Y7mpKM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nfuXuNF8; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf11.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=1724992198; 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=vsjQKbisoOW0P4k2LKeId1n/RkQG3vYsFDDL6+Q3PXw=; b=8RzcUMM62bm5EXioPLLgi75i4UXjp9LKf2FOuNOtfbXNFrTTOdEytCTSVI4FQ9WghoEiU6 YNKt6HRwR4QiuBD73AOnV3kaTG3SBeT2TMW+rks3EGGCrJj6GLdL9XKUyJ7jbDOgIZLWIA Q8qk6LLeX4D8tBCk2RL2rJriaiBJ3b0= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724992198; a=rsa-sha256; cv=pass; b=BLAXqmbeY7T1l24tnwD9vH/SWVd91RHb4cU8dBigVOXTvxudgisaXOEVpNbHgDliq2ZotK 9jBN88aeP5EeBAt/lDuM+0MBgj6SEoZDOA33NEHxANhP3HqNY49/NnnXMv5RDaoS9mvF66 HvOksASpdY7IY1KsttjSHxuKMw8aOUA= ARC-Authentication-Results: i=2; imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=U2Y7mpKM; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nfuXuNF8; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf11.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U3LAZj021755; Fri, 30 Aug 2024 04:01: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=vsjQKbisoOW0P4k2LKeId1n/RkQG3vYsFDDL6+Q3PXw=; b= U2Y7mpKMd537xJb9oT6mnpzgibrsfN4SYIGwqnGWcAnQJ7BORVptDcKFRObgWV64 UZxPTtdJu5+JBZAcBN8Cue3SLffhieTyfOWggJbP+Xz+LViw4J75vrdEtPfxF4iI e3yQInMRNHY1pcUl0+ww7zIxs0IFgFKpaxBpPwxe1gf8mHpIvDfej3gKM3Tsve1N Oyp55CG0TNoSRBLqFBvUGCd87w0Xw0cUp74VzFSfNa/IR/xQaaGrWG9RNyxkF+fb YgXRZ2tKABze6C+0S7qPhiFoOM2QAfzbjrpi8qbV6B8LKIKuo5uXUG8iWCGN/rUe 2DPpFb/K9jenLqHCexgP4w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b3myr584-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:30 +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 47U3jJaQ036502; Fri, 30 Aug 2024 04:01:29 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2swm-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bs93jPt3EZL1CZpMLgt8GmqUt/XFNfiMBj7F1LPWMDXgwicuxVaBOaZ5y4RIRwaY3NE99MTnVwuVzjCMKlg2axV+Z37/STJVt7wUF5nXIFzcZUQyjhFZ+F4xzLtT0C6FIr38ZP1R8wnRgfYiU41vGEa86Qg8fl1pnf9S5UNF+hVjk9lIo0ERh36bjpJvJuXcMbhjnoYLjc7vRHlawxGPNkH1a2uh0M+oaDgPxthsoYwCYmgrDADNNJkdIxXl+k5bYgxwE2wD+FF7jXC1rnyfveYwMCo9n0lqO68YNafGGQeb8Xs8jO1ea9M23dmj5if0Ji1hH6nqB53IXiXmckdL6Q== 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=vsjQKbisoOW0P4k2LKeId1n/RkQG3vYsFDDL6+Q3PXw=; b=KLsc26ZihzOrqt64jEpgVCa0/eXJdArnDrjjKaf5cwnuPTmoRfMWmI0SPsX2YcCLRvsZPGzstWys3m9W5GZSD8elYhfadRKTtPQcWOfAFAgO5VltC7K9jq0JeZ+74Iuvz0ob0QiPZrOrw7SSa+BmgqB9pMqWS0dFZBDFL1HkzVxGG8ldBAFY5vvVjkTMiLoXbc7yQOXGMK++fXSfebEGrZcOnzOnCZybs1Z66sZN5VRu/hbmcVU06CscHPa4p9z2YcEA5+xQchFT5wI7Sl30MwxEAEWxpHt2ivokMNzHvO+1rhMTHyrlWWQcJyV6buK+JJL3mWOZegfpr5z4Gd2Hhg== 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=vsjQKbisoOW0P4k2LKeId1n/RkQG3vYsFDDL6+Q3PXw=; b=nfuXuNF8m4LvfR0CEQ0R7tMugQVcoD4vHtlH/YypTmWMqXX7Z2rjJWr65IcWzmWff6f0rnBniOBJn8ZJQoeNlZMttWVS8AbjOighTiHVXaW2n2Dgf1l8WEtAglvLiC1FoY4mSSbzJ8WnlyMKweiUtHgPeMTF1nPywGU+OiQG6Rw= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:26 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:26 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 09/21] mm/vma: Expand mmap_region() munmap call Date: Fri, 30 Aug 2024 00:00:49 -0400 Message-ID: <20240830040101.822209-10-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0031.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fe::15) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 673e0af9-989c-4eca-3669-08dcc8a86b8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: seQX4AvNOFIrr74URqOcTZ+ted0+W+rWotzL4qGFY56XSp+9tATcyl3vb+8ndkNQXq9bzceHSx7arfjMSwnOC2rFWC0NJEBkzC3qlZTa8f3Inpz/MB7hG3sfYHrjVMmoXC45Sc8am3RJw29h9mcRe1SNr/+5CY5OEcdjJGwZ+FAQcIhZBMRgn0a35Npg7YDUUcFhkRNhD2x07wN7a7UWlxJzk5rIz2bCMNTFsSEj9dL5vHqYFW9ysXHhaQ3Lvn4QlD1uZG+2u7HtlKMizbPcQRGhwHXe6XHaQCwOlS5oH5rGSvR/cGO2CYJFzvJhvkBDed4VekaycfanS83Q1t1Q8JnzBPmo7M7YuVr3/5ZJVeIvkd1wVESlT827YCPxZiu97ij7e+kksQwKOy4EtTnE2ByeAg8y+so5gVl9xGBQbNtorfqgrzGSCL/HTD9T3Y5lWCq4ZGtUA0FvHll/jO3St1KC4ZTdnnnw1yb2WGgyVJhQ6uKnP/axMUMNWwelPp+CzpSMiWUumkXCI4TDJfSF3WMrfMrRIuit1kz21UWSNVru4bjENxiRsNmejC5/7TCSFzQa6XtgN+TM2gvfXWwQR4dgc+zxVL/i3s6OVMmZ4dt0NwGYT0cGinYxsOJDrj2Y0s3cGeaeLwsFTNANE+xXKDiqI2M6QwqN0BXPzRlqpAeIE2OHovHU65kwrfgIKM9lPTw1QyvZUcG6uhuG9c1Q16tMuZ3PUpr/ZgDClQLkeq6Ki9dVLS6hv1d0x7Mjwsc5YP5QYbA+lIvvexkqdUdDthIH7iBfj17sbHDsbGUXBExtwixUzNHNQAsBJUNqyJ5RbLfqEdjGO5hZpPzahhvjmWCbZzb7Xe4u97lMBomFp2w+NVEGMx02EeoAHNFKqaGUpym364/TYbjib3V+LVm6x92Is4DN/xTqkTYPeH6f+DotU6bYn1HobtmZfPDqag6ShuIFFSh5oXd+OSsGqEL9oCaBM319Qx69B8xpQ+HGoni5FsihYQhnHgmfUcp5TlI1mJXokDMwgerj1ctwZ6MP3ITHYsUTszPQkASv8f6FI01q8BXW0LYcPwk0Xdo22jfQzyC5WXlfHp8SPadYqMyxSA0wSyNAlu25GSMi0x68pIdRXKvXsXiP2S+xPISgPPACMQW57N33iAL5EfpaXMidnAk0A6yfxnmRCq/NhfyGujOpWR7ZspGq7e6bUAf+nXBDEHXRB8vkpjLDU2hnEgOOjUDt2iCFmjCwu7cDcOmqECVQeu+zxhLz8e16wYBgAYNAWK/dhIPL+JHrrDnV6rlwmhWWgVSMCt15Lvy/xo0aeIeCUoJMJlaF1Rvmc21gKksQZEO12Qu7cJKXrFbLxqAq3g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam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Eo5Kld9lUjfIWv6AjPZGhlA17hth+q2wzaC8mGdPIbtygzrd3iTc4RONq+YwJx0wVmbA4LLaVaAAUriI0Kebn/AzMzBiCKJXMCy3Jyu6Oc31Iq9QBxh12v1TDb354sz+fuyEuk9mG9ltpZEBvP4QouZ5vDJUhgC757dCMUZm15j/G+aw5w5ixz6E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 673e0af9-989c-4eca-3669-08dcc8a86b8f X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:26.5250 (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: WLBJIVcadzCbSxwWtXhY0ss82KDWT9nBj8KhNfI6dnF1aowHLo1+LV4fUrRYEAlzfA8XZ5Qxg+Mz2qQaMeqOpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: SYqKMsUtNBMT5GYaueVV1M8pjl14X6g3 X-Proofpoint-ORIG-GUID: SYqKMsUtNBMT5GYaueVV1M8pjl14X6g3 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 790F340025 X-Stat-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YgIeKUBuXF/Q8hKibQpTjA28vfwb40Svt2o15v17O/5azb4fJii4/Y11j5PbHou3JL/oHovRxnnCW7ypbTG8vLzFYHTFmRsHh1P8URVBudz2m65jmEAug/S3D7Ddv0T1V0q5IryyPXL94pLixhloPj+zx06/4CPu1VQaL+rp+uBY+oJKkthxcpGwx1qiYn/OgjQfP+QoHl/dKnl2gNdy4qSVX6efCZIUp0tBgIod1wUmeCqRoQD+I3xOQ4MN0wA/gYvi8a6zGrrdbo+fRYCUCGkC8ilQO9CBl4nf9uZIGD0yj+5kGoueWN1yvz2adVO2nVvf3rqjp85OlgjrQjw4Gd8adq/eiLZhuLvYVzL4M59MdIWQ4GDsTIxoAiRgdkupW3oXkZWfdijOTaS1K+eNl6Mo+AIfFoMgigGUBhEHEnClzoSUHmsviBVmanW1Ti+2x4Vip75qh9Jn7kYyu4ltydv+f/C6EqPJQGsgArO5ESn6lURgadZo/+F1GAFuO13HMedV/D7Tm8YTaFT300UmuT7g8HrLqByYPVA3e7rRjDBb6R 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 ec72f05b05f2..84cb4b1df4a2 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,11 +1394,28 @@ 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 */ - error = 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 */ + error = vms_gather_munmap_vmas(&vms, &mas_detach); if (error) return error; + + /* 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); } /* @@ -1408,8 +1428,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 4e08c1654bdd..fc425eb34bf7 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -80,33 +80,6 @@ static void init_multi_vma_prep(struct vma_prepare *vp, } -/* - * init_vma_munmap() - Initializer wrapper for vma_munmap_struct - * @vms: The vma munmap struct - * @vmi: The vma iterator - * @vma: The first vm_area_struct to munmap - * @start: The aligned start address to munmap - * @end: The aligned end address to munmap - * @uf: The userfaultfd list_head - * @unlock: Unlock after the operation. Only unlocked on success - */ -static inline void init_vma_munmap(struct vma_munmap_struct *vms, - struct vma_iterator *vmi, struct vm_area_struct *vma, - unsigned long start, unsigned long end, struct list_head *uf, - bool unlock) -{ - vms->vmi = vmi; - vms->vma = vma; - vms->mm = vma->vm_mm; - vms->start = start; - vms->end = end; - vms->unlock = unlock; - vms->uf = uf; - vms->vma_count = 0; - vms->nr_pages = vms->locked_vm = vms->nr_accounted = 0; - vms->exec_vm = vms->stack_vm = vms->data_vm = 0; -} - /* * Return true if we can merge this (vm_flags,anon_vma,file,vm_pgoff) * in front of (at a lower virtual address and file offset than) the vma. @@ -698,7 +671,7 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) * used for the munmap() and may downgrade the lock - if requested. Everything * needed to be done once the vma maple tree is updated. */ -static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, +void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach) { struct vm_area_struct *vma; @@ -752,7 +725,7 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, * * Return: 0 on success, -EPERM on mseal vmas, -ENOMEM otherwise */ -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 Fri Aug 30 04:00:50 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: 13784218 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 AC916CA0EE4 for ; Fri, 30 Aug 2024 04:23:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2ADFE6B00A6; Fri, 30 Aug 2024 00:23:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 252816B00B5; Fri, 30 Aug 2024 00:23:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 055976B00B6; Fri, 30 Aug 2024 00:23:37 -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 DB58F6B00A6 for ; Fri, 30 Aug 2024 00:23:37 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 774631C63AF for ; Fri, 30 Aug 2024 04:23:37 +0000 (UTC) X-FDA: 82507618074.16.E5A0E57 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf18.hostedemail.com (Postfix) with ESMTP id 18DBF1C0012 for ; Fri, 30 Aug 2024 04:23:33 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ic8hQ9pP; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="SVdHwDT/"; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf18.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724991714; 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=X3TVDEXy+8mIis7fJmNHmIG5dYhcUaHLYXCY/rRjgL4=; b=BSSmPHI7cEhpan20Elhb/iR2yXbTYWH/iciiXvIC1pWauiUgTX1hUpnu9hZbdk7LaDMTgs 8Fv8VYCMG9S9Gn2HZ4g2MOH1U9tgMeW8a9ORFyDQSTJT+YrmlQ+xmcNXyOhRLalb+MgdoA fs13IAiP/doxGQQwXkVDrtMJwp6ja7A= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724991714; a=rsa-sha256; cv=pass; b=NsT7jVqkq1Hs008p9u9W0o+ouSE9jYVCAHMiAIflWCRfK2sbq9aQ0bbH2HyrjnVnodwQR7 uyQdsLJCTGEW/yhk5h0WVmEE7f3lRS7gS+MjB1w5Khd9VYrbO2Lfj+XfuNK8ETeS2rVPow m1Y1buRUPnLsnjNXqojIqpOmlNPmr9Y= ARC-Authentication-Results: i=2; imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=ic8hQ9pP; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="SVdHwDT/"; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf18.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") 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 47U3MisE024297; Fri, 30 Aug 2024 04:01:33 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=X3TVDEXy+8mIis7fJmNHmIG5dYhcUaHLYXCY/rRjgL4=; b= ic8hQ9pPkBNxwDq4NPuxoJOSFC5XWqvCWHHSx4TZC9qPEM689PbNRFayqne90gBm 9z224mp4mt8tbAfXS0wdQmepwa0Hld2f0rWCsBnDffcJsLeT6lvCiFswvxn2GSsl 9DSfPQhpdDMND244jFKqVEkKKA5pRqX5CEYmRUC4E2LObUGFmr1mJ4K2XFZ30swq sBcCGoO4sLpA5h4nxMZv/NFUGwjE7hGnavJYLEqnoJbamMbysx6UgxmuRvLJqjwh vhK6UBmI78vOJj006QfDMyoowaSpAIYFUrQuGp0Uz02hBGxN205TQqIg2qawZ/Bk l9qkXqMK2Enn5ozd0ydRLA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b3myr588-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:32 +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 47U3j9dj034714; Fri, 30 Aug 2024 04:01:32 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 4189swukv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tUqFvfKmM/gnDTJAuhlDbJjNArRQnpLh3AOHUNVEysFDuywIVKqMLlKKc27/YPF/97f3Veg/hke1mj4EQU1djNNIwCCK8GOXDZpt1k30FQVfr110Rh9NcpYDo2ba9ov9Ce3ltkHFW3XuSzaE00JPsqa3Dtki4aMNBOcgsDavPojABpdWrGAdcp/Q1aeQ9KYEin57PS+ADA5qS3PVJTpLNsnUuoFFOlmZ7meNWJWKsQ1Du8w/xXHDpT+2kOeLE80BmWbd1WA5OUgFDjwaVSlLNm01tLygmb6tuZsR0l5+LHllWPyleegyDAMAoDN/BYIdUgkeYCGDVVFa8aq6I4AUxQ== 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=X3TVDEXy+8mIis7fJmNHmIG5dYhcUaHLYXCY/rRjgL4=; b=n3wIfYTx9X6pHM9wc3JPj064Rjd8K5ISNCmrtSI86NIlcOH8UuB8a/gDovlP5i5o70kSl7yQ+lbVBZd+IYt+TP0198cPJs+v4nsJgSkDXqN0cuFCsm6X9uGsNgTC0UMs9YCPaxZVKlD3ea5L4NOu5+FCcYvA5y5ywUUUINixrZSfPAm8iXMog1gdKlbBAw/WS7Cg9gPp5ZS4UIiag76jzwg4isnmNn6VWPvdECBD7UNn8oNZVXwjWtw1h8d2FYBfL4fBoCqGyun3NNQfpKf7wQLHr58x72+eRfw4aOgU2nbedG3rQLeWmE+j6kRBxgH3R0u5k7JNbr7bhLlklcsDsw== 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=X3TVDEXy+8mIis7fJmNHmIG5dYhcUaHLYXCY/rRjgL4=; b=SVdHwDT/3xNFUPu1eVmKU68O7YQdsp5ov7kj+dvtsFirIj+SjGdPtxjMbo+PNPAyBNG1oTABKHBMTTJ+DAuLcdokPWXl+fWz8tY07egBoWL9j5MdNkHnLHP1q2foGqVzYb3gGI4KHD2byY1lh+VyvsBJ3w+X6D3Z5kz+DyymkP4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:29 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:29 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 10/21] mm/vma: Support vma == NULL in init_vma_munmap() Date: Fri, 30 Aug 2024 00:00:50 -0400 Message-ID: <20240830040101.822209-11-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0014.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d4::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_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 16142e4b-0027-430c-eb64-08dcc8a86d22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: XjkQNhXW4d9SsIpeSndOAewtTj6N/ncaKr5X4R5PHNxc7Re0EX8A7pL123HBB2M3hEQMvNCv7Gy+E52HBOuXNf8O+ItgTKxGHr6jhta7e2xE1VD7FwI5yjvEcwaYuUxlyzlmcKTDI2vEg95+NpqyQZu0X2JeHXVVj49ecL/ee3XXOVgQytI9Y/OT6ZsvqdFFYhiWlO1cj4D+CxeyKQpTq7Jsb1EW5wBKF+ZQHpNEMwyMFuReQEUlqne5LQq8RPv3Mz2MbpG2eGKicC5qycnonKIsf8YEnnuPsJtZvdo8XCUswNCeSBYCrdUvGtzVM2dV5YrUgo4j/LtDbOBsqBdS5wc31sMsOxeIK84aGBnLngEOZti08AupKaLHPd9hjNoHl2ZCKb7SuPnUkFk/bgtr+stC3YCFfzPN7E4MHsW0iaRG365B5C1HnjG3wAo5CjSjq8Xj2PQ7Pjs1lJpwBhXy0TWEytH45DRicvkzs0wNWT+Hjb2omBZAITz9K6nkFTlvKDDrTCxlj5N4L+PMw+X3X08NIKwRq9ivl/9lslsKyTdPbMe+7dcbYf5HbsxdE6s9hTZvFYMMnau00cJuKfmZodquj26nQHN+lBzTFH3wxmj5mQoDbpZdnFwQbvbj/47krJU6UtgeoGMWMYtutT3QcMiA/Kj5l4BkjcP6qo424cqPwn6Zr7DZh9vZtMvYHsc3yAfn0CLWmSCzndhxIw0ndexhmLUufiKqfw+cKoX4Ta8/XBBUuTaLz3MpQMPC7jNCuBSTS8o7X50fWUIQGjIXhwEC17gJlrd2o/0kghF7RJKrwHteLAfJgw4jBoYWGIgl4GgBVtdgeD3igYqPZpDcRZti1J5gKMqH8rcrCU6ledZcOWhvxAsd2PsZGbbWJrv+N0GqFWCFSV+lVNawlO+wol1bb0pYqLWy3CiXnae2MRihqSE2tVkTnIfT29mU8ebEImXjrCKOIHKOocjQ7XXX00BATajdHZMQun4AZNtXUzMY94doSwxRWSCxRLQXnUUAghxRF+UvJS11iqjAi5sPfn++LM6PV9fiYcs6nMm65whFu1/eceMnuS3xnObiSO8xLzrrNptA144kjBzhFtjF3dHMAGy+TxSdX0W69h2o0XT2p1hFUcLySRtNZjbqcedxG2u8dJIsi62oBsNP69i1hOLxroI6ETY8wanlvSEa893ZBsdl6tgk5RTy6++oYzXt1uY76qJ/QTgD/o8PzCKrzITfXqDPTmE+Rbo660hg/K7g66mrWD6FFjlb3zqPQmWHLUxFgm99uzt6u+ef3xmKSbWop2TlnWpr1J1ecd6rm9dUSDyc7fd4YKDFOLpMIM98g/qMFhsFhjSmV9pfQhHZnA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Ant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VvXkkVqguKlHkltb5t1mr53P0MWBuEk+cN1hX8S328vI3GyTDF+s8r0O2uxqX/EAB1C6wqBXtPA22nAc9FuQkxbQekjcQcA7wfAjAelgOvjI3vGTsxV8c8TGMgOagtgK9ExLxwyAkQ88Ndfhs6qL98L60eziepezTxjK4+W1SaEK5HKCd4h8hzGcKg02BjmUM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16142e4b-0027-430c-eb64-08dcc8a86d22 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:29.1861 (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: iVwcVMbY2p0ouECm7pX3hxAZJ0CqWee4qHSJY9Ljs2tn0wL6M0KEuH/8Lr/MWVVKYEf2b7owbWf+jorLuIt3MA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: eOhw1X3WPtRStrFG46zQ7AKI6eVAj2tH X-Proofpoint-ORIG-GUID: eOhw1X3WPtRStrFG46zQ7AKI6eVAj2tH X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 18DBF1C0012 X-Stat-Signature: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PFPXcss3NzFkokxJdER1EQm0mS8v/AZlKIOj0PzLx+SA/Z7rhRMrGAn2Ir4A/oFlMpeixrvM2xQjn8C/MqSRV7sEegRg3qtDXoiGNP5VJ6AHaiT8RdDE7VOOM3zLgmno4aCdx7wKXsbVT6d000cwNC8QSPQ8U9gzpwNQ/B7uLUbb7lshBiZSP6e/QAhwKy5lYEjC/qziva7D3mQ2zQUHzcHuUuK6QyWl2GDaVcS+CXU4U9SHk/QEPlxIAhNkmO7yyU4jKzPiqNeRN8W3pYgYXYBiv9MF7b2eszVbYW8MySqmBdeX/oNtFfD02ETxDFQzvMt9uBJugaGk6RpCjBTep2K0Al6o5G5FTpk9q1XBQ0iX7Sf8u2jmauIrTERhxKPnMGtLMsHYdR/sXJpVF3txf9Xv3KboDetSkDhtHy3VtB4fNdjG5aWqnvs5hBH0Be+qxGj2O2i+NLuOuLYURnaja+nc4kCJtsRi2DuFu+IToOsG72Q5EEScj9E0USbOzgpmLI4j/I+5+PkPW9nkh1fGIGhmE6uRhSJQiFq85xkzG1SoHsGGiXqrkyLtE9eXRWk 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 84cb4b1df4a2..ac348ae933ba 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 */ error = vms_gather_munmap_vmas(&vms, &mas_detach); if (error) 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 Fri Aug 30 04:00:51 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: 13784219 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 EDA44CA0EDF for ; Fri, 30 Aug 2024 04:25:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 821B16B00B7; Fri, 30 Aug 2024 00:25:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D1626B00B8; Fri, 30 Aug 2024 00:25:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 623CB6B00B9; Fri, 30 Aug 2024 00:25:31 -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 3C8A36B00B7 for ; Fri, 30 Aug 2024 00:25:31 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D2D8740CE3 for ; Fri, 30 Aug 2024 04:25:30 +0000 (UTC) X-FDA: 82507622820.19.9C80363 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf07.hostedemail.com (Postfix) with ESMTP id 7E8DA40009 for ; Fri, 30 Aug 2024 04:25:27 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=LnYWZXTn; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=MB7Dy91m; spf=pass (imf07.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; 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=1724991808; 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=Z5cwf34TT/HBeM8I6zt4TT5YDhHE6v+wv7dphrKLbdk=; b=sRF23+dJAThki1HHXAhRpwdaiVjh/rPsd13lxfUMszNXvkWwEfBtV434KCkJ9OySDR1JzR TlpabXB3nRr5tSCVJ+0X8mZWn5l1YUNQqC1GjMUpFCChrH0sEVefM+Re8hp53Okf6f42Za D3oPzyC6bWojcSg7rIDHMalTxSMROQ8= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=LnYWZXTn; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=MB7Dy91m; spf=pass (imf07.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; 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=1724991808; a=rsa-sha256; cv=pass; b=W2clsxUqVakysN1vb3dB+tlh92704sNFQkOLX36lgitH3YMndAArrLbHA/CCoeKDpBAr8f EHbV9qVOL8nugRA/DnX1adsv0Xq7Wax8q+Z1+6o7RfaBuwmQzvfsqnQ+60vpuMaRipH/Em +UnF/P7j3fJWjtwC46ajREvnOQUxXjg= 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 47U3MisF024297; Fri, 30 Aug 2024 04:01:36 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=Z5cwf34TT/HBeM8I6zt4TT5YDhHE6v+wv7dphrKLbdk=; b= LnYWZXTnT1mSa/Za0iAOixcVHN09eRWG/VYWOLAdyQQXQEIo6fhjXsMZ/8mIfDiL IVv40CjhClZOFP0/njFXLHuMrJR17YDYUk7Xy/RCZeV69JOmKvEgcz1ZqJ8HgiMt 0zWh8nPuODeVIVwwik5/efN6w4C5WNN8gxmDXRddUHt4YmZUBVKykqFhArq9cHKr qKSv7YePP5mmgeZdjkpmbl+ohXIUtt66oOnKuQaJqk5E5N7Ymz+aAyCtSoql6EaX gjm4F4mNLav2MGxKelkY+54ClnTiV2Wed6lduuxdr0UOSxWQifsvRxbOSBekW0ki z2+yWBOaCeRHTYrsefk2SQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b3myr58a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:35 +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 47U214vn036782; Fri, 30 Aug 2024 04:01:34 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2t5u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tr/dZB/PefCM2I8bfpUDkZ3FZHEzab1L4ic2HahQj1jCxYLwI8ebhTpH0284Rqx3UDYKgo5ws2XFg9R/DVIS4UNRN96qBhDgllndRGoSxGOgnPzSuZesSBZZWAmzc5RCaT6ow+ZCSoUTAPuvKkTGWXFD/HQLPsu48/8/eamBzieGXDcAAlXudK5GZfanmvZiauvOyT/iU37bTefpHiUKNPcPYMf5T/4aDO3lubohEwC+gncuo9/gzq+gXvUbMIF3GChb35B6D6jSGFbhTSBVI3w75USq8PKrH9luFALEFGAgIWOqvr/AZ3zOLctJ1lm1ANZsFBIS0unCpqnYiTUYNg== 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=Z5cwf34TT/HBeM8I6zt4TT5YDhHE6v+wv7dphrKLbdk=; b=c8wNhFI66pYn5IEh7gy6hJw8SJtfiFjwqci2q2CNijMtroXmlNsRsD6RCLSJLkN9WBOSYQL0r4t0jWvIJlneHD87UL/SXQW2V43kSjlkOx5cFjkGnIT1kDAOgJNH1b8DLDpa6wSIQLcoUJEU6EXymhYODPxHW2vCbpEYvhjgFr8jnhcOty+ddQAtWqe0SAW7CTKQHc5VOLH9IQIFNiPTWV1HGciO36hJmjhuEIYA5EDjlNZs87g1bxNtYJnIev5oHW4lZif+vY5joPhtUTVm4ielLzODxHihqn2kMvgyf5R9TpcUMuHzvqezZA9PkGkmzbb5N7OMM8ycFjXo5l/WRw== 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=Z5cwf34TT/HBeM8I6zt4TT5YDhHE6v+wv7dphrKLbdk=; b=MB7Dy91mgCFvQnq0Hfk2AU0+on+wPiCv2VJJO25lnu/P2S9wGOaCD+fnFJQgMsXt52KTbrXCt3Ko17jQwChzEqxYUcRfxrpAuVac4SzC3dr+dq1LU6tCV6J2PQJnCuE3wQcKkIhnVRgL9CDqMoBznwNVlZEJCB7yqPP+hLhveGY= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:32 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:32 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 11/21] mm/mmap: Reposition vma iterator in mmap_region() Date: Fri, 30 Aug 2024 00:00:51 -0400 Message-ID: <20240830040101.822209-12-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0043.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:82::10) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a94a7cf-43ea-492c-90bc-08dcc8a86eee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: aQrSZO4bo+Z0caHDATn3gCUeWndpZtqv+bu40fbEQv2y0lacN9sXsjOx7syO7QRKknEZrTDlsk07fC3uc2TjX6mZTjwQ5ITyKhnS3JzPmhKxToqtv+wS/We1+34+eBIkezkUYoHFgvRFwkBHzVAqHLpdDcG+zPys4w4EU1X/V4X27TDao1AqttgUMbEbK2UZvKOEKagC8vV/mLnFX4sbW4fPS8yJqoH/b7aDJ3IIRZILJVwSJmKMFkiNWc6D3wZpAjQ/FmALLj77StuODhn86SbplyWtRz/KGqvGTNfwPiy7BsFRlc2GTFA4ZJnbgLMUYLTTwT3pZVoj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:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9yGohlGTaQ224JXYldn/QNgnOrd+gAwcZApYetqM7BPlvMT79a5jrPErBh692DNv3UuYqAuMzGqo/RFLOzMHAxzW3HqakNyfMabYm777FXEdKRuPyjQvNQ61Zzn+luIzYvIJuNDJ97lSreTA7++Sv2iX/sya3pY+jEeEqBBLQYY6SYrKRfiZuQe/koa54ZkgmwNuecDJOrC+wjzVL8X2hFBRomSrLPoRO88po+6HnUMrdsAYh+lTUbV3vHRrZP4LOMG6InfsvZxE3k9bkmWIHarfTcZYBEJK3xC5a2e1ivbx3QNiAVcUav5QKe1XFKtbQY6pzBaF8A/Djfr26JRqMHldHWeK3SUj4ZWqDIfykGUEk0v/3nWRlzF6zaaDfq2q1Ybj7wHz1xMrfx5KPDv+YhIJ0ZsidpTTypeBEYrPZt9J1U2v1d1uP7mVwCvHwkRgdgOvVVhpbo0oMRMv8x9R21UQDsjvlyuGnT73biz7GfoMAqwyRdy8c9qUR0RLPWIyRo2p6sn7hvV/Jj1Yr1Ku84I0X+qbVFRHAcsKDsEqC/N0G8jhFS0GDYOrJEbWlag4LnisGIGT9w102m32EPVyMr+mAosRwUKzTfqjC/ZFZAa/yuvwaW1342nrPpCFRUiMpZVN9P80MJ5w2Y8ftz0r3pO/wxq8jkmbImHzH+NwgFJuwWMNQ1XxLZa+oci6aDr+s+bn35WKnIGOfG1efZE7yvlP1KCugp1dsu10uwGkGT3ND53lPYq42YwqyEkNlujiHR6UPyo2l1xlUK0npxDitZWKujF7AgF5gofHcIU0qcUMSkCS4m5uBNrWZHfN3XTfUuSTXcXvdXI5F1ZSpk0hkDIzMBcocB93uaoGz0pB0HIHeKbot/AvGmOY9XOh+eCUYNDETvIBrv0QoZH6EkUbZ8GfaFof5nxdBwSpWq5hSGn8HNBQvMOwomfYXAmConq84IWop0lr6IhDR+43D9EYQuWrp+pR3IcFnsxM5v9ZQH8nrYYQXTBP9oS/4bwFxoI4frbTog5itFWasL0pBawauEHAIY9ZoPvR0d/d8ie9sYDeMWcTLrUPLcHM9zB204w1+aLhxit5WZWyewvoC5aCFBnfteTzlK+Zo87wothiUa4YQ/K4LR4U+GNuwM9Z+9Ojc6znhg3OfKr7ge3cMX7A1/XkZumOqP4oyTov00Jy+Z0qARuTrR1Jxlrj0L8P2HBKNYFyBe5GwDcrkTvbGHsAOxIth4TRjEqyd7/OYvYEAguRWWu5N/aPUvMmFc2Kyxv+Lof9pme8Kzjkh3wguoamaR3GxlW37CghMyTwRgo6vcE125/xhx1i169z5cogmJUju8CrPnK745oO9MeNYdNl0VeT4otpXEBk86DrNqrVlBv82WI0591kO1kCgEQ+YSrhbqMrXhFXATzQ7YuyHsyv7mwHd4ZPZ1b8/ZltZME0OrKUHRujlaRzP7bhN7Loq6wVk9SFrYRFoeTg9Kh6k1LZ2ICxUJCk5988VfkhLqbiT64NnCGAP4Y/fMyOkToWE2eIqtORNWm0SNPYcZt5Nye0oQwUfj7Pwib8NxLgYXTKWoMmL898g3JuNKDgImDCtvJdTll8MLIoubLXe0DfVmA2aQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6/pTG9Ih3/6rPluHLI0EdVWbPUEGSXYm7HnAm3AFGOOv7DnJbmhiUL1hL4flPU43zcGK47H8HxSu8iipO13OpZ+TXCErSSxWhWf8zHaevIpNhIlGAojXULXee38iS/AwXG027trJ6RqN4XRGqCjrR9d8dn5+5K2Z+EHuYqpSkhRaSqPwTc1JBSXqylZBqQqE2pbMgY6c5krPuy969hyhTv+2TMbruSXNP3otaNvfScp4e0n/pCj/dYTcOKQQa22lS01Ss9GJXvx4oVybmiVYOQISNZ9gpq43PIemeHXP9EuxdQ0SNBfcFR+IvMaBvH/wRiGieU6G/9weKlWHebixotRacajAq0kMnVJ3h3IWeMcK7QKjaZAywMemFdAUZrYv7975223VDTE42BP4vBDhQczGksu6k04SxgIVPjdvkJ1OHAs92yLmvPv25yK3lefzKH3F+hwj815LDh8UdqgbP/RI7aXCWWcJsjmyy79TDSHFyn9WzDpC2SsT6Oy/0KNqSxFkVLmD/eZk7NHwZ8Lr22MNd6rfzw5KLOkdwJodmueMVkiXD0JF42s5RWdoVKheqES7lOjFmNxpG7ExkCYJSMF9qjR+KSl85IKJc4O5Jug= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a94a7cf-43ea-492c-90bc-08dcc8a86eee X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:32.1919 (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: 51VkXatDBUx0xj2L+ZHWhw1HmiHJIiijKsV8IWFBj+2SU3odNm+HgYi6e7jt8/dt+RH1BO9ngcgjcEHEFkQXjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: 1yByl6WiA1mCMZ-3n6MHi3MfmF4MCiq2 X-Proofpoint-ORIG-GUID: 1yByl6WiA1mCMZ-3n6MHi3MfmF4MCiq2 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7E8DA40009 X-Stat-Signature: bf95nxgz6t73c198xs7f7s57sfgoxgcz X-Rspam-User: X-HE-Tag: 1724991927-117846 X-HE-Meta: U2FsdGVkX18anDK9ldMVhbeSqxoGxHrzsXmqCkg9akuZttkAJojL331suUFao3P57wJujRG/0ZusQDeFlMq2Zt75IQyxFTkycYDpymvSbC6kd4LLTaKUshAXheyFJur1QMPf1hCedWVBvwpEAkLNQeJu0IuWXwoireuPrU61b5ZCGNw+eoK2v5XS6oK1X88JnWD1s8VM/Z2CbmxMl+NocH72AEptsuajndr9OS22wiXU5aa92Ko2bzMWCrh2QgjYrkMfGoHcd91XrN8gfA4U9watr61+U7I8Dgoz43nEMuZ3upjE6SWI+L1HMh6NgUU8JLCeWm0y0JUhDwUJ9KjQtpEEy5ZUt7XGmNL6cOEUwy3v2r1W0K0myiKwLwZN1Sd54cbfQnyxKjxTeYX1jbtfyPdv2KM7LKy804jEzs34WDvPsh6le44fOvOm6ylkxyvnd8RAonmHxqKhq3rC/VR+wrqGElMRgyqZ9VC0xzefGDd5CqfuTv6voaSaBhLgg3GbQPa59x7lIM43C5579sVtuVILyYK8MeBlACicLLKleKSLm5agGdB89bEELytTrNXAZ1W3E9semjP4k6SPQ6mhIcrCf+1UsEe5tAE6lDUqT2iYdPRQQKqMpa/5z/q0kM0YYfwaTpiwgzqaoQNE64159L7Mzh8X/iIAmYnBRQXFRYq82xgzxkqmK6X65T+m2ly6grI1FNc3xA6qM/NLDryY/a6vCD/lw7KO0e5Yic+aADZ3RvMiW4qrpmC3oEAQvrk5/edFT3uUplQXHGWxQsgf06O2LASrIQbC5DW6cjF++zi5QGKZaRjKSGUiw08mTqAFRlbptCi8BVHT91XC/WcpUpKqaMpH6pIOwH0qbEa3tGIYVukHHiekfU6cK+2VGHxaSy4Q4FTEeGShnop8/yeCXPy/uaJxLvCEpnodZAFWLh++j9iaYRrtWZNZu21EGY9p7euidJSJulDV4XJp0o0 vXyWYysN UMC3+VVCqTRiCKy3+mne611QipOKPCrlIhqzzljD1nCEjD0Z9qOIBm+Hgy/rUhP22rLWHoO4ueeAY2OfukWvB1Izc4/a9ob0276B9p7Vm0LysnU/BfP6NJDnzplRfXKFT5EKPdgHGMyO0Rsw+DfN1BRocKHnXsa0dZxd7twZbokXFuRaDpUfROmGsPGYJLTWUP5r9FM512veIRT/w2MuuR22qno8z9iusBZrOLFZzy3gtNjU7WtRpG/q7gj30O1gGG4Dds8VOFXwt6W8GATxy/os3Ep9+gv7k31TYDG/ZeN9fhdWTlHgqd9KpNWQGfo/raKtOEGgRoJDeyVzelcXbtpmah+utGMuIfE/aag9A6SbwkMYuu5YlZCiy2rdXj6KdjGDVXeUEuF2vdGfpbDkO/Q2H5xKZLvDDRPh8l4fTPzPPlO9HR+BYZeCtMPex/3+pwXafqk9BMzCkqtFYmFwMQiByl8vMJzX9yXmTfhbbvSvgTaPRjK5IMjrOS9KUJE+fWwHIIUWCWYNJ4tAvi68EB70tAtSeTjsbiVnTeHZcZolsK5aKlXmrL++ll3ZUrqHte3iz 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 | 40 +++++++++++++++++++++++----------------- mm/vma.c | 16 ---------------- mm/vma.h | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index ac348ae933ba..08cf9199f314 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1401,21 +1401,23 @@ unsigned long mmap_region(struct file *file, unsigned long addr, /* Prepare to unmap any existing mapping in the area */ error = vms_gather_munmap_vmas(&vms, &mas_detach); if (error) - return error; + goto gather_failed; /* Remove any existing mappings from the vma tree */ - if (vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL)) - return -ENOMEM; + error = vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL); + if (error) + 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); } /* @@ -1428,11 +1430,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 */ @@ -1453,19 +1452,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: /* @@ -1624,6 +1625,11 @@ unsigned long mmap_region(struct file *file, unsigned long addr, unacct_error: if (charged) vm_unacct_memory(charged); + +clear_tree_failed: + if (vms.vma_count) + abort_munmap_vmas(&mas_detach); +gather_failed: validate_mm(mm); return error; } diff --git a/mm/vma.c b/mm/vma.c index fc425eb34bf7..5e0ed5d63877 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 Fri Aug 30 04:00:52 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: 13784189 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 9D8D2CA0EDA for ; Fri, 30 Aug 2024 04:01:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DB596B009D; Fri, 30 Aug 2024 00:01:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 414336B009E; Fri, 30 Aug 2024 00:01:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EF9D6B009F; Fri, 30 Aug 2024 00:01:49 -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 E7D546B009D for ; Fri, 30 Aug 2024 00:01:48 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 68925161393 for ; Fri, 30 Aug 2024 04:01:48 +0000 (UTC) X-FDA: 82507563096.10.88373A5 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf14.hostedemail.com (Postfix) with ESMTP id 03E9610000B for ; Fri, 30 Aug 2024 04:01:44 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=n7UQWtP0; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=O2iwDVOW; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724990415; 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=1UDjaqCUY5CJt3NaoL1p2VlJ7dG2+K7tNGwtmFfkaek=; b=oeTRsCR+Od/BFc5RQCG3A8EK/IocNTi2JhstPisE58wYxnvZmjXJe6IOMazrtWl7+PFxXu UTfwl22liYFawPKLetkW+QSjRMSUT73LADX3tLEwTR157JCkv2vjJIvIfUJaxUlDipKQ7a F7eZQAFQUCczBfKrkroXuOTNrO1CxHI= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990415; a=rsa-sha256; cv=pass; b=AbVQEN0POfGfXXb9d/5QMxIsZNQOV5oK3Gpj008yQClY9eP1pPjgqSZtaTcurm/+m9d8YC na8wCSneVg9VRUSDl+MaowhD/CO//kkaUaq+f7hpPcYIOvOHtIoDxe/DC6P8p7snV4Xaqx xESgAcvY3uuOVz0ElArm8LTizXTpRxE= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=n7UQWtP0; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=O2iwDVOW; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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 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 47U3MisG024297; Fri, 30 Aug 2024 04:01:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=1UDjaqCUY5CJt3NaoL1p2VlJ7dG2+K7tNGwtmFfkaek=; b= n7UQWtP0I71xATwhhSCJkDUKitw1JWUt8jsC1h2P+z5xi0KL5vIdBkov210zmi4V Ix+vIRU9ETRlvuYcGauZn8jSIZ5tx3LtD4OAEmKthK60x+s0FNKRkKGFRVL7sr1I jxAzOIy/LpjiWWXjX6GrlRzlXVNSGR3Hg/lhxLq32lR7Eiz0nmjKU4QBt+UdkfhQ Qb1scn9ZAr6tmoj0JA97V9Tww2M8STAv2mdZJh1pIStNSVzFP/HDuITYyFdVpaky W5eQ7oIIcRx1DNrnRSwgqVZwnKvQcivMZ4h/+pec2mFs893zobY39RDmVvlI6BVd 1rw9yBI7phQpuziYj26KlQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b3myr58d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:37 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47U1G4jc036539; Fri, 30 Aug 2024 04:01:36 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2t6w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=umB38vR58aHAHJAg/qM/CB9odk3xpE278u8qHB+8qrp74BibzOcwYMmk6MtAnv2UfClu7yW+7ssT9nkaX2g7HLzC7LHCd9iSahB2REP3yfeaBRVaGESuqd+VtMHCkTZyGuPCUmAX0PPhlrYnDgRVkBhcWNgjKR+LvYGlxLGUZxZ/OhdNPThy/8NdODCKqjt9VOmnv2utVwFXonJORybgQheTiC9bblbuhvvb87Q9CcdF74mGohaYlStsa3dSIhReuvsR+qwJi5qmbLLuRbSyT4yg+si2s2LPC+S/hmEfmhadNEnDQc/h/l5MWEuykTl5+WII/EhTEwvETbE8J2vbIQ== 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=1UDjaqCUY5CJt3NaoL1p2VlJ7dG2+K7tNGwtmFfkaek=; b=MyfB7Ajvq4+dpY+RSBGnujVoldLr9tgQpjZVJI+ok5FnTIv4wmEnaOmVW1yMwru9TfhlyiSzEimv+C8gOvrMrYfj71XM+qVVc8KtUEZ90tdP16uzjR5o9zB56DnZX0NfqkZGaIrBZdQZ/eMM9voLZe9q1JuzwccR6vBuwUAQYMddhi+kP+szceaEdlGoZafXABa7/YGtmRlmqwSH2hbieaBfyV5qaPdHjgBxtnEfy5Ht4KAkEEUy7q8hnFFxTi4jffsovftZ8eYCaWQOkg1xHBurpNeGc3CXJ1aFHlHNxLJgnDIsW2XZ4MD+FSZe1YNpdH7l/8wBIxJWksu9KBhjzA== 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=1UDjaqCUY5CJt3NaoL1p2VlJ7dG2+K7tNGwtmFfkaek=; b=O2iwDVOWWhC+7UlxKT8GmhbduF7fDfAcYCgLZl3SEUDDuZdl/vU/I9xapNN+6YKQZOdMdeyjXju18QhktbqZxCWvtvoK78B23mXOHm91BjnCm5/XfeMT1Mc8sp93AaI37FUrAZCRJJ45q1sigvEe98I9L10DiVn54IASzxtWJz8= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:34 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:34 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 12/21] mm/vma: Track start and end for munmap in vma_munmap_struct Date: Fri, 30 Aug 2024 00:00:52 -0400 Message-ID: <20240830040101.822209-13-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0031.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:82::15) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: eeaa53b6-d7a6-4426-03c7-08dcc8a87022 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: s5+CusT+Ug+CqIQLM9+Nl9iO0TKO6TP3iMpLroUwfX/lemZMQeG4l+oNLxyPjgokWXgQbfwBEi4zLE7/iPPEIGoPkNwksrDgCqDQ4bFMj7BkwSkF3oQaZW5FdTrp+7JDruQ4Rbfqb//OwIXFOssbhCvgGEt6mpxgcop+EsWv7gslozL2r8Qhvi0R3S15ItfvhMNivijmOHclzVr9CbOW4KE9dUnvosZZDAThC9tMMHjzVIub8ttWcQzq31I1wJMnu0E9fV6FFXDmU6yw9U1wror/9SA1CAasTEuHJkb/BvaECjAuVK+2OW/f9O9WPWbe2ee2cmmg1pXqGBF4ebf4XJ3k9WFfd9MQ3pwB0QqpKmj3rRFm/Y4rEJxrBYGJy8et7an7IsrXJGQOMJxk2Y+d1IWRBzBGcf6WQndj7kOFKm7HRbtVGm7CVpbc1q7xIs3laAt5KtW/a2DYQx9LbixvEZ/1u7jjfWbBsk3Skc/cUmHqZYxfxL6vj25fX2TLur9kaJ/A5BFrRFuHVjpFI3ZjEJyke55tmWdVyfULsjIk9rixPFylKiq7+hrJupwOXXcZ+twALkmGEFBJ7/CVSizvnFcmYnfwF9PDM34Bs9rYymAQC2WmYQskos/WAgqdbh+tB47FVYwFBNw+wJ2Kb3WPGqtWG2THxdpKGoHpIjuQZ1SHBslYDpt3bS44uI5RKTq5/S5EAi41p78N6XcvHNEtdv2XmS4S5pDt9NRTOnrndzRHmJPBJPO8K3bujuA1Xp0NzNJsdeKzNS5D3dHNX2P7ep1xiMMTIVgHwhViHY4LdTcMPSxuzMUPg05e18ZsRXQBNM459fJQKiLv+KtkV+EkvsFCjcbuVX/rZHHvGpzELESmFdD9jOqYXWARB/tTtgxgSpbjIP7ni8szPgLcSm0cCnflNMA3/FUJXzS5VHUnNq2xPTuIfTLzVSKNixCKkWlRJxuP0BkTCvVsDyCmBuVuPHwxdpqkpkpfqxW0KgOU3TIMY4OR7L1mIEa/TXGO5FKs8CeH0peaZGGGdiYhVSHSttvA2k4jRuhX9wNS3iNOWxMZ0VAC1YY8myWv/BzpwgiHUvtTxo7sfHO5RJLHyUrtGlzbYPdtfzfeeu6ysxj5RkfhpPdQH3O9p669953H4OpAmcJIfVjHW5CshxpkIxDIvCzaltDnWQEs/0swJkEe4CLtG5M8ehF/CTQScX7tVOPw11aSCeZLgiHrEMG6+YjcD5fFoZhf5BXi93WRHIvug/rCQETdTn7EfnX8AEG3ZzpE0/gAp56gQRluwTye1ACwA/Ef0xNca+Z3zkOtt52H7VDjL8akZVeWPfdrwsj3nUUn3fLefhRsUSGyqH5Htm7r3w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S3Q56uW159YVy3z4I2ZNeBZkitq9m3gsCsk2cyy6qtNxmllIyREhueQT2/RqvO5QygLtbNbI79YowGm/1cRd7OQY4xv6zROTjV04DXxxw9UmvzHz5Ehrc8DF/WZUceOYXaTpZtlYrlllg11jEFYEtCrx9UxFQ9h8+3MQXfSHPhDk5uTtcEbcL+QcKbCuPkDu4ot9oitJJRbToP7sY5vAOJVhk5G35OztJyH4OFR6BiHmcOFZsSqdz8zWMxDZCjpvh+Mdp8I4j2GtJ+f1zkWN4nf55UJwnxWrfFPnMfaCjGmvrxzjzJfDKQ2HhEkIQulBs5pVzPQwJ4/jQsCo76/cWB995C73JyMVsUuE7CThZT7qc5UyuPmkNUOCdn0CWhYyzI4ku1aHZKEbeSnBiNlN5olhQhdq3cBlZT2AneiuL5O24t91eyesl/KYo5psFFqJ2tVzL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IfER95jNbxYdjARRBXd49dIaSn8bHhsCwOuWyhHic1Dao8UV3bQThFZ4RUHT+NNdM2+ox2E7VPndczj5a9v5QPktm72rVf0x3pSJwffTwL5uw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: DrZGeCunhnhojLLZ6c6CPv1dqEWAY1L5lFZBCkLDQQpiN3AqVbETa+lVb5VIZ4fwLwD35GCEc20VETk0zqaWDjEQP5jfCKrJye8NBaCj9PSL4l5fUi/mECOayO06Ghc+E89xMdKlaMBtFLWHJrlnFp8t35+po5L+3vRCDHfmgsYnUkVfBfmRX1uJluqDx7pJcVIcujgzFcUROCUMzqhyMUd+83EJRYXFpJgdItmd8vtMQdYuOpShBPRzyrjdCnZ4/nLtwPBO3nRB7/YVy2qaHbylVovhI+aszBMVgnyx0+mIZ1pZyXQm218YLpHKUq3xvNPyAO6EmYcztDLKg84nWqnHyBglDZ9UL9foIJ8hpp8UwUi2r/O0EIaDZEuyeU6cF0qqDPz/pzuoJJqsScb/a1CHtFhlt0byS+Irb5wpMpNmaqv3aNs28NG39GYQa/GhjGH1FrstivmAwHxoJ/FcxKRNHuyruFxCbzNZ9ti/V2F7/tgnQzU0DfUrMfPH9++dG3kuig1ecpVYdagqcFE9AIiyWs45DK4vK0fVygTpI6WxzLUfGwXgW4ka6RLyOq+Zn6sGwD8uG3bbzgwF34WAxbF83pIAbyNosceMLWeRWtE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeaa53b6-d7a6-4426-03c7-08dcc8a87022 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:34.2166 (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: eM6+xp4JHq0pjzF+7V2O4My71/JPIH/sSrIfEGV8XnhreOQrYIkbLxGPScLUbUYmzSZSuIx768B9IUIHT+9rzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: gPE7UbEfr89SN2-XGAYnktLd8lFfNf_I X-Proofpoint-ORIG-GUID: gPE7UbEfr89SN2-XGAYnktLd8lFfNf_I X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 03E9610000B X-Stat-Signature: 5p8brh7ecps9us6cxryo9x7wusfubom6 X-HE-Tag: 1724990504-75651 X-HE-Meta: U2FsdGVkX19zWBYkxidkvXuQy9M6J3DIWoWoU7NtNjFQ3//pN0Y4DbjC2bHL12Nw/qQLccoZhicknTR1QxL+npulOKtTm7gOwhNAX9O5GbUBjuqU4Dn3gCZHC6kNujSnF+vd7Rca0bJte7A/Z0tmFVR4d3O1U1VIWXxznbpC6301xtRmwiLE/U4/uEmP9NpEuc7Qove4ttJSPVzPIdr91Jgd7vFjsfzYY0wj018KiDfg3OBLYPVtzDyfyh/o0MO0U3A/L1ls6r5FD1PRtB52DmgFGjQBQENPzXoZbnjVCWtbS2FN6Vh5lVl4rMxV3tvyTKkQF//FzbmUqU+LL1Ml4g3DiV8u9wL2+gxsv5irTCZCzxd8QznE+iKjADwVWvEiZkZ/xGKpNV7oA4EnsPmcmTZ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gUHZ5NRLNEtiimIy0E4M+UDuFaPpllcVi7+r6uMp1OL9wWKMCkHpzn4i9niFXfoorhZtga6fN3uxDq6UqJbd 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 | 6 ++++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 5e0ed5d63877..c71dda026191 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 */ @@ -745,6 +759,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 @@ -805,6 +821,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..8afaa661224d 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 */ @@ -78,6 +80,7 @@ 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); +#ifdef CONFIG_MMU /* * init_vma_munmap() - Initializer wrapper for vma_munmap_struct * @vms: The vma munmap struct @@ -108,7 +111,10 @@ 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; } +#endif int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach); From patchwork Fri Aug 30 04:00:53 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: 13784190 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 B663ACA0EDC for ; Fri, 30 Aug 2024 04:01:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B4716B009E; Fri, 30 Aug 2024 00:01:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4398E6B009F; Fri, 30 Aug 2024 00:01:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F0026B00A0; Fri, 30 Aug 2024 00:01:51 -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 E671B6B009E for ; Fri, 30 Aug 2024 00:01:50 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A1004AAF4A for ; Fri, 30 Aug 2024 04:01:50 +0000 (UTC) X-FDA: 82507563180.30.1F6653B Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf15.hostedemail.com (Postfix) with ESMTP id 4AE69A0012 for ; Fri, 30 Aug 2024 04:01:47 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=g1nuX0OQ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WOGOJekv; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf15.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990434; a=rsa-sha256; cv=pass; b=rHExjUqI9Y0FGbK1U8w/ULNNxGT3HWrg8sjUlYx/vuaT0rIvBtW0V+rE/UeWx7tvr5k3bO eQcsc8cY4aK2ikzlZYQawxE9nkNa4P9OgorBF4TDkO9rUXzgLUXGGL1CHFtUR2fdz/v75I U8pI8LkKiZEeUYEJrbRrjDjNVBnoAGA= ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=g1nuX0OQ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WOGOJekv; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf15.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724990434; 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=76Q2ukEjjb0hEfT086y7aNLQ+jQfS3rZu8flZm0AWsM=; b=q4TGDQQJ1JXmwtCE9/KVch+GvWRGwhHTzMFTcnN2g3rMEsEAk+zN0kJ4Y7D3dEvN0qFcjx b4qlcE2BfmE2JARRnrhP3zErSbLT2uc2fUbhx3hOl2fLmur7y9f//6lp/4v3te3sTLxKyE Qg1oOn0P0M1/cu4xkStTkm2XRBXhqL0= 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 47U2fV0h022842; Fri, 30 Aug 2024 04:01:40 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=76Q2ukEjjb0hEfT086y7aNLQ+jQfS3rZu8flZm0AWsM=; b= g1nuX0OQWE4Gh2cbdG7TS4duqWOKl9E+eRv1X6cHJ85+LCYxu6/+Uc+oDKtDRxP+ y2LS7Od4xquAeocczc2inybnYt9l/GFkSizHW89HaXHZygT2iw9XFuGKrzKZEdML F4Vgyh+UkGdXNPwYKqDOPudwpZQPvrh0QPV/XldnDpJRANvdeUD5icGtKPXt11xF I0miOZX3CXOrgnC5RPtSpZlaXf+jarkP2j1lm8dotsHPkDyC3GRZIyvica+IexUy Qpgy8/fb0b+E6wwfXnAEAS1DCI/1qdbiAmjbx4TuVpYYfNclmI837FLMjDbC09N0 FakENgSS2OpS2wLSPKQcNg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b28508nv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:39 +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 47U3hBLY016852; Fri, 30 Aug 2024 04:01:39 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 418a5vy50m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G//IAJ2oms38khheTgJTqN9wmmcF98bsWcz58NRX/O0lwl6qh+gV6Xu0yLiQxMnCLz/7MH1uoEpzO2Qw4EemAN72bc0hYigRDZZIVbADQR6oG8ICnwjj/h7Y1xqrnfcsq1NL8eRGJFI4zzlHtpaG7aUAFv/gvFfOyiPtDvCyrHyZpYBvYeai7PIY5mb9ygc6iGmrmamLlg5QDXiqeMqHvNnM86E0+oz/mTukU6VBum+n0BDbgQVjE089QGCioh4KdnF45oY/gag3YEWiaSY4WojFGSYqP6rvETNOCKQa+RPHb3JmH4+7+YfIijP9UWCdHz2SK+NMFhOtgQ3pcoSneA== 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=76Q2ukEjjb0hEfT086y7aNLQ+jQfS3rZu8flZm0AWsM=; b=phSg8iBiLVFqdHO7wcTrJbSbbFgcWYWB+U62xLFz27FWRqZRDjMUrKlZNBfq9lKAy1mFE+/K5Nz5oRGHqbP3514decOoSljwEdUxwVVavnKLWP8xNTaPgFOmrfUxAVIjl56SmB90g5uqHNKzaFeaaAnWbjvACn+o6VmQHoNDXiz1UohsL1TrmpFtuvh0g/lk5FfSOutIjn9W2g3gHsxGpN2FXYrGC8eRPQA/IClN+PCNddoYwwRevnnSHNy0MZzMT77HCxkn8c3Nfe4XSnfoYFu46fOEA5eGPmbSURMPqMvHhlRgxYO5lEVaWg9eXg7l/G74TE3AgSUISnAOU1cVrA== 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=76Q2ukEjjb0hEfT086y7aNLQ+jQfS3rZu8flZm0AWsM=; b=WOGOJekvxvwcTinf4vrlEtwzWfNltT6Vm6p9SlkXUvPHKWWe/4zM2atNoeKeDcqd1ns1u/sCPtxGV0l76YoULwSeD5aPgzsKgGUr8bNXUbdIzVMe/eXNHLQUgc1OCsidDU4uBWF5lK8edljjB3wnXyHQ0/NYdQYJNoz3lUi0YZk= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:36 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:36 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 13/21] mm: Clean up unmap_region() argument list Date: Fri, 30 Aug 2024 00:00:53 -0400 Message-ID: <20240830040101.822209-14-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0170.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:110::10) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 9142e4e6-45a5-4951-e3c9-08dcc8a87145 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: T/iJNEne6aF2T/rLX8iiU0BEdC88FDq0ny5mYE/fjUVBk0F5aUFQJ0Ih97Zjm2WUIx8e7EgnC021M8XYgTnWefl9Pwmg5t170FpGmMiaK5kMRqI/OKPcRFy3iSDbQClDq7zUDI3too663vKd3bRLe30f4MewYBJhX7Sxam7nKEVPhMm5DIz/B5FF3H4X2buG/PoCmt8pOhAIVdy11M0LPzzB9+11ca3jUPCzr2NBx/S5yDAkdqVZr5l/3RrPcDJCFAm1BQPIdIueZ1MLDCVc4nvEJMEO9OSDdDyZyjQ2BciI1ag4nRtSiCegDOAnmTuROg6IwmaPh3ustbw2kicQ3qDjO83kjQ6YEmHAWXuxdK2cMu6ZGHkMzWV7WYvTQvfrlaMwr41XL17JGF0mrYiQ4VaR6zTLO90gQREifKUu4fH+Kbz41AHIp3PEhDj1mFbtdyTKKUKc2GZCx5dcP6R21+dT42tBvce6o3bAnBFxDJseBhKPTAnqELrklXj12/r31YQt/UOOTjeAQux1Nqj4qilAyFmV3R8ZnP1SWRUFLiwiMwvdyCkBoiYbT/BOPFHoXWfIMoMKu5s+fyYS5zEE2SSOc18j8t9zIH8nykd+vffO8hm+Dm/aLAGxhDOTUO/MJ2T4fvANKc/tG6e9XbBiH6ERPRz3gVBnEj5IEp8Hz/O2cVRBSbeHW1KSDfCXUaic3udloQ2NRz8l4Mem4jaGnlEl2U4j2UbI6cYl+8T7/D/7kvJTNA0ztLSba/iCzjHizHTfsgKT3FarHTmiQsWv47c++trXtqlRGM3fumq/sqyY8cFFw8Ru3pqhKK1g1D0zVMlzxPIakAESV+16GZWAVr5iCes/sKr0HuKq4YX0PD7k3IjQP+KAwjWAGBp2YZCooHORFbp2eeWmi8sGsFGnJc/wPTJpKO2acAyw6FbMStz4gKhH38Am97rOh6It8pP6qZ2ESzc6/8ok8aXbXUU7C2fDC0ARAXTHRdRY+ihGSfbumtcWLzkPf8wq/UrVRnAbNgezDhjO2pThldaxVHqbGsdpegx2YUjuT8Jpq6L3qVox+4eULgoVajC8p8hrusDkPRzc3EdPOJtJvZRXXTM0hj4PMpppzeMTieK3YdleMYsa+8alnFFgnHqHdSjF1ZmrwcdfmOxGOyg0VXXp7AXcwvxq1QW3++ojpG9PlmVeIYNA7zSvtQQNTwHAeT/1YPlJwpgfeHkdkZkjzCKY8KHagCNzsnBhmYLAXuvRyJ3mqhKAPXHImSCcox2lVD2SrxhitsZ7khfvaNdPmtf4p/lRshXEmD1+usbJ6QL0nut8Hyjp6S0e8dw79iRLlc0fdy/9FxYuBFYkxsQUAodpDGFngw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aMuinCNqFcj+tNUxoSNpomxwc/N5uMVEDXmF+Kz/HiO+yz5cPhMNEJsa9zHpDsB4/8I18e4jJdc01wUWCDq/WSxrxFysXq+1EgXRLqvgZdY0R/xt0UwGKKCQC0+M541IIvz3Mv9tX9Z4HxZ+I+s0ogEWtjssmf0RYMtUWkjgVGBIl5E3X1moeOwnST7qEKnddAuNu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zneEoI5EFnG2hcnRCJrBsSlKbIDmMzKi//rTmmCzrKZ6ovV2ScEMatGk7PAcXHRpoAOMoCkC1BjEZPt88Xfa7Dg4XHiQ5KzsKoR1a4TGy0wE1vKv8sFoFvg1KwUG76w/gQXEZs2rKhtyyb8u59XCjxvKz5X4H6YWQpSxNFt0pl1l75a84sySWWkrudve6fbCXOFqVvVD0V/JuxjAOK/hbnWAzCAqQGlnQ6i2UFbB0Lq5/Tjp9D1FpbnvJn/wy2QzEmlpvH9wd95oxbAVOrTQrBlPZhv5lO4148mfrhsQGDUwzKuf0VsNogOq2kclv5op+/XMJvAI9KOPHUlC/JTb67Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rvDxd9h0IHDwew7o6QYUieGSLHqNNYcTiT4eezPGMdpAag1jxkcji1Y0hKImSQ1sy4hUbGyAn5n1pmeULxDGG+VuDAxOu/suF/HechFFfPqB44psIS/0ByBpMJdwDXotw8dIoVC1Y2LOGdisRX7IJh4QeOuCVqX+R+9T/AEiiNBWru0BO59tdGAsX5mPn0z7JMOVuths9njcjllg/bR2rEs5nP07MkdYRi+VIoIVTD3bVJo8LQZI2GbG26S4IERbTN/c4gOPKgnvwa/WWU0MzwG/lOtwmQIb1qSmCbo7rPp85CrQONyyF6LnOUpWOqa3ASMIKE+BIlTIQcyMSp5E+fsg5viUUPU8rHI1fBh+qgMMDj+viHH9vjjE2Cgnm44tU++VNXpX/lHJKX8KgSiGWLWiVNG4beZsnPRqEiziA0bgxARNDt5Q63jd1aOX82qGWlzInrK5+zDD+KOnwZxc4xoPFNeClPaD+wJRVBBN3s9XAe3y88c3mBB5u7FXKwX8iAf2MmrDK4UNjGlHc+Gd0tPPwY36Vpnf0QbCD6HcR+7XXmQR4DQil91vvdClmzaZGDWFZETllQNeEkfLsLDAZHFac7FYT4LM7zUALLVsgkE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9142e4e6-45a5-4951-e3c9-08dcc8a87145 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:36.1205 (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: riKuEO0cB54gEVl/A8cnAnNMpSeXf1dREqKhFr283FCMINMKSi1aeHtgxPmrxOYqyA2/IV3FAOMWj6EvuKhrNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: 6g6YUpPvGEfzmkLgHF3vEdC8_ZUWdpVO X-Proofpoint-ORIG-GUID: 6g6YUpPvGEfzmkLgHF3vEdC8_ZUWdpVO X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4AE69A0012 X-Stat-Signature: t97fxemm6i48q5ifn8dgupa66biht9xb X-Rspam-User: X-HE-Tag: 1724990507-833488 X-HE-Meta: U2FsdGVkX18kQ5hkHleSk5JyebWzV/s7Jl+muJw7RMkYHxIKTpxo6yAK2zMOE7ubxqusf8eU4SRgrS/q20hbjaoFVcS63X2ZMSm+HS/wIhmvE9+yNrCuX0b8ycIMunBMfB1q4zZekbOMasY8z6dy5GIXCXSWI6nipU9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Xnq97RsCtCs3qBXxJKSEgSrs7b8SNwHQUEin6TuxOZ27k6QxhqULI0rTMerrzSMYwySC7lZTbmdCBQ7j2RIjibLNFyUOgUwufqvv6+vfZhvF6uFkepznPkIEYeDQrJDP7pToRGVbV07ISYqVBPZiiBREHi36VgRl2rP1HAivUbH4AuUPNsW7KEPgOTur4TjFU4UddhNT2Ylz6DFnPSOthCq7g5V4I00G0Gj4/vVAiJZ76M6hid0XguWMSLqgNaogqNk3kP8grnXP+ktu9ir+biLW9Pi4Y/LO/ytv8hyGnJe+gDa6ChMpbJKM3uSFFFxrzCg4RZIwHH1w12nvZLb/Xx7+0c0fML9yk6TLhY 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 08cf9199f314..304dc085533a 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1615,8 +1615,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 c71dda026191..83c5c46c67b9 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 8afaa661224d..82ba48174341 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -149,10 +149,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 Fri Aug 30 04:00:54 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: 13784191 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 E5BE4CA0EDA for ; Fri, 30 Aug 2024 04:01:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 354E96B00A0; Fri, 30 Aug 2024 00:01:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DAA46B00A2; Fri, 30 Aug 2024 00:01:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 091E96B00A3; Fri, 30 Aug 2024 00:01:55 -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 D6EA46B00A0 for ; Fri, 30 Aug 2024 00:01:54 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 88188C1325 for ; Fri, 30 Aug 2024 04:01:54 +0000 (UTC) X-FDA: 82507563348.23.54671AF Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf21.hostedemail.com (Postfix) with ESMTP id 2A7F51C0004 for ; Fri, 30 Aug 2024 04:01:50 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SkHi8+99; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WC+uYKDd; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf21.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990445; a=rsa-sha256; cv=pass; b=6JwF40WT2inT7qfvPbOXdjG8VNsiqkzX3wQel37ITXs779xZU26HM3M3DDhJURy1eq7xVk QY35glgS8tv5LPjA4DDzJ6K9RVmLhWhQ+yGhy14+U7yS9RTEj/5q73I8+VeRA6tSj04ZZx 4GpBO96HpRHHry0Ku3Fps4eA1o62BJg= ARC-Authentication-Results: i=2; imf21.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=SkHi8+99; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WC+uYKDd; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf21.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724990445; 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=nJx3QG3RDEW0OZLwG20OZtsi05/1/vVoSWZWUJoiJXI=; b=jWLCY6BqRwPJ7vbPsgQOfDj0pCqsvpV5c+HugCSJSZWX+Qlj6Zhfprn0UWE+IQvZaoh5F1 CAnsWFg7Ly6SFm43zVlVA05msOEQHHAgM7NUmVRVLcQCWvU/yZu1T9Dd8J3ZuAYLQoijBs oNW9IP1qxBcIvv3JphE3j0ZRNL2GbcM= 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 47U2fU8g022832; Fri, 30 Aug 2024 04:01:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=nJx3QG3RDEW0OZLwG20OZtsi05/1/vVoSWZWUJoiJXI=; b= SkHi8+999tdsu/By25e5Jm4/591FBdSLscaHFL3VSNUl6pWdA7P7nvGlQUFT3x3U 80RFMUIyqgBayQ/ReJc2CTD+00mjo/UsJSInmy145bXhQj25W48hFAQ4FDEUD9KF dXhx7eTwMaN2hH+9Oekkw7y7empihxvqQiud1MgVBPDRsjPUPiQ2RHppqgXLUQgQ hC4xGqxKiKnyRT14uHf8k+zzNE7W5Ygh3BLOsOkTq91qnl8h83Ndc+jy+P5rL5YS X3N/9BwUrDDQx/lmyx/8ISwoQeidAZjIiD9oxEK4oiUAeS73BvjzdHuTsIiyH6PG cF6OWFA0uxoTd8slK0mR0g== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b28508nx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:42 +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 47U2YOTC036524; Fri, 30 Aug 2024 04:01:41 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2ta2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aTaCBfES3nwf2CEQF8r2iO4dYwqgbmrZPXqZYJgHajDVdb/vtyag1JiytmGZX8G69SxoSSVecKx1pnWW7Cw58cBi0vmlDGwCt17LsVHndyZIUgQfg7rCb7KkpFbk5bj7h20n3ZJtdpiJYP4BFJQOGq7lioq1mp+gw4OFxmrwodQApbZxw0yiw19f/5h5LdEtQ9M4drHIpyBQD0HcFefYEi0kMgkYb2Pd62WUpBx5WINOXxjG53egOtmQ5JCZg7kjXDXP1QvOc+mzefjKI4Iy1lhqs+pQBNf9UKHMzHWAb4rhcxDutckRp7K0Sa7H0h2SfEdhULytQRFzvHw5O/Y5QA== 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=nJx3QG3RDEW0OZLwG20OZtsi05/1/vVoSWZWUJoiJXI=; b=rxOcuShv5k+4syitjXaLzwH9/J5vHYDcvMB3VyinfNgS4llPqvwj62C7M9I8NG0JZ8tlPTP2AOOs2JQBL1C4WQ7wnv5o+LNotDKzw9JfTKWxDglmsds4QRKy40FV1rbYRt6vYM4OhVu/FmgJB8A9fL669OTL9O4UbcrZh7WIFiL19Dnq2drwqfM3wMEns0zJyX90KlAsOHvJykPNULk6wFSwaeg+7uuHeG9h/xEAtSSxEDb5FzF5MSnYu44YwBhhsdCzc53ImrLFQI2PaUgOMKQIWhDwwMa2jU+23znghd/ieEY/cMzvGEkFC0HkND1/GCFl/vTrJ8BrTd5TRoWzUw== 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=nJx3QG3RDEW0OZLwG20OZtsi05/1/vVoSWZWUJoiJXI=; b=WC+uYKDdztlEaRWJQVf7+/HzKQLm3iET649adsWwC0nmxHUlUgKUkdRRE3f6tgg9k5iCH2umDVu0zWgcF94gpN17jj8emB3mku7tCcwhQ9tfNL76Lcd7tBM7oWKdkzvF01qR0oh8+8S3XL8i14oJ8RkGuvfju+xr6X4dxPKlBTM= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:38 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:38 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 14/21] mm/mmap: Avoid zeroing vma tree in mmap_region() Date: Fri, 30 Aug 2024 00:00:54 -0400 Message-ID: <20240830040101.822209-15-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0175.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:110::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_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 6292d4ee-5e68-40be-b81e-08dcc8a872a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Rel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m5/h47Cl8YK9N/7h4S8Pj9LR4ZgW26atOto3mMnsaWhYnOpwexaW9Go+imbZIVN1JpUbObIYcoO5yTfS0YzaiVTDqRMAB/LcIF1mpUXEh6rJVuM2T6b8VwA3XMqWNal/h2nmXvsfumUuh+2G8fAxn2svVJVJrs3bYGil+oxEnKrDaUUBhflX4gv+0Yd7ZL3ud/8CfqjLoPi4JN/y9bFUmz0kXoE49tlclH8lIkwAKER4P7tQCm/725AEyzACA3yUE2QTmh4BIEPa8JFoIeA4z64316KBqkUTuzhGvV3+caFjAMi43MBYHbpq9sb57Zq+9XWRMgqcrLe/KHAd0QgNd9aZhXIP7/H6rh1jw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BPjVHYMzICQEphINLBXAwiSQAhYw/hl6rdxl66gWBlO6deIckNSyCb6HM7lDOD9myGqatIV9QooRLGH8QV3elkUXv6e/NQiUToXm3Zp9l+ugjBgU2t+On22EJF3tbjf1fXH18ENAapZqSj02Gh+JuyJERszXx6QNmRxz8lSxF0evPn9n7/xKOZvDYhUgbKmkOwbvnV/2EHiUHcdS2pePboREdL2XuI2Vf6rWs/dKxrMV8hVTqjC5eqYz02/rhD9M69fqlCGj//eb7taIdhYcOimk3py44JypJMQz0Pnh/wVGGT8sf0+i3xkXPSQLOg1lGRLaEwMUxoKQafHn3Eam3DOafMDNEU4Dpo48iQ/7tp1Kb+9JpObRQVU7bHDu4U5EOcvsIxmZbfy96bHdFbOLRYzIQofyHZOVoIq831JzEFphd5TIcesP1wDhAwcQ2Nx5PnMUarFI2zTl1x/KZd2Y2huLh9qVKpIghKbsEk+9jK7GakETWTtm1xHDgG5DcVRWB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GSGGpZ1L37r6RJnsKIbqumVe7EvPoTZFkp+QDw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: fwkX/2gh/9vVJjmrE8UCbLppm7WCU+k7SiP/KLk/KB5J1TZEjj9lc14pBYdGyQqeCkDsVlbvrlKErnaPJWcsDpTOf5V+PkY8KzA8NvWN7+tZu+n6NM5CHqB8Znf8nKUE4gnfjAdJ05YEk7HUM/9LHMdU1t7Sou9FcQYA1CAhgPI+YeUKJgt+FpvMl3Eyw1+Ki8Ah7V9/gZFRQjSuIJklfSUl1jHTYZgDYJUZ9NN+TPyv7Svh0DOjihYWT4gBgBMCQkV96w84F8TN6XgC9QZpeCi78pd4wj4leIxfHpAESr8Cq3/sWfUemaE0ekYRv6SHi5StyfpsAtIgBi948yS93thlExSI9hxgRoeoOqhWJ5XbeI4zWPQoV9YlT1Baoa8Rf3PbPU/bnkZ/Y+AMKTSa/cwVBBn2+DF40CWFlnQw8DN/Jg58wwqO6WJ6dOuuEf2+HuZowWSYxgelIsK9Hzb1/Owy+OL5JMpUysFuOvmPKFFIO3oAqQHQG7qCsu2wr7ZdVz+wIfUKTAlpweQGNH6pNuTW3mh/6VF5u3m8q5XOU8b/LO/a6VbY+SvKR/Vs9aAxY+MS90unoz1SBsvEsTXrFWBGRanD5pAj1r1C4Ml6fjY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6292d4ee-5e68-40be-b81e-08dcc8a872a2 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:38.4006 (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: JSl3n9qNTldgPnkDsqEB+3OofRDEUUNgefVvvnPpx+/52e6dMDWf1u6PM94uDhvamCHQ7/j2u3g+sAV4iDQTsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: TfGlakqAfAFPkZf5yC4KLqBVn5ZsHpXg X-Proofpoint-ORIG-GUID: TfGlakqAfAFPkZf5yC4KLqBVn5ZsHpXg X-Rspamd-Queue-Id: 2A7F51C0004 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 7t9hsxpn9j3w1bybkck9jwtuhgwuxijc X-HE-Tag: 1724990510-517691 X-HE-Meta: U2FsdGVkX1/WCMhxPpyoDmn61WV95HjfJG4sOxYFFtjvdhWiFCNQBSlWqXPVhExd1XuNzbM8uZsG6P1YhE/5v5115IUYYtRfC/xHQGGKVvabkQZOuVCHMAvsEau2hBJp27jtI4g4+dZxyJyuxGMrVlGHRfWgxMMeOOW9+6ZkTHusiNbkiDsDvFjgeBsdaosEZv/YVLvw/LoxGSo49vT5hxttDXmwm57HrwJ/aURGXrJkc1ZB5JopxnPQXuv595qB0FOZuc7lqnzyYfa70u/5TgHG0I/h0DgynyQp6PBlJZpoa0Adq+YNWt35jVuPhY8ATEpZzBPOB3ugpTQhOLITBp9diWW4gfYkOMWDU55qWtIemwigUBT2TxPnohJ/16DY7pBcyjnGsFoiuSjrlyfe/kL8dcsDUqJcDjTAUyzxzlqmcr2edoNZZ1m2+IG4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org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Instead of zeroing the vma tree and then overwriting the area, let the area be overwritten and then clean up the gathered vmas using vms_complete_munmap_vmas(). To ensure locking is downgraded correctly, the mm is set regardless of MAP_FIXED or not (NULL vma). If a driver is mapping over an existing vma, then clear the ptes before the call_mmap() invocation. This is done using the vms_clean_up_area() helper. If there is a close vm_ops, that must also be called to ensure any cleanup is done before mapping over the area. This also means that calling open has been added to the abort of an unmap operation, for now. Since vm_ops->open() and vm_ops->close() are not always undo each other (state cleanup may exist in ->close() that is lost forever), the code cannot be left in this way, but that change has been isolated to another commit to make this point very obvious for traceability. Temporarily keep track of the number of pages that will be removed and reduce the charged amount. This also drops the validate_mm() call in the vma_expand() function. It is necessary to drop the validate as it would fail since the mm map_count would be incorrect during a vma expansion, prior to the cleanup from vms_complete_munmap_vmas(). Clean up the error handing of the vms_gather_munmap_vmas() by calling the verification within the function. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 57 ++++++++++++++++++++++++++----------------------------- mm/vma.c | 54 ++++++++++++++++++++++++++++++++++++++++------------ mm/vma.h | 22 +++++++++++++++------ 3 files changed, 85 insertions(+), 48 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 304dc085533a..405e0432c78e 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); @@ -1403,13 +1399,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (error) goto gather_failed; - /* Remove any existing mappings from the vma tree */ - error = vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL); - if (error) - 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 = NULL; @@ -1425,8 +1414,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; } @@ -1475,10 +1466,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); @@ -1487,6 +1476,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; @@ -1577,6 +1571,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) || @@ -1605,7 +1602,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) { @@ -1625,9 +1622,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (charged) vm_unacct_memory(charged); -clear_tree_failed: - if (vms.vma_count) - abort_munmap_vmas(&mas_detach); +abort_munmap: + if (vms.nr_pages) + abort_munmap_vmas(&mas_detach, vms.closed_vm_ops); gather_failed: validate_mm(mm); return error; @@ -1960,7 +1957,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 83c5c46c67b9..648c58da8ad4 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -136,10 +136,10 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags, /* * Close a vm structure and free it. */ -void remove_vma(struct vm_area_struct *vma, bool unreachable) +void remove_vma(struct vm_area_struct *vma, bool unreachable, bool closed) { might_sleep(); - if (vma->vm_ops && vma->vm_ops->close) + if (!closed && vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); if (vma->vm_file) fput(vma->vm_file); @@ -521,7 +521,6 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_iter_store(vmi, vma); vma_complete(&vp, vmi, vma->vm_mm); - validate_mm(vma->vm_mm); return 0; nomem: @@ -645,11 +644,14 @@ void vma_complete(struct vma_prepare *vp, uprobe_mmap(vp->insert); } -static void vms_complete_pte_clear(struct vma_munmap_struct *vms, - struct ma_state *mas_detach, bool mm_wr_locked) +static inline void vms_clear_ptes(struct vma_munmap_struct *vms, + struct ma_state *mas_detach, bool mm_wr_locked) { struct mmu_gather tlb; + if (!vms->clear_ptes) /* Nothing to do */ + return; + /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. @@ -658,11 +660,31 @@ static void vms_complete_pte_clear(struct vma_munmap_struct *vms, lru_add_drain(); tlb_gather_mmu(&tlb, vms->mm); update_hiwater_rss(vms->mm); - unmap_vmas(&tlb, mas_detach, vms->vma, vms->start, vms->end, vms->vma_count, mm_wr_locked); + unmap_vmas(&tlb, mas_detach, vms->vma, vms->start, vms->end, + vms->vma_count, mm_wr_locked); + mas_set(mas_detach, 1); /* start and end may be different if there is no prev or next vma. */ - free_pgtables(&tlb, mas_detach, vms->vma, vms->unmap_start, vms->unmap_end, mm_wr_locked); + free_pgtables(&tlb, mas_detach, vms->vma, vms->unmap_start, + vms->unmap_end, mm_wr_locked); tlb_finish_mmu(&tlb); + vms->clear_ptes = false; +} + +void vms_clean_up_area(struct vma_munmap_struct *vms, + struct ma_state *mas_detach, bool mm_wr_locked) +{ + struct vm_area_struct *vma; + + if (!vms->nr_pages) + return; + + vms_clear_ptes(vms, mas_detach, mm_wr_locked); + mas_set(mas_detach, 0); + mas_for_each(mas_detach, vma, ULONG_MAX) + if (vma->vm_ops && vma->vm_ops->close) + vma->vm_ops->close(vma); + vms->closed_vm_ops = true; } /* @@ -686,7 +708,10 @@ void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, if (vms->unlock) mmap_write_downgrade(mm); - vms_complete_pte_clear(vms, mas_detach, !vms->unlock); + if (!vms->nr_pages) + return; + + vms_clear_ptes(vms, mas_detach, !vms->unlock); /* Update high watermark before we lower total_vm */ update_hiwater_vm(mm); /* Stat accounting */ @@ -702,7 +727,7 @@ void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, /* Remove and clean up vmas */ mas_set(mas_detach, 0); mas_for_each(mas_detach, vma, ULONG_MAX) - remove_vma(vma, false); + remove_vma(vma, /* = */ false, vms->closed_vm_ops); vm_unacct_memory(vms->nr_accounted); validate_mm(mm); @@ -846,13 +871,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; @@ -897,7 +923,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; @@ -1615,17 +1641,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 82ba48174341..64b44f5a0a11 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 @@ -96,14 +98,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; @@ -113,6 +114,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; } #endif @@ -122,18 +125,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); } @@ -147,7 +156,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); @@ -261,7 +270,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 Fri Aug 30 04:00:55 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: 13784192 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 E0822CA0EDC for ; Fri, 30 Aug 2024 04:02:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80E9D6B00A2; Fri, 30 Aug 2024 00:01:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 796036B00A3; Fri, 30 Aug 2024 00:01:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 576C16B00A4; Fri, 30 Aug 2024 00:01:57 -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 2B17A6B00A2 for ; Fri, 30 Aug 2024 00:01:57 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D6CBD1A0C05 for ; Fri, 30 Aug 2024 04:01:56 +0000 (UTC) X-FDA: 82507563432.16.EEBE8E7 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf22.hostedemail.com (Postfix) with ESMTP id 6F9FAC0006 for ; Fri, 30 Aug 2024 04:01:53 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oIVLn1Qt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=hKYivDEE; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf22.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=1724990492; a=rsa-sha256; cv=pass; b=M6dTA7LE+PUIXwgxgRD0B7JRU3KgAwFar8yrhcZpz8S9PHhMzecASCWUKgZSMko1Xo0Qv2 t0NLZSlH5SaUOZB60TjnzWvG2YEfAdIfVx7sf9xSIw1Mey06a4D3g2tggXkpRgt1GwZDuR OuL7KLBDHMTRNywN89/nrKz47S5GiI8= ARC-Authentication-Results: i=2; imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oIVLn1Qt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=hKYivDEE; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf22.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=1724990492; 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=QPEwLzEB0vrYF3G7jIZC0g0ABlZtn3Z7lT23QgU8XIg=; b=E19WcZDih2uMe+dNE6lGgp5u7cDVPVvO9NqxwXNQWi5mUZmL96jBFCszJIXoyFEiAWrQ2O FSiWWHybaWH/AHaqk3qzY1h0scKL5QB4HEGj2AaWq57KnqpGec+l11AljyCqViDziP9OiB QG/VYfAdNLP8FoZX3vHwfxL4QUXmv4U= 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 47U3MisH024297; Fri, 30 Aug 2024 04:01:45 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=QPEwLzEB0vrYF3G7jIZC0g0ABlZtn3Z7lT23QgU8XIg=; b= oIVLn1QtYiqpTfBN9QkQCULLw6LoaMfyVl/NiPKdYy5Tam+wTuUWRqrpXvejojs1 b3mTEH/51FWcN7edjcBvwX63rv+ZcSnshpa0cWiHBA+BTnYHy0HR+yCYuVOj39JU tVYT7jrc/D10+rUBigkPpb5lS51CRhv/OtUhtqcWmnIz/DbGdkOnNaxIGX6QSaia IXKX6GHLOZkBlQSDR1Umb+e+zd7Vxs6Fqv+YgnBjZO5NvyMww0AvY75Gf3Qtk1Lk YpRtXRhyjdfelVLleSA7hpHFmo1QbvRdXBoPsnA5YR2ABFTDM2L1sTvAZe6ZLoau eEhIDUsOXtsJMXo8gr213A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b3myr58m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:44 +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 47U23Wd3020188; Fri, 30 Aug 2024 04:01:43 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2045.outbound.protection.outlook.com [104.47.70.45]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 418j8ra3cr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=y5USXT9gwngBKjkv0pwdNA5LVW2fhu8/z3yXafo414KnLurda5t0Vq7dH2ncn258TfSSqe3QRcvprxuT7gMzTP5ZKULiheZn+LrIjd2RoOJq8eTU9pgqvv7FGgGIE810JLYYUgYKJ455nC7/Q0rB86gX3b9wiK/+flITQAtBasiDyVMkKZumvXWMHrjT6nlczzVJdRfVqDJIJ8ts+LOMeTwMiDNHDZB06tEiEKRLl7hI1z9drMrEp5Ict4JYRTTvynQiC/dQC5tCpHPgv+gl9u2yHnwkXih46sX72aL660lUVr6goE6jDKqhlDI3sl2LBCUU5/4lJDRbwH0aMs8/xQ== 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=QPEwLzEB0vrYF3G7jIZC0g0ABlZtn3Z7lT23QgU8XIg=; b=xrjqbp8m2DdJE9eES/UX+7LOfJNr4setcy+6KakuAeIXVtJngK7JxOH0ImEcrwer9ljH8tPNMCd3FJrwbcakHKeC+NfBuqVMaY+3eBdVGfEC8lyI9KoqpHKxkbh5+lxEdiRslZHzyG2iKEtIcb7Qed475cLw/GwSYgreOWjRQHbuq4sXYrR0FdqET7vKne3CxhrJIRz1NG3yTXZDfevtRczrVbjTUeY5ol+30AEXQ/0M/eE0oCg82nrielnmh42gd4+pcZWyT9CK7+/KgIDopvacE26X25nj8ab57CS/5zOFBlvRixxZTiyFikOWkz8ZUNwghzSMSdx0C2Fuv5a3Mw== 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=QPEwLzEB0vrYF3G7jIZC0g0ABlZtn3Z7lT23QgU8XIg=; b=hKYivDEEwLko5+7bZMtk66vCWIlVy+5XAl3sHNENy/sjZ+0hQbA7AlY+7z24m2y2nRSDrYHqYqcD+eNIaK5wpa+d5y3hmSvL4VC1REWkv7nA2SqRg3uxG6PIGKP0x6Ipv4jF8Ti7xGFjlJXsmBDpGwEMWpzszg62l5/o4AUvzpY= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CYXPR10MB7949.namprd10.prod.outlook.com (2603:10b6:930:e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 04:01:41 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:41 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 15/21] mm: Change failure of MAP_FIXED to restoring the gap on failure Date: Fri, 30 Aug 2024 00:00:55 -0400 Message-ID: <20240830040101.822209-16-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0131.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:83::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_|CYXPR10MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: 9be7a624-6951-4625-c0c4-08dcc8a87439 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: BlgNi9KzZlcfM22/qdU5AjWVTIqsES8rJFUokx6Lh3FPRcpU9VZ/QZCjFEh99f8GsFutHHzhNRZMD0tj7MX1zxtiyV/Z9myJ0OBjg7/fEUkH1iNop2Y/VqBFNsXDE0OZcNAur/8dc5XwAXbBCJM5Y3I3s0VCTrbwCZmj2Scvxundq+8Ibp/CuWT+iKZCJuOpxx30CARFnFG6OAWJyasyJT6Bdbd5H3pi4c3rsLiibreeVjYQkjUIpenQwP63GbJuc0X+5pyoSpdRLJfKkAdgjWS/gYAILvTpYu8v0gm33QwmojqzHYFCV/cR7WpoNpQ/MEm6aziQjBxVJKeLjzesMKecGUJImM2z1cbuje5XRSP7afO0J2peNfSudlufHE6Fz1jAw2N4IFHjj8fZ6XSIxwHS6zkP8DeGxMr/tPQT1fanLOK0RykcBKWZctC1n7//y0NU51kj7wUjP72OyENxuYGyqmCpe1BZ9qzg3boWD82mPsxsS6L5GkgM1BpuSTaqjHjwAo66lTCj7xYvUaiaNxgmB275+w1jKiL/gg9ozn6HQ1tU2LA4PEeHp7iwY3OxaCFhj+3L3/yMsCZ1M/sbVMT13NIolUYbV3HdtMHbaL3Pn73HZnkCmvah4Jj5ILluREJ17LEIlGXTjx5tqG8E1KEG21wvE6DWe6nuz2hGd/Zo/kNfGyUvJkgmHiH9ehb2Ywofv4w8wAWMAQ2caPetjKlXHR/998updPrHwkXTOMYPmshYMkH4c/n4mhd0c40+M+zutD36S8nMIsHzcYyY6Od1rjU8mCBfXeMHzZX//XdxHyoxBua2mSz+U8aRWb/VJQHWXmnrrrZPOuDSxRwgwOtxTmckAq62HZmyQYr/9nLrF5x1shID3bJ4bRDNeRc1247AKLJV2rHiiU6evafh/m5zJCsGGTXPbKFBqpICRGB04QXGUuTLx2qMMjt0I3sono3X05Krvq21q1bofLR3E/uBjDNpL/kJo+ulM/htWdM7jRJeUqfVbBRo+rT0uXmQeynVW9hlmioNdozGDk6bxae7oeceD/eiNJp75Nb1M9WCKVpcP5fs81lZjZjPTNUrPXzxnU1bTkSQdGP87t5Jali8xa3OORH5ZYcBXNw66rRNLlJBnObLrldx5qp3GCXI+FNQNkS+PP2EUz8g1cGGZM3/C0nPmRAJONTcB3SIh/pUKaQPduSCb6qR0OorHCiZp+HRto7Z+9eX2kwHxYJM2fVI4/kkFms9q/ceIRyuINRUyCLZj3Tihi3VW4/Sk17sMQt5b/7Y/KE17PlJRQURiU5/yqNLN+hHCueG+zEnSFL/JE3JAAGhSuJu80rV0BBah/Lw6cFMD7OYDWas7Tw6uA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dBPoZ/xrFP1QpT8FaUC9wUgjALRTUgWfufcIY2r2oDnjXUMuFqkCW8JBWJ0YDtF4MCEo6lW5jSuQf5M3fRvVhk/ZdYnGqrnmgzFqmEoy9uV2VHV6sDtdMo77hyqezwau02+5E9n6T62OBkcOfxvJ1pVl71fIkOcMgt8szE2+6oGL8i67qO1uuv5oZ21eyNfIuKRAwtJMr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NWth5somskKW9iYezyud0RsF11YMz6nFzFCvPVmGdmKHzhm8sbzc53rKRmV15kD5Wv9OswNM0+k1s6g+9BWI/cuBRyhGKPbNG/65O0ymLzJSYEtkhGCfWvHIUMPWhD7/vjLn+Jzxm+awkoKtwXwO3B+9R/CSEfZdgf6tXy5EfPP1ZCgaatqVoIceJ0DUxe6xHKaL5/gPs/SDCuJojXDYf2LvMamntb/xA83l28YYwAPdQtnZswc93REHmAHiF/a6DOY54gM2SJGh6POwt5s0jQ0QXs8tQ+3g3Cui6annAEfGYsFV9KTZX7f3EmonbEShwTEyho6GfWA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: RDkc3CbdVh+wlNSGqZANCw4pEcUxwHPGjBCiPAFjgd7dx1CzIHbB/61wu9qa4qL+8e1W1o4C+afzYt2cHxcCi53VWwlfACyeu1kFYmZfueWsYdcKJZ1+Ek4xMFjab55PR0W/AizjnWB78/CT20aoE+G8YSkQbstw2xdfVprnf03AvNCFv3gNUnZOe6QvXPYLuDWj8UUmJaEVdpb0dDIx+/NOhnJZszO/Sxk0SDuMcELx/FXlA39vNz/8yRq0XpnYQX1GXnxtTCiWqgNZBjeZx+BdhWq6napyekXS7EdllzKyiPtMADwejhJVKUWwaPSHIXjJlR4sqWSF2kCwLtq/iKV/7FfoBHKEqu46agy/Fm28pDEErHgRGPoL0PkbmQ6bTfdU/DGLC9g6bPNi0EDn1G+fqDWgP26u/ZFOR4AjdkSh23ajtrNKE6ZzKip9/h3HWX8o56gMoWEA7Lf/od6q6V+fb4DQV+rY9t7NXJ0Ne7rYPGT0lm9NCpdQHxvSYO7qG18KXA7quQm8yu13yN8bwHSdm5zFSyKEf3fhW7P9ojrDIo2e4qB3zJTZZzRN3ZBEl49YuPUqT84OiGwcEKITsG7G3kwiMmTvTThhXTeXuAQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9be7a624-6951-4625-c0c4-08dcc8a87439 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:41.0802 (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: tNRQp0Obemw0EyLJlP7yF5jNTf+wkh5vFd6wQzuLDS5I3xJk70LlptuTHk6TuG19owUyp4v5lgpD2jq13086XQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7949 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: Pg36GqwKrh4Su6Vegp2Qn8TUrdhJyRF8 X-Proofpoint-ORIG-GUID: Pg36GqwKrh4Su6Vegp2Qn8TUrdhJyRF8 X-Rspam-User: X-Rspamd-Queue-Id: 6F9FAC0006 X-Rspamd-Server: rspam01 X-Stat-Signature: j4z1h9tx4ms5omakpgdb7ydeb79fgtci X-HE-Tag: 1724990513-580771 X-HE-Meta: U2FsdGVkX198CN3mT7hFbhmhhLVUHhgYkagSL8KbfXmiq/9NU5/bJUdd5OOn2NMdQ6Bl8oLQyQTlPqSqiASUx4eK71FZkIoJG3VAQz539fJD858xTMLHDB4TMr5++l2WXPuP8OygoI3DF/K+iI7sxy5I9npcOceJjARurrOOzBF8sMe820q3r+w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pg7q/2l31KZRdcDH92IvZ4RradEC1fIgxdPn9/WBWgyQZbaSmgQohkOaavSWZxO9Xll3vvG9peRZZzlteovlsoI0nXfF3PqIoiDHmtZABTY3rBJ2mlmH46Wi9H5065hhvYlRH4JetaNlMldZFxEJdx7tq2FkPbjjj70+gm1fKDqRzfwmjjGEeNzRrkRhictf2fWFN8nZfPJocBDNcpXCZYiFNmE8zg/Wlont15McXfikaTp3bTIYDse54VIcBngmCaIDoLmNDWhXSQXOV31ILvRI5n64Ks+ko4ocykp7yO+z3iCyStxoe2HThpI/CU8gwOSObJn7HLDBmqiyL7AlAR3PBpwYUYXJPD7Zil655nH6wTXFkl5r X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Prior to call_mmap(), the vmas that will be replaced need to clear the way for what may happen in the call_mmap(). This clean up work includes clearing the ptes and calling the close() vm_ops. Some users do more setup than can be restored by calling the vm_ops open() function. It is safer to store the gap in the vma tree in these cases. That is to say that the failure scenario that existed before the MAP_FIXED gap exposure is restored as it is safer than trying to undo a partial mapping. Since abort_munmap_vmas() is only reattaching vmas with this change, the function is renamed to reattach_vmas(). There is also a secondary failure that may occur if there is not enough memory to store the gap. In this case, the vmas are reattached and resources freed. If the system cannot complete the call_mmap() and fails to allocate with GFP_KERNEL, then the system will print a warning about the failure. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes Signed-off-by: Lorenzo Stoakes --- mm/mmap.c | 3 +-- mm/vma.c | 4 +-- mm/vma.h | 80 ++++++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 61 insertions(+), 26 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 405e0432c78e..e1e5c78b6c3c 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1623,8 +1623,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); gather_failed: validate_mm(mm); return error; diff --git a/mm/vma.c b/mm/vma.c index 648c58da8ad4..d2d71d659d1e 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -878,7 +878,7 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, munmap_gather_failed: end_split_failed: modify_vma_failed: - abort_munmap_vmas(mas_detach, /* closed = */ false); + reattach_vmas(mas_detach); start_split_failed: map_count_exceeded: return error; @@ -923,7 +923,7 @@ int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, return 0; clear_tree_failed: - abort_munmap_vmas(&mas_detach, /* closed = */ false); + reattach_vmas(&mas_detach); gather_failed: validate_mm(mm); return error; diff --git a/mm/vma.h b/mm/vma.h index 64b44f5a0a11..b2306d13d456 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; +} + #ifdef CONFIG_MMU /* * init_vma_munmap() - Initializer wrapper for vma_munmap_struct @@ -129,24 +145,60 @@ void vms_clean_up_area(struct vma_munmap_struct *vms, struct ma_state *mas_detach, bool mm_wr_locked); /* - * abort_munmap_vmas - Undo any munmap work and free resources + * reattach_vmas() - Undo any munmap work and free resources + * @mas_detach: The maple state with the detached maple tree * * Reattach any detached vmas and free up the maple tree used to track the vmas. */ -static inline void abort_munmap_vmas(struct ma_state *mas_detach, bool closed) +static inline void reattach_vmas(struct ma_state *mas_detach) { struct vm_area_struct *vma; mas_set(mas_detach, 0); - mas_for_each(mas_detach, vma, ULONG_MAX) { + mas_for_each(mas_detach, vma, ULONG_MAX) vma_mark_detached(vma, false); - if (closed && vma->vm_ops && vma->vm_ops->open) - vma->vm_ops->open(vma); - } __mt_destroy(mas_detach->tree); } +/* + * vms_abort_munmap_vmas() - Undo as much as possible from an aborted munmap() + * operation. + * @vms: The vma unmap structure + * @mas_detach: The maple state with the detached maple tree + * + * Reattach any detached vmas, free up the maple tree used to track the vmas. + * If that's not possible because the ptes are cleared (and vm_ops->closed() may + * have been called), then a NULL is written over the vmas and the vmas are + * removed (munmap() completed). + */ +static inline void vms_abort_munmap_vmas(struct vma_munmap_struct *vms, + struct ma_state *mas_detach) +{ + struct ma_state *mas = &vms->vmi->mas; + if (!vms->nr_pages) + return; + + if (vms->clear_ptes) + return reattach_vmas(mas_detach); + + /* + * Aborting cannot just call the vm_ops open() because they are often + * not symmetrical and state data has been lost. Resort to the old + * failure method of leaving a gap where the MAP_FIXED mapping failed. + */ + mas_set_range(mas, vms->start, vms->end); + if (unlikely(mas_store_gfp(mas, NULL, GFP_KERNEL))) { + pr_warn_once("%s: (%d) Unable to abort munmap() operation\n", + current->comm, current->pid); + /* Leaving vmas detached and in-tree may hamper recovery */ + reattach_vmas(mas_detach); + } else { + /* Clean up the insertion of the unfortunate 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, @@ -299,22 +351,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 Fri Aug 30 04:00:56 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: 13784193 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 D96CBCA0EDB for ; Fri, 30 Aug 2024 04:02:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5546B6B00A7; Fri, 30 Aug 2024 00:01:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D5BC6B00A6; Fri, 30 Aug 2024 00:01:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21B866B00A7; Fri, 30 Aug 2024 00:01:59 -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 F10B16B00A5 for ; Fri, 30 Aug 2024 00:01:58 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A8EB8140CD1 for ; Fri, 30 Aug 2024 04:01:58 +0000 (UTC) X-FDA: 82507563516.09.C0E8C46 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 76A31C0005 for ; Fri, 30 Aug 2024 04:01:55 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=QLqZ8Jht; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=g1qbXRjR; 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=1724990494; a=rsa-sha256; cv=pass; b=iTnkEu5gIbxuua9wdGSnQ731ylGI7Ep/oxXLwlkZmrM0uG6ANDD62o08TLJCDxcZB5a3Ci 5x9jAVwYe/D3/6fqCCe3Z/Sh3EulgH8mdP0xsfvYv18fFm8sUrnVlOMxgTYFW1wxwuG8kM f0HRrGALUAzPz/K+RzUkS15MNJufhM8= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=QLqZ8Jht; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=g1qbXRjR; 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=1724990494; 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=wu2pkeT2CbgfgdpPn2Zuz7ayl+XthYdcArrCgG1Zpro=; b=iqVnMCXQi/ikOFa/HVtaoRuYGU2uCqbRS9Es/JndBBOK5I2uiXn56X9FyzyjYfExBM3Ezu 5ZCbRcPyWLKXGS3PGOiFNCRGVPkT8saqCKBUvxZ3EWZd4jyKe7BNEj+/a/u7EiKWofOFym Mkj1nRFsW3zUcENvq2d/ovsd00Un4fs= 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 47U3RDZi029580; Fri, 30 Aug 2024 04:01:47 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=wu2pkeT2CbgfgdpPn2Zuz7ayl+XthYdcArrCgG1Zpro=; b= QLqZ8JhtHL5vt89eNHFLnj0Ro7JveAhbmFiY4HfdgywuhjP2zzwgX+ZcuaZiM86o r4B+92enhp6FuSx+dYwU58pM3HKEq1wOZ7VbSEG6A5QZCThG5QfvjwmO5Zd5o2Ye 21xW66Bn0CaECDaVyGQETGyNaoXLSM0b2lQXNVh0mckBOW1ytp+QdV5aO6supKoK 16l3r1PL2kQBsgANCMXv4AU976IxpBEnLLSTOPeFmPCmGpwLOxKmrjlVSHiwDP6s kBbQMSNs7DgTHZcBsx4jT4PQrXhSxCG+K6iPEKxnmLncCPta6Tl+xzaPgdqoJSoR XsXKIlOsPMGH5zPZ0Mpk4w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b5q381hp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:47 +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 47U30EUJ016784; Fri, 30 Aug 2024 04:01:46 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2173.outbound.protection.outlook.com [104.47.58.173]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 418a5vy55m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J4LnhBMB+vckaocx9WVUVYLt4dJtSLHxALD3gzKqybTDcX8+msoVc0lJF4OSAmLFW1lB34/bjsOzCUYrGpsXdicXo5EmIuJW7mzO5znW8KEdHEK82hORK63ozLseOonG/ci6T1MXHjHrky+S4y1IMtbARkz08AVz2kcB/BzfULwJ/OUOGVMSFgBj7HvaqJuX+67nv+WBcEp916H8RKjTlq50jUkWh8s4w5EEhvSC7yHU4DtoRNGIUxiI3qrngwtWTPKIV9zU2/N/cGmbAo0Ql3i9pGgL9bbhvdcmFIfi76Or03L9EoH9Us2A6B8sySckvCp18vdTHFYAICnXsHRsFQ== 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=wu2pkeT2CbgfgdpPn2Zuz7ayl+XthYdcArrCgG1Zpro=; b=OfEmNfSUNJChy6O6LgP7D+RkPlsi0W8NECAY7AOIYvxVd0snSqTN1SP7gBBGu6xJYTYZpevDQVbLjNcLjzLjEaVew805t+VJueXl6RRyskJxbEVGy1M4jdlexrdUQJoYTK+HnGLwsRHuPIgarISYd/xFfiAefpJkg3D3F5hE8Bdl8CxAtuysQzkIlBZmq7/94W76eIAqzlTr6h8B2EVK+s5LwraJWrFBy0JzcsryqCsKjgqja0A1lJQ1h3C/7XWZcOr1cODZFFmg807j1d7qJcMtbGru94PqEqbHl9SQR0NuhOQSaPLYemskOJre3uKC+8i0yOFKiuQ+v5wiFjON4Q== 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=wu2pkeT2CbgfgdpPn2Zuz7ayl+XthYdcArrCgG1Zpro=; b=g1qbXRjRUCmrVKZoq56Bf1DjjR46X4MDZmRhBtDTppe/klsy79aY+m57tvoHuAkfFVjKWEzpN9qFhiBcVfg5Xv8bAJvc57pKpu5id6+eDtOfcbobFFkV1k5P5wOYmwJQHuDcZvWNAWokCrvn3WdQr0FfOBY6A9mRQzTQCveU5PM= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA3PR10MB8115.namprd10.prod.outlook.com (2603:10b6:208:506::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.19; Fri, 30 Aug 2024 04:01:43 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:43 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 16/21] mm/mmap: Use PHYS_PFN in mmap_region() Date: Fri, 30 Aug 2024 00:00:56 -0400 Message-ID: <20240830040101.822209-17-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0280.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:109::15) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA3PR10MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 3fa3af08-7d3e-4acd-e4c2-08dcc8a87565 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7416014; X-Microsoft-Antispam-Message-Info: cdLS9fsAz5u1d9J4yNn6mnGVP0f5qoZ2xVk4GPP3D5etmuiIKoeVtcgjOMClEEoT/HgcwyyXPOaIO04K/EgNe+0QZIj20UPVbRTfDEA9n1EIAWN3V9pd7/RDIJez82QBWUx8morc5KI42xFbcdpc74tZj13OdFl5z9IWnGWqOP/LKXSZCZKlzrHv3Sq0WgXhV4EuoZ5dg5fSsD+CsGsYfUDIkdvSIsQ9MNeBBUq/UbN5t2nC8pMC98uWX7r/v7P1+vvEQgFm4vLwl1HwyjbrSOsAx2+ONwUtNP+4n+cOHusOaGogRw6WoU4yI/Lv90lssBULBOv4WGsabwDTc4Lty3ssnNyRAF7sUHBY/2KyJknszWauxOuwISpVhJNwIC3Yc+RJlvo+DMZZ22vE2lhmy7QpjEbMVyYzJutNaX1V/2Vljo3/8gnlJDbbbkGvTVkbc2J0RpkANgEzJ+ypASfhGlhNCaCEnDwKSztTxENjl7ypFtTKKF8unsUR2lR8ufj+5OuvtR1yp95RcYV/yuMBakDGnnRMNB0uivxD+d1Q19IEuBocIk010wf84qs88hgdkD+4LzdDd405ExiF6AsfGdodkVx7AjIXVR7NsJHTXu/Io3Pu1qYDKvx3IGRDdcTFxhHLpcD5Lg03VrAqAEKzmsJfSYGChYxzVg11rv5oAr0wUsHBPH+7izLcnpTEPxPJ/hMKIHczVMXHvxLkYaBPt0GlybkkcP3hD5diuIZ5Lq8ynYB6wuOaOuVDDPGcLe5oL7EL1US+pIdiH+2FbdQjPnh1o8qmKbXcr9mptrjP1A02lqUVrFcpRaQbBqaVdSjrTarfhhZ5aL7VU/OXF8Lmv1v4CDWepSk5WamRbwjJamqaNP67h6zgPmOWmmI/K7SCscXWSefP3eY7V5J/WAHRgLAHMHay6agYe1APs12XT+tr80wHNeFw6wouZwyaE5u+OnK//kG5IbMrKr/qf4eX6pFI5a4Wrb0vcWvuZDQ6S0vVsLZjSSWjml2gD+2HnNeHDo/KajTaTaWAKYVT6hmbXObB1w7P5BaR6+L9yhNwKWRbScCYKOhUPAx+7t9luZmJ+z9MoDf5QuAfHGjx0RYb8pDUEuNbfLmktug19zUNRmgr4CJe3zd0pgAvy80LWNm+8HKA9QwxKXuicver1l6d0bMULxZOi3BzOJuaVP1InNjL6hDzTh6lzG9LUcpsmZ3q2Oilw5YRfMfN/OA2hAJDezCAy2J46ltgYZjP04f8i7L7c2dCBlgN1qf/1fXcxvL1AMp/RmrE5rozZ9/F3l84YURKbvYMWNcqRddesQp1HbBsshwddU9TFSXtjNDzA7bbv+6uJSpdHyHBVooskPsZ4A== 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)(1800799024)(366016)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CXTUPXpezwFqC9FRFPZWEOqcuYg4pE6GrJZQ+ih4DgjndUk5LK6gpa/uc9wOLZ6krAiZojq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pYp72OHC3m02NH41ZY+KHiHZWzM6X85tBK4ySqQx4njAGo+grEdNjp5LPwbv6EXZ3sRX8uGog8v0PD+AlH46lX9oBbHFqJ0QUDKhdPNGTYZnUQ9SgDsIrBI+V6abiDXo7mQDpa3Y+sSxsoKLYDruLi7e74BczR9S2WiRCt9wW4bR3ZooixqdlR8R9vJDcnRQepamCWqEudtIfKwEwh7JAPgYKyNxFvSwNB5BziLEYqhDz7/0huxa8frKbby4lEdKNxlk5VUOsA+q2cBmZDd/rdghFJPjTmYSrDrqCvGSzA0J8ttKIphm6dBieD5cZPKg0AIhZLMhL8zh/UzXL9WVmoKNvhSkIIMIrRuuSHfIYgAKfP0ZytZDUfmqerpBOYSvIIFUy/Mkuc1Y5MiOKsoSzfaCWPzQkRzpLj8/6w/drrKBxeMjwth9c2YOV/VZ0G6voN3VUOZEEOsVhNUXByzfLSZTYCbpLFw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: vjJYDxKPjuLEJayaxiWbLOwoptTvnAdF405r/eI9Lwi17DExpb9fgFK4SYXCyufnuY9V/LxplL61wM3DvbgULHp1vinXsX+zE56o5AdFaiHGl1YWt2pICrtwOuYE0+v43029+Ug/8yS1F8Luiq9cvA4r8Lnq2Gz2dxjERF7R7cq/0p7azoKHwbOss4trVTRD2oosp1vUoK4Sd0y9g9/S/3aOfnb8xXQeBrnTSffAMGyxaivHBut/RluNdr6nyiqNxCW8cpocTwVoTuYtIb0x5iTrxcTy+psZo/2L9UzBuMfePZxhti1VqiVY2jUdK8Xhc3f1rNocubrFRuIbcSJMQdIllEe1m7Qu+NsNI75O7A5puraaoumrzZ53k/mTrfoxPJIVxjGsf9OE0XfUGea7cm3TFrLGg22JJtmXpZr1EyTc9LHLx7z6Faepcz/NYba14eaetsFSAV8IvK2ZpBXP2pNyLDXZgwfou6WnGxmajWup805Ef20EMPUEACiase8qq5DshKm63Jt8drs+ncOLxlbuXi3BcIBHOZodj4mRa8qKAxYnJ3fzH/8Hws3BC9FX5I4N0h1mEnnq9xCg6g8Lswro50XackSBhNg3OgF73II= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fa3af08-7d3e-4acd-e4c2-08dcc8a87565 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:43.0398 (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: Z3LTC2rv4wxWELSRkXCA5kzst/kLKALzC+1qWH8+snGZAxFWZIazJ0PfVCvuUGaBqz3xy9cgL+ZgaEK36YEBKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8115 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: xtpqy_dRwCm76aPN4EPg24Ekjl_gyL1N X-Proofpoint-ORIG-GUID: xtpqy_dRwCm76aPN4EPg24Ekjl_gyL1N X-Rspam-User: X-Rspamd-Queue-Id: 76A31C0005 X-Rspamd-Server: rspam01 X-Stat-Signature: a8hoxh4c1w9zxrx9hd7nq3g8t3of6api X-HE-Tag: 1724990515-58320 X-HE-Meta: U2FsdGVkX1/suVBnPXTVpttG0BTAantYg3/Q2rbHZ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3uelLjkoDW5ukkZ+cqIm44gplHMRhSt9hgiFCdZuynaXziSuyncVpK8wrFmly1Pk+QRfzU74/R1SzJ1eljMoD7x6G/C+UHQ5cZp8fuzJQfZNOOyMasdc226FpTcuRu6IAW2jMqDPbcth8ooFphCmnsYL35ySinmYyQzU5zQQm2oVRCaCFrCltvWFztML9MYvNgmQlveJQCbwyfY3VpZDcwV/BB8EucNfIszsDJJgDALgUFPhhD/KbfFb64R65CpNUzvpDG5fPSKkJCZl2e1fiXVnxZQADx1uZVV2kI6Ui7oTm9D8sWNjZuor1CKimG/7KRokRIWU/l646FQoncDPRwRrweNDLyHmffetOw5cqR34o6XH70x6PUy3oBr1HWtlT+TZtji/iVg2lxv9JoANbCy/quNCKLBdhKuasWxDXwDQJA46XfuZZ+q0xli2xH9mmhL+hyWMA= 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 e1e5c78b6c3c..cd09dd164e85 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 */ @@ -1413,7 +1413,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; @@ -1574,14 +1574,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 Fri Aug 30 04:00:57 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: 13784196 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 E72CDCA0EDA for ; Fri, 30 Aug 2024 04:02:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3B6C6B00AB; Fri, 30 Aug 2024 00:02:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC1306B00AD; Fri, 30 Aug 2024 00:02:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C77F56B00AC; Fri, 30 Aug 2024 00:02:07 -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 A1A646B00AB for ; Fri, 30 Aug 2024 00:02:07 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 296621413F3 for ; Fri, 30 Aug 2024 04:02:07 +0000 (UTC) X-FDA: 82507563894.08.9C75CA7 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf26.hostedemail.com (Postfix) with ESMTP id AAF7B14000B for ; Fri, 30 Aug 2024 04:02:02 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AW8qP50Z; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=zOX0Lq1h; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf26.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; 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=1724990432; 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=Fh3l+ME+2D7vTnslOnVr5R+ASSp1cx2+4oj0ezr+S0o=; b=Mkoxes1vx1q3gE+hZLFpUmquxA2xzy5SdvJjCMA4IbthhLz3YXPnkn+YUHOYdteg4kak01 4RIbnBMyHE09BJxYb+2MezbuefhFiPBL/rMNJwvyfUm+ePbJKIkTq5283ISDhasdUo3Mvz 23EbEJY4R30kgsMlgAhIiIuDEOJV2+8= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990432; a=rsa-sha256; cv=pass; b=mU3WfjfJp6C6GBsZNQ3Zlk/uKtiigtseEs3wrcj7WaRMnW//r2jmABal4DUXHePIqk+F0w zyM6CenWfvq8lW/j0n2uW9i5ju3YdeviNd5CV+016M8TXpqcBisS0SZ2tyxLgJJ5U8ypGy R5MfKtWtyULv4KLV6f+1UFUKx7P8gVc= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=AW8qP50Z; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=zOX0Lq1h; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf26.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com 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 47U2spMJ011846; Fri, 30 Aug 2024 04:01:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=Fh3l+ME+2D7vTnslOnVr5R+ASSp1cx2+4oj0ezr+S0o=; b= AW8qP50ZdPrr59k0Awon0f7KVdHmNpQrg7DMAvLeIzrTQQmhWtoWiJJ4AtFPc1aF 9La/UHDdTtIfDDKAfdLLVXfpDHJUTlNIu5XPrFdtlgBi1a62bLs4D6z9Wc+D5hjA d5lolj5Rd5iKbpSJXRX/41feo1UFvExpNp7k2A4J4CHPuIZ2Jgy+V3UBkIPacmQM 0riDZcYKvhEUEVI9Cuc4i7iEhvw+GtVEfQFZpgAR0ZUnGWruOi1Lh1mHq0D1dmTr Ji8LKK1cg+Jme8F+bYGxb11b+DSnReNo2daOGaWC5lgwAWzW8j6oRl6DAY6KIOkR OIzRrVTXhytj0D4GtzUrcQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b5q3r1vt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:53 +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 47U0LvZl036604; Fri, 30 Aug 2024 04:01:52 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2tga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AVg/LzYQS2LiG4JE1LgW87riTPnFevCF/vBEXKvGQBGtEppzcGZis0QsF4+pa8iaax/d+5jFMzst4Vg9OFNBBBkNIY93exbajigYPcRJSLFqQiogBp0UG46/696+NMTV/sF1PtK421N/+71pIfHpDmltceE/HMRyVVgyML22wgI21mRG4NtN9w3sd34ULUqfoflsi38aqKyKEsifJw4Gj/ltElwxWcLlftsDBPSu8qYytURjz+And/HIjxwTEVgQ/H1bOdNghTubexI19/tiJCQBz9w6nZ8hrwuqog5R6bIdzkGfVIz3TBgebECOlKUH0P3pG/KsceBm/g/qv/USyg== 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=Fh3l+ME+2D7vTnslOnVr5R+ASSp1cx2+4oj0ezr+S0o=; b=VYFAcJ6lY8BddNaoQV+/bchKu/odF0gPZLXn+AILZwx8P1AMnF8AZdwUNrjXWfhWJrAdYjTZRw2hzbIR7bzhD9itm6seN6SaKPDSq9TEjdWoZ0cJi5TAdkGIgI8h+J7RZOff277Tp7nLqdvOkH5AYZgBgcFTWGSB80HxFW/z2LmX80MWco1gJ1RzTKn8QR84GrlCF/cOjM5um2tZop0E/B2PBrysxc4VdJ++Gomtf9Wpjd6Kz0CryivKepa83zB7FEjxwN2z/CU6tgFS8gv1955fbUGS87ExN+QuaxA5bZtViYRYvm6DOkmBCBcXjsrGGLxzAKz8NNFmDfpWrDcYwg== 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=Fh3l+ME+2D7vTnslOnVr5R+ASSp1cx2+4oj0ezr+S0o=; b=zOX0Lq1hj2KUseFK1BpoKXzRr1RiLEd3Ugr6EWY5trF5Qq/qiNpbTJtTHpoKzdXovIo8ywOhaOLS+QwLs8Bs+bI5w3sJCWt4rx/52vBjFHWA2a1lYe9+w0PwECrz0PASqFsFKL5dOT2LlXglCY+r37SRhpauKg+NCTs/p9eBOHw= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA3PR10MB8115.namprd10.prod.outlook.com (2603:10b6:208:506::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.19; Fri, 30 Aug 2024 04:01:45 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:45 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" , linux-security-module@vger.kernel.org, Paul Moore Subject: [PATCH v8 17/21] mm/mmap: Use vms accounted pages in mmap_region() Date: Fri, 30 Aug 2024 00:00:57 -0400 Message-ID: <20240830040101.822209-18-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0471.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d6::22) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA3PR10MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: b703611d-698d-4682-b586-08dcc8a876aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7416014; X-Microsoft-Antispam-Message-Info: MbKYf82IheOWPipB6jwqnALZ9QWjS2XCQoSs+NLxlWTTvQPaRmdPEFHS/96mmS+0z9DO5OZRVc7w4saf5zbmf0ggKkE+vqgT0rMLmY+UkJbgVPRrBaJA3lCYzYzibqFUgBljCYkKaB0NseDe0vc9zOPuGPmuafXEakCDJVuQEjW1SZdsgdxcMHPjrzL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7gxbiZXAUIGKop8IixPgP81Q2HO9wiXPHeyYVdgKGUiW04r5JAAmXiE9UMlGymXGHoojjwBbf5odYrga/0QX7xCr75ccFthZzurL/PqVqmxHDQ== 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)(1800799024)(366016)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H/OP+8isgW2W26K7s+IcK0vFBt9txn7E4pDhvgHYPgzs6qsci+UcrzxO9ZrXTYz9S4DQLx5R8KSVGAoXTYbAjPrnuEdRihpy+1fboK39wFUIFwwCRM59WYxtsLTw6j1tkJJEz040YmoLeLfjK+XFN1sVWCESkJNz4KxxAhRXe5gS+P1alP/7KmqUjZ/BhBN0jEXSV91v+aiS0o56RhExFDAdY2Lx+N3SQsugRJoNi4EBhg/nf4aOV1ilxSjxz5nD+ijsp44rIRojhDnbCWwj1dqo2ffmuL5MKcQkcBUA9JbiHGfBz53j7h+P/pjutWVttbnJHIvVvvfWMWjZ/pNOi3Oo/eZx3hu66pb+0sjZRdaarPK87U9An6MR95EL3znuIVfJCtFPIsPHLNE25i01/+5bxqrsmY37403dzvvTIAv2+oNhmusWwVLy6H8tLXej/ZxoCKXI0T2pZ2G16tLyzCx5nCreo/Ma/5FEykQoI+qOfZHqeV3jtlGrMbFstd6VMYDjZNNbnvnxGjN/D1LsJv2hyh6wf7YorU7MDC5e7Gzb7pyRhtNKtoW3WkOWSivy0UbC9tPAd9gGuB/iJoXRgbPrl0N/OKaWUGM2cjnBnIvzKGud5ptMdw+RVAegjieAWzvdY5ZzJTIZ6TPyF4ufzKn/QoPvY/ssvQxFv1QQdciOW8kEQ5EcajfnW7bOwxLCvd8wF6Nu6AgnXkrUrAirKvnlGvHKq2Mb2x0x3KxdfjDO72y5JNsYkoQwyn9Waj6MFz94EDSTVeIepEuJrlMojOX7AHupDrCbvVCm7I+EK9FrVeha51s+nNA6FVcZZl/0abkNV4MhK/1C3jcUZGSdYC9vZ78jQJk3+0gQwcANsCn0Qvny2/gMLZmrfLfpBI6cVRCLfwmfpwb64E+p+HJkUShPD7Ao2/hOz6uXZdcO9TUr1xyeEy4NHDqreHtUSeK+EPRnXKaWjeFmeonmTU+FgytBf6l3HEQfDKpIZ/1L4Htrhh2t6ZSex2Xmc339w0898xjHjruw1xJIwz66U3lKk6+cQQ2k7Sp+PKzNBVLOKqA1PEfT0Thd3lUnk3QVHN7wZJxXl0YxmyczZgK91CM2TcAb4CpUQ7IM8O3ADDw7Ljmdgf+VBeohkHcXfyTcJtGBom1DUb2S+KnFOGAnijc3lATBVqKX6CCCS4XOUioIOe9dZ1wbcljXS1qovdrAMABO50YW4NQv2ul4UTd1wIDWmsYDmYE6C4JHnPY2ZzxPG4FKjGhLs20rbDO2yW6X+/3EbqJeb2dY/nLTN8+R9PNoaHC3ziLaX0eP8CtYoOGgq/fwiFS2dHHHG5qVFxkfsatOuNUSUPOpPW05m6jncOiQmVPYmBwAA7aPG5o21wowx+5xFSAHNKcr1z3kV0y7RRTg67sAWYEF2mTMhGBs4FopBhw6CFq3TYrRAVStxOBZuezqogfOULebqy1qQ2t/p9Mrti0kyCadzFUbBLwMpRLuFnZNcHfvi67Zzka79SjGq/CbllsT01oAANmPjLGAakh+XBgwm613XULqQBZHlakZB61fPlt9KPbsUHarCXo3rrXX0KrPa9meGi1dtG4zEv5ehazl91fGXvX1gyUSPInTDQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: O5BnPQCHS421i/dEpaqvmRWx7eRO17/7t7QUSgJyV7CgfeyLvpNT93TBtpAU0V2YdmikyvHOuKysjsxtG6Fr3YIAJXHh3naO18sj9ELzmPJocOES0JNdf4fFrejUN7eMk8OTLYMoRcAMSgEAyARmvVhZtnK2kX17okeoYLEtOwpRkL+jFQmj10eAVQs+mTpdVHXybhMmTpjK7QW4nvJ8to1v4Uet8bR/s+AswRT+t7dy5ERL4+RLC2d06tdkTZLYXLgcFaNbh63mk7givJTQG/rfkJ2ZXlNFAonY+SvMTeQhysZHWAIS02LFUZU6tISilzFKWl33Uu2oPIMOaFfz8QQve3J3N0QJCOdSinUqxVXKxNmTW3UjI/UNhf5LvwVMF3COBzQC0jfkhsOVftVmpuJKYmA1AKndxS2jfbocBpTfa2jE5QUGxPu1YQhcHaLMEeHKLdMEtW9P21tNHQ/lRdCOpDJ+jahsar/kaywcc7SB9WAETe8ZuFwIMxvViV5PCUDldrNKzu9e/Nik1D7COUI4Y/gP2i+0yAkg/4eXk/0Aq0MKjZmRKQk08yeDFj/J+IEzFTx8XISnU6ayeUBoef5iYO6jbJqW+vMo/aFFClM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b703611d-698d-4682-b586-08dcc8a876aa X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:45.1835 (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: 8DSCd3HTkjiHgUd8TIevB3CaQsSSvjkuHDqJJT/P5MHoaYGv9kfvqh6DMqFnDw2mK23C53tyliYZipVgb37dcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8115 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: FmX4xC3_iodGktVw-_nHx0pwMM3pcAdl X-Proofpoint-ORIG-GUID: FmX4xC3_iodGktVw-_nHx0pwMM3pcAdl X-Stat-Signature: mynym5tur8enut9z4germ6u6j3ptd3r1 X-Rspamd-Queue-Id: AAF7B14000B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724990522-578246 X-HE-Meta: U2FsdGVkX19NynDZSOIuPe6npSHult66AUjIcYgYnZjHrsyOoslGADfWlnDJl4nEYl3X6lLSrbJMvj140bSNN+4+UwSUlcMADyDJN89MDtouBwCEZjJKVfKCQKwmskTc+ePgBJY7qLx4Ms+AQT5odgmbybprVIFO9Xyj9XP4QekI8vYNeo2msKldedEpc2iw9Y09Tgfxjh1js4ZLNRIupQ6YhWa6jQL94CoMfRvVO649qwRY+pgJyJcy/L7m0ijDm3I3/6LKALeLl01mg/IadByk5X1ZEzp6bnC58BUUG3cNbD3pe6rjlKmsf4kwY0h9mzy+zV7ZJZL5i2hg/7bXSXGXXv6a+xAXt0EPkc8YoM5rWbRDTFN7MkgDdVK7bwkgkPWCi9drZwniWLueJI65e8fPn0ARchEC62Qpr7WThStMJOYLrIm8nDRHlqJMIADTwc8ql6/giXIXAnso9a8WYOJ/CQXuSIVMZLq/IMAdyz2A08oSwuwYe5VLnOxAuyEYlcik7mIJJNdzb4ZAfUR/TTKatDcGDDnFZh/xmEwwNeUTZ58fFtIfPdN+SumFLkiee7lTlGOBzeFuDoc7nBoOVKYr3mqVEG1nbfw7/RPqQi9vp7s5wm1WaBYL5dxHQAtMUpCL65aJ7YXqTW2+xQiguCiI2A2v6i+LGazmLTgEaIFOxszRIBMTylUhynlqDyjfQGrF2HkmYt28OHcIUcmqDFRLpf9Vmsc2lupuCVoN/ZXrtUnPDCmFlGt4UaxL4cnX1nBuFhk0pBDPWQv3ypQqUlBAUyhNK/2xU282UcqfSVatpthmKdKWI9jm8PjsqMCO9sXrmsdgc3tGHtDCQJWrs6TZrebcApx9yODY1d0gHSIVKAVGWuiNj5pk5BlOoL1wnkgea+EXbd1AY6/GbIWexV41PFM7WJ0YiH9NX3A7pwNvXL1JrUNpUfan/n946AYFbXyK09VWkaU2Omw5w+x yn6nFRGr ig688rgL7Vle0pZoI4rDKO4uk20mJUnIbl/mM6w5UflGOEnsvqHlRJgT0OcCJDKgXxlW+AVXJ1xNp8/BJj5DhhuhDfRM6W6zOZtNplktap4fmAZpFIOPPB3e0fTpTt311qrLxdSmyCcAFG0z8O0nw1aipEjzSTyuXJVLB48EtCHlTrGw1dzwxd50GlA4nMZZlp8pOaTe/B2/vWZIj2p0Izh1xf5/Mf1aOP5J4+dE6yQYkB2e/JDidv9iY1P0KCi15PvEYL8Kk6qQ9F1pzKxVV/2BLQRkKPaxWOq3VL1Pne1xRW+xJyYuppOGzXOX+iAa3PLNVqn+EjGapOnZcrMu1Fc8rN9YtM4MRJbe6RGFa7bHtICAjt23WaTq66dSTJxa1FlcPBqP1IedpCACsoeNO49nWalHhAJ61ETc1SZOkprT4jlmdc8ztvwaW6F/fTB+KbD5Zxb38aRLJpNmAKZO7ZKCfzIAyOeqmo5lOq6L5rux9OXwfwhKa6RbzvVtZtDJ8oC/AXm5DFM344zO4UicRMI0U8/hSzf2jWdhxxLp7qHvvUXnwrOAUiynmkZQwHrVdZQ4p4NK10McH2CH0blfCnMRJpK4dzz8qNo08yMpyBdS49Ac= 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 cd09dd164e85..4faadc54e89d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1414,9 +1414,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 Fri Aug 30 04:00:58 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: 13784194 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 0D0B7CA0EDB for ; Fri, 30 Aug 2024 04:02:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E79446B00A8; Fri, 30 Aug 2024 00:02:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFF256B00A9; Fri, 30 Aug 2024 00:02:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B90B56B00AA; Fri, 30 Aug 2024 00:02:06 -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 80A4C6B00A8 for ; Fri, 30 Aug 2024 00:02:06 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3CD3E121401 for ; Fri, 30 Aug 2024 04:02:06 +0000 (UTC) X-FDA: 82507563852.30.FA253FC Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf09.hostedemail.com (Postfix) with ESMTP id C36E9140017 for ; Fri, 30 Aug 2024 04:02:02 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YrB2yYhr; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Q7SvwMNF; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf09.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=1724990501; a=rsa-sha256; cv=pass; b=zqulPISwV2FhDoHEOAieKA4a7y+RzbW06jbtFAaFgeVZlVk8OV8NAdAZg2OEvMO3rMsRmX 3ktNuT9b+OJWqFqoQCRVWai4R4qGvO1NNBabihow2kYXhMRnp6Ds7lh+mQdHWUYqxxIuqZ e7G7G+sI5crbBbNuKFLeZO6jaqP8pvI= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YrB2yYhr; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Q7SvwMNF; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf09.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=1724990501; 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=pb8FfoW4hL8yzz8RrA4fEnWEaS/lgspvQmeLTt4miDw=; b=gi5suXs6roO69zXlRRN1NJpQvjZ43qyrTy9xea3AAqaRjaJMpI8yS+wRKSyeXcdFZRgP1U 3P4j7JV4FE7y5cVKCFjLs72ls+sAu2Z2nF+jcHvkT3hAWoSIK6iKjDxlsOjEPMKEULpIYV vaLnYHUzSY7Wh/KECfh2MbhXPifjdoE= 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 47U2fg78022887; Fri, 30 Aug 2024 04:01:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=pb8FfoW4hL8yzz8RrA4fEnWEaS/lgspvQmeLTt4miDw=; b= YrB2yYhrl7FkVL+E9T1r4padjIze9VoK2cGvHoOQ21dM8xmw6RS7OLS71aw+IQHB E2PsOcV1CECQIGEF8+fMyDZVggbZ9GeaA0kzbbictR0AmA8MXaKC+uGXVRObwOqA esHmfd5XIKCmO+eZ0HmEVxGZaMwvC9i+3sutUhbg2wPuUkw9bPCcRR7qbRoW4iID 4OcHKU9bfILralyPjI7bJ449KdQT5TBJtYL60YujvNQ9gD9VWgbYpfXNSFIfn1qh D6hi+wW4gbNlb0ECtCrgLCuMS7Qzau3KcYQ5PKJ/12hd9a7xC1gyR8JVo+D6pt/O gxNWYNj6GgfKQ5SHGRc8ZA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b28508p9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:53 +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 47U0LvZm036604; Fri, 30 Aug 2024 04:01:52 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2tga-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bW+oL7pmBAHqUvCIUdD0nrFv+W0iPZZViNrs9t5VDgzbV2qFA5UAyx8n+cFhfA1dShVabus3LNz+gD67xsi0UlJR61WUWSANtLU8qzGP2rsNfpIZz2Av8ufiuZfF8lnEa1B9TlwWqAftTKDpoodqOKa0M1GT9GE4xX69Mi+wzWCuIUQbyy02V04Cs1iJaFg7WaMdcVcnbmQ2wjm/02TFrzpF4G6s1wz1CTOW+hggZ2MghhtpBRMl5iBlI6kk+JM5S1nolTzEicPe+rQBONmlPnLUVSrzraqlhULAxf36bPbRNknonrHWFQR1j7Jh5bNZIpIh6O8eKAIMAU0vXL8a4g== 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=pb8FfoW4hL8yzz8RrA4fEnWEaS/lgspvQmeLTt4miDw=; b=XjLqOb4LGD14q0cirXGJHrld63i0fOzTQLe6swFvZrbCBS4FO26T5K4PXCcQ2YMMa5xhJzQcT8zICxm+IDelGxeXR/B+XGAHBdT1sbt6B5YQW7LktyJn0hJXMbq8PEOaBW3o+jp9wZxKJrjJJSGTqYONN7pV4efJV/rVaKtuVZzCAPxtBeBlghDAWSA6Xt5g79SvHgqWsGwE0ZSfGkVwnvs43fVEYxiACpxiOsqqaO4WSC6kLZKkt3QmxTc1eU0FkNH1mPWP+P2EBJup/zb3NERtnFvre/eAgpXXGIgUN1oDTU/Rjery4Ix/ngPWG+Iyv2K/dVlZaWaqfqUGMxgFeA== 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=pb8FfoW4hL8yzz8RrA4fEnWEaS/lgspvQmeLTt4miDw=; b=Q7SvwMNF1ZB3Pv8lq6U+GBa30WtwV7Aes80aoDQJHQeFUSPNU7PSLCIlVPpG956ZRVVCZoE9UkdOyqWwZvFIQib62ZJ21p7hPeCl6Wu/Maz+9btNXbpqBe8uGf4PLchhJfydivcZu+DCCFl5f0JsPUZzG9yP0RvP/IXq8LJ3hsY= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA3PR10MB8115.namprd10.prod.outlook.com (2603:10b6:208:506::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.19; Fri, 30 Aug 2024 04:01:47 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:47 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 18/21] ipc/shm, mm: Drop do_vma_munmap() Date: Fri, 30 Aug 2024 00:00:58 -0400 Message-ID: <20240830040101.822209-19-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0465.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d6::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_|IA3PR10MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 642ca968-994f-4f12-bfbf-08dcc8a877ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7416014; X-Microsoft-Antispam-Message-Info: nirAp6yA/MPSgr0yVCEr3AIZA2a16Qcx0A49E6YSl2FxIniJYje9lXgdCD7Qn4Q4UO5/Mj6CIqw+FVe9lrAVc59ZdJ4l+dZcRUeA8DYl6/wOvmQQ7EwGdObhpA7W07ArLvpzsNJbBREBm0YI3x2bRM7nPyKkJEqsmwEJWcu0xXjBTA2//KxiRiWiQG/gAehWZ3iQydp1rflO3eCeb9tDF97m+1oTMakk4ki1JtLfU3oC2tX3Skjd4LkXSNrCUgU+DxsS4DXYY3O5chrbefWIyc2s8IwF4/3Qgfbu9Hd+ylbx0cBm+FFUPRDiZr8X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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)(376014)(1800799024)(366016)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7TnNJlWXlOAvpbmFNMZGaE74giNN4wVzuYLjRtetJ2y/M3UDQtrEIQay3hBAv9kCuDRPajyD6n1j6kBeos9WDipkQKfsvnrIGqIi6Nw8KBV/OKJlz7l/wauPKoMWMDVyxPQJgadZOknVZLe/u5aL/DsOEUgBqFGMJu3SJ/oKPYeM+IJsAjOr8zoltH/yxfVfuW+zWIudtbBjGLmo1zdXlndxQgh9uEajCgZy4q5tB9yLpbIapuCPELddm6Xvlff+f0QKSBoS9xOZg1REgCZFIy1lgJGDaulReD+s6XdJwJLnHCTwNlRJq1rR7pK0Xhi0JPJyESobxYfjf0KUQYO94ZrNvn8KrHveiNaUw4jyLEj2rVhLCKUSCwxjjm0S76u4DoGgO0jABxNr5ufNV8iFu4ocb2u8mYa64P0s0wtkkXWTzIwAMsztxL4pZ+oyspPS5JWWZAq3lXqjLCZHt/lQxrmtdeWzqET5p7YOcK7yY7JhBvOigYJsRDVSgRxGyT/V2FGCEaeNnTk4a/ajX/Utb2PdCmZyg32VktGR2oxsokpZBFbF+SShyA7TghsFpL+0YBPKmWq3KDb5c95x/ZfX5UNG+w93laMoNbpmAA+mJL+mydMIS9+/zQstTQyIk6ECX4bOg/DdC+u9JpqMNeQxOgWq0J7w5wtaq6Q+6FJo2ZukuLPLU592JzuiOEj/PK8xpWBaWTv7knin1+HqgGv+EtaHMJ4Nn90L5NZctf2g08wF2ty1UJaw7mhbBpOuVY/5TMsOrFAf/0fCJ6PKzXf/ZD2fYTbXjC8f9ZWMCgtVXx60m0WiA+io0QanfniorS7NahCQ0/rN7X/LyxV5aFJSmr4T91zzid5XywCnh22ixAt2FfR655fbxLeg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2dtpcIsLIeuGgTJ9UYZdtj0UCDqtvifoFGdFDceRdIHHGycemw7oMkw58L9JL2kAQ2vDGYT7XfKwJdfobXZd/ctEaCyoPzw9WZ2clcFUW3E7tWP+EdoQOV9AQZbg+UCk0FxWJXoDmSnyIjsQ0p6xFzVGktOWFONbptPxnhDt7Os7xplp2Uvirv9Knmys/RiiYbai1U+6t5GPS/N43ZF9N3dfmY6YpnDwBQcBpkU511DDW7KqEUEQmieele1YqHEdIkf5r72wyr7cGhMlA+ymz6QkC+0my1B9zAt39fJxIUijsg/Jb7esBPHI21w+Y870euwse3KY1mDNfyTa/AgUKPI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 642ca968-994f-4f12-bfbf-08dcc8a877ee X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:47.3186 (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: 3a14O2bpsr/n0s8tKQosAJi+LE/oL5eZNmyIlhHq6AlogsPh6vWRNPFHcJDWZX6OPrk6zKjtxzBNKMjGLufIug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8115 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: 4RDZw8oszWaGKRmYvPCSNNQwBri_Kmm5 X-Proofpoint-ORIG-GUID: 4RDZw8oszWaGKRmYvPCSNNQwBri_Kmm5 X-Rspam-User: X-Rspamd-Queue-Id: C36E9140017 X-Rspamd-Server: rspam01 X-Stat-Signature: jxuk79cde5hedec1bs3ci9z4c7koqx3i X-HE-Tag: 1724990522-261905 X-HE-Meta: U2FsdGVkX1+RXKchmuHBa+sPq085tDihpejjtcCbpZqwbmmR5aMJvK8xE8vn9lRHay4Bc2Lg+cjTGjcq7ml6aWdUtxWifWz1K2wraLB99QvK60FArh905p8TmZQCRnhSq9vrvudqfpzNUABmtckoIThYD1O0U4GRtZWf/nNTE3THO2J6HqFC/h1PT27lksxD2zsFWm2pvLxKGWqWqtHaTHz8eXiQm5LQQzlYxZHbAcrQMViJDkwxJeeLbYV7jPHbKcGAg6IxPCQScD6UR/1YqTnITzn7ZIEU3WqX+wdJH1OoHHQsOoR6D8cqCI1ivK4T9RFl/1az65fr/CH04Z7GOyvJRcQUkpSmXCbvJPhjAbL1ewZP7pth9B0PJIb6SECmqEENw8FO+eowR018pBL2r7Nu5sELCm/hEbyrgKZBkvyEJoiMs5D6pr4ugld402sV5NE1bR4Qs1WWr8RbR4S/gvEosnmBfBoSHBscGgLh/L54D8wHijNfGBvg4XLDRUZqMeauAuyXUeBOWpVZZtFlElrX1u5TXgPV9t4LsOqe+13f++ZjOBReTJ3onO/AFo3MQaJrUxZGL0V83/Nm/l0ci3Cp431vrIv2IL3aAfkKgWiFcad0o8f/G6NC6malHo5CGDMe2Sv6jk7W8nSy82cIySXwg1GAcwP1gak6YlHTy684DYjoUZNB5L0rZmRF/KGQgZaivI5eTHTRj2hXw4LPqQ+zN3B7NCel9ghHEUCzBLlCOHY0RsrbuKbMi7Ppxoao+2rt91un6HLOAqY/pqPgslmMPQIRxtKPuuevJJGmLTdGUdl08mlEfjNQTe6LnGfafPZPZwszMoo9a3gNWgQuFvmdPmOT6XPA6NgsaWYu0yHG1na6WI+9OQ5K1UGxxiw4fF2/oRS52JZK/83S+Ie8VvjToHusR2W3Z0uo/EVhArsfui4u6tXU+lJ89JmH3zJIz+bPNPmy21RhGFx1Wak Gu4xnF+f IomJZCNEcxo48nr35XgfN1XOKt2A0TFsJq+i0LqRIdWpI8Mmcldq37qbwEnHhDQMQWPzjO5nPsaYIiccG0j2BAfo6G8SZVY3n/iOBKsxCz+JRcHRF4mMJH8ZsdZC7NeaZaOdyrRL5gjUzO1Q2eBhEkd3mZrd4HXpsb09Y7YbC+KQSm6U5rr0CrJN0BmlRedEiZEbBwCKmsjZrzUGquzd7eaeWn1q4BSwBoQJIANOWucvwUQW04QkmfNdKEF2EOXAoSlcJW/u5lGa5TskG09Rti75Xh2ushhcm+HD35S0oSoKu5GMQqGb5AuyZqaQoJl3QwIdE5Y/P6mnVdr0aVulOg+rJpDisfWEdVZDE5s0RSEqtJ+4yeDZVAFPQExNI52k8rij0AA054plZRcuo1tvhNProyDm8UfN2Gog6PIGa/L51cYOeOPVZ7FCQ1OR+b+sUUAgZF+6YGqk/91LXealMxyCzgiyMRXR33rrImoqfPXxoZJt8NvIM3TVzf10TFFcweN4ZIYol3y7TL7G6TDnAjz3/r8kC6xRPJRNw2lXK2DBbnFSjTtmpcVe7eAAVUWfKKm1q X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" The do_vma_munmap() wrapper existed for callers that didn't have a vma iterator and needed to check the vma mseal status prior to calling the underlying munmap(). All callers now use a vma iterator and since the mseal check has been moved to do_vmi_align_munmap() and the vmas are aligned, this function can just be called instead. do_vmi_align_munmap() can no longer be static as ipc/shm is using it and it is exported via the mm.h header. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- include/linux/mm.h | 6 +++--- ipc/shm.c | 8 ++++---- mm/mmap.c | 33 ++++++--------------------------- mm/vma.c | 12 ++++++------ mm/vma.h | 4 +--- 5 files changed, 20 insertions(+), 43 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6f6053d7ea6f..b0ff06d18c71 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3287,14 +3287,14 @@ extern unsigned long do_mmap(struct file *file, unsigned long addr, extern int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm, unsigned long start, size_t len, struct list_head *uf, bool unlock); +int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, + struct mm_struct *mm, unsigned long start, + unsigned long end, struct list_head *uf, bool unlock); extern int do_munmap(struct mm_struct *, unsigned long, size_t, struct list_head *uf); extern int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behavior); #ifdef CONFIG_MMU -extern int do_vma_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, - unsigned long start, unsigned long end, - struct list_head *uf, bool unlock); extern int __mm_populate(unsigned long addr, unsigned long len, int ignore_errors); static inline void mm_populate(unsigned long addr, unsigned long len) diff --git a/ipc/shm.c b/ipc/shm.c index 3e3071252dac..99564c870084 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -1778,8 +1778,8 @@ long ksys_shmdt(char __user *shmaddr) */ file = vma->vm_file; size = i_size_read(file_inode(vma->vm_file)); - do_vma_munmap(&vmi, vma, vma->vm_start, vma->vm_end, - NULL, false); + do_vmi_align_munmap(&vmi, vma, mm, vma->vm_start, + vma->vm_end, NULL, false); /* * We discovered the size of the shm segment, so * break out of here and fall through to the next @@ -1803,8 +1803,8 @@ long ksys_shmdt(char __user *shmaddr) if ((vma->vm_ops == &shm_vm_ops) && ((vma->vm_start - addr)/PAGE_SIZE == vma->vm_pgoff) && (vma->vm_file == file)) { - do_vma_munmap(&vmi, vma, vma->vm_start, vma->vm_end, - NULL, false); + do_vmi_align_munmap(&vmi, vma, mm, vma->vm_start, + vma->vm_end, NULL, false); } vma = vma_next(&vmi); diff --git a/mm/mmap.c b/mm/mmap.c index 4faadc54e89d..6485f2300692 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; @@ -1479,9 +1480,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vma->vm_file = get_file(file); /* * call_mmap() may map PTE, so ensure there are no existing PTEs - * call the vm_ops close function if one exists. + * and call the vm_ops close function if one exists. */ - vms_clean_up_area(&vms, &mas_detach, true); + vms_clean_up_area(&vms, &mas_detach); error = call_mmap(file, vma); if (error) goto unmap_and_free_vma; @@ -1744,28 +1745,6 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, return ret; } -/* - * do_vma_munmap() - Unmap a full or partial vma. - * @vmi: The vma iterator pointing at the vma - * @vma: The first vma to be munmapped - * @start: the start of the address to unmap - * @end: The end of the address to unmap - * @uf: The userfaultfd list_head - * @unlock: Drop the lock on success - * - * unmaps a VMA mapping when the vma iterator is already in position. - * Does not handle alignment. - * - * Return: 0 on success drops the lock of so directed, error on failure and will - * still hold the lock. - */ -int do_vma_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, - unsigned long start, unsigned long end, struct list_head *uf, - bool unlock) -{ - return do_vmi_align_munmap(vmi, vma, vma->vm_mm, start, end, uf, unlock); -} - /* * do_brk_flags() - Increase the brk vma if the flags match. * @vmi: The vma iterator diff --git a/mm/vma.c b/mm/vma.c index d2d71d659d1e..713b2196d351 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -658,8 +658,8 @@ static inline void vms_clear_ptes(struct vma_munmap_struct *vms, */ mas_set(mas_detach, 1); lru_add_drain(); - tlb_gather_mmu(&tlb, vms->mm); - update_hiwater_rss(vms->mm); + tlb_gather_mmu(&tlb, vms->vma->vm_mm); + update_hiwater_rss(vms->vma->vm_mm); unmap_vmas(&tlb, mas_detach, vms->vma, vms->start, vms->end, vms->vma_count, mm_wr_locked); @@ -672,14 +672,14 @@ static inline void vms_clear_ptes(struct vma_munmap_struct *vms, } void vms_clean_up_area(struct vma_munmap_struct *vms, - struct ma_state *mas_detach, bool mm_wr_locked) + struct ma_state *mas_detach) { struct vm_area_struct *vma; if (!vms->nr_pages) return; - vms_clear_ptes(vms, mas_detach, mm_wr_locked); + vms_clear_ptes(vms, mas_detach, true); mas_set(mas_detach, 0); mas_for_each(mas_detach, vma, ULONG_MAX) if (vma->vm_ops && vma->vm_ops->close) @@ -702,7 +702,7 @@ void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct vm_area_struct *vma; struct mm_struct *mm; - mm = vms->mm; + mm = current->mm; mm->map_count -= vms->vma_count; mm->locked_vm -= vms->locked_vm; if (vms->unlock) @@ -770,7 +770,7 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, * its limit temporarily, to help free resources as expected. */ if (vms->end < vms->vma->vm_end && - vms->mm->map_count >= sysctl_max_map_count) + vms->vma->vm_mm->map_count >= sysctl_max_map_count) goto map_count_exceeded; /* Don't bother splitting the VMA if we can't unmap it anyway */ diff --git a/mm/vma.h b/mm/vma.h index b2306d13d456..eea1b5e9c15a 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -31,7 +31,6 @@ struct unlink_vma_file_batch { */ struct vma_munmap_struct { struct vma_iterator *vmi; - struct mm_struct *mm; struct vm_area_struct *vma; /* The first vma to munmap */ struct vm_area_struct *prev; /* vma before the munmap area */ struct vm_area_struct *next; /* vma after the munmap area */ @@ -114,7 +113,6 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, unsigned long start, unsigned long end, struct list_head *uf, bool unlock) { - vms->mm = current->mm; vms->vmi = vmi; vms->vma = vma; if (vma) { @@ -142,7 +140,7 @@ void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach); void vms_clean_up_area(struct vma_munmap_struct *vms, - struct ma_state *mas_detach, bool mm_wr_locked); + struct ma_state *mas_detach); /* * reattach_vmas() - Undo any munmap work and free resources From patchwork Fri Aug 30 04:00:59 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: 13784292 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 18A0ECA0EE1 for ; Fri, 30 Aug 2024 05:30:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 770AB6B00AF; Fri, 30 Aug 2024 01:30:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 720266B00BC; Fri, 30 Aug 2024 01:30:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54C636B00BD; Fri, 30 Aug 2024 01:30:47 -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 2F5456B00AF for ; Fri, 30 Aug 2024 01:30:47 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8E566141471 for ; Fri, 30 Aug 2024 05:30:46 +0000 (UTC) X-FDA: 82507787292.18.09959CA Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 46476C0017 for ; Fri, 30 Aug 2024 05:30:43 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OtOETeOC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YyrqeELN; 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=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724995798; a=rsa-sha256; cv=pass; b=rVKabgxBk9vN4jSaCkYKyB81VsA8MB9n/wyK9AEEN2Am5lH85MqB1pZFmX2rmawoOobWHL fV/3pvoryjar6yScUY+UzcGOn/TzqdquGCWiVJJVxzsUhGSyWeOOPucXPO0WNDphGwd6Pp opxhsC29l/NP49q3fpGnWm37jOx/OtI= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=OtOETeOC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YyrqeELN; 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=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=1724995798; 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=Ls6YlP+qGa3+3FNlDv9PERPNFJAt0V//E29iP7vaPv8=; b=FBTCQSKv31PpUNmzxvx5Hkgsrd6CGI2dmWqCUWG6ATXAfwIrif6XAwKh0IYHtlpPk2mdvu 6k9IhHwnT6xNHpVhZRrRfRRr2AvxZJ2TqdJelSuc/pS6H5hY91tjjJM4OWsJR3fcK6p1LK wRb0TpOFG9wqZ8TUhmCrXIiFYutoKJQ= 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 47U2uL9I019681; Fri, 30 Aug 2024 04:01:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=Ls6YlP+qGa3+3FNlDv9PERPNFJAt0V//E29iP7vaPv8=; b= OtOETeOCENI+UV/YzUmpykj0qWupQrlXh75cyrweWNFvEVwOHMXvkHh4t9avgYT+ 3GiHvJrsRrXDRFU2u/pu+imN4tDZtVlgUiiYls1qDbKIEhsgBfcP9wjsWGgM8nMG LWrXUfT8FgVzi4GY3FQvrEFThHb9TpXRmNCA0Fwo4F0SfICaCLB1g21FJ8ueyVC+ g8gQFp65RwrqS8IxjtEvY1gEzwdD5q+2YXTXNQvSjplaSQS0H/lXdHYsN/TQjls3 xy668czWckjo1IMijqCiaBytqhMrplDmgiSRiWtC2ChPOhiTXq7IxYhBbiPh9COV H0LUWxrWm51ABsVoZq3Ndg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 419pugwrfj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:53 +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 47U0LvZn036604; Fri, 30 Aug 2024 04:01:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2tga-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FRCquFTjlwz6mjQLAKWK7sl/+oHtnYhtuEpxdupu4owqgPEbb9OX9chAglANmafBlySVRQWbw522KLKZiW3U9vhGsopA7veDl4gOyWcK1ODWiw2obVsMf3HNZRI4zIW6IfwTBRIU833vlERMiL/TvLfELkHEKixHefP3ixnPbub5q6CCEHI30CspmT1Q8KHGLZqPFULbINnv3l6WXqwfKgqLJ96QHjWAj6hHVy7YjcgihjWcw+inI+eNI6OJjvobw4zhdTxTntWUMmdBKR+DY051LwVMA9Vk5onKA2RMEMeqN8BHIBF8GaCHSXPEBRKgPACEjZ0qureAo+JDpAyDtQ== 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=Ls6YlP+qGa3+3FNlDv9PERPNFJAt0V//E29iP7vaPv8=; b=VoFHlwM0cLjlraVK9ytP43qpM9GVB/BGVnxJYBJ70KNH1wPIMW22fUBLn1NZJ10c36u5VDzOVBjDnPyHaq+wVuvUVWeeuWnIQmrt7pbkAxvKgv4FE0A23mk2SOo+TJU0fQG6D0OubvG6CRDZybFJZVTkAHgLlikqSpG9Dt6kZX/5lXHDSDRP6Vhm7plzmefglON71euLgrOS/PnOdyswo2hCFPSRZl+Em9ScEZsIr6TsWd9JK0zM1+avaOH+HkXMHBujg5VtkIMQN9XJk9iKA4ZxUYc/fYlljOVCLhu+LMbC9YUE6mDvu78Abf7z896EBgz2aFpmtJL1uBFq92oxNg== 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=Ls6YlP+qGa3+3FNlDv9PERPNFJAt0V//E29iP7vaPv8=; b=YyrqeELNPY8dyNk0wuBbC5sIBpD1A9jIP5GEYXajt3ajp7hAu5SUdfmC1L6Mnn5xJ5UjiImf+kZkTaJPO2SrtkEvz5MXJcGNY2pOF2YyljBISTUjHQb6LNFkQwQRt3ob8k82xPQ33HHbuuVj/sWUvD1haxCyFbQcimWsqEraBUA= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA3PR10MB8115.namprd10.prod.outlook.com (2603:10b6:208:506::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.19; Fri, 30 Aug 2024 04:01:49 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01: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" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 19/21] mm: Move may_expand_vm() check in mmap_region() Date: Fri, 30 Aug 2024 00:00:59 -0400 Message-ID: <20240830040101.822209-20-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1PR01CA0056.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::25) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|IA3PR10MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: c769d78b-4085-4f64-97b8-08dcc8a8792f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7416014; X-Microsoft-Antispam-Message-Info: 7/tuBpwMzUkHAHnUPRBxKTUV1azZ9uwST74CA6ssFQ2J26MGpJngyKQVLlyWMz8a/cFL0Yh10neH/fA5EbdJeIrh/Z3N2JAsyrO/pgkfHIMBYDmtDl1SDlf6HfmHnpAe008gTizHurHEnoDxJguoZhFILAXupcJO64rapXJ0mwliQDnVyH1pXzIloSY4skVuGZOvFdFqM9BoK/fZWYU8JnWPRDAOedMRm/X8koyw7IckogOi/bXJRd1yRwxluwFdOxFyisAtDprsL6iQ0HasrLisj0eQ2fNgbsBfC+m3103/dJ1Q08Ow6hUgiRw06bUZlyVo1wz+cd3Vzl9GiRwOo+OioGyCqK+gIKUwuQyE2bBZ1tqaUVhAvAcjwIFZtz4GpO8ffImnOn8Jg+7PGEhIWxZossVIZJLeNTzNUhTmVVsD+7TWOENpAIWAVXdj6qHNH0xBp/daOc0q3cOjmRm6g0TUPjqPwjF0zLxTtsmip9DLoRr9uWE8MgNLjNAwFK9ppxBRbkrHBBXJhWqOHFxElQH0lLlD92BROMZ5AgTCpZ3aUPmj0RENcwULQCSWlnhIeni5G5xFGUAoezG1ezDF+pGgPkRkc+i2xX8MTBz+IUuOQvV5YCm+y9nAJm1Qz2NHQnyoijr4fM1R66gFGSKhSwXRRD5RWgU9ChfVlYlVDaSrEkvOqw/ZcZTyN8JrIdEg+5euQiS/b99wP0jdGo3/fbcsvwqRtnLlFtNoQ2Pdc9qvnpK7Be3xiShrKyzZPRkUYhfbmD/z4OH1A162PDUaMW6VEzeN4cPH+p18XRQZYJGWyid9GWO+Klt+DvZtSK7UskoZhIAhrzCJ5C1mNmcUF2nPChEqIbFrcGKKPfKD6vjZiFokYpAofK5irGs+S9sXCX4V6dM0NL4xIloZqxg3xeV/ASps6UPbFy+muAk4+w5CtBT25v6mX9bwmzGsAa2iNjCBV6DY63EVuff5xdDcEnS5h+VI9fdyYEIY8zhNvZcVcBKdKF2Tkd2ALXEckZahc1U9tiHyeTN3E/2XPnSersXgdkorwpBvi5ISZwjRFdW4i9MlFcbx8PgG0SQXgQIDqvcKWynJvMajmE5tsFQjbY/0XTOG5I1l3l6rsspPLXoWN0YPP7tmwWB6rZ7MKCwyxtQ+EvEd+h3yfD1GbzGjwTFfizExZE0dcx1piO5FMeDgcPrjnEgg39ppbKJ5uOD6jDl/dc/0wJfRLhI+rGvudp5nc/UYDH4kW1XBNsZVQF4SP35FUZq8Fx5/T1F/VhnNGs6VJnmUqe6HB/gjsIUEZaqF8Cbqmpou66D7FedEwg1bx7z8vKZF9ukp/RDMcow9HKKukIas6Q3ssEAtjZK/SA== 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)(1800799024)(366016)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gXTl6CGO43aldaAfvqb6TPuGzUrWfnmt0ZCgxsUUAfO/lyXJLbdRYrZ+K1Qhp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IjWwpxgg5iPPuS1hEPxv7pPUS2zXqtBnYPrVfCnGIcOYXLQ5TC92nmK+5wEuSFibueKD+VXgWiQQgK54Z3L+nhzHrAdqSuZZZW5fvDt17Pw4wYLA/9YGnCPGvR5Jm2r32R4TpB59pPfrhbP6NzHT+sYPDx+d5DKxOFVPfp4KP1LKyonOklMRwzuKXXeYuuHDGgIslXWBD1qrf1cjt5LkspDhqtA4OIMGeijJwV09z4uoUxmpAXg+ATF9YVWWbmn+kCgGqL2ZlGH45EKSXxXOVrpMkmprIQ6aHHu5M9PmoFYK9b1iyd0zIXlE4bdMKYrlKBRuWNPT3+2uquh3dn0KME44s9uINaVY+OfSP+sqI2fdkpbOWQ36oO7MuAg9Mk5E10HN6kvENeYAyzY4yLIFbhepR3nOSCPZaEPUyXgNviw/P4KKruXt8PwgLCaMEELas/rfsJB/wcgmRj7nmo4rog53vqw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: eUq8eiU7bPCcZegGH5tYw/C7x7a6F4tniPSmIkrRbJGeJV2xbmgTcMINSmgTqZ61iT5iVOQc1zZk9XmZuGeFEKPAveKEQxSLddF7VazQTLEn7vLT0nn1p5kaCnLdy4T5d9miTc6643kmsTNbtf1vklOuILCD3GdHhwLyogTuyRFd24IeRLeQwU6SKI3JR80PWGMQa+2NEbamncTURYnDWtGdgAUF6H6QMIazah3g78ACB+yAehJby5pQ01Tgiy27EJxrniRSGBjPD++dX9MG5uIv0Ibvy00qqB6qDo/JIEK1V8hTQC2IoE7z2P3WuHYZR0qxtUe0delJLy6K7L5W12v118pfGW9UD0ekXjX3iaKHQZnxndZqbP7Z5hGRqMYIeHwhsHkqI/a7/q7I+W6sy3PowqssduvxJH50XON0RIsGa6Me2/5YNrfletOnsVpAOXeoT3/o8xBxObBYVOccsEOC5nzTQ1RG2w41iTL/fh6UHTxd810WY4q3Zs4NxDefrPSCzFHYU1vZ3lzQ728/StTyU/0mbQqiA0NB158yyLU8abk6CwaNyIXY5O6S66vgN/QSkmTHocJggBJCGH13QhMbao4jpuMLto4MMtsFlQU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c769d78b-4085-4f64-97b8-08dcc8a8792f X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:49.4056 (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: rWPs0jN3bfJmaRT/sxcCUk1LJ38oSQH6Pe/I9Suw2gelOBg0hFLfGsXzSKoPEocfn2txSxoS5pmcTYcxpM5W4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8115 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=976 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: -zRDwOCZO6MDemVYfKCuJLUwuhvqzR5y X-Proofpoint-ORIG-GUID: -zRDwOCZO6MDemVYfKCuJLUwuhvqzR5y X-Stat-Signature: htxcax5eidkmzbqyfuyqhhp31h9ii4et X-Rspamd-Queue-Id: 46476C0017 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724995843-827684 X-HE-Meta: U2FsdGVkX1+VH2YO3f9QnzNZXCjhWRmpmRNSLW3tDtDEE84bNFsd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gY6JYsWgY0bRxx79e4ECv0caOXztnjbSCkI0vvR5WZN/79R4f9SPzvkYi0qqaO4h6c66WiPIEs5EcS4opmYia8HwQ9oQXi8IM++1BcZFNSwMhGxqnicHjkgYBXUVjugFnbkfJ/BJCnbR9ivmjeXwJW3ewCfsPvybmIzKxbYVRToZIU9TuBsYL+0SrJFKYEqOLb7iCgJceZ6dJitAtTim21FNvWFsDm48hwMEZwoo1fJQrAWBg17DpBuNfMTPtiS4iSPbSAYuKNzZRlTcqFGQZ6pm2WDVfqrmeopoFSIkpOM9Zrm3PTqwU0CZ7UnwDnE1H58XxurfHnquN89N9GoLpMY6c9lZNtjuj5T3UZyDaZ9WBmP7/aWkdXVs2IG1kfNXUzgMVg+e0+WsDGZic0Mm50hCur24E7GWTNRXHXeu9nURPd1Jz88sy7Q1eABPpZfgp3pySkGCcEyQbrYIt4dFdw= 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 6485f2300692..fc726c4e98be 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); @@ -1410,6 +1399,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 713b2196d351..3350fe2088bc 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -1640,27 +1640,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 eea1b5e9c15a..6900e95bcaac 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -319,9 +319,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 Fri Aug 30 04:01:00 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: 13784195 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 18A9CCA0EDA for ; Fri, 30 Aug 2024 04:02:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 944FA6B00A9; Fri, 30 Aug 2024 00:02:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A6236B00AA; Fri, 30 Aug 2024 00:02:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 683876B00AB; Fri, 30 Aug 2024 00:02:07 -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 431926B00A9 for ; Fri, 30 Aug 2024 00:02:07 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 09970120C64 for ; Fri, 30 Aug 2024 04:02:07 +0000 (UTC) X-FDA: 82507563894.15.85F496E Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf30.hostedemail.com (Postfix) with ESMTP id A88DE80005 for ; Fri, 30 Aug 2024 04:02:03 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=hDCVX3HS; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=lkt5rvEZ; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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; 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=1724990433; 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=MnHfI2QsMe/4zoKN73j2X83vCMvsXwhWZmXTDDHf4XY=; b=ATH2HxftrOeZxfwBKMHH4KGmCQzboB+ejGN+o3RLofh5GRifFfqRC2bJH1xu6LpTDuZVN+ LcXy+Um4Dybf6/uVcuXY2ikJLXOdLmKOV6l+I2u4urIisM1gf+zdPV0BrYeUOPue7f/TFM WF3G61v80DOm8Ph8h4f9ByL84oE1ZYs= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724990433; a=rsa-sha256; cv=pass; b=MZR/IdLDoXUJKGWetjznYKe6BkyRf7WtjKavUlSgqquXcCv+XKd6IRGfOP8QZj5abU6+rP s5Jf1MSj7ft+6BVMngHlUUg3FGujQrPtxcCsCF7EU2L0pHzC0G6HrXeyqfB+9Z+4i5JFca iXuBIk5iGqW9ldMLmYWgH7ci4HP5a3g= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=hDCVX3HS; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=lkt5rvEZ; arc=pass ("microsoft.com:s=arcselector10001:i=1"); 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; dmarc=pass (policy=reject) header.from=oracle.com 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 47U2srfF011858; Fri, 30 Aug 2024 04:01:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=MnHfI2QsMe/4zoKN73j2X83vCMvsXwhWZmXTDDHf4XY=; b= hDCVX3HSZEkw2nzYnVTH/+6tLKS/q0w939l3eHRnEOdbT+uQs66m0AcO4hFkUI2w ktcbYoLvuYazxbn6l/XmMwA0hhRk8RMNHDOCRmjycLWbsY1/H18s5Gl8tsZFrJkc CYkz9t2rznh0AAMkv7D8yZvzcJDvX1etJ685vCEOHInzgToe6CyXLOV2ea1dhVBr ltV6v2cb2NpMTcQupgC4tTLEgJnpNdb9OeNYFxdR/VCJOqEh8OcsAv10LjV2updC y8kSX+JLFsT8i/rt33EfSbtcxXsC5R9gSxdLqVmpaez4cpA0mzhK5ktbWZwT1akm xHRME9Ayx88S/nR/xXA+WQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b5q3r1vu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:54 +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 47U0LvZo036604; Fri, 30 Aug 2024 04:01:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2tga-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WEgGtfwr9t14+Hk19fb7OeTedQeEisARfIA7fIe8cZmqYnK+cL9v3CiDkCCA43Bl01k1sghcWe1bxIToq9h3JoPxxOikCpzIrt1v3HGN2qjTryM+MczyH40I2q+U4UwBT87ufNgQMS4rPBbnE2V6o5geYtNxesoI5r12nMlU68uWYn96sYAAU7chVaorJ+QPyQ6IXY0NwCl1RD1GhFv7K5HpFalSNaTX3dlml5pMM7A91Z9DHYgTbEMKKUqAS34RFCtspFPxyGPQeA+15L1twYoGSZZ/zjZdfphs18egx2BD5Ic7tUJN6zzhwEAmMOdXkJiffAxY2jOOihMH8IU+Og== 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=MnHfI2QsMe/4zoKN73j2X83vCMvsXwhWZmXTDDHf4XY=; b=CSIAqAyX1uiQ60gGzpR/9HfbTHs3QiUhHZg+WYeXARJgnGwcKlahyzAtUGmNIrT65+J0vr//pKzfy9kPzMwmfJWuNBk9nwimi/UbLN/tS9VepfluvNsYIxgYuZ/XvIwxCxV9Sw5Le45Jnpmi+va1Ohj/u7fTmGMDVwg1oRM0culRNlB92kUbrzbRUkgMYlDD3nQRlVLrj2Qagn1bsEhVly3b/yhhhkF6U92wZoA6kZb10O4CbZYZ/71T8B9aXM4AUHBJEVLAqHeKc324SQXt3xIx9TMjg8Ecd1NLg419GoY9ySTA1l0JB0pMcH57vCo257wyl71/alHmh/RBynN4mw== 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=MnHfI2QsMe/4zoKN73j2X83vCMvsXwhWZmXTDDHf4XY=; b=lkt5rvEZp24VQXY06uuWC84sb/d8XtXNp82JLBjlW79KSUSF+hzE4HzMJO5/bZ7vbU0+u3U5I2Ky2U0MWijt110yojf1Hv0GYxkrqUeTlyocSNby//RfFzuKnrC3MmRMCtiBTS9q65ozOJp1t98w8YCCRaLfRLM9hhqL8Mwjm+w= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA3PR10MB8115.namprd10.prod.outlook.com (2603:10b6:208:506::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.19; Fri, 30 Aug 2024 04:01: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.7918.019; Fri, 30 Aug 2024 04:01:52 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 20/21] mm/vma: Drop incorrect comment from vms_gather_munmap_vmas() Date: Fri, 30 Aug 2024 00:01:00 -0400 Message-ID: <20240830040101.822209-21-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1PR01CA0037.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::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_|IA3PR10MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: e560711e-e243-4cc0-376f-08dcc8a87ac4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7416014; X-Microsoft-Antispam-Message-Info: M42PXbeARSjtG8LPNhvrnfql/DXiUfC0TfCtdeFyzjCdyZwOzmqTXMPiJ5bvDLcgA7oNSa/y1ET7zhk5dNIq3o2rzrRtTMHHqUIt7pTsUTvH7Tq2UM1G2S2we34sLTnlI7OxOvUehUSPcrMLP4VI5nd/qXzLu+Bzur6YGpQsOZfMPoHOIQVnPgmN4vS19pZg3nn5W/3BCDrqrmKIaQ/JYcSQDrbn4ynyTI6JLFU1TMBl61tO3weIIMqu24G8IPsKHkMVyw41B/cOxMObb/99KQj/il5VNcpWckiAuLGnTVbbEzAWSFBbrnuo19qhwHLu/z3L4GyRB8s2mdSPsyCgZpQelmGRkoXH9opYaS77nOMZP07yNocExn6QlZ6ST2g+0rfvQL10N+OSS06HYAfwFlLQx45NECXql5c47AjtmgMo9PW5XyPbwTv/7aOa8jVc7fhuA93AW/njTzWK7JKndyEwxriaZgYMrncM91ELuw48UrIgqDTO49uKz41TqmIOp4VaWZMoIRyqqyomWVHjAf6Tut/1t30MpMl+J/jyZNKrREji/gi8i5OVMOCgkAChR8VFF/ZWBtnXsCsu1msNM8nREyUXwr1xJAEP8RuC7jirpM3p5zC6JQpgMjXBW5AaocRQQielTSVfYywdSWVyvnaHL4fBSy20DtxDAWIcfLcb0DtjQ/7FOnnZnLO+0+OXmA4FoUCzPS+KvSc0CUBVFjzVB2fxtApYf27mi40WmTUMDoth5BGw7m+wLMvrj41Vthmm6vr1lVYvAUAQN4MCmnQ0tbVELxkrRgPK4Inncl1Z90arwyUtinfUKkjGneYTc6lNElcPH9ECOW33vGw6kvr5kGQyibh/gZgA4dbO3CWmEmda1wg36aYogIc45rBL73BEBbrH5aop2oJzFENe+F8ASU9mpZDfK2CFYcuGQMEKYLPd1k6GJObSgpwGGSLv+jYBevA2r0WegsC1dxTdXkfwG/Z9wQvPFAYyELTCd6KrK/Xu2SzEGk9komvuPGrXvHHAuoXA+gfQmMLtrNR6wJC7PQd7bePiw/Ja0jENpcAp4n11rfL5THx45N7Ll1EcdEN837giUQRRsBEgUWwcP1e8EKFY6miQ5VYyzS3Jk8BKU2juQDcfFAn/nLP7nwfT0M2F+SFMf9oki1ar5ix7WmPoyJVoYs+b/lQk47QL3NBdQrw0KTOFLYf4B6W8IMY3maWRHgh+qJV6gEOVbab6BmheAHqa3uyX2mkblNSuy7ZSN4qkiChhrpVGi7qWfAe/CfqiT7KpW0rtg0UjhwwJi03u11a+qqhNy8/WVFIHu14H5i7L6D1qVpwQILGHaNUcpjYXSTgi4uWcPR9V0nBFoA== 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)(1800799024)(366016)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X03T0nnf2NK4mZC26S5sZz6RVTfVCvHpduOELOsscZhep7MWwNNQq/gc/3IC8AB2xiu8vu5+Rx6Vf0frXWIumhJ6rOdinwrP3518ewNaLPdvJZz5Wny1zrXrrbHWmaYVuQB0PQMNIoPM+Kr0cEk4dJKF/LFHZpQ1wu3r+xjYzLfSRlLLm7K88zTpAiktIKx8QysK3LGnsmG9BJLWLlk1zfN4mk6Pi0MBh0cGLiwk28BX3A6H2rBifhK/7NZO81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PT6W9R+w/jMYF1P2KCumhuRwhjXi0jfwJnwsXrzgGyTEeb/0IIbik4TNQtXbtLKUM1RbSmVQuK5eYubW3H1qgSLSuGx0F7vlczoPAWWnTTQgYYqWkwsb7UbxIIuRB+SqQtAtwWTQ0KeuWbVTfphrLlPeT2lLXVvejllRdAUG6gFQ57rBT1ah3xjppBWBd9h8SeGOnW2WOjvNTHK+56x3b/3XsNkxzA7xs/aorccoZtwx2Qhb3mUOPKaWxx+iVJ/4HpdVnck1NOqiGxJOmlKauFFzfRWXrInZ9FT5YQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nLD+u1RBYX+qkWqtzoz7j6K7zpvfIx8g5/IA9Q50jtIGdlClitc1Fnzc2Jf2c3NsKLi8dO/ejRwAUGRVn6MkyUG7ktb1CM36ofI+sNhp/XChTXoTdIK5dRBcJxCzj/6fNm4XaMq1PNjGFWFegu7MvHqv0/Y6WVI67A9Opg45yIDFbRulWbP1MTRwo6JdrRVHKA8cQ05SaX/lEctXbfQz/nQESHL0zw7kt7F1+grJtXwvk8Rzh/xnfLXqqCTnpSm9wRu5F7CPNG8kusNdaHAtD0GPzclgRlKNSxHxXiqiceqGe2RIR0CoDiYzFoyFaMdz7WLUA6LN3oRj/lvIngJHT4yKBquzXNLGfkMGTw90bA0zTmS0e/8DMNAHZVvS3ulq24jMLRNEbiwdLNqGx5KSwHucHOekPjog5+WQS1xWY3R1WZJKirQyHrDKi0BjBUQkKLjaA5hk4Y6fdFOxbfpyo37/0n9M2UyT7yHldqJsamtVVdxLsbRNlMrKxSTjLVUBJc9cChZe7bKdv12/fOsRaNMWH6A+IoN6vCNBV67R97c12jcPTk6rdCtz18Qfx2rSt6VoeW7ZMivdelet9iPLRd6T70BCF72xtM4RslIL/ZI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e560711e-e243-4cc0-376f-08dcc8a87ac4 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:52.0426 (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: pqT/QIWynxN4nIyP0STnZ39DLtV9223Sf8HceKBvUFqApnwnAxGvnlvmumnXFTUWaC3R2wIuLO2p9pH35yV8tg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8115 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: TLqOEXDFiIXaOHvNKb_8VWoFr3P55gp_ X-Proofpoint-ORIG-GUID: TLqOEXDFiIXaOHvNKb_8VWoFr3P55gp_ X-Stat-Signature: cturw4ggxrrtzmjuuog954rncaduyscd X-Rspamd-Queue-Id: A88DE80005 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724990523-455342 X-HE-Meta: U2FsdGVkX1+UrBTop0DQQemxasNVa2QTKdLbXTVT9qvAAZtL2ABgcW92az+TYZKuzTAeUBCpYHgKjNLsw3ufU3ktee2hmEGoUEaU8JSY9aXvAM5/W6N5q/snYjjpQmQ3b/nxg26aIEiDu5ht1zpjEcE8T2Qgk1Rg0JSlePID+XIFY9wDJ8Rbzad/8BPN6KA6qDVkJWPttOme/KCBEi3G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qnCPjmMZRj7U/p6VDkVoS2WjeHhW5MgjPrJBF1DWTSu/1wc/+Ku/gGIawzZVE0HrsBW1arZuERQ7Ro0zBXDPpJKafQ5D0XAqIx+j8Fg4g1UpUdhwajXnUJr0KCnkSndR0XKB9mbiyVhlj0rU5mutuMZN8IOw3E5JadybxjbDOJmVvTMJHyFE9sGEXDcxXi78C8PT9i8nJyPZOR02YMW/8Cz5PuAL0JlwXVpCuyNCgv0k6KrP0iyA+kM1wU9NTY7wpzJy2jKARTahF4qUszc7F7Afi1YCjfaPYnE/Ni8oKb8RgrXxN91CCENOcCjiUPOViDPye4Y= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000011, 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 3350fe2088bc..1736bb237b2c 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -755,13 +755,8 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, /* * If we need to split any vma, do it now to save pain later. - * - * Note: mremap's move_vma VM_ACCOUNT handling assumes a partially - * unmapped vm_area_struct will remain in use: so lower split_vma - * places tmp vma above, and higher split_vma places tmp vma below. + * Does it split the first one? */ - - /* Does it split the first one? */ if (vms->start > vms->vma->vm_start) { /* From patchwork Fri Aug 30 04:01:01 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: 13784197 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 B0941CA0EDC for ; Fri, 30 Aug 2024 04:02:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA7766B00AD; Fri, 30 Aug 2024 00:02:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A092C6B00AE; Fri, 30 Aug 2024 00:02:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BD3C6B00AF; Fri, 30 Aug 2024 00:02:11 -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 50E406B00AD for ; Fri, 30 Aug 2024 00:02:11 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 007E6141405 for ; Fri, 30 Aug 2024 04:02:11 +0000 (UTC) X-FDA: 82507564062.13.C9FD264 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf14.hostedemail.com (Postfix) with ESMTP id BEF0E10000D for ; Fri, 30 Aug 2024 04:02:07 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FIUxMWPp; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KVmrCEOh; spf=pass (imf14.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=1724990408; 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=IkBZ6GD23mbbB8bJTVNg6HDcbosrtE9UJ0jUv27UWio=; b=MVcKjBos/dgtL2BLMK7eu4ieXog8fVr63Iyh5g4Y6bg+aHu6UbUIPebxBk+tpcQMNxSTNQ ZyqkAlRO/z1p0WIEOI6uyAX3efeCs3bAJ7ORIzuFq5+VMo/3zwmNqVIsySrUcsH3UOyF0G GcIqBTB42+S7cZThN1qlxIedMjflzdw= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=FIUxMWPp; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=KVmrCEOh; spf=pass (imf14.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=1724990408; a=rsa-sha256; cv=pass; b=5LMxYEQoRTl77ap5FXoYuQqrW+LbiVEtkYdN7cwQ7rCrmJr01A8vUlUAqXYaPGr6588Wnt UPS5zfdEokp6InMujOlTc3xMEh+NYQ7g7tRQywB/R4r8PvaA0v5rHIjk0PndM2OJ/34Fq4 OOSyjUUHthsGVTUn5EANyZkG/rL0wTk= 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 47U2t1Hm018731; Fri, 30 Aug 2024 04:01: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=IkBZ6GD23mbbB8bJTVNg6HDcbosrtE9UJ0jUv27UWio=; b= FIUxMWPpig3MoPvn1N9nov6adRhP8qByjAwvvi5ha3haGaOHTrS9S47LvZZ9o99Q rkvPgLxA0KuBxrqhnIcI9EIUqFAa843cpC0glod5dHJAMlWNmopLfwivItuoKG1C vjbVxXr5GUjqsUIk/KBh54PS6vG8MRT+Eh6KvOzwaoT9hRkByJ5Ww0W9BSSx7kj/ sRT98mGch8VDWHBNdqj5MKg/2a/VPKz0fUx9V/LrD3+aFPnTI5Fl0QIoSWm2pofI YJ8WSepz4apAV2N/SPNhO3QhKEr8Euzgw6zXFKKnuIKeA48ig1oNou0EeEpwFx9k mEsuNby8bgGvsgrEsnqzdQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b5q381j2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:57 +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 47U1FiMp036757; Fri, 30 Aug 2024 04:01:57 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jp2trw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 04:01:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UpdL20deIAHzhKov6aCdca3RM2IpLONvMZXtXEzgI8oTlZHKRQIgybUqx2CTfW/AkXU9REf62UB5w6EWGxNl6YkcMv/ur6poD2d7N6eFBRnB6MaruYMbT6SCTWYnsMcK4W+Rt55NsQdV471zqL8isXydX1PnNCLku1aiE8NAR2xcNgFu5ORXshJpEK+LJBOojQ9hxNCTc9Ew/sbgyd0F5TV4pbZcpLFkrmtwmw2aTpsz+DNiF8I/VN9x2PrCf/BAEgDKwFrfMKt6XEXWCoxbz3C7tLFAOZ2GyEa7/kAWC+QrnZ0UBEoCv6MvQGVmR30grWOP9pakqp+F3MUu5kO5Yg== 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=IkBZ6GD23mbbB8bJTVNg6HDcbosrtE9UJ0jUv27UWio=; b=SbIGnQczqAxSxrj2CJlHbxsz9d1ytRNt7wPNOHOsj7J8SB5mnv54FOtWebnJDPWwjV4t07+o8opHDXzN3jzLdRqCkmNCPhk6sqh1stwT4Vdhy/e3Ig5OPnpADaEGsg2bxDmQC377tTG8TpIdZQt5HGhNqwjKdrMnDyxn+EjLcSx1rItAdWZ4YKwf2tTs/454Q8Bo79476KffKoGbKkAUgxSVhFlIyTpqrhtcc7UhGp0EgCnm7quj+xs5n4E9YuZ2N0doxQdO8mVCl2Jt1oFGpgFt3lHmrcphogT/1xTLveXbKkkbVin6dSC3YFFPOvMcR50XRBnWgvulPYFSfDrmGQ== 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=IkBZ6GD23mbbB8bJTVNg6HDcbosrtE9UJ0jUv27UWio=; b=KVmrCEOh81hlGBngWm+OuYkDsVi5rzFuwbGkckjgjcOntFCbNUqst8RL0CtwbBAsk1bIrqsPr5pELkcpw4QjL4/H/4tCD2rzdFzxXlhyZl2KJTyWQkEENsOAl7hUYf7MlUD9ObKQWp/DcJ0baIDN5kaiX43INmMJlflTbXdlhgI= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by IA3PR10MB8115.namprd10.prod.outlook.com (2603:10b6:208:506::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.19; Fri, 30 Aug 2024 04:01:54 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7918.019; Fri, 30 Aug 2024 04:01:54 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , Jeff Xu , "Liam R. Howlett" Subject: [PATCH v8 21/21] mm/vma.h: Optimise vma_munmap_struct Date: Fri, 30 Aug 2024 00:01:01 -0400 Message-ID: <20240830040101.822209-22-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240830040101.822209-1-Liam.Howlett@oracle.com> References: <20240830040101.822209-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0119.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d7::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_|IA3PR10MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 41ff8fb2-7576-4cf8-f03b-08dcc8a87c26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7416014; X-Microsoft-Antispam-Message-Info: G7jf839ShxVKWgFTzRVkF4+HO4/VytUIjIQFQFS5fy9mUfaCLRD3rRlJoF7dEKBzGJmb2XeGz/f2ejXAGzcTJgVoXu4+gfdaeF7gp1FpUJiopS73laK9RgKJQ9RLApqB/HJbSRi/7eSwWA53BV9XH7dCru6b4EkgrYaNf/FVVoEvb2NJUNxC3IueTmVi8bJFTpdZQQePYb4H0xU4IV9lUoESdkIu9Z28mfb79ov6QD6jodJCVEeF45dOvFqRj4ByeUDZ/Ql9e6fOZoPcH63NlYcaOBsI8Eye1/dXYiaW7Hc7JLxL/eUoB6Y+wgtT8DKPVe6k3yZBl84s9HZow+I9ki/q/aBEEE8oF9PJsOlxjGQX5sr0V0CLVwozW1H2/Up1AZ170uGFV+pN4eg20uRcv1g8EO4D9b3M6tEe8WkRvVxSsMAXK+i8KU35F5bFZlAPwbrJjYiXVckvgJmwW0j1UvAm6/ODtAFyo6FfPdizYl9SvrtA6TfPMO3Y56wcId+qyPG82xufmECiXsiLgfQoHAR1HJUc1zT8ib6rvdKuQSdG2/0U+0rXXoJT2+RyW7FjLkcu/5X2IvxlO70Cy17dAVKnZuDio34lNT1WeTjylzH+5NB4Jx2R1UDWBJLv4+sXseLkIXXz2AXSxNffD0hOWsTJp1+vZGtfcFVRG++L5z26UcpEyxYKVlNJNsEBQmGwzzOKLoMeZvKKvK3c6KBwsS/uYOAJid4bO7ghITxs1decIIgHzdJY2f9lHAsUIGM0fFJ9LUTMC0q52XmNTKhZtPPujhSI0OaRcvbThMElDwaEbuBzBMt/MLWdxoUPdaEH4gQyBra8YV9CPIYYp72xRnwFaD+lAulR9C4LjSKfDRhpThq6mW906U6EbNIpyUvgT5K5FAqFf2r+8n92L0hVT2wzy+sVWD/0kNVWnoDHvv8zuYVAhFQ+fn7SPMAS454kNSPcby2mSMzVZ7zjAzB90668ne26pMWu5MWu6hC9CYBgV/NZiQP6qMm0dDucWuszPadmhWbKOg+KUc8A8+H3Rc5GQwK2GfRAdECtmc32klX4Q9Z0uG9reH6cp7570kQqjh/zrKybMTKelDwtCJxr6JcfYiRNoiGJcvq4ZwolQefkg7TWAUIjcDN34J9nBtnc4YvEp9/fmYRjy/5EJqbsX6SrZnCoV5b3haQLVM6x4PTwYdU4VHrOlatR5xe2IXsm1OkpS86HtUvoQLKApkQ9bsQMRICoXGJ8myOvAIPep9NEC15JK37nAIYqRT594MESvTWiJA5SrBhfrjjHpyKuz7jek9ao7pWuR2eEyGIfO7pqJEfK2KP4fksnUX0GDbr8TSE+MdI0OTvzXgFGJU84hQ== 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)(1800799024)(366016)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d67dAFAilp4OI8vPR6X2c1g5p3Zv+4W1lLCe8ZqyfQFpXTcy7283DdOMVgUqZKI9yY+TxxH2FCCpx02V1gXII1hKmeMnEqUX0f4hrNzXF06nMeO4SuIo2WG1d/zCn7K7X7K/UYnKsWmIY3YQR0WqNYx7JLvXF3zjriAM0Sh7fU5RxyU1f7IllOEGsqarBgU9fMj806q+WKuS0R7xCna2w7ScxIQlUjN+84ssCiZlwB7CPkBomIC7fhNhpPPkUtwrx5fW5PZTxultJW2lanSSfpmyv97MFFFzcXibh4TfkGdhMiwBAGCwC5/2yp5GyvyUtWC+oY7aCAPzOeQM0WjOoENtjqjgmRTi63PMNaGCRMdIqzAD5FjVuOuELs3ax7/D+STZPohonk/BDVAhZM9aWns0f1X8OoVmHgOy2Fe04bVmjz/IqDZYPZ4J433rPOvhFlTr6PyaSJZNPog7Ga1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Ffp6Lm4EcO9mUGIoxXbasQkzM8ERjQJc8ovpa9KvJ5+ZyUB1iohxfFAI8piO3wVAw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1oQA15hjtjlfNQAwAP1GanlpFtXf0PZmB+yPy1l9jtH/1/a1UA1maPhbHknPm9pHPy4pRK/pML3CkiKcTZCNZvAliAu7dlFko2aKtSzA8DTp5dpsNOFaO6Vx6y+6jNjBYu144zn6yCDHA8b9cZhCanA28rIh8urXjzjsFX+Idh9Mk0xNNb8Nd3GYIUjJ48mQHVRWV1aUca0y+S8SNmkviotmqYhn+alG7Fxu+OTmvmAbU5WwJC5KPdtD0SUj+jmFGTLwo5MSb7R/SfG4OBvZELUWyHTtiwDLs9V3221viLyLw6akZd2qMIc8JGsjraADBxLvGeDwY2IGGLp3l8o0hrYkjX/PTgz6zU3bXuYWBbPAf5wfQsatF8XeOw9A6u0+mVZy6z+3tHHMT9M1FRDWBBpFeL8bfd6Fg70BDGt0EmKXz3OXMhgXdK984yIikie/K5VKcPXsFsetWEZqJNHdT5sN0AYUFmiPdqsG0f18NRL57ZEm7RgzUWbqgzkmviLIZl9GlK7/q0fa8WFXV+qVeYXk/kEYpAdzdrxKa6jR+2Xe+L9UVUNMDB4RYgF3GyVxfDdHrCh/nuV+mLYm1agobk0RSDA/AdzNoH6AowuUK+U= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41ff8fb2-7576-4cf8-f03b-08dcc8a87c26 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 04:01:54.3624 (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: bf7QfIcvpBhcxfum2CBcEIEQUh9LyZOhMT1syy0IsJ0EZaueALB0HvUG471D3Ltj4Qe/KnwO5yU0HUCpTtdlKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8115 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_02,2024-08-29_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300028 X-Proofpoint-GUID: GxSzGFAWR-p-cHxD2Uvldj6tTmhvTIDs X-Proofpoint-ORIG-GUID: GxSzGFAWR-p-cHxD2Uvldj6tTmhvTIDs X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BEF0E10000D X-Stat-Signature: dsbwfpfb8e9sdkt6eb4pqtqpn9wi4ujc X-Rspam-User: X-HE-Tag: 1724990527-415531 X-HE-Meta: U2FsdGVkX188FqHtyTz7Ceophwq+6vrzbiDL5WzKfMpSZPf6YYEGCL29uM8gnwTMFC2+I4ABoICnlxfDowWg0byES2SpzLzHt+Bt4USJJIo4hnt6Z/+KL/ml0OBUOvsf85zEMST3XRf77R3CdVjgdvHcwB2XK3+N3UmApE+xFx7fnInAiB4YwE9pCsp9m7aJABXY5ioXFx/YhjmRuddVbg5xeTgKEPgR8pFiByjgio7bRDWH0sWqkWOK4noHRdRXUHF0JrLLobbVZnpjhm6mRGf9wZsP1hOZvSK0091/WQP2OVScwjGeEdhqZ2Dn4OT3FdzcVeGYbWjwYSISCo6TegzkveC6RoyfEWU1Mfd/MEcJPhkXSprL+UxMeWfHGEKrwv5qlJgKoRo5gPMtUEsoXWyWVphAC/BSKVBZCKwNtMxvQ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3DuDTSLID5tKw9WSvY6TE5sHmqVqz36gVQXntkqybdv0FOo66zUzp8BwbVyxQDJUgJqyliZnI3jZeDQj1xPUi9qAEqfTS7Itx6Bc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" The vma_munmap_struct has a hole of 4 bytes and pushes the struct to three cachelines. Relocating the three booleans upwards allows for the struct to only use two cachelines (as reported by pahole on amd64). Before: struct vma_munmap_struct { struct vma_iterator * vmi; /* 0 8 */ struct vm_area_struct * vma; /* 8 8 */ struct vm_area_struct * prev; /* 16 8 */ struct vm_area_struct * next; /* 24 8 */ struct list_head * uf; /* 32 8 */ long unsigned int start; /* 40 8 */ long unsigned int end; /* 48 8 */ long unsigned int unmap_start; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ long unsigned int unmap_end; /* 64 8 */ int vma_count; /* 72 4 */ /* XXX 4 bytes hole, try to pack */ long unsigned int nr_pages; /* 80 8 */ long unsigned int locked_vm; /* 88 8 */ long unsigned int nr_accounted; /* 96 8 */ long unsigned int exec_vm; /* 104 8 */ long unsigned int stack_vm; /* 112 8 */ long unsigned int data_vm; /* 120 8 */ /* --- cacheline 2 boundary (128 bytes) --- */ bool unlock; /* 128 1 */ bool clear_ptes; /* 129 1 */ bool closed_vm_ops; /* 130 1 */ /* size: 136, cachelines: 3, members: 19 */ /* sum members: 127, holes: 1, sum holes: 4 */ /* padding: 5 */ /* last cacheline: 8 bytes */ }; After: struct vma_munmap_struct { struct vma_iterator * vmi; /* 0 8 */ struct vm_area_struct * vma; /* 8 8 */ struct vm_area_struct * prev; /* 16 8 */ struct vm_area_struct * next; /* 24 8 */ struct list_head * uf; /* 32 8 */ long unsigned int start; /* 40 8 */ long unsigned int end; /* 48 8 */ long unsigned int unmap_start; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ long unsigned int unmap_end; /* 64 8 */ int vma_count; /* 72 4 */ bool unlock; /* 76 1 */ bool clear_ptes; /* 77 1 */ bool closed_vm_ops; /* 78 1 */ /* XXX 1 byte hole, try to pack */ long unsigned int nr_pages; /* 80 8 */ long unsigned int locked_vm; /* 88 8 */ long unsigned int nr_accounted; /* 96 8 */ long unsigned int exec_vm; /* 104 8 */ long unsigned int stack_vm; /* 112 8 */ long unsigned int data_vm; /* 120 8 */ /* size: 128, cachelines: 2, members: 19 */ /* sum members: 127, holes: 1, sum holes: 1 */ }; Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/vma.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/vma.h b/mm/vma.h index 6900e95bcaac..85616faa4490 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -40,15 +40,16 @@ struct vma_munmap_struct { unsigned long unmap_start; /* Unmap PTE start */ unsigned long unmap_end; /* Unmap PTE end */ int vma_count; /* Number of vmas that will be removed */ + bool unlock; /* Unlock after the munmap */ + bool clear_ptes; /* If there are outstanding PTE to be cleared */ + bool closed_vm_ops; /* call_mmap() was encountered, so vmas may be closed */ + /* 1 byte hole */ unsigned long nr_pages; /* Number of pages being removed */ unsigned long locked_vm; /* Number of locked pages */ unsigned long nr_accounted; /* Number of VM_ACCOUNT pages */ unsigned long exec_vm; unsigned long stack_vm; unsigned long data_vm; - bool unlock; /* Unlock after the munmap */ - bool clear_ptes; /* If there are outstanding PTE to be cleared */ - bool closed_vm_ops; /* call_mmap() was encountered, so vmas may be closed */ }; #ifdef CONFIG_DEBUG_VM_MAPLE_TREE