From patchwork Tue Jun 25 19:11:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711855 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 831BAC30653 for ; Tue, 25 Jun 2024 19:12:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D93E56B00A0; Tue, 25 Jun 2024 15:12:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D43A26B00A4; Tue, 25 Jun 2024 15:12:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B96556B00A5; Tue, 25 Jun 2024 15:12:12 -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 973BC6B00A0 for ; Tue, 25 Jun 2024 15:12:12 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1B431A0575 for ; Tue, 25 Jun 2024 19:12:12 +0000 (UTC) X-FDA: 82270356504.23.57FDD67 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf27.hostedemail.com (Postfix) with ESMTP id C460440004 for ; Tue, 25 Jun 2024 19:12:08 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mPNhXfD2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="lEiifg/T"; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf27.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=1719342714; 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=vBrw4cpyDlw0oCxrS1NpsHrvh6il04b/OpjjP2KEzV4=; b=a+d1FxVY2nAyEcmpvJYo7Vciuk+uemuBuTPzfVid7i7g7/EWpvhTBc4tr5bG9C8NiGXZyl UoYsxipDEu3R4EimBRDdqRgjoFnKmt0WC4wEUTp3Osi8KxCSE89sI48tmvYOnr/qaWD47W DcVM0Vqe04f09oulSXVs7tiroA7m9NM= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342714; a=rsa-sha256; cv=pass; b=DuCHk8plOal4xx2mPZU9dcgQx1VYGfsOCiyApR4xFa04lLhLSg/id/kFmdWz8B6IC7PmtU iiRmE6UPA2LEuZb/yoQJFiB5NR1wJqJWwtkBKChaNW43hKSwlI6tG16l2DzU35SGZkTRS0 kaJecWwQwpLx/TfDS6Z4DubcXVyR6Ow= ARC-Authentication-Results: i=2; imf27.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mPNhXfD2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="lEiifg/T"; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf27.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 45PIfTXT012777; Tue, 25 Jun 2024 19:11:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=vBrw4cpyDlw0oCxrS1NpsHrvh6il04b/OpjjP2KEzV4=; b= mPNhXfD2YyCu1QIjCFq1gutp9o7z/wM2W289Gzuz+bqYxQ6Crv9PsTN+DN+bIhR/ 3kV1FgF80boAM3+/SWBueFViWUqiZmvawdFLH8YIqiEEpyCU98KUW3OL9nIxTURe yR483TYCp0mqvCeWDCTRzeK1kMHxyj+X1iUlBvWUZS32chO6cTSma0akcMQ3VbtQ SLd96eMr6mosG2hrHceyBgBnIVpmlaSMZa1O9gJu9FV2v1gTRElXIaGUS+eKgpEy HCiVPbBQA+qPdAzRyMCJsbV4J4y7BDYvA8OObhJLIWJ+j8QgSkk7BCF4MYCUX82l Ni3kfs9bkwdOHcPEi85vTQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywpnc9uan-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:11:57 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PIqmFc010741; Tue, 25 Jun 2024 19:11:56 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn2egt33-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:11:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eEHpOtHErB8DakbB8jrEBO+fZjcvBeag8XHhfItckG090HVNw31TsV19UG6wYN/PeF7yk0XdZBUNevZmSb74JuTrAEwB5MTgX1ZZ/enadeKldZglSvJFP3ahSlxA8K5iNRu2EtRM1VnqHuSSAOUZFZMQrAZFJ0i1Ywh/XjoV7sWR4GvBMcqxRuGoqgB+j/RWAAEMMe8InV3GLT57sgdicPvTyBtZqZFbj1j0kJjkvAjTZstxdgXGYqUz0WimUiR5+ZpBC4c0aMX3cIes2zhokiOxG79ngNxfrAGrDrfNILnjgPCcMk5HzK0kwOFg5bQ6qZn6BU+kpwiWHsbUaQVA1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=vBrw4cpyDlw0oCxrS1NpsHrvh6il04b/OpjjP2KEzV4=; b=H+d9WVsjwI9R8RKiXC3XJWSXos+N5UhqCL+hxhpTScTrkqQPh0xdZXO2+JbRv0ws4FLZd77o45BS2TGp4qIzOs7dGwhiEuu+uR3BD3lfxDwqOWXXYTChA8m6VP/aDfw1LG4lA2o/WwF4cq7kHtpYZUGXCauVkBKwxkl9KlmUO+KW9HPoObKvooIG2ha8m1RhJSn6CslVq1OXsJ1Cy3Um3iHyWrJ6FiRM590ceQk10luzyJkZy1AS2KHG2MAjaVdZ7sdVsY1U3EpBWkStFgTqjT4hW265ylHt/op96sycPvZGgH7ts41HDo0J27FyxsETdw5g852b9Mo4IyUeKBqZxw== 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=vBrw4cpyDlw0oCxrS1NpsHrvh6il04b/OpjjP2KEzV4=; b=lEiifg/T1c4VAYIPkFZJVXwjAHlnz+oQD2jcS7CVsqEsW+htt/xdGt5eh1c80LmwygYPzImYU6/oaeZHrEri4/yQnS74hIYVtpu+QCALyrSLvYtHqgmeY0zQTIfHmXXG3ainwl/2m1v87I6HKEz/ajmtKzhc1SeBYMK+UtS7upc= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CO1PR10MB4707.namprd10.prod.outlook.com (2603:10b6:303:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 19:11:55 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:11:55 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 01/15] mm/mmap: Correctly position vma_iterator in __split_vma() Date: Tue, 25 Jun 2024 15:11:31 -0400 Message-ID: <20240625191145.3382793-2-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0058.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d2::21) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CO1PR10MB4707:EE_ X-MS-Office365-Filtering-Correlation-Id: 6265a5bf-9856-440c-4431-08dc954aad83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: fGy679aj1+cegQynxq9ggpzb00Y6VPByi1kssyyONJwE71PtdaOvSQuO7vmXPdcGD8IOtbBawB/HCv3EJ1rK7nM8X+Ue/M0l3NueHADkcBZ+Jwmcvswnfm04cLlkYhXS3mkoOup1K8RqjMlNo2lsGfPHh/XSAfMTF4lM924FFpHxDayKYmgP5zpZ/N/srJNJ2Y1wDNv38JAwq6Vnsxe6KClD5cKv4j6HLSzRUj2KuFy3Qq6a/ZLFoGfPV09W9g3v50XJlX2diBchyodIvEy5PdsbDyIkm8ik+rzzCbb70ym6KXBp/xh3loD6RjO4YaENv0oXu4dGx9iryNQlMEUHcJIrYXPJ7qzjs9a2gcSMKyQ7g09MnJkT6t3IHDqzORVcSRBX7KSWzT0BMsSSKYMxDeiAw5KreBTxqgaL5SYQmJJnutueBuezajvCZVaUwg/Sd7tzLjbNfLXIjat/G/f4SAUZ/GBuJAWEXD8rLxcjphldyP4jkwm7bftX+uh4rrXBU30EwiZhOT49eAL644+TdB94yYQBtCQD1d1TOcuNh+3TkyfP6iAQT8AJ+Qd6GyaL4i1tJNgANwD01LVX4X6/q89iWhSSLsfde1g2Ozp3dWf+TgcxajBvXzx+L3K07yYScLxNTjMkMSE3E2NEdlwq8U+rB2btC0zPTM/QTAaMRguaX82yjXCu3eRMAod9UBtgIZWWJxS6+k9uM8keapKSEUVNIkefj1tzSPTc4fd+9U3gME77oFsOx80cfLolN4IagrDyaAYpSgvLwTxAV73g3qHyUa2g8pJ+NrsTbdslRVmygBkyd26iurjx9iZ8pubTZd2zEtLTu7u4TCu+nTaCi2GutyZx9CG3WAwzZwztuIYqbVvHt70WbTxCKp/fhD9/iqJGPSFR5ZRvLoRwOVfNYefbejNA0LW3SUkUNRxnV9CZbLtRFmw5Ww9jHX8E6wuu59BGRTeN6dQppDbZJCYOzvCRlp/FMz9Am4pioSacaKd1Hm9Sn0bJOJZOJileyfnm0NjPMjwjgkDWmsBt1bAVDchp4Ajlk7fvCRRvagN8xVxG2kld4p1TepvI6RTJTMuTyF9TzmFs4tg9akthxEnNs5HQwj6hmdNyEgYJE2MP1MHInebtDjFlwiWa/fPbWlw2hvJ2owqpQnb17IgWVEvuTLSNpGqo25SlfldGrMFztrgpt0eTxme+k/ok62tsZ0A7AntM3Vass++uQDf2tcIQGNEGBBHKy6ULk1N0FwmcP8IG4cxGKNeTE3w62esOnRkHubvX9EHN2M9GYdpdbvINL7TjL9GoBeAm5x3kxDRd2ZXHlwKMk9jurz71LkXL8U1Q 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +WvB7CrGT6+VIuwdJdz0RX4/UtsTVdPYzyptIeTgnxvtwzqMRg35ucQFjn+m5jg14AOsNULAA4Ce6hVFtMWJI4JliMOYcHOTNaLnSKP6gLHmcGd+J4sSXubciguHog1Y8wNyins3xzVsO9Hf+q/mMxq1oy+CKkUaHWs6g1B22WHCo4LUwJQloDVQQ34Udq689smDjJ/rtrusA2dYTsdwV3buOTI4K9msF4JU4iFhJYX5ROXr+aKRGfSRPuF55Di/q/TOuHU2UsT1IECbQCNiQuhbIe4bZA2OVXxv53r4kIZfzIn3luK6T142bZSERb6Lhg00PUTsJGkWPVKhu20k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PSyH7zurfa/4gEN+Efhi+idgyqXPNvz1cOIVvC4aZkb54DSjQaNjY0LGZdxQMTt8Fy9nqv+TfLvIv97Zgvp9aVRvfqZzb0EhdpcLpgK85FADMOslbAg/PiUyCO1SHXOJx8vRdIcoC8eQCM3cKfdOuQRapzfuX/4fF+gyAboIwLPGHmWntFUnahKeL X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 55LF2vGPax14wf6hiMqCHwaCXf6D2hSzzKOPnyoxVcWQ/RXnUQ8SdxrhediNHsD2axM/bBB9wkPjH/H1JCiQirTlRyLtoNMgIaG8YbswbwR5ZBX31UMzT8upyQKcRk0gOByGR7i+c5QhavPEFl3mbBIjJXCNmSh2NgE/OD7fGwDWkwkfT+SDIhLzeE0ZUi9mZHaapJulspq41cRmgmhrWBog/qan0oYEc0Uu+b8ZbV6x8rclXstxGSLbeLSorKGbsoCQLYIj58U+P4oNp1Sz6hhVxnUlYeDyMkjL0LDXM0gepaJcyhxWtPMzjG9BhNSQIgPZ7bv+0vuP+q7FR6Rf1n/CgeNCP9z6unbxyptVhiYvKqSOMeBP7Ww/ANTWUpd6uiuv56hfXFVo+6TH2q9dzEawcP22FY3/M305ZqUZO9Im/wB5iAUtUQ8g8gVi5xKnJjB80zmxmEAfT0r257CE0HtXLof4tTep6xlGOI78bJ9Td/ZUVzqXXHbpLZHs0pu99kBO3WfrUGaOqi4WYKfsc8XzObr2Gt4DRDjYezXypP4vRT05X15t9xRROIuWTzygrdAdGu6B9QjcRN2uD0g66CXcuOiUbfHF1lWNcBHfFBM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6265a5bf-9856-440c-4431-08dc954aad83 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:11:55.1989 (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: Hrm945YIyWRIJ5/dWHA0UmQ/X6F/bUQIb++DVHwkX52j4w5Kw3Rp4db6vsXycDMmC+uFoCVZMnOXvr0Mt8fw6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4707 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: _NQkidzSuWG8KZKS_Xw_eGL4S8d_6KHA X-Proofpoint-ORIG-GUID: _NQkidzSuWG8KZKS_Xw_eGL4S8d_6KHA X-Rspamd-Queue-Id: C460440004 X-Stat-Signature: y1tr4ys6yiwtqsrmmsh11arino87bor9 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1719342728-262338 X-HE-Meta: U2FsdGVkX1+XiGtgFI6VD795JopTFBtmx2emHMavKiZ8EbB5adKaO170I1utXp/ztQzFRDmX7Rvo1jLb5Ert/V9LaHi1/0TnLIjaD3vp8NSRKtljMpi/o9fOnwpyX4iiT2K7X/CHAOnXr4RKcCFgQQjZMHUuBlkVxTEhZ73ig2uBAl6Z55NICFgMg5cveYkooBrhxTZ9BycAII0/BNErNo2SF6ZsiGurambdutSMRhXuA36DMNal6LFg/N6UKup7ASYMvBTmd1xKfwuAFVmgaUEQQJc6jIvaBwYhmNuAm8eZ7OlsIfMLfuNaBjYSgkpmEqI56zh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sIwFJABscAJaBIDucqaaplEJHAuUqRqhtxzgWL50bdCkrDA3jqKOKOVm9rrmNskYefMXEunXJT/gohe1Q6CFHxMpVwMGfskyu8ZNpxjAzL+ivA= 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: 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/mmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index e42d89f98071..28a46d9ddde0 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2414,7 +2414,7 @@ static 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) @@ -2483,6 +2483,9 @@ static int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, /* Success. */ if (new_below) vma_next(vmi); + else + vma_prev(vmi); + return 0; out_free_mpol: From patchwork Tue Jun 25 19:11:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711857 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 28E60C30653 for ; Tue, 25 Jun 2024 19:12:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C84396B00A5; Tue, 25 Jun 2024 15:12:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C5A2A6B00A7; Tue, 25 Jun 2024 15:12:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A84EF6B00A9; Tue, 25 Jun 2024 15:12:13 -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 8031E6B00A7 for ; Tue, 25 Jun 2024 15:12:13 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 262BF1A057B for ; Tue, 25 Jun 2024 19:12:13 +0000 (UTC) X-FDA: 82270356546.23.C163614 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf13.hostedemail.com (Postfix) with ESMTP id CF87A2001C for ; Tue, 25 Jun 2024 19:12:09 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=geKPBgWh; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=a3O9nx2l; 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; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342709; 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=zSu8hDWlGjMxPlRgldY+gYYh1jH3ES1rfBL14tJEjt0=; b=4cZoHfXVdERTDD5kCi9pgQqaBvlH8rav2oEa9ROpQxSbgGpEQ09/twK4Q1I+aB9u1VjiyS jHcvcfpwMytYyXfhnD2h8oz6gek7RvQzCkFgwyanDXVq9h0zwSPELgKg9dGS2c4ZOpiS7K SL/nhxk8Sc+1lZ3rh48w2f9lBnuop9Q= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=geKPBgWh; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=a3O9nx2l; 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; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342709; a=rsa-sha256; cv=pass; b=x9DtyAsvQJpJUvViQVrR39+eBs4IbneJIyI3gJTi7Cru4OrUZ5EaU9rTsK/6fWN64xivdV uX3p4ornyUmhQnuX8/uRcAm82cQiwK5NdBUwcC+k+JP2RfGPWrFszO3H8Q6AWN98ug7rKv KUddK2udRLE9AqjfAfGvWFEdMwfYOFQ= 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 45PIfTXk018305; Tue, 25 Jun 2024 19:12:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=zSu8hDWlGjMxPlRgldY+gYYh1jH3ES1rfBL14tJEjt0=; b= geKPBgWhM5WIp2+ekoXwDoNwufxBJj6bRgerNypGXAtUA7xW3ZNNxoUVSdGqXbRJ aBNX4C578kFSazvs5IZODIW8cE5rvpXFozxsaJtMwsfFzRQLr7NrMS0ciPt0mp/v MFneqkDrTWAwl/Lve2qZsxS1KJiM1FXVDNgfkbvMJg4ruhc6DnLRUZXT8o+vr/J8 wNFVUxJjjsgNky6ekITINPuLKtlVTbKtk1ZeXOR/aNx/doMRNOV47ggxeQeNehLd /3IxnJ8jboqTbU4wt+WfNpYjia9vl5eNEhlMq35RdOM9Xt94cqxIm3+wGSmsgkbg l1gFkPxXArJiUSdG+RSLVA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywnd2hmby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:01 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PIrYKp010721; Tue, 25 Jun 2024 19:12:01 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn2egtb2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RnMtv6b7znPbELE25pRfsGA4dhQEgmzFIoZQLJLsaQaszzT2myG55Q+s7Jn+k15jwGaTNs/gk/oGLwvH9/iToBwz0RAfmN3gB0v/r7P573zb/fQ4HXPVlqcfM/d9yXE8hbT8/EdgJliW7l87JjZITwmHCDqYZAW6DKgG8ITWzViIjygV7ZKCBO/mj8RRLXsRsL+mNfqB39Q2MGMk/6WF28PsDsxXZgqv3R8b2dSjw0CJV18OGAfJGPtJQWhaSap6UYXsBBSF2Kp8tlQT+B5+0UFBWk5uruIQdHVSo4iNElpDH/2U9NtJi0XVqu0WglUR6hsORue2eYxVi6B8OLbYMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=zSu8hDWlGjMxPlRgldY+gYYh1jH3ES1rfBL14tJEjt0=; b=aiiFpfm2MLxPy8cPZrCQ1VaLeUrXWqmvObgzQhJ8cLdC8VkSAbI3BeGAtd0v7MLsUxwi6jLPYWywyRAcm/aT238YpjddcF3WRAT5iUX+0+twMYFO4al8XWvK4QOBciY0u7SVGpG6a7wgZ2H6hDNCi1GpLuMEmmCHyUN56oIQS7x0MoJX2ZlW9mv+3NC2uqCCDis7XV8AKfg4Kl7wJPvDh1+t64YG+nr827Zh3qbrDNjIh+p8qLn28gzQ51fdoFJ7EPSIB4w3A4DaPxJ3Je4Vu0Js+vsGtbFLXXoyY54+ggUHWYyf3Qw4RcS9fRyPN1JvtPoYcRFtp8xHonM9eRz/FA== 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=zSu8hDWlGjMxPlRgldY+gYYh1jH3ES1rfBL14tJEjt0=; b=a3O9nx2lOKAGh3dnVekeXdbA2QoGK7yqMC5KNM/Uv0xzLBvrv19YGcr9BDefzkSRLW5DCg1nTfiwBNriwS/zMX/QyHcekfvjzBCVPB4tEEjmC5sCG5X/qPYChEnBirSRVy2W2JLdxA2P/5ql10AB37u7eA6XU/qGRqQp5szAIbY= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CO1PR10MB4707.namprd10.prod.outlook.com (2603:10b6:303:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 19:11:58 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:11:57 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 02/15] mm/mmap: Introduce abort_munmap_vmas() Date: Tue, 25 Jun 2024 15:11:32 -0400 Message-ID: <20240625191145.3382793-3-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0057.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d2::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_|CO1PR10MB4707:EE_ X-MS-Office365-Filtering-Correlation-Id: 36296a7f-ac08-4850-d64a-08dc954aaed5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: NwbYqFQpi44WKwMz2ua+aosjy/aeBPxdj0XcvPiHNqSG1gPeTxeYhcDkRZhkCwh+75iVHNFMj0Uydm1kGR+lk+fTY97DuoH+W148JKIUOiDUgbyOT5G9xkai2fIq8N4w7G7pDo6ZaanbJK26SwN3z2mp3lka8440Az4hGBOoZrXsiSimEw0BxFL+/k62ZoxXHGtiQD0To+/wCJDbTz9BnFyOCJTRfaIFt5hc/aoKnce/GwzyShQLve4Uw+f7OgJ7R/fvXTiJ45KI29Y0YU3UBhcguQTVQdlHGaAxo+quPs19effPMwrWlUMwkNMjfDxeFZG/oithNYYVMJdJegPH3x8egi27pBQvTrKoCxtb8Ajyd/B0CtTydIdAtk+UHXzGjiSw7TH/V7ZjfROR/8KFpawofR9Eu6BCqvF9sPm++rma4Nymf5WnsYVWQBGhhGD0LPGnfkMCfIeC5TgA0TYq+MkSM6RObQOabNn4saIF0IjHzVl025dKGlq3OOwiZLicV5gGB2W1VLGwiLSLgUFJZjfqAPZ8N9Hj7czks/nL3HfS95wkcc9Xwk5bID466gbSmeT1OD3PUgO6hq5udTpbFbkJ/Rns7YbsqOw5FAVnrOUTmuwds3LWcjCheaQu9sv7eQ4wRzgI+46LW9/4DLXh1Eq1OCqjgoU0lKWVtzdCr8sX/3zfaeTozy/HLLj8rBlrpQJmCuAJuo+qmXaMFDJEvcfeDenBi9f1WLmWwpv4HL/SsmdtPZ6GCjo3gCgSf7ntrXl77O9PEusg+yNkv4TOSpXivUzsDIMx5TNVIvXCj9bicoX4gyGDKLlENjY052FtP5NlQBOpapTeH0b0ty7D88MszwF6ty3B0IiOhLKS2/JzN3KJoruZuvrRto2X7DHs9INRHM13X47flaR64tJw8cpUEti1lqullI+mA7Q3/uZMDtufuaa9h4PbKAsTTWL4eS8HS4vSnGhA04X5ZUm9aRF1c0BjJYahXWmKdU/22B1nwjPkr8hKql589IR2XmCBR4I8dSSuKRff6NEU2oDk1pQSHacYjXSvsbUER8YCkVXYCFvE/tACGvh1CDDg5bBn0E7b81/+NxUTlS+a1+s9yXnmAAgUp6RdUm4J2Wpl9nZSgDE1eR0rJZRFrUGpPRUkWqvTK2SK6oQ0poXoyyFCK4L9O/ph8U4S0ODJC8RvPi0WLNjXkGxp+v7LL1oPLewJHjit5fRz3VNn0S7tHa0vmFNMptT1gJJpgX5bg4SUq4gMpEZ7LQJuS0s0L2pC7Y7xHh1Ku7XUH+wQ3v2NpqZmjyTQMvVGJJWwpvVvyvTfUFw4KlI/L0VfBmnZf8qlpLgx 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZmGh4lWeZyu1V8C28NP2HqGxJA5f7XghJnpgzoOWgKiV+CkhW6au5o1W8M8sHwclAxflOOfjjMsjByhiaany0+ArZ4xL2tCDBBN41/YMbDMUNcfqJvoEWN2CnEXiIwfTfJk5XFCM9ic9PVE/UXMgECqUiDIJKkA2TWXXDQLhljgi5nAqTnj+MnXY5g1FshSX9NQlbLY/4Sk7ZeoWQejPwduMOONUsyv+CcQlg2aCvkZQEoXIXKjjJ2Y0K7SOL4BsLQSDODzs/tbEaLoCXYBEFNxKavxSqoMPRjF0CxE3FOHbKHqj8CMkHbBcjuklzYqucv87D+Y0CkQy++VWTmy1XAuhCaAlIAByWgB8LYjIuc0iDjpsKpHPpdI+7ybtuiXth3ytQOSSF/8GCZ6KK0Ez3QX8OjCMmisV4bmm8d1/6M0XkGsLYQ1bAk6K1ydYCArmyYrJZeVO+3gF5vENmF52tkvMMTKxfAA1lnO35bFGpKc4HLU2sVl7EXHVXZ80Z+B5nsier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W4lP6okZW68NBPGtwb4BababhmoG X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: c5SVP4S2q6JOIpxfSStRILTOdaDmbXf6Pqbd6UU1XKSyR/hWrKKKktAcIzlO/FaKQSc6mLnrGTDkGIlt7neSPmoe9xzz9k94dCj9m8K95AHyEz1ePez/QXlNWRFA5PJTIldiW9KUhVfDkMWI89bmn+4+AthJntPhxodvDU4NqYibQS5ta9U/3a7YLZ+zHL/Po1bnRFs8UbqfDknTrkTW0LRZgKipITjoFB3GOPIGPCZ/uxGk77CyMq8SSbk1eJcyoc9bMeqj/qGiL3vLjg38NxYeNyfdVhEfTD2z33WwKpRSajw9K9DxoMpWhLv8mgwlawpczqywBY3vgx16lKb9Dijuj8XpdmAK2RR6/ju1IQ5lkGc76ZuMSTLWdPblWlpcz7xXyYy0kamzkhUPAlKUD8Oo68nyjUQAf2U/VkVqmpUFQCGRFThP0r4pVGhdIpwHMgNBaFTTOYOdaWLGtW6BKY93OkNq0q2GehQlcVcTr9cUcmCKfu2cE9GFJi3gthxkHdJieydAljk1fxrKUSnRdaWBYkfKzlIPWIewuraAJJVvZb0mR84OtleoNhdi3cUur1ENpglsvt2ir8lU+63hAi1XLeaA6oWPQXK1v3+RUCk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36296a7f-ac08-4850-d64a-08dc954aaed5 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:11:57.4211 (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: DSliW50W3k0XYfzLXr28pMJ3Th/3QMgf3FrlmPXSOnqfhCvMZT8IBs4WvkvClr6i1lUWqv4wzdD9WQh//w7aOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4707 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-ORIG-GUID: wwxhG0xOyhSs-M8cgL1YVo9GwSdW2cxm X-Proofpoint-GUID: wwxhG0xOyhSs-M8cgL1YVo9GwSdW2cxm X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CF87A2001C X-Stat-Signature: czic3nfpndtbonwtsndaw6rrcyn94kg6 X-Rspam-User: X-HE-Tag: 1719342729-912985 X-HE-Meta: U2FsdGVkX18wYduetJu58MJvsXF3BqylcZrT7f8me8htu7AHim77NTa8q23MRny4nw1iRq/Z9iWrqe+A1oQUyNZIXxfYIKUvSh5M3oemYQ7mtXJ1TgjRM6gpF/gV7vn8xu6UkN8pedoGdtcj5m+xE4My7mjuoJ/BHr7/CjwijUBM1A6qvJaBfmPNLylPIJOLDvJxtOFHPURMzRvOgnQFnO/q0F2vl3gBkBcVHnPalKlj2inNROPnw5NQ1jb8dBlrdXrNGj+3joJ/qeCN1TmornNeBfgk0Qc5SashcOun8HSoH57kh538/b+z2J2513A0G8jWwZJHpnjwtSf7XmnJmKrs/wz1eyDxClrsboawvrvCQm+pd2C2sbQj6r3URcl88p5X1WWY5OVEKBP299Q++rJBl/8hSccUTeDOAX+MMVpf8/rLSoFpR+duKSxufuwSW1qQ4iO0pNzBdE+vPdC+w4eYXfhfuRLZtQd71QAbDpNDk7O4ZbuwsbTD0Or3/LzeZRH6yWuyTX6NwzHkDs7ZvYGQgoHediLuX44KExPn2RA0iQYkAdulbR0TcB+rIXs9/orUuMty7BgR8B2KEoWVvc6a1YYArmQ7WhifQqvaiOjDXLCCKAwpSRusmoFi+Z2/pcrTGOiAmDU+Q/KKqKpaekbbDIKJqIwnrWjrgwaJX8GZCbAX/gEMPr/VBxlKl3JO0u02cOYQW59vEQWq0tK9YJiEHoy8jbfSmA4T04ozmd5OV7Jg41UrYJrw+9hn/WM4OQEHgExdDC7ekFn+KNfIpYzlCQcPhk88YA7fnFZ9O8IrKugs//3UG7bY+NjOZ/s9Fg/2RMlESJPp6iNqXrchxfBKix/jmRueZtx1JCtf/64v9j3FxPV+szGaOc+GpUrBTGeMlIWhDYgu/kVNacIOuinOVXu9p+YHd5qtT9qrMmoZUk9tbN+w6bKKQdHEdN/Sa+GSt/BBk/MeZIjjkRV cf+/eA7q uayzD/17rFZwx1syZwHv349RJj++8w6ss9cJ7KVbZNlemqLDsJc3yUi+/IwayhCeiGu2xhcj17sZBEGn7d0BGaLv85Ai/ZYrhHGKo8sGdyIidn9zaWm6DaeTYBX5wiZ5/lNxy5HwZiSgTFy6pErz+VdLqqENNSk/5+Fj1MsyPhDPjOmQWxJOrQBsQPO+osyN3r9A6O0TMfFwSNDGBxRR7bfB5Ic9EtWu4FE/Xq/ggEAQmZAe/g1DcYIHcSTwX28IkjnoX6C23H8ruXvkCQRxbiRRDaLKo36uQBJ0Ueg1cufjLCquQYMFmyqSAUPUscK1jd9WFCa3ObZJjTQhHq48LeIpPjm6XBjWpc19OoH5FQlvPihF5xmdm+ic+2/xaKLSEr4nxhNVArq0Ti9he/ObsAQj9E2zrSMqwfqGdU5jr7HdEuyhTqGVXW1aPfO9XEb3Tj1ODrtdqtRd00tzIlZAqWX/jWg== 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: Extract clean up of failed munmap() operations from do_vmi_align_munmap(). This simplifies later patches in the series. Signed-off-by: Liam R. Howlett --- mm/mmap.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 28a46d9ddde0..d572e1ff8255 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2586,6 +2586,25 @@ struct vm_area_struct *vma_merge_extend(struct vma_iterator *vmi, vma->vm_userfaultfd_ctx, anon_vma_name(vma)); } +/* + * abort_munmap_vmas - Undo any munmap work and free resources + * + * Reattach detached vmas, free up maple tree used to track the vmas. + */ +static inline void abort_munmap_vmas(struct ma_state *mas_detach) +{ + struct vm_area_struct *vma; + int limit; + + limit = mas_detach->index; + mas_set(mas_detach, 0); + /* Re-attach any detached VMAs */ + mas_for_each(mas_detach, vma, limit) + 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 @@ -2740,11 +2759,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, userfaultfd_error: munmap_gather_failed: end_split_failed: - mas_set(&mas_detach, 0); - mas_for_each(&mas_detach, next, end) - vma_mark_detached(next, false); - - __mt_destroy(&mt_detach); + abort_munmap_vmas(&mas_detach); start_split_failed: map_count_exceeded: validate_mm(mm); From patchwork Tue Jun 25 19:11:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711858 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 04C29C30653 for ; Tue, 25 Jun 2024 19:12:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D6496B00AD; Tue, 25 Jun 2024 15:12:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 139BD6B00AC; Tue, 25 Jun 2024 15:12:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E574D6B00AD; Tue, 25 Jun 2024 15:12:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C143C6B00A7 for ; Tue, 25 Jun 2024 15:12:14 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 659B1805C4 for ; Tue, 25 Jun 2024 19:12:14 +0000 (UTC) X-FDA: 82270356588.03.138E60F Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf01.hostedemail.com (Postfix) with ESMTP id F0EB84000A for ; Tue, 25 Jun 2024 19:12:10 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=kJ8GdHJb; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=b4xN6jRV; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf01.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=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342714; 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=60kAsYjdha+bVEANDM89tZg/qOvXIAnhtflm3wfsjyU=; b=trh/1c0akOPDuy48hBtYImr52UJrr+CKWVWs6C9V8oq0HtUntq2XtJWfMabsSCUeuTbm3F DvKeA1WnzTgmg0i/zLXbfa87NraDFDxQ5ZJxxucDSatVlZWnRiqlvkPw8uGm5liQseXnUe 9i/m8/mFltR8GmLddkGTaCjd/jRNZbs= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342714; a=rsa-sha256; cv=pass; b=dNlIGakpFa8Svs0GEFEiaJrhVgPQK9hG7Gza8JOq2wWyEkb/eS5E+XWCW3m3gtvENgOl44 iYjiPEhv9LInAZTNEjOfZ3X9v/iRFBMpZFQCKUVBI7YBR74TXqre9U+E1vsxk6SkFl0ABV 4yTiW4Y9Z42aUUwUyCbga8ecbOoOSP8= ARC-Authentication-Results: i=2; imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=kJ8GdHJb; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=b4xN6jRV; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf01.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=arcselector9901:i=1") 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 45PIfXCx007445; Tue, 25 Jun 2024 19:12:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=60kAsYjdha+bVEANDM89tZg/qOvXIAnhtflm3wfsjyU=; b= kJ8GdHJbigNqgTczOPTBabgG/RBfqbUkPAXJs4BJMM7J6xLgTvlOwz63kBItV87O 9c9tNCcNtQy8mqVuqhvED6b5DlOVJY+HXp+BzVTT7U2eeu5rcB5MCirxPTWo2RGn p6sX7L3UmzQDtFfvULPr6RfLB9NuTS8fs5EpPTxRbjIpbXCDt3g/568hoV9RnKQD NqylEjw1AqmBZjuZ3h3xpEpGE5oNh0cnvrpMcs3PTCpmJaJb7zoC+VjmIHkylrtg vVMwVIGZldloeOggQHZwgf3uz4RPNJvnArEcT6V1rXL3XYpV/svowpSsiWIkTo1H 7ErUK5YjAPXSWgSWzBljag== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywn1d1dmw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:02 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PIrYKr010721; Tue, 25 Jun 2024 19:12:01 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn2egtb2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RA6RXlGaG+L8D043UXRcY0rbikkAyfMePKGiGR68GKqdVXW16VhzfVymwJj9lx45Bn39EIAN+dd6FcHGW5CIZvTDlsR90ViFTdfkN0F1vOkX8jjJYfz1pVnRa5Gkm7SdPmkMuToAmazS+lvCm5WNI7mPp+oIfVGANQwQ7wmgSQOGoWstb+h+XZym704F+EAcA0zW8PqHc+5cj1s0ZBGdu3aqfoJPpznes0ObQrk/ieZeJDbP/loaUeOH9iTMCGNHMa47l6h2vEMQpXyeN/Uh8pqyHncgAeoiwNl6bnjIn6d3znLnqBilx5tcj8jcD4sqcfKVw+uxu/Vfa4vJE3hBMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=60kAsYjdha+bVEANDM89tZg/qOvXIAnhtflm3wfsjyU=; b=WwUQ8fqekeflwapJ492t4mAUuc/yIjol5vWExKiQyLQsLBSHyvY6SP5OcHXCJShzKEhF8g3ywuoX5Iv2cruj9kOQkzC/dMevl3FceLT77Kjg0ufP9HEZSBoGMnPTLqsJXAASFWArMx3d0LivgVHOu8mUu2dxLijUPBYjyzIi2p8+3l+YhzIrGkCWyhgqbgmq5hoWbT6Fz60krd07vMdpprlc/uVN9/iyyqidZnXU/jxiA3IMubAGnEzdJ1Gw0LkOx7yv3XAmSraLg2V5kAk7PL7wFgfYZsnlncWKC5SWnKJFmlNe8Q813pR9aFWmYF4IQciJezKz3afwOVXjYJ0aAA== 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=60kAsYjdha+bVEANDM89tZg/qOvXIAnhtflm3wfsjyU=; b=b4xN6jRVK/EUQbw4pSUeypT65S9VjQSTEpw1StCMPTgckV56UYnFDDvkP6SORjHOiMNWwI5rQvu9VsfhI5fxX5KbUuJXOEpfGWxn6ccl4I3XF6/64pI1CTWiKF0GamP2tsNj/0DNYP+INpWYgdCIF1YlTuzOHz1nU1w/WbbsAyw= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CO1PR10MB4707.namprd10.prod.outlook.com (2603:10b6:303:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 19:11:59 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:11:59 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 03/15] mm/mmap: Introduce vmi_complete_munmap_vmas() Date: Tue, 25 Jun 2024 15:11:33 -0400 Message-ID: <20240625191145.3382793-4-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT1P288CA0018.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01::31) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CO1PR10MB4707:EE_ X-MS-Office365-Filtering-Correlation-Id: 86905b5d-8152-41c6-6d0a-08dc954ab01b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: xpCY7NHADJYTBlJoX9Bm/GXt+xiCEK2G8mdUjoGG1rvPPgpA8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ksPJMqNBXpYIQVntPZnvN95L0wu17JohQEYm/20f7XuDgFHlfZ3L13zQCNGW8WgoooIOMEMR1zUv0H9KTQwxCzm0cw8HRXCR7C41rGedh7xSIuhc9ehfXml/26mo6/icLashS0MQ6dcUGNQ1VU79Kfj19tmoiZwpUQ4g4lik3vn6mp5HvCBpB1dPM0i/7iDhLBQ+4oqXkLqocTOj1Eajl6/1uR8ZD0wYDLYzBWpio 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fhn6ygJHsZEFH+Cqh2uyPSzNsw7mHNyh2hcjjxB3LSx8/1wFNOdVorItwg1QdcS/PeUxx8RX336oTjd7GwYHvEbE4Q7FAPhWo3GKw7wrqEx+NWkDjGvi08rUDIE0OEqFIZjyxEniHtREILLjUgaB5WsaFlxcXgxFdcLFv3UMRwwSKqiOPQtFptD5FDnnLO4x9EgPDCNMg6yhosnJyPr4wDgKd/osMRRWw9qI29VMTqghtO/ESYwd9cYvkrJjP6g573fdLi0ijDeqKscLha7dXjY1uZYNcJ/rApOijUcEqVP5MBmqKMTywRntRL4XAvwDyFM+n+jR+dHH9NOcCT9OSCsCtS1r+RnXJbjDJH/UN7i1lWy627vyzqLQ54PSRh9RTxhi4kMTVde5ykZgdMssHssOt4Ha5Nxbuj5H8rckUD0t/fNrGW4+T1aMFGyTPjgLSPztL72vOWHVfmBp9H4Gai8vSKcdEyFi2FBLlTiFfTbiE0HQvITKJIGQI8AHTkot/drbtfT3jWdLsHk8t80rVXo7+NI/ZvE4GXTrBqU58DjaEsOENcbuBQJJcymtDbdHE7TzpS8ifD0gHQRl0KTPg8EYwq4T4QED5uL2yijFdKMJRSF0zjbrEP9saPW4sneHkgtisaC8XNf39OHQgKoNChH/bcP+dcVDKsa1ei9Pyl1VQAlL/85mHRzHrdNhZSmVdqMcx9aBlXpIuVzJBj53mz1/hJlnTJ/qeyg9U/mxKKt/cRliV+mBtESo5DsSoXLVhryCEM5j8uZzeHmLZqlgQkER5RNCvwATncsKYrkojfCkast5MRN+ta3jtSwWFXYL88FsgkX+nhC7X25e58Iz7jx8mu03F16TKeLVt4vGX3QuMJ8cwa5O2rjIboJNZOKxlSje7vLhIds8PK+dmYzwXEnM4a0VF7qVxk0U5OnSAsOCVIWmdorXVShqp8Kqoa3NzbEJJzaqgN28LdMlD1f+/yYFnRmJxfqL2QV9mubUZGp0JJYTzdwhpqYI2hjapcGu8RO5pxWSFernE2+p/IyKbz2RUXXNcfFDh5UV2fOCRe2jldRWbISlzNBy1da8NXqYCd0zuKZJz6kBkNIUhaptImbNaTE6u9PdhGmVsOvs49JxdKkWAc1Gqv3sW9g+nmTc+zb86HIwXf6B3uKi0ISDac2E7ZhN17io2QqNslKMVtntZCDTalVVJV2tvxePP6HJ8xM3NQWY4HjYRCKbzaCwV/lZa4N1xy5nzE1kCYsGtkIfgLd+/iGQmajK7gRdXw4NsFSRNt9G0cJM2MqGFSP90zkYyS7e3FkwuYrp/quk+DVhqvsDYDcbAYTRCDIjXt8JFI2q7nkZf2WYAd+XuF/h2ZYdXF3J8R4hNu0AXGknn05j4zarRmugKfDuO4bWyB03lovGpRlbPxcw73Al2pmBnJU31g/kgBDPFqef3P+kXVhFOb2+v12KpD2yOKhtIgfg8DOuOZ4FuHTSUcj2Ga4DIStWcsTvE+VRGwX+G0njCo4lchi/cWqI90yqdG02bGX+I4ndlS9VvBMeCay7j8iOqRKVAo24r6L0+AT23tbrVZqLZZESjxGgVAgqp9ZcJW9A70HF9A7yknthypA4UtYmBw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: BPYnE8m6tUwjBVWAaR410wjY1u+2ugLK6L9zS5egkp0akeQRYurMBL69qdKh4A4ORtQf717oNCoch5EqONA7d78AdrudbzQaCwHxC6mZn0PBvbEg/GJ/iLDSFF6Hn779nnZQ9I2bvB8ihnC3BmVq3PlyziuYLUHvtJ7U/MXbRVd6THT03X3aMbF8KKewYA9eAC38nNufBDkNLLZe2B23EahLF/eb2zF9dEwUuabGQgNdd+R0dqVe7tbtdTestbNC5nSCNPN0HKga+AWNStsSpodTNKJlDu36cSXWjcheCiK7+MDb4KIILQaOOY8FO9rrbvs0IodOrnK/VYyd2QBtdrX7zU0G/0DCmq0fVtD/BTyuXaS+4hEznO8wcMxCXLPAot4AC+g6IW23QFmnqAKe6VUlABYNIA1RcRccsYFNSLXl+vmnNK2vNvXLI21Z83hlCi1US2+lCaHCaMJu4IrPjOLBbWhp6Cn8AmIxiQaSdkEV8J6KXwrijrZhJjTHa7gEdKQaAkFca7zFGAcL2Ysk/ApgHrbhr6iaqYI/m+aTcyTrnfijYrba8yY/jbVi3ju/gnaubJjLEhZ6m4nkQoh+IWbu5qyNA+OEmRDgYt3lpBs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86905b5d-8152-41c6-6d0a-08dc954ab01b X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:11:59.5390 (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: 130V9HAdtTt385QZ6VBJGgMoVnZaGshn0tzzwAcGEXG6fVZeu6iPwZV34nfYuFt3v0xlJb5SOJbLmjeJcikgLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4707 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: vDB4gi-6sXuHqLqtcoE5JwYBXbZ3o3HZ X-Proofpoint-ORIG-GUID: vDB4gi-6sXuHqLqtcoE5JwYBXbZ3o3HZ X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: F0EB84000A X-Stat-Signature: pgxa1hmkikduqyz5rwcszsfgjimd1hke X-Rspam-User: X-HE-Tag: 1719342730-856152 X-HE-Meta: U2FsdGVkX18aGPlyj8zLM2VyUVcKcWyJ/rVsYRszi+5NfyZVUZoDMuSne+1HOdoNRMR2UpqlCq6/YWOH7ngWgVdZd/uY5jtUquDVd3dRX3uASTtyHKYudW4x8MpKMLTcXRuxtMSRNMTdBUTu14ZVReHeg8HBY8cGvZJuSCty+by9QLj4+wYpsE9/sCijvjLSbtJPQRhjjIwNvRaZ5pCmMT0M7CCSml5879I6TzwU5moyH76QCk+eaJuhLo/Ddk5tIM+RJLExh05noYlMko27hNeO5ttxAvGyT04Qp11r9pdO8iRvMQ0Ee1biuLkPdOJXWFCodIZ2W3LnBU8b+AuNMPAWDl/7j7VQSYoUK8HhudmCPzQ6Wl1i/Di2X4fhdbL3hkfLbYbkC0wej23T+gcLdVRFMOt1kPkDhGHRJNP/GbewfKXGdQYsrb9PV6ry2g/gcS+s9OAAMkdPQPoq4jpgJ1wmzOCPPFImdUAckQSryHirHgBs0bI3p/9hoNQScv+0J9l8e18woSmMEpBWMUyu8lpFvcaWUVcHlMhUGc0GoYRqEmpwI+9T7XwDtHtHAQsWWL30pBK3vaHrn7PVYS8WHinCjmKL+i8qSG3ouiwp1wL9e36SBcgKhuXLI1GS96lkXBNVDviu8M9yn5gxvGcfGCTHE1nwHA6pK0Ggj6GIEiyGMTBxPEOQfv8GKBb2vUkxStpwEtkFWiDMCNj/tDRmuxwC3d4E2fOAFbwIg7GBxeWFRKBf6iDJx3UAgv5QjAC8Mx3PDEo7D2LWWa+3e4SAob35tnsrGdZVY332lXOxAehz5J8IFlrHkbrXe31LSSxC13/grVmDDPDB4LziGDNvDIhL1vpJhWkojJw5L/YQpR5rE94WZN0pyt22Me0swBly90+uKxB4dR6busSPgsqkB4AY6hKE3Ddz7M5a2LxeUAGbfbMuYVJtvxt9qPIA2Z+2SCMGc2wtyxS8zHRLBEt axC+fkAN dc9koH4cnR+vXDv9JcHMwvqjrDi6Qvza7heqpx5RInsf5SwJlWHYovkrCgSZzVASae85O5OrMeHlCsQOWUJLVZGEQQbzpCQyhJR40EVnhNJl0x7XvmEIXJPLX3+5wcd5v4VCMMijmCffYWW5Xj3ij3xK1J/mhuRXzM8MatNPTiUj9Zh5lkHVDs9VGXabOBpNA12AN/+4ep2PXhe9zXEtih5dS71OK4EvC0rfepJsAruP5bKQwGBd9cOM9hqYTSLVUQU8rDZ9/AAyljwJCS503esdP9mEcogf91lpSGFbTXYNibJtQOPIidHPTiDMjGFoZDcafMGLgmqZmJpFS0nUiseq+3hn26+OCjpCQXhnsjK/l/cKXwLn/eL/M0wEnabbnZjlDs4nFk3lnmQm+3IgDP4u3Re8tjH0WK3QOV9i9QoVpxRIJ0C1rMuRatK0h/DRh73c+mNykPuPxc3iR1BbKmW65NAHLgnbGC6sq 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: 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 --- mm/mmap.c | 79 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 26 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index d572e1ff8255..411798f46932 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2605,6 +2605,56 @@ 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 + * @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 @@ -2624,7 +2674,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; @@ -2728,31 +2778,8 @@ 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); - - __mt_destroy(&mt_detach); + vmi_complete_munmap_vmas(vmi, vma, mm, start, end, unlock, &mas_detach, + locked_vm); return 0; clear_tree_failed: From patchwork Tue Jun 25 19:11:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711859 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 D7A18C30653 for ; Tue, 25 Jun 2024 19:12:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 532816B00AC; Tue, 25 Jun 2024 15:12:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E2326B00AE; Tue, 25 Jun 2024 15:12:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30E216B00AF; Tue, 25 Jun 2024 15:12:16 -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 088E26B00AC for ; Tue, 25 Jun 2024 15:12:16 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7282280598 for ; Tue, 25 Jun 2024 19:12:15 +0000 (UTC) X-FDA: 82270356630.02.9D289BE Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf07.hostedemail.com (Postfix) with ESMTP id 11E5340010 for ; Tue, 25 Jun 2024 19:12:11 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oxJisfns; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="lnXd51M/"; arc=pass ("microsoft.com:s=arcselector9901:i=1"); 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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342718; 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=CR5r5SlcrI9HaSM6OStIkTOvAIfiXnGdaLZK//vb76c=; b=uArQ7USox6toChXPYWFWNV9pW6lUOUUmDGhf1tIl6j1Q8qeGvugXb5sIWvMMf8evfDGD2X TeQHtc7qTLUWyB6oTz77hTxVSXTzv9eh3cKXNKWEAvmUjRufQiU/PY0XWP++hYdpcMtiZB Rm/AmysaQWVfNOpDfHxxeq0uTV+SDEY= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342718; a=rsa-sha256; cv=pass; b=8cRBb7Xpx09SN2E2AgwLskT9Abx/Q7Wm8T/aTdjC/WoOjqUA6nRgZmEi7UxQju/UJh+Gwi 5GuR2pCtgqbP2n7XE3OvN+LWj7LcDe1GD1C0heSgJ+WXuy3hHNmZz0fHTWPKN4G8+jcYhH Uv20zuEZFdQ0JyNB7WILjlF9nOZQvas= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=oxJisfns; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="lnXd51M/"; arc=pass ("microsoft.com:s=arcselector9901:i=1"); 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 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 45PIfYWZ009059; Tue, 25 Jun 2024 19:12:05 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=CR5r5SlcrI9HaSM6OStIkTOvAIfiXnGdaLZK//vb76c=; b= oxJisfnshsrnegtJUyWxs0XdwrjdjgGlg3+NpANGu2lo4VRqCknZ1EhWGZUZFTxS qDcMd3GRud5uejPKvgYB3Utmn7/oqlszzudC+9QWg7Xb+mLgMJSvWTwwUiVpHgjt Kh8+1FtMMgfW3Pbg2y4KwVkw4Sa0kGQS/vf/XV2/ISF9JkB5zHu+pCV/i/WiQrvp 8i9uqz1NI4tQMmf7Fv65vhE7QggH1sC394TmDn7+n13axdIX1hI/ciTNttbDuaPN oYSrGdJjTEJJq3HiMQKJtelJNScTGGuN+Dy3DFh12ZsVTg7q9Fe1POIGFN/Y2M6g 7VEHjS32CRVPXvjNE3FxIg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywnhb1jqk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:05 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PIIVKD023395; Tue, 25 Jun 2024 19:12:04 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn2ehg26-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LDsOvpLLHsTKZMOjc9q2IjPRbG0VeK7/soCSFSnpWcL4gx41Bu7T7U9BXWr+hxaPiSdNOdZ2sCjRvEwqaGxxJoH/IkRoPMKsVf8jAQ2MVEfWIClSno23uffvr5LQfoVF62Uc15HaL64FXDEYKfZLCq15VyFFQy6gkVPCgmeuxcbynPUXtzAlP3XXNdasGPbAgTpjeFWAodK9j1Sjmipa4OgCPKyekp1OC2texHYblpf7kyidUGDEyD1vtM3L3rwrU6FW5GdswIXXNdcJoY4QpxZjTxwoQm8/Zbw9FILJFoVM8RBk+/wEtwO3BjBbxrCIatGa4fOUHJDYOPXteGoUXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=CR5r5SlcrI9HaSM6OStIkTOvAIfiXnGdaLZK//vb76c=; b=lWDT3LLq1phJLLLOle9+ozr7YSJgY+xjuEFn5sVYa0dCaP0TPVYQzPnol/HZcWZjb4i6Bco32zb8N3YdCaPipgkw6HhEa9R62/kvUi9hT6ge680RKZDO2CUGsmPLTIg2OOgHQwcfTNes+sJaREizDToYcOyGPMrHfaEc8idBQxTQXKnCPHme8NXRFKSbu6ypq0sBg23O0suVTNhnW1DCUVFBZ096jSa1ssk69cRLOzKEgHDQ9odpxWvGPAUIijNnUVtjgkBzDBCYWtVpLx9kkt2VUykG9eYdkTI8K902PgkJaQBIGxMoYwUph+82eBHvtDDN6hUd1Kv+xNN9hzOo/A== 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=CR5r5SlcrI9HaSM6OStIkTOvAIfiXnGdaLZK//vb76c=; b=lnXd51M/eh/MXJoXCVHntLspWlYdO+VLCMkVQCv+1Uvx5t6m3mhbZdsfFRJNjHEfgHZfSJkPCHCb2ebhI+DL8U2Hp2eRMKeE7z6B+4s87O2hUW4j7CR4mRRbYvPCxG6FAciisDRHcX1IXcG8c96UrDp8Erit47OxfcvWnkj3/lY= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CO1PR10MB4707.namprd10.prod.outlook.com (2603:10b6:303:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 19:12:01 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:01 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 04/15] mm/mmap: Extract the gathering of vmas from do_vmi_align_munmap() Date: Tue, 25 Jun 2024 15:11:34 -0400 Message-ID: <20240625191145.3382793-5-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0212.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ad::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_|CO1PR10MB4707:EE_ X-MS-Office365-Filtering-Correlation-Id: 329da883-a507-4f62-9da4-08dc954ab126 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: R7Ic4VwgaDcjJgACyc+WI1l1n9oHC4aVmKcWrh5kD2CGSw4A836U11M4zoL+lHv5Qexo6OkPySS8ztcJNnI8at7EH5wobZMNUl5oILT9U8AuRh+cUbCvPe4N6n+4wx7IVobwtIJUs7xhIUSf2HdSBuqv+9k17BnOvGKEX33QYWcO2uOMeaDevdk0E94fm05PdjeqvfpT1IvcU4/j7Z8QmtLhHxrDnV4F+yUwcPlV56F7pW+RuwNKvacz1cjBGZy0wB0cwQpD+3Zpu2PyMQZUOrLfalFxgxl3/i/qgeyzWmCeKRTPZp1wxPnyYn0EEtNiDc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:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Xnzkf56g8fUz3XvQU2ICBzyAay/0Yf0HahOvAtMRKUpbkOgxnSbsrmmxAQfjIMf4ntFp0+0SQBkzStzBTR5PxX1O2TXm6CLlJLKhyomFvLxgLfjaxABuc0DUMgkAFaTn2kZP4PMVOJkQPqfbil0TUD555LUJ9CA6WbdK19quFnCA9ss+5QCq4wZ9lwl0SDmVhQwhezDxeLZrSK9DhnskUUTp2fRn8LIu73TJQsvTuK7Odtp/4UOwlxE8SmkpQtCJOpqIwfG5QP6dQnRP1EZnxktkwolQSGwRUjNATw6Hxf2GirtmFkwEgHxA1pAhHcZfX4dflFiwNt6VX222Sh7EmBxUqMf6YLLYu6dZmt5mFcxsD7KFk6rfqPhPHjrSyF1KTu6mtUeaQfLeL0Ev3zUKEkkiA1bfW8LY1WYc06YGdDu1SOAWA7+ifthsk5bpzQbpwTVIcjLWPQey5oqMVvKEUX3fD1+Fw1HL/W+BBiogMRji3jkvht86UutNKmmojpp2UsZffxM5kXewemAuu42HSErkR0wmL4UJYSPkmkQLlfbhG9Nr3dthhxxbKwfP1EW9j4/U4NxudYbKHCmHuW9vEioPZsnb+iFdbQWc2TzITaaIalqt9pHB051ZCKoYbrgjzOI0wgQo/pbofHaYQKzAL2njzeY/RugucMma9WhZrMdnsnRkxe8vdneQHW5rJSvGD4rb8jU9L5c+oD2F5Td45O4pGH4fGZSflFqjbVOA70IBjmz5FG80r+xZWFCNIv2uudFiPo8AbRF91bLKxczwHQOrxj5vDa6OtqtKCSB9JV0lIb+uPPekbgMgkZoZa6ufOse4rYys1jfEWOh37v4jAUQfvAN0eJIIPCESiZ/R+FFjsSJl+FZlcl/jqciWD9ymsfHZgbckuC0w9iNxvbHTDb1Fqkzdu+mVB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KNBhArcL/FnAXcDYyUisQL8Czyttnvg6sRMvLZu4XdugNa29adgeYrO+hqDz5zuUN9OB7MzmOq/DNdQWwpONJorXc6Y0EtcTdzY3O7Fw7/UuIOnTso8nPxQorvZH69+bMRwJTmmVGUmjQUEymtWMib+abG0B0CvRIHZHtXxTwxZxXaZGK40YPz+RZIdNANy0jVHJ5nT5TzutBQ7XZG7+WQ4xQKtZWW4FX4jy7T/9ec1rtdhAvUDts+hYy915J1wv10Uqfyzi1Pqqkq9TW7+W/vGwJleRymFZSs8IEZ+3d99rM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 329da883-a507-4f62-9da4-08dc954ab126 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:01.2995 (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: lCs99qoXMWRBnTqXzMdFqzDe8RSDgEBKAmyKRSHAM7kUdwzWWEqML3kEgqCiTrHhZYtFktvjWQ0YXpo+M6IdtA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4707 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: p4198vMT2zga54XI8MWqHsd1_Ikof5No X-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YiCvcc2WMqD9QMUCp9pfAS7omtBYH07yVx9JruVjBpxrwDrAWGZaKHbmsvrRpKDqqnD0DP AICbW6WX dSRzK+aQSeCF7xHRTzLVLZEYW1chiw6BCyq3l+KbdElbk+KDAAxznMTL/U54j8jupH9FSPT6dVAy5kNh4ywrNM0KnO9jVSz6yKq/y5RNT4BYkOh1ow0hKfAKVj9iqPNKjHF6nH9/IxWRbR3VR/dN7PcmxLJ15bxOfDLs4L3cqNX7W3xmLPLtPv9pbIBvC82Ppzod6ZH48yBTxZero4a2kIBKka6k42+rcaRWdLuvH8l/lJzZQT3QR2nCJzCRyN3gQAXDmH6P4X6cM+SoEgRqZuUTu2oQNgqFHgIK0KoXSZ1Ve7cUTtbvuYJI5A/8y6XeSV6oeWg5B1QRjZAziN7BKH5UA2b7L92NVYnAitjktk+FNlpBrzijByxtCfLpZOw5q9sPtq/pavkWr2ASpvhMQzHMXrZW6gxNtlnKRoKfc6vBUzyp2B8zd/6IoBtfUWCLZb+g6ZdcOIHibl+5AD7tl2N8E06NEaAigJfeG 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: 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 --- mm/mmap.c | 82 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 411798f46932..8dc8ffbf9d8d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2656,32 +2656,29 @@ 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 * - * Return: 0 on success and drops the lock if so directed, error and leaves the - * lock held otherwise. + * Return: 0 on success */ static int -do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, +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. @@ -2720,15 +2717,14 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, goto end_split_failed; } vma_start_write(next); - mas_set(&mas_detach, count); - error = mas_store_gfp(&mas_detach, next, GFP_KERNEL); + mas_set(mas_detach, count++); + if (next->vm_flags & VM_LOCKED) + *locked_vm += vma_pages(next); + + error = mas_store_gfp(mas_detach, next, GFP_KERNEL); if (error) goto munmap_gather_failed; vma_mark_detached(next, true); - if (next->vm_flags & VM_LOCKED) - locked_vm += vma_pages(next); - - count++; if (unlikely(uf)) { /* * If userfaultfd_unmap_prep returns an error the vmas @@ -2753,7 +2749,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; @@ -2773,6 +2769,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: + 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. + */ +static 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; @@ -2783,12 +2821,8 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, return 0; clear_tree_failed: -userfaultfd_error: -munmap_gather_failed: -end_split_failed: abort_munmap_vmas(&mas_detach); -start_split_failed: -map_count_exceeded: +gather_failed: validate_mm(mm); return error; } From patchwork Tue Jun 25 19:11:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711860 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 1CF72C2BBCA for ; Tue, 25 Jun 2024 19:12:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 003B26B00AE; Tue, 25 Jun 2024 15:12:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECAB36B00AF; Tue, 25 Jun 2024 15:12:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA8DC6B00B0; Tue, 25 Jun 2024 15:12:16 -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 A23B36B00AE for ; Tue, 25 Jun 2024 15:12:16 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5F7D740509 for ; Tue, 25 Jun 2024 19:12:16 +0000 (UTC) X-FDA: 82270356672.25.8E0BE55 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf30.hostedemail.com (Postfix) with ESMTP id 00CE080002 for ; Tue, 25 Jun 2024 19:12:12 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YJSJDqwa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=iTzP7DrI; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf30.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342720; a=rsa-sha256; cv=pass; b=0EogMY5wk2xF/OxuEVzxPy8jTR0CO8vhF0feFuPYjB3Iq+4A+TzMjqQzoA/m+hsFNVYSZz KG7pbvS4We1oYlvqH5PNe8y2863G8ZxWqxxvODim38+QkDpMpAAFuVdr0F0xnka4G/jS4w 48iIzQqgj/Er/XYcdTrAUXEdpWwBOOI= ARC-Authentication-Results: i=2; imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=YJSJDqwa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=iTzP7DrI; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf30.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342720; 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=eRq7JyP2yI0dRhju0RZTyqnMYJTiuiqUZEZuPD6xbEU=; b=AwGmsz+eh8Sym+FnZVXKAbacSv5gbS/ji4+zAgFoKhFCRRnuozEcTl6vvzj/9Bb/2dCcWl UCEHDCjEsG1VpW1lHJ5YZQC8e5fODPxhHSbwPfBFkbRmgUh8RiOrBCKpgU6cTPWSWcP7Nk P19n+IbAxCmHJYRqmAG6UZs38oKU/vc= Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45PIfXbc021444; Tue, 25 Jun 2024 19:12:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=eRq7JyP2yI0dRhju0RZTyqnMYJTiuiqUZEZuPD6xbEU=; b= YJSJDqwa+5+TCTgJLUTj1Cmhk487/LTNbONa1JlKMIMDaCFE44zc5Lnm1qKO2IWC XOVbMsSaikQphCg8JzQU0Fdp9vTeg3e5s1qzlYIsrs1jykXmkO+Vw2jlMCNsZ8Ir CKHebnIuIRx626oEWIBUq7ZInMrVFYsPPgd/cZK9F0Ab+C7LLqO8E3SUs8moEd46 rJTCD1/FP/LOl8ejY+DKmvKfngVtllvzcUvAW3iGWlxmdEKTQNrFeANB4yVi8qWA AB4sGzSK1c94XoKtVAEqJtKxBfOZsRaFV+H3DpX8jhv0g3+KTpIFEqjGzCpXKp00 xIHa77oyD9PEqMBqMBmUKw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywpg99av7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:06 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PJ61Pg001320; Tue, 25 Jun 2024 19:12:05 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn28rc1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hP0ZL3/ObjUXmGeDUnkGuYQ1Bwr2M8u7KPeK9pq7TEdp/umAx8WX/AK9wDXBeHs0Mj0G13wAoLr8knbw6XA4YUYwrZuhTfrijKfxQLE/4hrsbMAz7MOYWIvwgrt94vNPVI8TPD89Jz2OsGMLfzPCjLYcD6TcvAG9Xm9Efj5eEBd8G2N36C0Bj0z52GlPCt6ZkfFSV9ZZdx13iYJAcb+wLGfQ2r9pQo2SsYYbg7yzknBnRS3Us5qBVOtaQQjCC5OiVYGrZyASQR+OkYCkAnhxc2x6Z6/M9EVYzsNR6Qk38R6DZHbNyGgBaF2C8fuhVVccQsgPp7NvYjzp+ew/gmWtAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=eRq7JyP2yI0dRhju0RZTyqnMYJTiuiqUZEZuPD6xbEU=; b=dO0UZPAPzVxJnJnl67ADAevLpXHdcihxMLJi5nxiUTRu1jADcTyvSObIN84W9nrT4suxkQXwgBk8eOKSdmxmtLjB7AQ0L/I3Jv8wv1s8mTf6wHGO+j88J6BMBHTihdQT3Izy2cdr1AfOZhaYdQLK2p+fYFUmk34HtRfSs1LbpHB2k8+4UoUyrTTV4z7zPu1eRuOdg0llEHrm+0TbvkXbM/7wQP1FgOHRyCdm+UCnBMu4Fr1cFpfup1mxS80owwJiDAaUWEUkOE3ETUod5CnL0Srca8VB6C7ZneHIqC7jFsqAEcOE+DkfDZsRSnF6l8ICuYdfiG+3WQ/71WuBoy+YQQ== 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=eRq7JyP2yI0dRhju0RZTyqnMYJTiuiqUZEZuPD6xbEU=; b=iTzP7DrIQJRMi8hAjDlw5rh6mBTIga11RPGKm8SlndsSLO2SYDVkxbCFLT6e8Zhon1hNouiIdV7GHxuBz5wh1KNNUvsMbf9C2lGPu4rMnHLbII+kIYmIWGOWnK72bbfxdxR+cP1cONi1WcLTGPfFZ6fwNkt/8mvBJg6QcbKadr4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CO1PR10MB4707.namprd10.prod.outlook.com (2603:10b6:303:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 19:12:03 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:03 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 05/15] mm/mmap: Introduce vma_munmap_struct for use in munmap operations Date: Tue, 25 Jun 2024 15:11:35 -0400 Message-ID: <20240625191145.3382793-6-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0336.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10a::20) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CO1PR10MB4707:EE_ X-MS-Office365-Filtering-Correlation-Id: 616d0428-3c02-45ff-68f4-08dc954ab243 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: dJVQWsEQITQzEELYI/Lqtd6uZ7xSl0rd1D16K3J3dB8TPx5+4KMgn5VlRcZzzIiFixI6M41BBapCA409VCgUHg0D9VgaQsb9tBCzktAz9/SFVLYql0LjWL1sTYwPhCag+wW3JJ4JWoQZ7qTLe6w/Fg7pJBCBPV09dWqQnYKrso4izCoLeEh+Q6LK6TUCRvPlklBwzU/ZFW3CDZoc85qqvgNMNel0LW1B7OvsIzF4bgUUTAJJ7ed8zWpXUuQ+NeRZm6LOYtS/8bvXayvZp0xuBEn3ZMlVQo8IiZu3V+c/HxGyuUxvEI6Y3Ae+Pm8/ceHSXoVDK7dnwONcaY8FRF593L32A2ndcUxrTTTENih2uv6ycOSMLGOxsco8iayCkeVzQMQr1fx03ht7qrFeoGKmxwrJTu3GV4KJVN3OngtDQr40IklrqXHc4w962b5raK18ab0fKI6G9Rz7JKqen/C6ncO8Dtg19b9KbUUrKKrhrilbvb+u1wRxklRgUFI5Ulzy/5a1e9iagUQgi5W7ZoESzc/zGXSxUhdAGo1cotlwwB/VgDf/aIOldx12fM1vTiN57Uv1W4RQS8nzmA42L8MSSZMYCRJRC9NlnFz3X28BovMItRxFPFomO19ZXUegaPZJZvyG+E/CwUHHiAtQsr0VyuQWw639fINs/4WOOKpGQL9fqDNmQMb4dpzyZ7pqt3Hnldn4cMeClVSKnaGygJRg51z0hH/J4u4HcsPzc3hJLBhbOoHDirVNZb2s3KSWJ19j4RJAHRk0kCHfAPMS6zeQX24GbFYwor6I4mpxyRyZXY8VgUQl0f8AXGdzotV5WnBJjiPBmd4KCTlS+W7XYJVRaeAGzRDE1v2n2qmkwuKxgNUYLpAHyPUn7yNZUAHjMC9mOyBZ3G500dm4XSQGczzV9M3SqU3jD7ylPWlCVbOzxoXTGu4fiEAqxiuCWEapLOqffd4j0jiSNuInm2z7KdgFy8XsVLsxiogqyFvnjnvNtShX/PfdpdcwD9akEVmopbJSR043Q0oD3OiyyqTU8PQBN9Hv6tiZ+RraY2ISbI9AmewYJuyL8n8nTnjfUGg9z0nmQhdHs8QvMk4qC4/lgUqAS1ehBhj3719WM3NB/GA0B6OAw6RtgtMLXr+CXbNWztWD5BEEOnKf97LllGOj7nuEoigZjWK5J0l9u4n/R/K3JLiMuwHUKvMQ4oAPBF2IaswDYycn50yg/1zYTB4OkgKvt9jkDq/2mNhnQ6XSEmzwEnQmoeCAl/Ux6omUFKW1NWwherMFo7xd8oOVghrIhbDgJIcrzAGqC4IHOIcsPx/cVunWrcD6xQYZKKZjgf67wID1 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4iH4xbZ85kdg1iwLgjX3ofdl2cud47vV1BtGuU8H91bHoDBySPhc003PsFQoPMHsYoCIswIAnHfPEIHmzM7BJDYNc80Ubsn6YBOvCX8GU9j21za7yBXzwb9tqXNc3rfz5kkx9/VnrobUDTsOVpTYJBsAKOTTSIedwQncZQLk1hfL3QToWacmXzYNh+tt0C71jPMRrUQFBEsinDrFRK3tEXPxbOfd+slWat2CKkD8jN8RYFK+OPHyNvlGjkXgxPS9+gSIYw8YSJFYYGSHER6gcx5YTozokZAsANUbb4eQrTqaL6b0BvNE/iociVu5PnAPMIhNlb27xd8ggOdOKn3g8dJ0cS1/UBfJqs1moO4t3uoDXJmOJStNugjm+7ix2VzS61xSVsivWJzD9X1sq989ZhaRIeotdV03stRbDAzxhlBjCSChYjOvpXc4lC/TA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SlTRNux1HUH00Kv5Lg0pbO7WOdxbDrGB54bGyxoWiJDQM/jqnonmXU7DnOgv+GER5nSpCCISdB1uZVK8ISM3fILjQTN9wbZoyvJOuiN2NKMxUFA0Ng== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: I9SYR3yqE+calzTRTJV668B0ecycMvIpv4Q1oera6UB8rj40oGY5KUh1Yv+9LfcHiMC6DOEeOzqB7sH5OYF9fHJ8toT/AlOsc3ckBpQsRE8qyieov8keUjwyUOak+Aj54qBRKS5vbzr/pPswc+7tG8ofan6dHaFBNFYQaFlariqlkkkfYV88PuhZP5hOrFDQ5iDyHLDYHH9irVcyj4SmtMgnrZlecj44RCiIO9kixdXBlv+xBc3KKiu2va/7ywgjnHnEE12AhKeofgn4Fo9LKU38lz2ATF5FkI1vxQR5Qx6Yhlf4n9GylsWhQ9tkehLbCcNEEcY61sx5UgnjQiLnWSBiSSkgNFO5gkosGNx9P+SFICxEVHApQcLgG2SNU1q1yf3evgiXkaalgWTEO4IUB6dSyokribX3Jsv4OD2foBDsvOhBQhrLaoENaUTCtpuKO9ooMOTQRYs4Y9fM3wI7gqRSdg8b9MbXHtbPSwEiZ8d4HqJZlcKjNzCRYh0E1MHzje58IpIFZb8DIG6HktB148Snj/eRlRbDJ1PkzFNiFExF2dvFp2oXG73rITsX71u0VETkeQ7l66EnT/TuOJsMjOzU5UAfr5DWobAMHus59r0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 616d0428-3c02-45ff-68f4-08dc954ab243 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:03.1579 (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: dWBI0C7mDayE8dbiRcb7HgoxgKXXc2IW4jU6FzbvBoreAfyP8lXKI+HIbNoU/FvwaB1VS97gumpp5qZa4RM0FQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4707 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-ORIG-GUID: Qq3Bz_KxF5J0wx83meMA9FSCHhvtb3JH X-Proofpoint-GUID: Qq3Bz_KxF5J0wx83meMA9FSCHhvtb3JH X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 00CE080002 X-Stat-Signature: 3zuxok7wgwj1gaypcrgpiz3yyw3tfson X-Rspam-User: X-HE-Tag: 1719342732-385353 X-HE-Meta: U2FsdGVkX1/hvShM6Zl0eFb1tDZLvDAw8esjG6bFPIjR+n/XSEL2xCuXa2ZYbtAUXzSnl2xgPoTnF6Vuac5BHDXEKnLFrP846UxdNSNbXLopRfspuy7HT4tEz+WI8rVihYydomgBl0LHGvKF9WzEZYkzBJhCk5RhFQREiFMhpFVQbYE67cQupnwBS+lnw3NDjoHgqrZJPqS05JhSPfdP1OaYIvQOLnjoHljROCoyAyeQnVZuV1p/oAOyszEWF5pNQ+f+kvR5yyoOohjYtXg7+9pj3IFI6mR0pVB9PP6rt3RsyVt99ERtwUmfGfXOaa7/GBIuStV/IPOxbfcRjQsm+jLBSZiIA395LvxJIT0jK4PHZlyHdVODKzNGORu5ffMrCs7f2mctYKVjKYaLHM2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fVhJCgdI= 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: 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 --- mm/internal.h | 16 ++++++ mm/mmap.c | 137 ++++++++++++++++++++++++++------------------------ 2 files changed, 88 insertions(+), 65 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index b5e8484059c9..22563c959861 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1480,6 +1480,22 @@ struct vma_prepare { struct vm_area_struct *remove2; }; +/* + * 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 */ + unsigned long end; /* Aligned end addr */ + 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 */ +}; + void __meminit __init_single_page(struct page *page, unsigned long pfn, unsigned long zone, int nid); diff --git a/mm/mmap.c b/mm/mmap.c index 8dc8ffbf9d8d..76e93146ee9d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -500,6 +500,31 @@ static inline void init_vma_prep(struct vma_prepare *vp, init_multi_vma_prep(vp, vma, NULL, NULL, NULL); } +/* + * 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; +} /* * vma_prepare() - Helper function for handling locking VMAs prior to altering @@ -2606,78 +2631,59 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) } /* - * vmi_complete_munmap_vmas() - Finish the munmap() operation - * @vmi: The vma iterator - * @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. + * vms_complete_munmap_vmas() - Finish the munmap() operation + * @vms: The vma munmap struct + * @mas_detach: The maple state of the detached vmas */ -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 * * Return: 0 on success */ -static int -vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, - struct mm_struct *mm, unsigned long start, - unsigned long end, struct list_head *uf, - struct ma_state *mas_detach, unsigned long *locked_vm) +static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, + struct ma_state *mas_detach) { struct vm_area_struct *next = NULL; - int count = 0; int error = -ENOMEM; /* @@ -2689,17 +2695,18 @@ 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; - error = __split_vma(vmi, vma, start, 1); + error = __split_vma(vms->vmi, vms->vma, vms->start, 1); if (error) goto start_split_failed; } @@ -2708,24 +2715,24 @@ 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 { /* Does it split the end? */ - if (next->vm_end > end) { - error = __split_vma(vmi, next, end, 0); + if (next->vm_end > vms->end) { + error = __split_vma(vms->vmi, next, vms->end, 0); if (error) goto end_split_failed; } vma_start_write(next); - mas_set(mas_detach, count++); + mas_set(mas_detach, vms->vma_count++); if (next->vm_flags & VM_LOCKED) - *locked_vm += vma_pages(next); + vms->locked_vm += vma_pages(next); error = mas_store_gfp(mas_detach, next, GFP_KERNEL); if (error) goto munmap_gather_failed; vma_mark_detached(next, true); - if (unlikely(uf)) { + if (unlikely(vms->uf)) { /* * If userfaultfd_unmap_prep returns an error the vmas * will remain split, but userland will get a @@ -2735,16 +2742,17 @@ vmi_gather_munmap_vmas(struct vma_iterator *vmi, struct vm_area_struct *vma, * split, despite we could. This is unlikely enough * failure that it's not worth optimizing it for. */ - error = userfaultfd_unmap_prep(next, start, end, uf); + error = userfaultfd_unmap_prep(next, vms->start, + vms->end, vms->uf); if (error) goto userfaultfd_error; } #ifdef CONFIG_DEBUG_VM_MAPLE_TREE - BUG_ON(next->vm_start < start); - BUG_ON(next->vm_start > end); + BUG_ON(next->vm_start < vms->start); + BUG_ON(next->vm_start > vms->end); #endif - } for_each_vma_range(*vmi, next, end); + } for_each_vma_range(*(vms->vmi), next, vms->end); #if defined(CONFIG_DEBUG_VM_MAPLE_TREE) /* Make sure no VMAs are about to be lost. */ @@ -2753,21 +2761,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; @@ -2803,11 +2811,11 @@ 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; @@ -2816,8 +2824,7 @@ 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: From patchwork Tue Jun 25 19:11:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711861 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 E68B6C2BBCA for ; Tue, 25 Jun 2024 19:12:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 446F16B00B2; Tue, 25 Jun 2024 15:12:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F9876B00B3; Tue, 25 Jun 2024 15:12:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FC7D6B00B4; Tue, 25 Jun 2024 15:12:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EE79E6B00B2 for ; Tue, 25 Jun 2024 15:12:20 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7CCEFA220F for ; Tue, 25 Jun 2024 19:12:20 +0000 (UTC) X-FDA: 82270356840.20.E437272 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf02.hostedemail.com (Postfix) with ESMTP id 35A9380017 for ; Tue, 25 Jun 2024 19:12:17 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mYltdP6s; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JBPFvBVk; spf=pass (imf02.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342717; 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=gvJyWlTu7KPZFMbPpZBAcwY6aEsrPPQT/0buDXuoink=; b=BzUebuWcL27QoJ2jB3T0xBO2/pFXmER/iBbSYpD4Kp5T/3rMU1AStyVTzCGY1wWqbT6yEa CQgupg6YCQVlWwIZGnYnVxYfqD3bC+Cb3QgI2Tl+JrwTVCP17vlld4zvKYzLyXyDHprEIg fkUWsD9pDMsANh5SEXHRRuj280jOYBI= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mYltdP6s; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JBPFvBVk; spf=pass (imf02.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342717; a=rsa-sha256; cv=pass; b=LHqR6bGkFcQBjleb3hY9rGXO5+5ypVZ6BTZmuP4eiF6MJmBSOsdjz1yciyMs2hvTa05UPf VohplxXOiWwp6kf+3MK0r72FGOx09xVb1S7QmpL8fqZM4/7E7G6ZszdGdOfkBSYzpKad1C jYS9CsaV7IGyYMoRsihiF3wxkOHpSpk= 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 45PIfXD0007445; Tue, 25 Jun 2024 19:12:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=gvJyWlTu7KPZFMbPpZBAcwY6aEsrPPQT/0buDXuoink=; b= mYltdP6sihKm0kU73e8zYu8v2hoQijFs0KpbFLIsZ2SCH0eQsEr8t/6F2x1f5yo/ C8dWELvqcQTC/OCiFS0qDCA15LuA1WMiuw9bS2GdqIPWlz2i6Bk1H66ib89Emq9j OE6l4astbfqvr12nmkIQl/qdDalyvNj+fuDlCxrCr2HDt4wHaFFLemb/dVFyJa7e 1/YaIdUmCl7NRZbHOFZYFPrjPS8rI731YFQNlLUQXVtESMr455tDAPDVYWqno3FX gHbkfXcvDJJ9njLLX9DkFpyvSB18Kwva87IQkTBFYfuE99OE8OKBoXmUmEdTZfk6 Nmk4BgYeI5sf/XbnGjoKzA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywn1d1dn4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:08 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PIrYL0010721; Tue, 25 Jun 2024 19:12:07 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn2egtm4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ccPHSULYHXBlZTHAar4Y3ajYBY7nZ7BW0WyYhuGC8RynIWpLLiIMszaSVDUhMr/KihpOnGgnT6kDWswSr8QxWhMsgQjwQfcA+EFUStYkoYzmu0HD8vM+gVcnaKKma3hyyeokG3HC+RT35P2/Hps0IVgOx0B6kLNK9zzLPvSajUFzPj4/ciMXeN8D9kCLM41dYM/tpq/KQuS4a1ZWhm+XyKKa3bbl8U9OZ6mp0zBRyFR31VqCrNy61Vnp2D5JbEw91UQsKBf6cMvQhdngMhvZkJ24rZJFF+zCQ5qsfBnLUaTl2djhndptvPIaDO8wJoz1qnKl7VXuDKeR70Kr8IVYsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=gvJyWlTu7KPZFMbPpZBAcwY6aEsrPPQT/0buDXuoink=; b=NYrAFjDj3LmeLHWnq5ZyCJfl3DmcGq2DSOwFgzzwRTxyjltyMH3BiTnb07k7Udre1mGH8L7badhcBweK5/ug6Kok0wj9R/EMSQZOpFyD6j4WAziuPz25Fx6kwx5QxjR43XPBJGrk4DwWjZxmMa58+3Em3uZDCxVRZA2lg4u5VLWPSLeSxMDn93Nb1t2pIb5dZ8PjTpyFkyR1bQ7He3hP9jnZ30waSBqUShwCwjSFGRoB5MqcH6rMWBa9wsN0lOx47GOErH/HtkNH7h2arcZzWv5UNPpyI5WjaZvtKMp8bbO/iMWlSk6lg7Xgxs656lMiHZi0dDPfocv2kifO5aU83g== 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=gvJyWlTu7KPZFMbPpZBAcwY6aEsrPPQT/0buDXuoink=; b=JBPFvBVksAoHvYQM233xnmDKjTG7yMRbglugyMp0xK8eLIur6av7u2wJ+xNnmCP1xzHDZmHnRSJdRPtX2N4pOcvB5Ds263PRDelHazYQ5IISe+3g2uIfBFls2Pfwd4kImFSSgspAKeeLcdyKP0pepi9qCR3qtU5+U2ebNaaGIXQ= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CO1PR10MB4707.namprd10.prod.outlook.com (2603:10b6:303:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 19:12:05 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:05 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 06/15] mm/mmap: Change munmap to use vma_munmap_struct() for accounting and surrounding vmas Date: Tue, 25 Jun 2024 15:11:36 -0400 Message-ID: <20240625191145.3382793-7-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0207.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ad::11) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CO1PR10MB4707:EE_ X-MS-Office365-Filtering-Correlation-Id: 101ed9f5-c31f-4fdc-7930-08dc954ab382 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: LW2m8ctWuw18W+qKj1JicIB6pPqOAj4qagJQBSd+8d1x1Yx0P4mpTDqxu+uzFOGK3p71Cd4rOxMraaFzmjkO2rWyeDSQ2TuK6gpwHH4sSD0g9DMtdhO6jScbYDeLIVbVgjywcmhpGG5A42kCIAAdf1B17TTTl8STydwoz99q4IT7e7K+FFJtKsxITWgeIw/ppMIsMMWGThKBeSZ6sWTBELFpNymbRLS7P+APvsk8xf3nI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O6u02MmARG14Jm6gaKtRKQ29srL4rZX/X8J 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iaBnNptSocJCeOY66zc4HXGRN32ht8whBXJNcWTEUsxxz+kFUmbOnDHgGysqOeXRKiaC3NG+AophcVSi8TRSoKMqz0si70v0E5akdZM8Y/qlP2pjjr1CwNOEXnVzODYJb+SQypIj6wlVXdwI44OB325ZeRq6sTUQB0SI7BRAd35mXb0LjNHrp00jAdqTounpFnuACeUyosnPS5Pc7QA1d5FULZJLdh0N9wMbRkzMARg3Tnn18zjPQ71Ls1IIKc2xRD99pxTU4Vps65lB3q8lwlgLLPuzYRZw84NpWFqhY8QkyaCnSPzJqRRU8sm6DvcZbKfUIHQlzXGgIKl9E5p3eU97At7tC127R8jNVW0eReEH6A0oYFgIdDpYQzHZBKny8ezB+Gc30opV82RX4VGK7dS/RvfGh/VG+jm7Lezkndi4edGykmWY/TwYPi/hDBfohxb1+S1AfNSeES63MjIJyoeruuFpVPbNDuiC7eoxtbrmovA1M6TAw/o/q3HEj4hT1YKIp7q/Mg9tQ++3XDuZS+JFudppPfdKimlr+OnQUCctWmr2xDdl+bKEpXVZRStgcDTIQvbUVCb4yFFGz2FN+zxZiMLzR8Xxqtu4DDwD2d6ImbrtmkRG+YhwuHkwKkOdSkvp6IpaJJAV+6Nxe6K85SulDS8pZcMd91YarxrhAJm7SM0h91n7m0OlxW4LPGTo2LIJ24SzUi37L5Sdn2pCgFE4Dpc4LkYnDE5DT0lkW3TcHk1XiMSkxonckTLAbLTUi0Yo405D5LNkZ9+YoDXNru/dEoWQwOKshNivDyqIYi78Esrb8Ko8VEKANKjRqvczLHOKl8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audE7oNYKd+QKSeq5luat1/al30j+KPUVN2HGbjwTmXvS/3PxPJhQh6YxwOdik314Kjr8zHveVTvHLPU3t4Zvjg5NubDxjfjDni+i5yawrryCSBGPukdcwUqDtvW+li5j6YbYKcaJ3htL1zp08vEonz/Nz3cbBg5m/EwvU+ZxRfjXeOBrBb8jOzZc88+7GqDE+TLZV832mGLL3SLQvJVMO82KeGvwwcewWgO80CMtsN8mCdBPoKQrKQDEEAr+zC41AopgRt5d9sFhOrXG0K1ocX11A5ZqhltbPYVXAy6QRjo38Qr882OiqumHIx56wBlD7T4eTUwqTZUpuBz0VNWe46rRyCSzwe+vycUcxrOK8ab9XoT20IBQPVyg8nqnahMJlGjG1mMWVis= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 101ed9f5-c31f-4fdc-7930-08dc954ab382 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:05.2540 (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: FJ+E3ALETmW8vgS14YB6/vNevLk7Ws1GFEu0DhrAZjf6cOwFmenIyPpMVsVgJdMnMC2yUpjCEEielOwWSd1uYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4707 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: I8i7_gVCIzPEVzxY6BeDzbuukvjpCCyj X-Proofpoint-ORIG-GUID: I8i7_gVCIzPEVzxY6BeDzbuukvjpCCyj X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 35A9380017 X-Stat-Signature: foyry14aqpyp6wo99y5yxewrqibaqawf X-Rspam-User: X-HE-Tag: 1719342737-894224 X-HE-Meta: U2FsdGVkX18Z1WYwOBynZVdLJK8SKrNRLlwviiSWJe2ox3RzDM07Pb8bDRNovfreQqz7ZZaJjkoVRf+tf3m+d2G9WSrOjBJdlyuvXK1wOIjCv1NuLoo+qO0jyiPrqJXwGhVVlpF8Ej3vPI2ABwq4dDUS8sXn/3aAPlEwldyfzUK6uZFfPatpVRYmbcSBYma0N5WPNVtGV3ko5RLXVlNY6P1J8mKup0B2IW1Ih8YTfq+kvBn10C8TxVGGWE8PBotODiopayjiBO7NBswGfT++mso2mo44v6c84joKu09EMcw7Ms3LdD3PMgniksfTK52DbpBQCg6H6LYnwe9ryvGWDvvnPgq3hsgkS1Ep/3jLKAu37Nhz02kswdmX4vBsYIgpJEyXbSBY6V0gNnr2kam9dtItvHosql50Bh2ktsgNP7fNywTooyZGQKWoH8gtOjFDzhoVvGFycQxq9dPb0HkDijeFYg0+z8nI7MfgLJd+h/a4qT6IWt2JfMzIt+QWOmJiu6y/4La8kKK2fVJYs45kprm9Bgm4ozgiGs/Z53LEwKSZnvhobnu2EtJwO8qLcVbijS01eV46n0HgBqQm27e2pGAG4KB/VxfSsMr0i1ZJS40njOmPGdSXmQxisE5SHIct2pPK6R9VBSMSGXidDbA0y+No8NeGNmd7TEVBJbSGH6SN90DkvY16eN6dbadvJu423fDIo6OfCwqH2n881f1HSaCJ0za2g28Lj0fyaQe/wJnrqFVLlx7DKx/ZX6M2Nf/f8qsBDFbdkimRorquZ81cFtQlvbaJff8QiglbykeKYUN/AS+ji2ej39R3rt3OTyDeUUxIcDLvH1UpQCm7aQ5Ju5u1KqFn8WpJr3upAkC+DQlLGauBczLKLFE1/XSnJqCLQ1m40isrdEIGpKpiZSWnt+ystHtIHcPk5cz9Q6AZxIIX3gjFc+hrAHmfjipcdAvAO0M0Bc6hVktRsYj5KNc Qq4IT438 fza47lA3/GPdZSkFJzi6druR6HIrxnOkINlAgMhx8g0TKwURXf9Ns6HGSzLr/hhe9uLe2fhetaxGPOYivOZhxGLWw/tS8e51kHRyuvI0IwZtSC1hNx+a/+X182I0sAzbdtnsgYYVc+HTV1M0Ds/0O+t0d4PxrDvRQ84alu+WFUsCkGtzucK2fl/QqRvy2iOxRQAI1eJIF5D28lfnu7CmMmzrm/2teJ10g7vMoNHBQPFsXH11nMwqcY4iBTts0e3+/i8sTfU/887hRMjOMdbYJqRFchv2bl2qxFx5FxItSHYZhkEurUOn1od49HP96Ckuq8Y2z6lMgn4L7APfFJYoUsGMehzIZhRp+SWSHQcb0u7tnyKeiAKq3cSnrAd3ZE7GDJZuJzX/IHbcJE2novzJnpyzD4GTYiQt/7xDnd0U3adsRdDz2CX3hhJYgj43nIyfEPpXEbCVEizJHHJXOVRAa9DkZ4cJxyzji7Ke4 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: 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 reduce to almost nothing. The remains of the function can be added to vms_complete_munmap_vmas(). Signed-off-by: Liam R. Howlett --- mm/internal.h | 6 ++++ mm/mmap.c | 81 ++++++++++++++++++++++++++------------------------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 22563c959861..90cab15c3b81 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1487,12 +1487,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 *next; /* vma after the munmap area */ + struct vm_area_struct *prev; /* vma before the munmap area */ struct list_head *uf; /* Userfaultfd list_head */ unsigned long start; /* Aligned start addr */ unsigned long end; /* Aligned end addr */ 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 */ }; diff --git a/mm/mmap.c b/mm/mmap.c index 76e93146ee9d..2a1a49f98fa3 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -523,7 +523,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; } /* @@ -2388,30 +2389,6 @@ struct vm_area_struct *expand_stack(struct mm_struct *mm, unsigned long addr) return vma; } -/* - * 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); -} - /* * Get rid of page table information in the indicated region. * @@ -2634,12 +2611,15 @@ static inline void abort_munmap_vmas(struct ma_state *mas_detach) * 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 + * 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, struct ma_state *mas_detach) { - struct vm_area_struct *prev, *next; + struct vm_area_struct *vma; struct mm_struct *mm; mm = vms->mm; @@ -2648,21 +2628,26 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, if (vms->unlock) mmap_write_downgrade(mm); - prev = vma_iter_prev_range(vms->vmi); - next = vma_next(vms->vmi); - if (next) - vma_iter_prev_range(vms->vmi); - /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. */ mas_set(mas_detach, 1); - unmap_region(mm, mas_detach, vms->vma, prev, next, vms->start, vms->end, - vms->vma_count, !vms->unlock); - /* Statistics and freeing VMAs */ + unmap_region(mm, mas_detach, vms->vma, vms->prev, vms->next, + vms->start, vms->end, vms->vma_count, !vms->unlock); + /* Update high watermark before we lower total_vm */ + update_hiwater_vm(mm); + /* Stat accounting */ + WRITE_ONCE(mm->total_vm, READ_ONCE(mm->total_vm) - vms->nr_pages); + mm->exec_vm -= vms->exec_vm; + mm->stack_vm -= vms->stack_vm; + mm->data_vm -= vms->data_vm; + /* Remove and clean up vmas */ mas_set(mas_detach, 0); - remove_mt(mm, mas_detach); + mas_for_each(mas_detach, vma, ULONG_MAX) + remove_vma(vma, false); + + vm_unacct_memory(vms->nr_accounted); validate_mm(mm); if (vms->unlock) mmap_read_unlock(mm); @@ -2710,13 +2695,14 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, if (error) goto start_split_failed; } + vms->prev = vma_prev(vms->vmi); /* * Detach a range of VMAs from the mm. Using next as a temp variable as * it is always overwritten. */ - next = vms->vma; - do { + for_each_vma_range(*(vms->vmi), next, vms->end) { + long nrpages; /* Does it split the end? */ if (next->vm_end > vms->end) { error = __split_vma(vms->vmi, next, vms->end, 0); @@ -2725,8 +2711,21 @@ static int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, } vma_start_write(next); mas_set(mas_detach, vms->vma_count++); + 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; error = mas_store_gfp(mas_detach, next, GFP_KERNEL); if (error) @@ -2752,7 +2751,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. */ From patchwork Tue Jun 25 19:11:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711862 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 95A42C2BBCA for ; Tue, 25 Jun 2024 19:12:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61C5D6B00B3; Tue, 25 Jun 2024 15:12:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CC616B00B6; Tue, 25 Jun 2024 15:12:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BF1B6B00B7; Tue, 25 Jun 2024 15:12:22 -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 075036B00B3 for ; Tue, 25 Jun 2024 15:12:22 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C56B0C0565 for ; Tue, 25 Jun 2024 19:12:21 +0000 (UTC) X-FDA: 82270356882.20.8158FD1 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf15.hostedemail.com (Postfix) with ESMTP id 7B073A001F for ; Tue, 25 Jun 2024 19:12:18 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UBxLI7bU; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=j3bwJdP0; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf15.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=1719342724; 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=piltnTByFrtmgy9GlOmuLW0JbDdTYktoJ0ISndNfSNw=; b=1UFcXJOr6Nl82p3TPtHa3zL5xDw7Fqy/NwkM5f/H3ltoqJu/R2Gb9r9D6ChFAAzSnIfghx IDHb2t043HNZBFTzExhxlkm3VYQprBcDk0MRELvVrujrDI52WB31mZ2hSWKpC9nnBmiZKb xu0eN/00kQs2UQmHBKW3HWnM6c4fFvA= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342724; a=rsa-sha256; cv=pass; b=5ppjGO/PSMZGJsS3zvaNMfDu/wJUbljjxGnCiEDgKF9ZP0Vdphd0hJ21XcbfTrPEs8W4ut 54mghRcr+ZnxCTdEjcb1T/gg6T9D5YJh0A8Iiu/+K5+dhUa8oOcLA3/R6W4RxR/R+j9nN7 ELICjdCFE6vxnKQEVO+AxI4q/qaFKe4= ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UBxLI7bU; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=j3bwJdP0; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf15.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 45PIfTnH012802; Tue, 25 Jun 2024 19:12:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=piltnTByFrtmgy9GlOmuLW0JbDdTYktoJ0ISndNfSNw=; b= UBxLI7bUcEAsyFW+Jq9cNnNP3aYY8IwswQYwtJQWKwkJPpzXMow/Vyryx1w82vse 4ujW4T4nOxUYBAgH7/svRtmGm7j95y4iIVfrytMP2paj0PPzGYpC3BcPjnVKjnwR 8HyrjaS+u4HJoc9dQ+3272vqY6Nk85cthRbmyUnHSu2/zhPj2MRTLMA5Xuf6XK6E j/F6pCfxuuxLObVRm/An1Muapy8JgsZ2gwjS0PfslQQC733DpGgu3FcY2cdpze+0 siynMztvwb0Zv4QAQtqKrfB5PJiPJkD74YfgXM+7yor7p94U2GrTHimvDh+8ksf1 WPf+U1VY0Atd4prv3qsjWg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywpnc9ub4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:09 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PHonQi022616; Tue, 25 Jun 2024 19:12:09 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2041.outbound.protection.outlook.com [104.47.56.41]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3yxys4xa89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KBviEvCxPsvuXHyws+sQvPeLWcv9udH8BcQihPhQ8wanYkMjoy6UjV8pnSvc0okpcYdpgsdBosPwdOljCx7YZD6Pm3AzBn0HbdXWFEFZc4sVdys6U0KyLEonESOkSpovJSr1EZhsvjm5AVTNJve1kNhziMm5nfal0h+dAhA+NqSK8q909iGLX0BhsDRag48Bnc7J9Yeo7V+grlTLn48UK+P1HfrKKQ9QTkntQ4vBuS0BsuEPlVJawmWb3hCx/CczZcwfVMrAwG2qXTk4F2MFtplAzrVWEEbzhPhzVISl+P1jRccH8GztN2Rj/q8y7lXZPm7xp/eBhAbeEXXMkcXzfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=piltnTByFrtmgy9GlOmuLW0JbDdTYktoJ0ISndNfSNw=; b=QxXzlQ/gI4uOlCMfkpjmKhCjID1756JXKlx/YEvtqBNb/tFG/RFyYB/tnSLMu0/2ePqGv9pjQ4V3jMaQ4ipF5YBItipL3Qz3rQFJvWCCzMAhcJ/IE1uLJ0ejf505gzMIgQNmd6GXN5kS6DqCBw4axfH1q9nnMce3UPryZNd3yULXZn/jTS64BvSRe+OJLXx+xdfLfGrHprNOvsIxqSTp0IPp7PFE6QF9H8I7AjapNUPzK33jfVp3Tw+c+AGMlUKl6/GrQKrjoc5JJncDebung0GnWhvxdOk7MQcwlOgm1+wjOPQDUA+QOUSaQ3GLDYVQidJr5pT7zS2lCtNNLg/T+g== 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=piltnTByFrtmgy9GlOmuLW0JbDdTYktoJ0ISndNfSNw=; b=j3bwJdP0Mj5Soy0vUqIljN3Ubf3WM3QPJuUa7XoqadTCNv/B2n8ccI7Gz2dnwS8+ilGOOF3Dmr4GqPZckeziLKsA6AeB+6ptfJfsxKKHrma12gzpuwhmhWZUoqBdmKmjToMjZzz6AVaV7rq7OnYR0vACDuNj7WDd2I7ZOGb4kP8= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CO1PR10MB4707.namprd10.prod.outlook.com (2603:10b6:303:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 19:12: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%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:07 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 07/15] mm/mmap: Extract validate_mm() from vma_complete() Date: Tue, 25 Jun 2024 15:11:37 -0400 Message-ID: <20240625191145.3382793-8-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0074.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d0::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_|CO1PR10MB4707:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f2ee483-99f2-4bfa-815c-08dc954ab47d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: bVnz0EOH576OqxSRSvRehCQGeXhbLoV1DZrXdSNXeSbhMUdJTf4hWQuvA4NxSxgzuOsdU2OscNFJ06QtVFf3sqK/F9Q+3yiC2e3Z/gZKDOcjC49Fk4B5VB77Y45BeSZjpGaMGBWOpF8/4xONQf71wv8qKAFzxXzDVT1Awq/71Zb5VQXvKnTr3DIoyuoGxXAF5REGT0tpg8YcAwTyRpZkVZy+bHwejFcemvb4iZ54bbUZ3WUIIgvrBTkQD9FxMTSNp73c+yyxdhjMMxFc4/uTGly9RG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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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xAko54osaQgQYp0inu0tSjJcqHNp+gyXWGLV8e2CLWxUw9ROF/j819zGDKZriXoB4WZqX4bRD6UxFBZvIgCcXuDhXmm940o25Nb0/Vv2FOi6JqThtQ7xLFQRVdgeFVe1SyBowidIYZUyPJ9MGYFr5QEXr1j3e/tiQdLFkNYTeSf0UCCMK7GrlXn3L4f+Qq8CFqc26C+/9Luy1ZJdxsoLccBLTy2FZ/heW1GhlEa3hshZHrA3Vh/o9L0FIE0A2vV1StCkKwC6ape/dPplnE+ALh9tIWrDkduEaZ5OovKCEazRTvvGJysQqwI3VmGDDSl9jAXUmXRe+Ifqzj7wpz3yrzztFnxtoVkQFqQNJBo9r7dqEsiMMhXhIC8Ix4AJDFW4F9qQpYn4QV7FAYerOMLTOqfaUPNFLWDXEcBhBRAk4tJ6VpT8eMSBqmbhjhXCPwq5R+aLj8qkHO6KWQbDEkqDvNcHPbtyXNviqibot2/hsM9DECvZdlgHqGZ8+UwqenRSABuf0JlgslCdxSPCro96HyOWLqnshkKRKg34oWqE+kvpEiyRYLAyHMh9gKIS+ZpeOIRIqXSJiFdNigEHJarFOcjQkkxOBGlOAxesI/OmplLGA/pg+xHo+kYV+bDStClvH1sFRrcwv9pnHCDUly1HahxTVm/8NL/wbs1cJUShy+XQ6dsmEiQhzLTmrF9kpEeY3xhumzuBbly9bF3RJCuXoehhzdkxATtJSw4Pui+sPGFWD+EHwDy+2RVf5i4SQ3e2xnpIVuDaiR5etYLTrhi5D13CtAjVGGQ/D7X3imL5pMxu18JKIYRInfIoU2B2+cQqkcA8pwmFKXa9rDYGyGxyF+GNYR+C09BL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fz9mYZ/2BAjHRUvuN9Jv0C/vgV6CKiWjRhAoIpH2nU/U+jHQyS8EYaljPwQ1L35ubt40mlxyx0tNd9G9PHQGLlvmTNekTdIoo67pgz2RUxarz76dwa1azEI9vMsHCkfFB5h8AZ+EXNztw0+c6tKsO3VOTZN/6TYd+DYjRRJMv92zO7bkEtv9BDsYxx/nGC6MScfeC/8wjXkcQnFTsqV8sUljXGWLSrBNOSs/gnhaw1wwvMMjh4RJyfs73VXClOoFTXd4Z6R9s2ZzD9E7dxCboXPU59V72/ckeJA5EBm+AOQrQKH+WVZexaOwbc6Y3ppBgxv58uMC167KfvEWSHa8dyiSYeuTLiXIvRWlCKdiR2RDWA/548= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f2ee483-99f2-4bfa-815c-08dc954ab47d X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:06.8934 (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: HG6HzSEihWllR3si/dgUK8ZNiml+01U4kF5nCJtWOaCbJ4oHncRwVwwx7bvbPeiRWeix7FNmfadPUtLPm3zQXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4707 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 suspectscore=0 bulkscore=0 phishscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: gvt01nU0efeSsIA4YmeX9foVf-PRWNiF X-Proofpoint-ORIG-GUID: gvt01nU0efeSsIA4YmeX9foVf-PRWNiF X-Rspamd-Queue-Id: 7B073A001F X-Stat-Signature: 9bq1gomhkacae5cm9x6w9muxghet59b3 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1719342738-242351 X-HE-Meta: U2FsdGVkX1/mEM7mfzrDMXy07XarkQXv50Of4NiaeR4htxL6JM3putfDh9DcU3x8jBBgojRSgbbN+vyE350+ZY6l/J/pjBjwB+fQz5mwBs1jWqxbA28e0L9udzE4idb90bkqrVZx5zxhZMloqT4RNSQiHqb/V0RMI/MOdr28hZDbkbKpCfhwR85zKHUO6lSMtto1PO17mlCqQX/PL8QTxJ9J2xy84Vavxw4CDyuZTmH/LK3SNAGBUE+Fd9O6IftH5HQK8NaRkLR5wDCgz0TVN1IlVKfvHr/qy2rEalStAnnaDwxYjeKmMhVV9AKvx3yerrSqv59SGCmFVs00aBHzMoidW05KsAy0bQ7Gd4yrUsoto/HJYlkqVlNM/0iq6JCmnWjufe1Tw2CGqNmZZ/zQDLz7GJ6l3XqinCuqFvlzXrVo+ksHkF8OQ9WYc/2kl7zq1PK8J+833BRl+++Ce/1/pn98vJ/U+z1k5vXRUx5knRDq5UetgyNIPs/H6GkF925LsORsrMsFqJI6bT/OJNy4LWzrVw9vECatE8ZXonL7rsapvpmxKl2AHdjpl5RNuLWDJoBkEjMGcRM5LEMDuXzbOHwb0c3YWxcWCjF6B1RGkZiizIHJ+eACAMFXOqD4KvHHVZCt4u6gOjjI3nmGYWwXgRAvnBdj0ok8K1syedV7QHDs3szFfEg3B9IOHNwNA1HdAdzucKC90FLsXYh8QGd80FqTZ8oSOINbmNOtglWgOFCa/RYnBX6YlLPs58quF/MYd9GAGOHNG7IR6kHQfgr7dVZRz3oVciBnkm1SazL4VW5ayKYaLtTj1o+c6Q/DL3He0lMg1HbZGVs6Nnb/kzAW42cSyQ5ESQDhiR5xQCknBRFVQyoZuPsG5+WIcWeeeedSqU0awpM2og0Cfsw+GTx/WveSMSpnKKEp4531zhV4LoCZY2rh7JowXTpkHfd/wyPpaX6FxGpkreQvpkHlvzr kY3IYD7O YMLdNEtehD/2IerCE4JWfseS/o6JgKWjiuCXzaPFo/1mXFuYcuqOLqMPo+fyUCtLfCxJf/9hsIjvOzTr0EhELBHAmeYuHRGr+149mZxBKcIjIhBFZx2biZdL6aaLLvFDv7si8Bu6F53Sjws75One5WOZtDwh4thkIjlZzqxVingiegWzUHQmoMtN/9zxp8khyXhdBeZKJhrqUrit/+BduIpqO1PEaEzslTI2ehqCJhGFqKyfIj94KmfWzG6AaI6G4q4pxDnLcoF0vtHBnlZfjE30z/oK9nc1KmB+3oRLmHnST9FjwzsEDKqzMxfVGikQjvthplIPpk771WgWuz3EDZQrsvhE8ePlE8u6uvGiGp741sBTuQc8CofzeSrGNrTeN+TQ3RQAIaKGjRhrpCN/ulJUYaowTeSUm5WOAofLkVC5W0wdDeSKHvP07IFuQPLGAj7Xice9nFP3NYOJ/540K4G2rf7AKaNpupVoy 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: 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 --- mm/mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 2a1a49f98fa3..8d9be791997a 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -646,7 +646,6 @@ static inline void vma_complete(struct vma_prepare *vp, } if (vp->insert && vp->file) uprobe_mmap(vp->insert); - validate_mm(mm); } /* @@ -734,6 +733,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: @@ -775,6 +775,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; } @@ -1103,6 +1104,7 @@ static struct vm_area_struct } vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(res, vm_flags); return res; @@ -2481,6 +2483,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) @@ -3353,6 +3356,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; } From patchwork Tue Jun 25 19:11:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711863 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 E7B0BC2BBCA for ; Tue, 25 Jun 2024 19:12:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B7216B00B5; Tue, 25 Jun 2024 15:12:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 813206B00B8; Tue, 25 Jun 2024 15:12:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 368DA6B00B5; Tue, 25 Jun 2024 15:12:22 -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 0A8786B00B5 for ; Tue, 25 Jun 2024 15:12:22 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BBD72A057C for ; Tue, 25 Jun 2024 19:12:21 +0000 (UTC) X-FDA: 82270356882.25.D12C21E Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 664CDC0002 for ; Tue, 25 Jun 2024 19:12:18 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=e9BJF1HU; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="yl/N9pF0"; spf=pass (imf28.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=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342730; a=rsa-sha256; cv=pass; b=wrw/WGqpAiXwgWBfZoipkTcO+/dwVTE2uhwvxwU+H90KS8kKef1xqtuVBjU81G3zWrUvL8 XNfABjQv2zcDjWRIboZ1bPiaBy+nc89bjd/NmrvPrnyMJsrxhg8wzIxCEZB+PGAloHeV/a zvooRVkh3xl2b+ivSMhMRwfKx5ZbhXU= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=e9BJF1HU; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="yl/N9pF0"; spf=pass (imf28.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=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342730; 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=1DoxtPb5EdsWVu0FMLjwtMRXKfWWaZ02jMrwbY8xjCg=; b=79VWHWFhSc7+eHv0LK4n4Hz7u5HSSOO0pC9kwMLp9ILrM9OAEicTNo2bhj10SJ9UUOIcjp 6BOH7EtYAXwumWeMTJRWSqAsqjLp1QJ09Mv+WquJSKfx94NmaXG9dJ5QYOEylxnAKgvm6U lk2sdNgAYqFGpQtM7Ul0WKFk9krgHI0= 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 45PIfUqf023000; Tue, 25 Jun 2024 19:12:12 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=1DoxtPb5EdsWVu0FMLjwtMRXKfWWaZ02jMrwbY8xjCg=; b= e9BJF1HUBMWMMg8bhqOBpGItD5sJ5O+xJYOCDIMBpwhmp8udgCSTzwsWADl0TVTh Fz0T8AFsEn+IiJFOR298dBW6LSoYAixPXVpXY19flWbeh4GwQxuXHkwab7N/oyEP d4a/HWr6YXx0U4/jQKbNkHZ8NqR8+ZOklDLd6bjjXuqz6Hv/DOBAQc83SJSeVuTP rliaWVaOMjSAzcsss48NG/n4K7FxNF/jGFfmVcXxZ8TWqGeugr6wOHPeG7o2s/Nu kAd4QhCsfEvNxlQqX5AumXVVQmokXDIoqwK4WAWWyhi3ud9ly/cMFXnUtP3G6m8A wODlO3iaOONsAN+wJve2xQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywq5t1k2y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:12 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PIqmFt010741; Tue, 25 Jun 2024 19:12:11 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2041.outbound.protection.outlook.com [104.47.56.41]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn2egtpr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QVEo4a73gpKT7S2BBD0GZxKyo6AGTXtA4cxu/Pg7i7sbOkZsW5rK7d74I8dByts3FmDn8Bf96ZWirHuqp2orFdCTnuMSHj/jp8iYlfMt4uc9dU2H7AHe4Q1D0tuS1kjqHUfYS9aVZPqh+Upq/sNea4ZTNixeJzAAcd5ZemfmB2Jqswpv4EyWjOX+oBKBNiUbJbo+aTDF4YJ478iMHW9ib/4Ef66D7vkv3ibGdtM2i8IJz3Lx4d0m0eu/f6+K9Q4QKX8SdgaN6G+OLoX3y2aVE3fRHwbLZmZZTP2R3RIYIfQmX8tup7QkovfQkpHESZ/8B3hAuoiLqvi6owpjIeGt4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=1DoxtPb5EdsWVu0FMLjwtMRXKfWWaZ02jMrwbY8xjCg=; b=Io5uHQgc36L6Ad5GRup7M1Rlqxhqc21MZy+EYhKr4fVJrSEa3cEmiEJm/StfacDSPcnevsaABrMAAMzQYHwZlp2ecrZ4Gt9iGoEVuyVMZlmQcke0Hxmn4aB6bCkUS1pQViUjjWhFoU4/Ismek6HBE4Od7avPyJh2nt0eopQ63x5GH6FyAnWYku5zfzR/VxGenxJvgblNFMkSHoNscVxBYNRd87Ns+qFvcXOUZ3S306vl2s4j+t4IUjcTOlvllwvuaShvum6SUl4VL/NpjtkgiQE0WTGayAKB6wOH0J1MTtcsOkUrw1i1s0wz71Y3gCeIH+HtoCLMunsS1dfqq7dJMQ== 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=1DoxtPb5EdsWVu0FMLjwtMRXKfWWaZ02jMrwbY8xjCg=; b=yl/N9pF0DEtFK6O/i8ZduA6JFAgN5xV8EYgttJU8vTmPE1volFpw7dY2WgAXa2binJiOQIjHeudbPWV1EJ16+hf3RfrXXvTxan66kwJQEzEx4AryWBTQO9BieOWGg4ZquigG6aY8f8mZgtj0Rh63U/AQH03CUuwAS4aLSWueESU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CO1PR10MB4707.namprd10.prod.outlook.com (2603:10b6:303:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 19:12:08 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:08 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 08/15] mm/mmap: Inline munmap operation in mmap_region() Date: Tue, 25 Jun 2024 15:11:38 -0400 Message-ID: <20240625191145.3382793-9-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4P288CA0017.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:d4::28) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CO1PR10MB4707:EE_ X-MS-Office365-Filtering-Correlation-Id: 5dbfd661-7819-4291-36b4-08dc954ab586 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: XwdcP5vv4jbudIqAzSrKPiN+e0G3/x3yS9/KrqGM7hB8aUIy9QsXM4yavS1CNHuqeAol8MzlMTrRUiFcxHByddZ+45BAltVZk1ZcByatXtxQI7Y59OCDTt5Rgy353yHwu2j/aAaGXiPYrXladzZR17ct//VQ443EcAP8xQxybcb9IIR8UNCXozcsgTxoqKTSVdBxH+nuDDfh98nFu1Pg0pU3NXQyKqqT1jTRLL05M86m/ArP5fpiEwWB/+pW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QcbhZn 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /RljETI5WQA4YzLC2oofCgCNZQgljRaqucng+uaiMsQkxgSNGlerZp37Acc20ZRKpZoEzfObLBxC2l3FjrciuNSatK1JnZPYCbp3V0i6IlxftisBli7Z3rSEY5H9CXApxTFafqaYZT3ekEKAGmoZJpeW+q0Sjt0AVLgD+pL3TaBJ2b9Z8lBHRNO9Bzc64utxbyvy9CpIybf3/fmFG4HhfZbo5qC1K/jt22QZkDtB7UYKer14rkPNlELRJL4VXmKvsWnbrQs4r6GZSX96aGaCXytWqapEhUzVAKiwVVNqowYY0ZxDoUgX4jn8QofSiZ0UKI3lIdRHm1r7QQz7DP+VcVBOu1UaQMtwvdVLwBeTFuoIDqKBKxDA5qiZ0DuaD9vAhoEnzz8O0A0dMPVItrlPZjw8Fj2MV/npxGwAsFPDwaOz+RWaf8MiqbZjYfunfROidfLDiri/OP8EtwN66edxEnl1NfvVtwU6tnF61otElWk1YsZrxcaHOvpHiwhcNXw6F5WjA/CnegAzyGWH9M4/178weELjEHMH/Snngut3bloTnv03AINJpzUVGG09kWxCWWMqZ4pu1E1SoBroShOKoLc66VaHD8ip7vQ53/g6X2PaRcpZpyiaQGEBOqlWJ/3xWHlpmLd7S9BAoYRQ2NCDWr5itX9AcQOpjdRZoFFDgG2NH+wmxeBk2KPxp/5qDDcvjYdOrfxuDafXJQrggG+2q7TE3CZHA/21L9VzhIC8+E4Lhufkhtbq3Dkb1x7JT/oLpm6G0r8cBiK0UQU2Z4LwRMvEMa71TwXRBJDz07g55FhQfbMKXn9yN1EQTAhVVdO1VBn0krcAxZOrWYPg/N39hukIRNmbU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HPZqyM+0TQx9UxDgH4Ca90a6ut37ZlMUYbD3tp+57V/Gb2vs+EJtRbtIKI/mVh2ksPouRd8bmkWXQO37SRJKE+HJcblGo8M9k+z7QuI6o61YJZTlzn8dEYvXcfpu62GBqAy6Rp5T2cQD78Ui8/D/LwtvCg0z0mfJ8aL3whwObyj6LTqGA0PWHXJ5CothPqh+IkS7p11VfJdmsVCUo/KXiNzSKvGeBQw7Kced1P15ch7r+kHp4ViXJzO8YB8WJejh/FtecxvkXgao8c61sGpeEztrci6p3lOAftt5Q0dFo5MMOte7Gt0cEBDRH/pgbmxvmFeMqu8jL3UyjKPYbH9pWQJUKrNIsv/4A5fU7mD0nWOBQScORv4+k0zL0m7yQ3TtT3t0g= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5dbfd661-7819-4291-36b4-08dc954ab586 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:08.6168 (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: jbmR37RPGx4zXRF6d8ITlOd6vpXDBfHcwAz5HY7KW90YQD7LzednJqKwVoiFktdpRpAD2l3nDL4WiG1Ur5tTcQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4707 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: Qg10Wj-9hnBdFnDrHzvOAY_JxdxilOXj X-Proofpoint-ORIG-GUID: Qg10Wj-9hnBdFnDrHzvOAY_JxdxilOXj X-Stat-Signature: rfropqfx88wfn4o8dz1wsjp7zes58qd7 X-Rspamd-Queue-Id: 664CDC0002 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1719342738-323115 X-HE-Meta: U2FsdGVkX19lMzh85JBb4GvcYAj6uWFYYAinfhUuch2nL8veNKAKcnR8OvvSrFkDWr0okdXkAVHpGnLpcdyFu1en7gEkNeU4F6EwvQAerVMSJ/ekWrDDOxIowP6w/4iWeWWQGc7iy+s5JNLVTJfJwmHAnBXeevbL8UXS1OSy49b4i5ro7TFmXuw+bvfpyNmkm8IncNk00Zm8NEDpd9oi2H4uciBzlzMm09ifrhOszMcO7bJK4POk5nSj78IM8gwxKJSIKDnsNx88PrWFnqHn5NTlMYfIASheY3ALMv94XRdlvT0zW8hqBAzJmcn5PP0By4SHYQw4+jZgqdFGEBGoRHr/b06j+/aTLp39BR9jGbWd1q/ekousGsaeTKoJ++69lFe3M9uXL6E9HGe+pxBVZgyakvO/d/o//2pAjQKhCnxmme7/lCV1YPO3ujYK6mFK99eH8CCAwiJ+GhwEx8Vn2z2gAc1iPPdH9nTw1DTjmFEqrThjmmwF7znmVZZHK/qtBoBDGsbf0znAWeZOMRlQiP12Bta8lOEbODA3Y0LSBqfQzIWBrJQN9bC5qf4zYwCI0mKCe6+PX2iNsWtPPE6luIzufRWFH5S3k00CGq/AUCYZLeT/AN14XGlYSH/Bn+Tn3VE+ygu8Po7QbFJECeRHwv6jlbxaObEX27+bsXu368NEj6XwK+ZgG/U6zd5dqsksU2KGD14CS+bBHt+Z+vgZDtycoQ4g9qIj19CmjDZv/UiT0Q4VQZdNaYZ0SNCjN3Kuc1tDh5xlGXWBsx7d6swJLpEV0/0TFgtlNVuD+cUnW44xnpICh9Bnz01Xyjczyffne35AkU5Ct/5YypVcK6KMTLfWEIBFYUqySnNhl2w3O/P9b2iSDcbu18ogHpLq4lyHQvqMXORFZbWguLGFL511M+/1CwC49dyl3m895aCO+XYInR2xVGv88godV4AVKx2ykD0Zpf3v+yE4a2hlE4z M/Yp3cmO i+PHjy1LYDJ89wj+zOsPa4IORLz0k5Fj1fHIzA71guk2X7reuOs+VzvxBQZ4ax5r9DXX362gL1ivcgxRseAUjBoTQyD7gjDUkz4ECJD2PebnH9t2Mo5P9FpMfkfiaeNQ6K6zkI+nSdOWThsioPzc/1xy4eqZy9mnxGxGjkGXN6IF/WjXLi2vlgPuAuBOK6BTJigYqn7TnV09UqHa/iIjEXLPmaiGkd2YL94mRqNwk/sdhXhBEdaxvRuYBeBWESqVD6d0OMrZ2fuf2Q6f7cC3QQZ/6ZLHxsLZvcxS6OPpujsjsHpQNaA3HpONcZEZAPriuQRIy0CpKcgUROPTNcHK8hop3i1ovH6hbgxZhs6c/jaTTTF9oWXcOn6HDlP/aL4shCen5WqI37PRYcpNzNtHvgpeJiFAteyP+2KivMIbrEMkaoHPQ/zU5TT9HjWvbYQnWQHZ+tc0pCY7duXv99DwjRC2Bhw== 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. Signed-off-by: Liam R. Howlett --- mm/mmap.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 8d9be791997a..e9858ca8bbd4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2937,12 +2937,20 @@ 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; + + if (unlikely(!can_modify_mm(mm, addr, end))) + return -EPERM; + + /* arch_unmap() might do unmaps itself. */ + arch_unmap(mm, addr, end); + + /* Find the first overlapping VMA */ + vma = vma_find(&vmi, end); + if (vma) { + if (do_vmi_align_munmap(&vmi, vma, mm, addr, end, uf, false)) + return -ENOMEM; + vma = NULL; + } /* * Private writable mapping: check memory availability From patchwork Tue Jun 25 19:11:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711864 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 9F1EBC2BBCA for ; Tue, 25 Jun 2024 19:12:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95A496B00B9; Tue, 25 Jun 2024 15:12:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D6C76B00BA; Tue, 25 Jun 2024 15:12:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E05B6B00B8; Tue, 25 Jun 2024 15:12:26 -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 47B566B00B8 for ; Tue, 25 Jun 2024 15:12:26 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 04930160539 for ; Tue, 25 Jun 2024 19:12:25 +0000 (UTC) X-FDA: 82270357092.08.F0999B5 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf10.hostedemail.com (Postfix) with ESMTP id A1BF4C0008 for ; Tue, 25 Jun 2024 19:12:22 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=DqO1J6Ih; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=bRfITZgs; spf=pass (imf10.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=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342734; a=rsa-sha256; cv=pass; b=Gi6W/snlz3Wp07NChXCyoTw2q0SJdneA2czxFFlU0MX4ITf0Jo/K5TnENzIkHQ0p1T2OlS kTjk/HFIp89Yw7mbd0Jv0UKioPHY6F9hE+NiFcxOdDoybmM+edcpMn7OSfZtlU6IhRNEmV PudGu5dOSsJbkLAtqzYFWB0XbIPFOVk= ARC-Authentication-Results: i=2; imf10.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=DqO1J6Ih; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=bRfITZgs; spf=pass (imf10.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=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342734; 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=f12gUZaqT5CBj0qbmSntgTFf0542jsJzkP1hUweMEys=; b=6WWej7N93tFgNz4l7V99kUm0kEokEJDBCJgtubVuPTXM8uYYA3XHNceDm2xt24EM1B6jrR qGqC1LUgJB6IRGXeev2d4qcKprqTJ7NMfCb+p/YnME3iLMs+QiGqEZV22KHX+RmsbLxlOv AfrE7iznuKrS4OhVQpbzEkYfzJtQPnk= 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 45PIfU0l003528; Tue, 25 Jun 2024 19:12:14 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=f12gUZaqT5CBj0qbmSntgTFf0542jsJzkP1hUweMEys=; b= DqO1J6IhMcP/dtTaWo6D91ODUm4doxqGMDGJV0ufxb89ftvspfkTWCNR7b0TWrZI fG4qlNre25FDYRfA76/4eNY2/w62r3aWJxUpj4uVMGliISheJq0IPBxbVWYx23wr WQNKyXJFzJHO4i1ReJuyG95NTfo6s6nWtPTFANt9Vz1fSdSmpRbofUb8EhLlino8 gwkT7WVN+na2migUeFOg5I0rcS+bPPU5k78+FIbd7w4XYUwX9RDhsAS4xGQBTU+d vrpAoAVKGQVosEiA6IQhlQ0uyj24NnEguKMGZpRpKpiySIv7+weIgNLtBl2ZUied 72T5H1mC/F4eS3Lz6YigAA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywp7shjvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:14 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PHoVnn017823; Tue, 25 Jun 2024 19:12:13 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn27ytxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C42bZ4hMJy/AX/SBS2652Lvbnm/rJFaWTEnZGh5uY6bKFoVV5gsTIm3z1IkCvdsuMS54Jf2rh6rvOAY2BjHJjrRyYlT4lSbudOaT+zDymX/kZIOC9tNVetJ28dteb/NwBFl6Ka6uZp09d61ORfmELtD0i0k3eBanpXq5V9WuNF7aFfAfG/2RKntGcJqV0huBHesvLDitN6asC2rlfotP51o6PWy/CevF+vJ5leVf4yDdMnHX2XcAeL3gU7Q2vJF6uEUyNPqI9z/J+HfF0fl+qDsMCRZ/nd2IZ0tsjkHfgPf7JGDWLpjbA5LdoCsKaJw7+p20yjuAQT89GJcJNAVkMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=f12gUZaqT5CBj0qbmSntgTFf0542jsJzkP1hUweMEys=; b=itU09f4py/NyPLlE3MlcZdaqVpUZ0/12cqNoujMr4rNpjiDjZ/QyEdKgi3FTGE4eduF6eFupWXtjAJ/vrqlbcnw43PD6lWjv8lEKcccoBxn9OUAYr0ug70fii9ekOy1WRAspw5dCDgi6FF8TDCiICfcGBGaV4uMDl+6byrLJgUvaFLCF9CMfZXgsOAdXrqGq43GnXCtVJxWNXXHMUIqcKVv9ZvwVLKBbCddEdam5xtL+gcFJG+/9LEm5dZ+njB281HRuebCrBXbn7xqnI9cLpr9LJrLuUQxaLwaJbNBQRNJ6VLRnX9SQdkq1CMTq3CsW3owmQQYb4Ze0sCWUIzKtcw== 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=f12gUZaqT5CBj0qbmSntgTFf0542jsJzkP1hUweMEys=; b=bRfITZgsv4jAbU+yIcHq5c2Ugr34q/YPeloenaK83xjhgMOIK4Bq8fJZqFN+CMcTGvSv3yxOxu7z36ZWIirHJY5jYtcmNnsqjsT7UPjz8akuFf0bqFh+Liw7+XF/aquQKxtOQ9pWmoalPRSJdXhARBo6LazWmQZQBWamB+y4DCE= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CO1PR10MB4707.namprd10.prod.outlook.com (2603:10b6:303:92::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 19:12: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%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:10 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 09/15] mm/mmap: Expand mmap_region() munmap call Date: Tue, 25 Jun 2024 15:11:39 -0400 Message-ID: <20240625191145.3382793-10-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0320.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10a::13) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CO1PR10MB4707:EE_ X-MS-Office365-Filtering-Correlation-Id: 82561080-8a7d-44d9-8486-08dc954ab691 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: A/875Jh80dxjQbYKAgvhvUBbPBoZo0v5zddbMQG0iA2UpqArM+SfSi6IFBsCZWhGUP29UO+RsFDW73TlgAQ/Cod36mVuy3GAqXb36oIFtmzu5Ay1EgcFtLSRzBtSk3dRaGUe72oPfKXqjokG1pTuBA95uSCXlmZNQ8lhzsdhFfpvcGiyarLYnoZhAT3y7ntOtgIZ1Sv6Arz9h5Z902uIGM2F/PzN6cSC9GqNH/YQGmfs5XS/AKLxsrdAWVV6QWbmJCEr/8ikPTgJmpdfcAe15szA8T53YTt0TpJe0XeFzLW1O/yaX2NpiyitA3kgiPIRk6Sucx4Yep5H58zuYouXvlE8KWsiUdRRbYcdQ0E3F0wJXh6r/WBu7v9bGxn2r3sMFHHMXVPprrqYLwpn2+89e/feGgYjZS0n9pZ5v+HcbDtRsy/Oi+lDGQ6aFByLkHb3aHMWQ2vfNlP0E6AmOv00PeTNYHNq8Ucd/93q3CGdApWx1o1bWmUEXSevJdft0CDQI5me3PegZY0Y/9L0YxOP+px7eB78nbMr+PGvc2b1rlYklNoRBsZFHezqUPuU6zyww+Vh3ZUZbRFUw5fr8aQCBm69lfWiy23kSQqp5euFSFzzkYbAEd+rFaun5i8b70Ri7Rxi+VLfT8VuLOrpfct8O+dy8ETsU65t9qNcO3hyVwxCcCllzuoOm1n7dGyd6WQfpb0tjeeex5I7BBQ+KpPpIaPDOFbuvhGRP8NobR1CX8kjMFxKx8HMymeGcfwqlr9TbLZQ8/+2G7uxbHxbF7aTQAlNgJEVSxjUVUfKNTkFBahOVwVWYpkkO2JXOR0QB3drYHOmFjdm4ch9pGs5jLQD46SkcWudjOnC23QP4GahMwYrCFl39E9XGxmw53Nzjw7N8NWx1z6G1BYPe/FPGO4gpoY+WzgXpTZelzZRrxMaYWx2qsqD2JPJDLajEfhLDVYOVVB3z8gUVTMwW6Znk/z0rixNOx9gGI+GlQ+tmz0/XmhvZHH2UzLlMS4m6nNwcZDecbjgfDTto/2G+ybSOLYBIt+Nvra0MemahXTj9Ov8kFQy0KTr142plCT5fF1ZVHuGzpSAvVAIgkZLuLGIQDPOdg6fdKlo4KAfTB/WtMJkkTTtPczAzUQhNYM5hNUJqdsSd1nx2ehiwdeaB1wDRFWnPyaKdb+ZDpqZBwia/aV5MVsWv21nwSWYULBjQQm+tUbC/OUO8vZw6LSUGX/m90hBih5yR2DZ1aMTIHo+CyZcgbS9e/h44j83PPuThXM1MiI7yV/N+DgDulWhtjYkarcqzg1huSqKOjyI1UuHVENHzm9QBJj5MOoHJc6kbYkbdQQ+ 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ejsJDs8VZW3cr91CklcKkBKXvr44Klb2Bmeeme6uFIl4rYwWNN7iZBwxyMC2xFYaqmY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c1zB3z0wHGSsU5p6e4pKFWjs98RVWKY9Jfu2Yw6XxwHk5wOcPAJaA1KNCfEfqkVri0LsYfJtT/JMCEdq6WE6Ihoo0J61shvyHR8vkoziJA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82561080-8a7d-44d9-8486-08dc954ab691 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:10.3827 (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: +9Uo2JVJ2NXcS6Ou3eXPLCvKwMWDS5jgQkXI3ciVmk/8sBA+6JZpnMNVhdoTzrrtAw6NYZMadk6pQ7j7+ojuKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4707 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: drSW4CsO7QR6fk1_fLdATppIVTpTC23L X-Proofpoint-ORIG-GUID: drSW4CsO7QR6fk1_fLdATppIVTpTC23L X-Stat-Signature: tepsp4z8c39skc3wqbq8gmjxmybjfiwx X-Rspamd-Queue-Id: A1BF4C0008 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1719342742-867754 X-HE-Meta: U2FsdGVkX18OU1IpE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vufC7MPDpypwjK712A3luLYjPg19jiztgmSkFZty82VYBqdxgheasxs+rr6wXgVv8i8JKI46cGdQNOxO80UsxcLY1uwZcMhQ+hH0dW4GuLePCUPHrkHszBsLAAk6n5+gZZWflavp3Ozde/C+CAM6b8SSwClRcdMHINpEVTNBjRSgr9rXBNZug65wh4aYdctvGU9RD+bCDgw28FYVVQkFtxjlrgutf3M02BE/B47Rt2rkPA0V62GzreGXRxecdbKnuHDANKUqXHWSTwkI7Y3amdXp/HKb3Gak+TW/bODGxaoMFDHaCXkmB5RFtU0hdwaVVtsOqrqZEkmGqU47+9nE2fGImSqWOA== 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. Signed-off-by: Liam R. Howlett --- mm/mmap.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index e9858ca8bbd4..f5b33de4e717 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2915,6 +2915,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; @@ -2947,9 +2950,24 @@ unsigned long mmap_region(struct file *file, unsigned long addr, /* Find the first overlapping VMA */ vma = vma_find(&vmi, end); if (vma) { - if (do_vmi_align_munmap(&vmi, vma, mm, addr, end, uf, false)) + mt_init_flags(&mt_detach, vmi.mas.tree->ma_flags & MT_FLAGS_LOCK_MASK); + mt_on_stack(mt_detach); + mas_init(&mas_detach, &mt_detach, /* addr = */ 0); + init_vma_munmap(&vms, &vmi, vma, addr, end, uf, /* unlock = */ false); + if (vms_gather_munmap_vmas(&vms, &mas_detach)) + return -ENOMEM; + + if (vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL)) return -ENOMEM; + + 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); } /* @@ -2962,8 +2980,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); From patchwork Tue Jun 25 19:11:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13711865 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 D510FC2BBCA for ; Tue, 25 Jun 2024 19:12:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CE666B00BA; Tue, 25 Jun 2024 15:12:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 778FC6B00BB; Tue, 25 Jun 2024 15:12:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 530986B00BC; Tue, 25 Jun 2024 15:12:27 -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 3483C6B00BA for ; Tue, 25 Jun 2024 15:12:27 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EFBE24055A for ; Tue, 25 Jun 2024 19:12:26 +0000 (UTC) X-FDA: 82270357092.20.CB20F7B Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf03.hostedemail.com (Postfix) with ESMTP id A3DE120011 for ; Tue, 25 Jun 2024 19:12:23 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=J9Mg+Yg7; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YHI1plFG; spf=pass (imf03.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=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342723; 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=481Re+ATCvAQvWbPAjt9N9MaRrHnR8VIjSEjBs80iUY=; b=ikwyAidjI7qCZ+ZrZDMhXKydE3KSj//rdKBX84VFU6zFOHNu12a9wglNpaWSo7Q+q2uskO 0bg/pTL9k+wsAJGYTG7mpjDuBq7mGwfMEOT0KPsIIlTJgtEBn0nXpKOqjYay33V9hsOwvQ RJNNrfCcCNG5LXk7yZEKYipTtkKo4ZM= ARC-Authentication-Results: i=2; imf03.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=J9Mg+Yg7; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YHI1plFG; spf=pass (imf03.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=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342723; a=rsa-sha256; cv=pass; b=3O5MpIStytxXQm5r0SHpQEU9eQeN0/7nUODtaYTjaL45O2+a7q+ejd0eW9J1czZwNvM9gG xzaY4X6m/fjWpVdNK8N8NRKUP4yaLz3RTZxXriuTuTC+7/b7scQAVj7gPXEnH8liE3U2Mi faVzd3xGUyntaMjjGrsfhMU5+1FB1aU= 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 45PIfUrc003580; Tue, 25 Jun 2024 19:12:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=481Re+ATCvAQvWbPAjt9N9MaRrHnR8VIjSEjBs80iUY=; b= J9Mg+Yg7s7Oj68CD+mUS5p0Z8A4sq3INPfOOKmfMGPs7zGokXw9//Yz3aCdQ0PHh AK0uONOzp9ktDH7iCzb/rGxhRo3dnmVsZGL+gZrK5A1qJjYvyqTEWPfUHlsLEzLU RAuc7QcjdANBqqo25S7WVHeXcPa36gVj4eKKxJrtGV0qIpN8QQXL/dfFMPVyvvGc YyxD84HHqg2jNtanHKfPZFhhn+fFn70hRzCwtz5ydzGmYWahbVoox0tuKWhyD6vO nJP9hT49hrgyy25zh5xyx4lAS1Y/vTb/1pquzGmh8zXx3aKZOXbgfgJ1CXxNPbKm HONenIHTarkgZeDGDPzpEw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywp7shjvh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:15 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PI1vRu017872; Tue, 25 Jun 2024 19:12:14 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn27ytyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mqphz2H7FQJIlJQgw0C7VXYQmslO2uoBaiEzjwvjl4s+NEhlAfI80+Z0WLTm4qrvQvwpd5WSuwuDYjLxz1fk6q9RJfcL7bVAqDya7k2+9BUvMOguJxshZnkZgQrKKZRWU1NslDyFETNgOYJtx4YqxqqL+blhwezcLVeSM7A9dp23KGmID7tEQtgEBzi4hNWsq6ffeLx6oVs5E2Svqx9wwe8jNuXdP6soIdIi1cNvvFfJRz299gut3SZlYA5th0Th+fjQjLweE0ardVr9N8CLorbswvZ5UhFcwqrM7fCLuDG6izMnOXYUJK6h+Y388euyQpuli5l4PLBZcZfxZ/xdgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=481Re+ATCvAQvWbPAjt9N9MaRrHnR8VIjSEjBs80iUY=; b=jM8yFNq2XeMZ4tvLJS+pRUJvcRfCalJOPiCKojuL/ErbrsEj9RRSY/WiJQV1Zb94R8GRruGgafsKG80cfej84kN6ZwYRu7c/wqxjE3JZftJIr7CR3gTc1vfcZKs04WA0GT5e8wSjenWzGgAHlmLqlHKQKl353i+62A3J4kl2llFjK6YfIuy9nbaNJV6c5oENz+cLzZCGcmgwuXZqVARuWyz37/VbbNyI9CDQPFGdU3K+maNV0t33Dl3gY1qb5qdlDaKXMAnSA+f1IbVF8yCbjjRImE/9q0W4PdXWSWpPpVyYEPgVHOjs0H6Tdw7tWETWUaom4dV8ClPa4EV0aaFMCg== 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=481Re+ATCvAQvWbPAjt9N9MaRrHnR8VIjSEjBs80iUY=; b=YHI1plFGEqv9txdfkNk5rd3CcuVz7U6sHArFhfJvr3If2L5s4vaKIxblFYEuRQyGR8LJ3/BQq4ayMbQlL/gjJ0Sbxf+EKGkLsBQ4dyTOoRycQHkkqb0+2ysYcGErPL2qfm7UvlG0Fyp3tLsrxaShgRQS+WfDHoLZ68OlCVeZUUE= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DS0PR10MB7066.namprd10.prod.outlook.com (2603:10b6:8:140::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Tue, 25 Jun 2024 19:12: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%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:12 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 10/15] mm/mmap: Reposition vma iterator in mmap_region() Date: Tue, 25 Jun 2024 15:11:40 -0400 Message-ID: <20240625191145.3382793-11-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0205.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ad::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_|DS0PR10MB7066:EE_ X-MS-Office365-Filtering-Correlation-Id: 5dc89935-efde-4818-2a13-08dc954ab7ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: tP1Uc2fXm5ac2F5YcX2DhpC7ERAnm4xCWm/HKzcRr3PoRvY6z4Klaz5fOnQebz/cWCNthbQJnKj68N8/H5Pk9ENOLAwA8RRcvKN0u8hFMKV4uengDoYCi3YqSR9lmxHH9UuD5OM9qpgh94nsBSxZGieDz8ZHlUa4cYMB4EppFog6QkMFA5gJoDPY2vKaRf7EYlRxuWPoelLGRDjp/6lfv+UWd27TYbouNq/rkgZObyVmVB/TyI6NWfs6H19EDouJSIw0hkqZzB8Jk5ei6QSXZEPSXDfzTluf/cFOHKkFJcCyJSIi046PWBOmfBcIT7MFIDnuJ2ESyw0LS50nmKNj50I3jAWRNk99qTxUkUbX3JfWEIGsdG+ZBeMHZdEtHoRsIUN3Y82+lHBGuXCabvO9F2Z5B6ms7ZzUmR9no5QS17U/41XpAh0H16TvKzC9EN2ky33KBPcGnbtENQnkmyPP/yRjac1GkzQ02yfja6oRmA42LvkW9l7EXcH7YWPOgGhjalyg3J+yzAIYkalfUYL8ss49YmwTRyvntSQl/5PtgMNjoHWpPXjb/cWPkw3z7KND/S2CPYE0U7mYc8hFXEU7MyksMo0pjbp0F1FsFwblYhkvLnJn4HobqNrGt1Z3tRpzPR5CQi7AUqVcVPs6LtGpIhkCF5zVsFHZnyWxUaU8uF57RttiAkzB7T5KEqhQKvoEWbcvNz/KO1UYXNlGpPAIwMIlGiiaMDY+REiDfS9ub9RLl8G0URknpPBTaBws+12d4Yy25vrl0j71atiuo7hjq09OIk4sc6eS02fC9C1DEMHLMKRIeQs8df40o8x5OColR2+1N++I/dSnx93nAYOyaL08AQawSRnojlzBVY1ynaI1BbrbbelPwFCezW9EUGrVuqj0fpO+pEkTE6W+yQlkSFw7J9Hhn6frhGH/gRtN45HU0xgamys+gtRw51rtgRgfbogCUaUvymAQxZkT1R/nJbrCRizXol22knB2HM5z+PaWSILh29wlVfW4G70oWF4uPMhPZG4wzr1Sm1ht0DqpcVbzGYfiiXnL+AAncgQyNz5rYUU7lGd5lSyy/+2jXtetzyd2EJc5xoVJ+8Qs148I9on+LUrVuIu+4FNKMmEk9G5BJQcTvHpX4uQvIb+FkSm17HHpl1p68FcWLu8GR9orzLyW+rPB3ByxrrHb5Ooo0Ou4Sb3KsIV6wLtYBzZYVl+sKd5RABQUepF2d+nR2qw4x3W/qbBO2zXWZCz+gnUAofl7oZitBSCIiJGowccEXP5+VWWoyTk5iyBe5zxxeMU437HwR+pdAKoVKkgjaP8NJHH56WNACvtC7Wa4P9TH5sJyD/YJivGF61B5M/pcjke8gA== 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP: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Ol4EATawnxl1DAceQP/cvaPL0ee0OgyQq0+feGOh8mId2/4W5YUD2kd9y4mc8+/2krWp7ZNupG8WIjWwyay+bMmVvGu0acv5wEqdVKCYwEo2zbzlIhDX1rdhtKrCDBxDSyA767CkAkIx4eM/wugkf5eclmWyyiafcU52R74YFRs0U2wqVEzoJKr8aEkqgAm5BW6+HfDWdma8R54vQSuTeJMDOz58eKPmp32N26ORBNr/b7+t0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5dc89935-efde-4818-2a13-08dc954ab7ab X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:12.2432 (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: ROZ6yEI6FOCXlvDdnHlN+f24SuXarkZQO1gWoq/qdCORv4St89Eziiq69V4OZWBk1bgYvty6q5CGTB/XSm7cyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7066 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: t5mv1WdILhOnp8Zm24i4lfQttnBsh7QE X-Proofpoint-ORIG-GUID: t5mv1WdILhOnp8Zm24i4lfQttnBsh7QE X-Rspamd-Server: rspam06 X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4cpD RyIP7EaK sUk6bV5BjIZK19WChfi9YcJlQ5ag9stoKOYFwzvRS1u4bb22nR28aPpTkDPyROWgMiV8nWCBVSTQN+yEIDSKr3DVdQripKDtJaHgX1Fw6ylJdU04q5mWtGj26GL1XgqIf0tPlXulbXd6AM6OaYujOICuC3kvyCDf9EjObj9iesayppJDiopmEDvMmNP7JZ8dVGjpQpuFuFKiMmQJKTLrlMQYQRsfAJGjCqcuiGPS3HVX9wVvGoOdSMSFhep5PEkZYIZDfHMX06YtDU/NqfX9kZYEk+RHzlqKmxmdhJOhBXROkCv/nXihq9ilJk1DR5DBDybSxsZ4ja+zE6fBE+Sf2JVYWVgpwvqUh7nnCgWb6MwhC/cIWgNB4SiaKh3izg6bfcO5FbOnUm/GHSIrTsrprChg7bEI1pgUdzk8faCXbkad8hlNZ4mxCV8bNuv6mIBU+dttSG+Rg6CAJYaEaecp4BZuWYA== 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. Signed-off-by: Liam R. Howlett --- mm/mmap.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index f5b33de4e717..ecf55d32e804 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2963,11 +2963,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr, 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); } /* @@ -2980,11 +2981,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 */ @@ -3005,19 +3003,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); } - /* 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: /* From patchwork Tue Jun 25 19:11: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: 13711866 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 4CCD5C2BBCA for ; Tue, 25 Jun 2024 19:12:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35D5B6B00BB; Tue, 25 Jun 2024 15:12:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30BC86B00BC; Tue, 25 Jun 2024 15:12:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EBD56B00BD; Tue, 25 Jun 2024 15:12:28 -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 DE0DF6B00BB for ; Tue, 25 Jun 2024 15:12:27 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 93F5AA054F for ; Tue, 25 Jun 2024 19:12:27 +0000 (UTC) X-FDA: 82270357134.10.4E630C4 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf19.hostedemail.com (Postfix) with ESMTP id 3608F1A0008 for ; Tue, 25 Jun 2024 19:12:23 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="T2o7R/1B"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=mGYBobBc; dmarc=pass (policy=reject) header.from=oracle.com; 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; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342727; 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=2C47QT2h4bMPUfGiEQ1EmT7/uBhtsa8B2FgGIJ4qDYI=; b=OLYQMOXgxkCxI1W4tvUF22Ge1eni7Y2b9FSKcLJcAtQZ5geAzcXZHvPniXOBKxUL4FxCqu TNG0LxSvaFc0XvTRxAYQLTt3j/fIbaBdF8jvuSn5vojgqEovPcxY5yNtHFXGkUCt7+5zC4 uao7aguVOVJWPLFzuJLZaJdEZ8uqPk0= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342727; a=rsa-sha256; cv=pass; b=cpe8/njq9Jk1X4hJOcIst6OfQYF9tVrkJzF2GyYkZyCV4MqEJi76TUM967BW6kgvmQn1QF 74YUvxGNvP4D3ZKSyIKfpeHf9JHC5yS7cVhTij/xjrgWjbOcSDWCMit0BzfpcL+l4GY93O Z4hycTWcYEOT003EydPsReaQgCeigi4= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b="T2o7R/1B"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=mGYBobBc; dmarc=pass (policy=reject) header.from=oracle.com; 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; arc=pass ("microsoft.com:s=arcselector9901: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 45PIfY7q009067; Tue, 25 Jun 2024 19:12:18 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=2C47QT2h4bMPUfGiEQ1EmT7/uBhtsa8B2FgGIJ4qDYI=; b= T2o7R/1BxtVtVS1qwJShcVe7ZB/vUf8fxDcy1xApRJqshafHuJSMZUYwxlyV2Wjm L+7gK9dYb9FRXN1t6EXB4tnlBmtyEXM3H3pH0ssPoMf3bGK1PuQvwHJJFmJUh2wa vlBSpqZ4445ASVzxIjpvTETyNP+RLbivcjkLKGhDNWI1oJdh3U8risZXDgfVvjxc di6iuMlldLtyDmOSEz+wl+hxjOiM5TnIq2eBSQkdDq36zq/Pu5aaybHSIOnARjZm HmW3mH83/uaTD7YsvQqfAIbgCyoKEjZpBSs3OJ6XVjNSZzqARNndM8kTofiBofmV p9ZvSrAfhoLIpt9tVcjfzg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywnhb1jqy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:17 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PIvN1s011492; Tue, 25 Jun 2024 19:12:16 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn2egtsh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nQm2af/Oxk8M4+P8zw2Cxv83bHOq++aKpEQap02LA795N2qz5+s/UalqCDudYfLXIks5ma9hSB0tQRn2uxiJS5h5mOW0/lD/LT5fos+R7jkQ/l5Yxn8VZaRspMGmV3F0bgJH6PK81RcScDvmlGQgxacmqUaX7k/AuF3saEqtT+OQ33X1s+LfZFBPt4IkMQBe2qjDssgtV41fl/etnC8/pRzC3Af30Sv6sB1DrcMA8vfwFymCf8ikRapq6dxzqo3QeLfKrJX0ROSzACCDpmDPZh1cw/aK7py5waFUeN4mIsGBWrz+f0HWAgseHIWzHQIx503OZLE2ThuON/+VsUQ92g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=2C47QT2h4bMPUfGiEQ1EmT7/uBhtsa8B2FgGIJ4qDYI=; b=G1trylSndNv2kCKmp361dnXM9pAlQ3ZwBPqLI1vmlNvSilVdTGykqadhTbIca2/pp//miBTCBW7Lpa7ZqqicOjPGfoiTMnNWohqVG4pWnMKX9XifBezbqRWwtHu7+6TNiZPT1kX0/JrMuWIE9Y14C8rZKJd7qh4ytljKikbKK/i3eySriVIJ0k1vLYKIQi2uE7j/Dt16/g/Vn7gVCzDGm7mH2q6BY8DEoVppawT+l30dbfGKwDYqKu/Q8QXo68g4HbuWJsPW39UefVZz0rnQjl887S2GaVpEpZIj1sx83+iaxyqJUAnOudh2qrj7YetK8bsFAeAkvaFMeWn88h1rNA== 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=2C47QT2h4bMPUfGiEQ1EmT7/uBhtsa8B2FgGIJ4qDYI=; b=mGYBobBcMRUIk2viXHomlfi2J0hHrAozHEfT6dJOUFBF1T0Nia+YzXI7zjzoq4OU8erAw/Siw66mM/4wKVAVSc7PunOwET9zjwXLcMFzmXeB9cXil9e4/+CvL2YMVyRCj7M0D2Hg1kpQaV6nqIUfy2vEMbLVRmYzL4/iwNJHKzY= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DS0PR10MB7066.namprd10.prod.outlook.com (2603:10b6:8:140::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Tue, 25 Jun 2024 19:12:14 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:14 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 11/15] mm/mmap: Track start and end of munmap in vma_munmap_struct Date: Tue, 25 Jun 2024 15:11:41 -0400 Message-ID: <20240625191145.3382793-12-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0200.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ad::29) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|DS0PR10MB7066:EE_ X-MS-Office365-Filtering-Correlation-Id: 759bba6a-442a-4ea6-fc50-08dc954ab901 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: 9EcHe8MMTkNSZakHbsxcu+Z5T9D8Niv68ojbfe9B9wibT7cisT/B3akxbWelTCGxYt3ZkTL3byKxpPcA0rW8VWAyiE7+YBfICpnMCToOMYt1dKgKEF6cOWWlQ80pYvKAUHBS/W25mSw6GI7a7RglG3RQTXBYHxuWL2I923Wkyr3LZ1mmE/D9P2Dg1P1DPDoxjawlVJFoRhMAHpATEoFhrTeNlidU+w67m0IHY6kahp63ncp4BcpkBuo0b5MY19ZC3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ra4xCk7i7Oyo5dny748MtYWNTjLDPq1SzA== 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yeYjv6UhBoHNMHCFp9L5I2dKDkYGW5F8q8NpO4XD6Hr/k9XXFBGjHDV/ouB2PqV3WCGzp5JuuuvMr2xcrJnO8mqTZCvLRHpEynQQLvQw30PphEGGXw3lmPcp3CJj44Km76/+vTfiBQFZXWQgWp1A1XUzQI7Mt6WW4k9DrS0eJ9UwSLKGyksd8NYVhuDWFUtyaoJ2yUn+3tSnAWBC2Bv/lVxB1xEJWWRXhVaFWj2heCR+V0EDi78z1XHZJoEK7MAn2Dq71xj6z78QMO8btCfiFSSyCDGZ1qEBe69BCw1jrXeUFmR0XdJR5TWEtvzjKP4yv8e4E7BB4C9p2xUnJPBShEF/Bn9KPx5ZeLIcKIFs+kbw/ddi3M+9Caap5sSWCRrtY5sciffdnmmqY0F4/oiUsKh6h1sXTeHwqjQwvB0twwGZgUMXFPItxOxyvC/JrrIK1Jk/V/yGD33wx81HPrjHIZifl8hwlae4LNu9NTc21iriXgRcwuUlYmh4mhB81LpDJxAfxsNVb+qfRe2X4Lw9dQLL+NJWWAzL0bHu3hzFoPDYciMmUpx493GkA3Xfy+zi7XjCVWXo7qvw27UZnjbJNp5F9QHHK48LP6onOZNML4h63i7hOJxWyEOeCYRc+ZWDsXYdhTkKnd3gQtgZqzuHIHQS4OG/aLeuDrAxJAFOWCqEMybS8bsr3mZveqYPIayowVwBdP3jYimo5nbQcV0VDr0FJlhGkDO/CrYFkb3nP8aVNrzU4q061N1DpEYj4tsawS+ADrwK4PlzWnjrDni0qt7CeA/G/rTJq66KsXps34qu+9cyfSn4JdEty4Ac+P59I4mhpIBK02rmmb3cErhnYZ0+ezQSnD1sjvMSXw5DTjBKjlfVGfJlVbl8tlwKUlMVBLM2fLm9gOr3yME0UquR2jbJ2U0ktjc3OxrIX4zl8JbwxqD3AU5ocMKMxjvYkegJBT0OjUvZJ/5AenEu2qeFhurQtgJv1LjSwrwa97KKs0Fl2tGx72maHJmfMhSg02cnV7VYdnh/99+q8LPaOpalQOyWDFWSyadvquDMlPEKjQl+WsugSDX8MMyqqtneGoWV2F9xE7dPoxcVzEfvGVuz4yis2CXHaoozVtxuqQiDtJbNFdgX6kAa37LsKIhO3dUDRSeDDlVRLIR1j1lmLrjcoWd57nJfTpaHg1JMD1Xj95HP3tqcxM/fA/nm8RU5mGuwYP+EwoU0DiPkaBmuTKAhHcKcRaoZLi1Dwo3Q5RV280aNkLLOEWJEt9kWnGGcWWbJYi7y8W4ZEttSj03NpHMZae5kYsJC3YWx83nqSnnz7o8KNyY6jbBDvOgya9RmUVIaQGwfykpBCW+NxWdDFTthn3gOvYCNwcw1PWCh+u5dwB1595dpXiIkxu4xfVsFp61IearespTSbiE20NbyxebCRHo81uz8FBoKRD543QZjBt3eCY3Jm04MBCZyPgiZXzfMoJxGHKzoc/JONWjF45qd3kCDYHcragCrCYTQg9XIGg5IcD4YqWABGqVWnVot7UN8+J0fmcWl4XYHPbEwhfreJNrZCxgkMxoQQODtNCyYz+K/bcOaohqVtJYRBf3pZUEBhAtRU6SbuFgq+gQORu7HVQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: iR87Gtnr6J8DbyiTfTn5CChZSq692p1Joss7uevJmoQUcYXuYu+OgtYzDQLgHftIG1ncz7maD1cVL3HXKaDjZKleCEceHoxgXg9jB3KKmmOO5vtRFhvIc7nuxXLLpi38HGD/ZaVsDFScE0LM/EsrEtf861/cXA9CTltjWBS9IRqd7UnJjuiaLnGWtICJS91fGDe1d9fr/zN23pvBEAquycRtrfNPIQi4PuE3gZsWbIoFyuLqwk8jwPHxn6LaV2u0fYjfEno7rfmF/O1pn9x1AoD6ZKYZxbzHmcxLFZ8/EVIj2/janG46/sUxwphX9hePKgSowwR3A9WtAke1ZWYLiUACoujPUlJPvNOyIBPu/n22piI/q8VnrNCyYJ+FCtpHIjjqVmwNodzTCrRlCpXZxUadjD3i2QWvsxmJOUQKfGdQlaHI7GfJ1RWMRgSr5/TQaHD3qSScb3mpRjxrZWT4LhhaYAV+knqAlbGl4YyFjZG+JadciZgI/J+M/q/oyu4fKS9NbLx6t+CZtaj3LT4xwL73wK8bgpUP63GWMt9y5CGCofsa8l/Infg+IeMi5BeqRYtbI5VF5KXW2fzb7O+LbXzB0sI36XaapE0hxXbELaI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 759bba6a-442a-4ea6-fc50-08dc954ab901 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:14.4733 (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: LlYM+ZHEVeUfW8yNKNJEn49BFB39K7q4xMpRwawlk79XVEhDeF5HNkaGIMMDKtB/Ygr9dQNpztsLDqejpWFvoA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7066 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: vHLokLqYuztwhig7wlvafLp5p9ScFa0i X-Proofpoint-ORIG-GUID: vHLokLqYuztwhig7wlvafLp5p9ScFa0i X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3608F1A0008 X-Stat-Signature: j5in66cz4eb3cx5bek8i5hs4t7gaif46 X-Rspam-User: X-HE-Tag: 1719342743-308317 X-HE-Meta: U2FsdGVkX18eUvCcxVz4P+3AaF925sRAkVNC9uiBOdCQxvlY4bKWftMCpRxh7V6lMRKViULKog+KyGWerR2+3/dDWmv/o72UHxNjSJ+U7hUuI7l0ChBYdqFUmdserkj+s+mA8zzqq9VzO1KcaT2Iap6ZItEg/stn5px83d/vGTKv+vI8G6J7KvS1J1kKswqnuA27kWjYIMA5VQiVOacgCvkY5uhX5QICMlCPSe0STSehUFpZNX0W+ZRbogVMPzRd1sF8KOqRl2XMZTmt4DVZkImjxiKyq4sH3BlfVSc/1Q8gXfLg1qWv3o66aTwdRIeI6BPAH3L2AnecURNn+p01CAhH4/x5ar9EZ1y/s62WKuz3uz2yN+GcAecnp+dN0lYHD0aNJ4LbAaBu2rjLj/4uor+HrDbbNmsvZOD6kvsuL1+cK/FdLvp4zwKY3rzV8NvrCC4bedjy8Y4/UCW694xKtZlnvbmULtP9IcMX2GSFdGqTmxXF6cpoS4HRtf1SGvEhlARfFlIQmIMMwqo+1DRxWYsnkJha33dq5+vAS/TPahiR4usRTGaTy8AkuPUiAHYRJVyLn4PVv8Xw3KSAUFLO0vLYLJvc0hKiATZ3zB4xZblgRpHVZwXEKTsgyfP5emNyJ8KEZd+ULPCaTXOf5Qz7O8vv8Jqvc2xtumIkjMW941Xc1O4XHRBbkg87RGAmQiFmrL2YoT5JUC/3P/S+lBdtRJkI2TuwiZDF7stJ9+CaTMAc2hYHmbVYNnS69hIFPP8buZXvfKU4Nmr3alo2FmhDv23bZ/WaJ8gEaHTq0NU2EIgqGX+Q0WG/XuYSncMyK+04bwUA/2d91GfHZ6SxiMQ/OckWgBC51MGjmBrnm2z3XyTX6yFxdc9Ryn1m5zZ6DxsJhNSfe+ZwEhmSY7eIUcn3DeVl2PZYZUkzNnQAqEUnsa7GNd0KxaR8bAHb0KmlZX1IAfHpnqPl+eUC4jEpTP/ yJEatNDd x7vs2LvSmPiq0nD9E7oAjL9OUoNy0Up+DfyDhpwiE7z+lv5i9gcfR84xM8w5DnXFQ7j9aJLzjIq66nNSr0m0lpBMICYmnvZNWbmRXeL3fu0IGE3Cw+EdeDix3ZSHyVvuBEgWt5ZKgw3hlW4jZjFrZESANjVPVSEwvDzRknvGn2XhJWB78C8h8OFTakBRaf5/CFKXI1SEFm3Oa2aKpEmjZGoFaRt0yrUIKCur9uOjGvw2IWZVrKpjF51YyoH4mv+/dp3zevKiRd0Psn56nJ/Huocqg9bybfTIu/wtfgnEfzO9EruFV+KSHXp8HM/PjrbhRzFZgeOX9rDud3HWE/ioCiBXLCqHRUs6bcMfGleTp+Qu6LrsQK+5pOLm2HL6MupCsKPYrDME5VuIa4pu8lkyQCoTWcCNP9LavFIluoDcWRBWaJ135/99wPB0NgkVJ8dnk3C5WenUKGusncp9zOfEkBdpboX8VLJR5H6mF 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. Signed-off-by: Liam R. Howlett --- mm/internal.h | 2 ++ mm/mmap.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 90cab15c3b81..b0300cb22353 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1492,6 +1492,8 @@ struct vma_munmap_struct { struct list_head *uf; /* Userfaultfd list_head */ unsigned long start; /* Aligned start addr */ unsigned long end; /* Aligned end addr */ + unsigned long unmap_start; + unsigned long unmap_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 */ diff --git a/mm/mmap.c b/mm/mmap.c index ecf55d32e804..5efcba084e12 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -525,6 +525,8 @@ static inline void init_vma_munmap(struct vma_munmap_struct *vms, vms->vma_count = 0; vms->nr_pages = vms->locked_vm = vms->nr_accounted = 0; vms->exec_vm = vms->stack_vm = vms->data_vm = 0; + vms->unmap_start = FIRST_USER_ADDRESS; + vms->unmap_end = USER_PGTABLES_CEILING; } /* @@ -2409,9 +2411,7 @@ static void unmap_region(struct mm_struct *mm, struct ma_state *mas, update_hiwater_rss(mm); unmap_vmas(&tlb, mas, vma, start, end, tree_end, mm_wr_locked); mas_set(mas, mt_start); - free_pgtables(&tlb, mas, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS, - next ? next->vm_start : USER_PGTABLES_CEILING, - mm_wr_locked); + free_pgtables(&tlb, mas, vma, start, end, mm_wr_locked); tlb_finish_mmu(&tlb); } @@ -2637,7 +2637,8 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, */ 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->unmap_start, vms->unmap_end, vms->vma_count, + !vms->unlock); /* Update high watermark before we lower total_vm */ update_hiwater_vm(mm); /* Stat accounting */ @@ -2699,6 +2700,8 @@ static 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 @@ -2757,6 +2760,8 @@ static 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. */ From patchwork Tue Jun 25 19:11: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: 13711867 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 76CEDC2BBCA for ; Tue, 25 Jun 2024 19:12:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A0BC6B007B; Tue, 25 Jun 2024 15:12:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04D0F6B00C0; Tue, 25 Jun 2024 15:12:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D943E6B00C1; Tue, 25 Jun 2024 15:12: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 B43326B00BF for ; Tue, 25 Jun 2024 15:12:31 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6621F1203D3 for ; Tue, 25 Jun 2024 19:12:31 +0000 (UTC) X-FDA: 82270357302.03.F14940B Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf24.hostedemail.com (Postfix) with ESMTP id EDAA718000D for ; Tue, 25 Jun 2024 19:12:27 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=N30n1JsA; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=T+k4qvWb; spf=pass (imf24.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342740; 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=FLMzwSR29XDWPEQnsWekUcq8E8clYAdUu5IUQ/x0/to=; b=mHo286GKiFiQf7CZjt/ecbdRZyq5vNeCqeTaP88e4AyjbwLH8CmMY2s9IRqrcIYG7c0T8d ODlem+eYsLuCVxUodPi++OAKKaVhTw2vsSMJv8gSdnClIJ0DXuXozi8foz5TBBOeFnl2zF HIAKuva0vqQUP2ACp8RNV/S+MSDWNRM= ARC-Authentication-Results: i=2; imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=N30n1JsA; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=T+k4qvWb; spf=pass (imf24.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342740; a=rsa-sha256; cv=pass; b=eXl2+TkLnkhc2C0JAyn0jJdDkveOLrokeDsy3v6sJYPJMBmi1BdNkmhxRcjwn80/W2i0Hi Ht5G/Vyjm3vVQVxc9CckhBlnPCAbZ5TJx56yvjKx43iM/Po3J9ldSV5g6Zwgb6zxq7nLMF kd+achyL/wv7PsCD3eXsCURyyrQwVpw= Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45PIfWwb021417; Tue, 25 Jun 2024 19:12: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=FLMzwSR29XDWPEQnsWekUcq8E8clYAdUu5IUQ/x0/to=; b= N30n1JsAtjsfzqvZv3QCX+Sew8ns1puamUD4Z2qNSKSqOfR2EwZFq5rkNdMjwCmX ioTLoNfW78VZXCUsS6P8gBO0ypWUB7jGgCvCMAFPmXXISHWW20alq6mnpzw2uuxn ZwjSgrZjZHoUXnxIcddhz31Wzmwv2CXZxSPcZquJKiebuyr+jawkuKbmeSLCoWYQ +gCJesQ/RxinCan8UVx6leFNrS5uAsrt+5j9r6d8ydoQ+3LQMoPNUmI1XgqgdThd qhJsOkqObPYWLiGdEeP0+HZibyaSsF/fNdCNvfQTaUt82C3OhUV5E96bVikQQhdL QRBX54/xOypTgQOR2pHOUw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywpg99avj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:19 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PIUOx7001333; Tue, 25 Jun 2024 19:12:18 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn28rcbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HNv0TkiuWW5STURQAvbbZkmMzeVXtnRGNWuPrkFFM4gUMG5S/iD0jVlG/Z/y6zq9fnNRtKLrUQ+gs7rE86EIbjtU4qdtqoyjQRpUrugMrnuZYUP3kK9oIKjmlQD9lDz1BRg9RMmaM1VmsKTiVtDQctDHvMBHzfw4+PnxEVgldeaY3Z5VYuQwySDF0tp5BgzEPofrzlvKl0ucUTqJbwQK0tAnsTOxs5DXHnN9bPCk8qC3fmyxrH8oS5ESzYSN/y8OOpJkDTHl8/EV1CFsMPr+c8nMgnhxPfEGQsJXIpcpsrnr0KAs+8ru3gsOAthc1hwdQY5DPbfBJznk3WwwVSMIrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=FLMzwSR29XDWPEQnsWekUcq8E8clYAdUu5IUQ/x0/to=; b=OnJtgjRAIU9acT7TdH0ppe6qJ9BMtb3B7hvl195QBntlCVjHhPHg5pbK1nvqycbAR41CBhggcbwXOJASaVSePay9PYQMGyJeHyY/pnrtmNA779C8BqawOP5JL+mO9Ti2zbyTivPsn72Oy98bdlocNgXmQnchQunLyg6X8DaPQEksIP9n6S0W2qmQYXxDtrf23DHZq8tPq34vIygor6OEK9coY/l5QlwkeDOxrM6Kz8SVmlVjynpGFtwSBla4GAkQdYhEIegP3owsNXH5hl90iedp6nzslgV6axKbxUZ8H6fxD6/PIZ4nyetLZF3cjjRS9z9ZYXEF1l15le5WA+CabA== 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=FLMzwSR29XDWPEQnsWekUcq8E8clYAdUu5IUQ/x0/to=; b=T+k4qvWb2e7HJ44dM3wsK7Fqiq114fVGV02rKFcxFvF7r4+Vnr7YYixjVMDzEbBleU6uPKV3d4v7K2Dnf8d9S2LQ5EmyCdkgG0SxI7ULW3R/aKFOrZo780fe3QTB4agHShFdCEovMMFSH7H5VlUJzj9Z7D94UZbQRYEnnzTDuQM= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DS0PR10MB7066.namprd10.prod.outlook.com (2603:10b6:8:140::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Tue, 25 Jun 2024 19:12:16 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:16 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 12/15] mm/mmap: Avoid zeroing vma tree in mmap_region() Date: Tue, 25 Jun 2024 15:11:42 -0400 Message-ID: <20240625191145.3382793-13-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0199.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:ad::23) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|DS0PR10MB7066:EE_ X-MS-Office365-Filtering-Correlation-Id: 83ca0bdf-217c-4db7-4f78-08dc954aba3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: mztLcOeLkbYIIZf65nkyiSuPyUhXJmiOhpQrYKOTfcDdhUPo1VTDEadg7lI2uJAJQ47xMUr9Lrsycj0c/yPxNxuc0PIMz71H+cd/hTP9SDtCWQywY+vftGNk9xc5XhYIaoXWgG9R6zPBUVQoDhtsYrufww57MqfOS0OVnl7LzN7WQr0ddpa7dJWHzbld5PyBsMXkPRSV5Xa5KeVstdby14xhgmaTSU0sksvVnDps2Z5JAS7+ySD88J8y5cALYbNzHSNt2KwF+f72SY5Nw0gAJlHAoNOKR/MG26Gl9Un5fUBD5ZR5sd4Ba2CDk9YZei5PVuzWl4seLcB3yhlg7y+01vn+EIUrQKqo/7QjP2B2LBAp0oncMXYgN2/nMEVp+Q+2MAM60nnj3kgjjih3BP6nEYP6BiogXyetfUS4gglTSxNNc99l47CSISjWNRP4CzWq6WaR2B+iy0gcA0s2r5Jc7AE7d7MdF3uQn3NYhLBaRsaoLXcfEABpp+meyoaWpoQ1X8nP71NoCAbe49kfCOxY1nVPeA/wSZeg26asvZUyevp/RujKcJJ3kXQKqAO1mKQd0xi+mxDaXVEoDKzVhRnmM2RgCVAuDk/3Rz61bNW5GwjDLbgw2YdaS8b2YDcH8BvCAlqjUnmhxFACdna5hUmtnB8xu60NgdoquES0okLCrrVRKlFQ7NZGU2UnCL9WSf9CJ3gyNs+sugUliivG/nOlyahDVwInGpYEbtwfag16m1113WT/fLukVRMkgEYlz4HLBR8L287nuiu+9zPtFRP4SG7THp3nAN+2jJCcGwvtIKwktj7uH25FTo0EJD4Y3SIpS8JmCm4IFbXPoa9QHcs1o0pJbII0DsQu2DUvJ00xTrnGNh5xw21060jwYlX0j5euYDydHeO/dV/07lq6TVU8KSqcuTImVfEqXykloGLQgZJwqPe16/PNhU4RBTP0zBPzJdtZZcfV0MGG9+yvjE8gy5uMMnHn6ZA5bltk3+Bs+I1nVjluzu9F7C09z59e6AcVF/K9N1cd4F2mJcw4ERjE7mIpbQ1eXYtNx6i9AmwWgNUpT+KCnLkAE1B7xFX4Bxv5hXmakTrx51YodPcsl5WU8Sr/0ic+ZwZPuskPmn9rh38oEJuHtAtO78ddoj8dCNPdu0BVwzfwU6zGCznE2XZjp48ddKgAxxTFSOwpVqUf0lPefHqozUVjbYjvkBhgNHNWHomn5pLeruQWHS3ne2iWbjyr7Uyy1OeSfK09T7B8OsYzcrmLY22vgCgq5c2GGByJ08qe84krtNooWUUwtfgZnyTLpuSjteHPANWBzDmYJcSMVweBTywR6URpwTwWGw2FohYE+i2rr4b/aysE+JEojA== 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pHntuzeGr0OwO1l4QqReDOBX0GEFNTYvjEr4JmSeiqRZaGPvmAGUV2G7m3Ra/zXCDQaXMbKZ+OvUTSxsY+xBOXDr7v+zMmN2RX2uBLh+v4XtvW8e2R2YXiKkBs8ZmgLhDlk9L6nlaggSxzk40z5ytl2hbpzrdkmQszvI8XE8TVLMLuJ+vsCB9mC8QBEhiWQqiI1NnKtVjH1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OuERz2XqcNkeFF2hZOAB5fxu7pYXqUzwNBQk+Vplpwj/clfeC5PbEqxgD155Pq/PVXE+LiZ2JaM5BLM/Uf65fNs/72ni4MCrT/sDHs96SSoq0lSnQZvoKUA9dA4eKKkf7tdIRp4RbCcm33SyJsXPVgvDg7P7cI5HDkmwqmq1ZSOxKIL91MUHhbsl62mkY1vCKRNv3t/sonU6/HRtZDb+bZBuPDeD0A+2I03I2Lxz6frDKqSXy6W5zl3YYWMXFHIr0ayvKRvXU8E6hHutySO6fKKXD3sduvi9jCASh07mN2lkPLEmmiOypby2KwZ7oHr7jzQMn8VrCFQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qReHgEFtEWPdZEjALGOHJsTraNNYfpo/ddaVamY8WaGhPKh+zEmmlnXblr3NzVyhhHvubCVy+SZtOwyrBnSH06rXEdCU/iAYQQKJQDh1lRGR0tIeRcBtKgX/s1nv75mNCSt61V2zp153haSSwTNHT04U6hD2O7WfhyusQYS4vAHACFr82YSGZcepmZAhv4bm0fLSnXCX144+ABPVg/Z+vTBqEByL7Lk+fn9n0ixPB9OVszGR7d8RFQD5sigWNQoCRcdvR7oKCAZJ9YyBI1/9gakk29TVS73BiEyCYavj2lqt6xXtvRihYwo3pp1SrGRHJDB8qDHVQubiPONxWtIOCEdpcT48zf1kYxDaniDvVz1bbsbcK7CiOqedL3XuGlqXWFfBwIAOHlKbIdYFEx/C4wbkOIeAYrwjHOpm/h6RV3uCjFLy/X1Unj8wc17AY21/ozQRbdb3AAuMvLnvF88xH2zBV0ZPR78wpO31PS4DARX2wMhSao/cXXjzO4fs9Bry+UDMta+//vW16ZJTnRHwtoDfDV5fKAvF3zVHu3tiY+3ej6fmR/wohYEjbCE6yXoRaVD2guEyLLTytTKND29ZniiZ8IVgaCnDAVjNxE/taPQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83ca0bdf-217c-4db7-4f78-08dc954aba3a X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:16.5089 (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: vH32XTh5Z7R5mZ4lso04p5CVsM6DB3S5YIF8AtOa1QFaXrO2D2NfrT37KrvyOYY0H4yjAX80alNw/XKufD760Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7066 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-ORIG-GUID: _GK6VpiDVsHhyEHGAtwo8rCkUpBH2HzW X-Proofpoint-GUID: _GK6VpiDVsHhyEHGAtwo8rCkUpBH2HzW X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: EDAA718000D X-Stat-Signature: osx6j6pkb5t6x1q8bahrppnarpferrio X-HE-Tag: 1719342747-278311 X-HE-Meta: U2FsdGVkX1/LAVHMH60+H5mubXvCjBcM7rTBLjiwuvfM1I6W6QZXcESWPGUJNr3uLCPxlnGHLE4UzGrMMffsxSLwo/ZU6o2ahoEjY4+hXJ4NXwfvuM4r3a0+uSLVqBgWmUtZBcma3kCwTcO4pgg60bs4g1JcKV5V/EzzLEQ7ex2MLiOWxpczMiGr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vnFPHmmNDhu/vg+fv9HJhiwK8JNJgBp6/KCd4FeNcDigLWzZdQdxq/SIFOAUgS39663kOYFuc+xeL/4bwuRPpZzsAOwBsyWTdZCYc7Ni2EGCM0sqfCbLKpcOkqnHo1tmNvLnqj8tZVKJbphf/zbtXVIa/1b2jN6jSDo3/f2P/6BxLpGb0eolf+cKNJKsGGbD2CS/Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Instead of zeroing the vma tree and then overwriting the area, let the area be overwritten and then clean up the gathered vmas using vms_complete_munmap_vmas(). 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. This is necessary 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(). Signed-off-by: Liam R. Howlett --- mm/internal.h | 1 + mm/mmap.c | 65 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index b0300cb22353..2ad6310059eb 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1502,6 +1502,7 @@ struct vma_munmap_struct { unsigned long stack_vm; unsigned long data_vm; bool unlock; /* Unlock after the munmap */ + bool cleared_ptes; /* If the PTE are cleared already */ }; void __meminit __init_single_page(struct page *page, unsigned long pfn, diff --git a/mm/mmap.c b/mm/mmap.c index 5efcba084e12..b7f47964aaf0 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -406,17 +406,21 @@ anon_vma_interval_tree_post_update_vma(struct vm_area_struct *vma) } static 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; @@ -527,6 +531,7 @@ 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->cleared_ptes = false; } /* @@ -735,7 +740,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: @@ -2631,6 +2635,8 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, if (vms->unlock) mmap_write_downgrade(mm); + if (vms->cleared_ptes) + goto cleared_ptes; /* * We can free page tables without write-locking mmap_lock because VMAs * were isolated before we downgraded mmap_lock. @@ -2639,6 +2645,7 @@ static void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, unmap_region(mm, mas_detach, vms->vma, vms->prev, vms->next, vms->unmap_start, vms->unmap_end, vms->vma_count, !vms->unlock); +cleared_ptes: /* Update high watermark before we lower total_vm */ update_hiwater_vm(mm); /* Stat accounting */ @@ -2927,24 +2934,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; - - /* - * 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; - } + 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, (len >> PAGE_SHIFT) - nr_pages)) + return -ENOMEM; if (unlikely(!can_modify_mm(mm, addr, end))) return -EPERM; @@ -2962,14 +2964,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (vms_gather_munmap_vmas(&vms, &mas_detach)) return -ENOMEM; - if (vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL)) - return -ENOMEM; - - vms_complete_munmap_vmas(&vms, &mas_detach); next = vms.next; prev = vms.prev; vma = NULL; } else { + /* Minimal setup of vms */ + vms.nr_pages = 0; next = vma_next(&vmi); prev = vma_prev(&vmi); if (prev) @@ -2981,8 +2981,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; } @@ -3031,10 +3033,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); @@ -3043,6 +3043,14 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (file) { vma->vm_file = get_file(file); + /* This may map PTE, so ensure there are not existing PTE */ + if (vms.nr_pages) { + mas_set(&mas_detach, 1); + unmap_region(mm, &mas_detach, vms.vma, prev, next, + vms.unmap_start, vms.unmap_end, + vms.vma_count, /*mm_wr_locked = */ true); + vms.cleared_ptes = true; + } error = call_mmap(file, vma); if (error) goto unmap_and_free_vma; @@ -3133,6 +3141,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr, expanded: perf_event_mmap(vma); + if (vms.nr_pages) + 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) || @@ -3181,6 +3192,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, unacct_error: if (charged) vm_unacct_memory(charged); + +abort_munmap: + if (vms.nr_pages) + abort_munmap_vmas(&mas_detach); validate_mm(mm); return error; } From patchwork Tue Jun 25 19:11: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: 13711982 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 43B53C30653 for ; Tue, 25 Jun 2024 20:01:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCCE56B00AF; Tue, 25 Jun 2024 16:01:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7F8B6B00B0; Tue, 25 Jun 2024 16:01:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A836C6B00B1; Tue, 25 Jun 2024 16:01:24 -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 866326B00AF for ; Tue, 25 Jun 2024 16:01:24 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3D6471205A5 for ; Tue, 25 Jun 2024 20:01:24 +0000 (UTC) X-FDA: 82270480488.27.4B3F7C7 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf11.hostedemail.com (Postfix) with ESMTP id B511540021 for ; Tue, 25 Jun 2024 20:01:20 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UpOhjxAW; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UXnLlavu; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; 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 ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719345668; a=rsa-sha256; cv=pass; b=oxbFQP59O5QLZ3WZ+Aaf4rFW36bhJCKV/fLmEf79ezMIk57tlu5jYxWHwPAR3YP5hv4bBM d+r44mTHaK9wKtJYYZiDXuu6sgr0EFSNbEfiQDzhzFQWiIDHw+GdUl06O9JRFKbnsbZyZ1 pNH5Vkz1KH1NhCOMESbY25SYU6Ip0MI= ARC-Authentication-Results: i=2; imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=UpOhjxAW; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UXnLlavu; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=oracle.com; 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 ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719345668; 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=1pO27aodtfvC8X+gLBZpKTNrexrYAjXEivQorvyFbrQ=; b=G9/rgw2fAVYIW6Wax//oe47WirHfhS+qnaR5rag0ig8Yawm2lb6b2B7ZghDElUPC1N0m46 oYYGg9gZYev8B/QbfSdyZbhq9XSTEh9fGs9NnVzTiMm5mF4yZFbUUyiFPMfIf6orZ5tV0q A+KtxsUdDFp0P7g82pONp6Py097/Zas= Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45PIfXbf021444; Tue, 25 Jun 2024 19:12:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=1pO27aodtfvC8X+gLBZpKTNrexrYAjXEivQorvyFbrQ=; b= UpOhjxAW4BbjWLH2YPy77DKK6mw3HwrM6gYp7K5hx98+Lzldd4b6wN4E9eLB0L6v uO+fO0EN74wB7prIL+cXDNOIQDKytRDHoaNgAElQN/HG3y5B0zYeLKtEyDI1Sl+F gzZtC81MbDYruaaUCos9kehrO30Ja4mB6/y+1nbgeXVgKYFwJ0REGURb6+cP0F3K AVg8VpGhcJzqX5WDjlY80RPnbqUHAQcf5q4jKHV/0btfrGDCDzZs7Lptu1m3dY7h 18NW6E7BrYaljIM3vfWoZ/vWpD/2q4XeI7vCuAtLbwL//IU2FcgbrZQxMDsJ1Udy hy32T/n8+jhP5xoq0LRbxQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywpg99avn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:22 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PIWuu7011498; Tue, 25 Jun 2024 19:12:20 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn2egtu9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bI7IsMAlUkALICVZV47uE65hpdNqbJqOWfFOoyvD7BDWrPwH0lb6ldWkZpg9ndq+L+Z0mqR6tjIAOmg77xjHklmOZsFn1DYDZ7VkyOh+tGz+tXc3jGuknyub0AumFRqqAXAeyX7SDnB0jWVL/nbq56erKBh8xCjwrVFc0qLCNLcWTKkMlf5Q31lYfe5aCRaDisQwT1zvk5vqm/xX1EGE8WTpruHnrobG6Z7aISKvZzN9YOXI/+w3LklVdGsbE0DAsiG84K6WJZHvLc9viIdb4AdmvR9SO0zvPt0UTEKbKRi7pgI9dYv73IDzDoYVD8LLaQBCBcUPQL0ia9PDW8HuVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=1pO27aodtfvC8X+gLBZpKTNrexrYAjXEivQorvyFbrQ=; b=OzyPTK8gn0KQyFcLXpzTHmar08TcKQ0AQZJzAjNA1xCejW0k/f1LzdskogxbphqirtLWPptM7hkMiktgX/JdJrl5BrUz+OW3yzFAMb1a8+BkP/ClI1jQoZVYD8Z7ApP9JmVeJOCrzi08SnXMBFOXj4Ty0zAbg3+MIiIGuxfcv89ksoIyYhaKioNZ3z5hQjamkkPsawoKoimYRsxjMy56xpmIxAeQ3xCyeTY4hJACvy/MkQkuvIfCtdrSRcMjQsxWUJMV0ZDXeKyiz8KH3+A1WT9mHlfx7BLpn7ydSz/9afVpv7xzUmEUQ2d71diSyeoS81/emuSoRZ2BX2LacIe42Q== 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=1pO27aodtfvC8X+gLBZpKTNrexrYAjXEivQorvyFbrQ=; b=UXnLlavuGJI6Qz6uxUskuLiVgRKheu9dvuRXVv4uNR4CNVX5Wr+TFhnVNEma30TUUtS5MWhJ2LRLjYRXHy3iEBlvytI4Sn/2Yo0zLsX3ApdxYpO0gVtFbBT6mtfmQYncOcQDTj1YGmGMyc6JR0cVSnLESl1xMIhEkqLcgqs+H2k= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DS0PR10MB7066.namprd10.prod.outlook.com (2603:10b6:8:140::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Tue, 25 Jun 2024 19:12:18 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:18 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 13/15] mm/mmap: Use PHYS_PFN in mmap_region() Date: Tue, 25 Jun 2024 15:11:43 -0400 Message-ID: <20240625191145.3382793-14-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0022.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:86::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_|DS0PR10MB7066:EE_ X-MS-Office365-Filtering-Correlation-Id: 31b9780a-7e65-4eca-787d-08dc954abb88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: Hhu3ERdUxZxhPQbOqNZKcJjZRZFI/3UYyQ1Ym7kR8Y1NfjO3Jy03boiNHht2lCUssHh4jg88udvP2JtjGhgAn7RUMd24HfXRHSpimraal9GKKCnY2nyZpQfjbB2v8ulcb9OE54khW5AwaS8Ic6Q+nk45gzNwmYsrCViSYTcOQqFpDlHGieD/iuFFesZTjWWK+yTPDtRTYmiHNqefubyUmG2kCRhSIRz2yltb3Qwr2XDfAT7hBqxKuFI/0kqOcAvN3vHJo0f/Hk82o7gTSQvSh+Lx30V/ETyqiZsJAhIFoVnn7EroTQVHiQAMPFWioEBWHEbi9cXt9DL2x36dpkEIISWp1Uza6FUQO9rNm51Lmk1NGrkbmF8pbmMlRhY76tRCTG2qHGOZJ0aGEIeyN+ZPHKHgCCwx6pMKru0O0+bziIod1dl9vjRzphP1hX5LDChDJkkMWZpGD2bMLnUMtZz+rfTLYoMZeTD2HKCPXQw5Qxi94zepfhXMr9dY5byAkFheVJqUrUaggHIJg2R4hDvzufGyr81+MrTzmMnVUKrug7zsy3uoO1pcvqRWymQVZa0qmJmzLXsXI13w2X1ZnIiSZYA4n13MP+ymONWK3RS2dK7ixx7ZLHyWiG0pJYnT0CF/D/GpqL8vKvZ+3sVMoZwk6Eff4dECmgHwEwJHlN8ffrgio69udCjcVa/9Y92a8Z+MU4fEaywkKNAMSaK6FGygn+A9n7znRX+SlctiGPL3WlJJDdQYNvmMEQ5KkD4SWkn8h7vMtPHdszvDVBx0pooWl2P/8UymA0GECPvNDd3MlZVmkfKC9rCdxMLd+HsHTS9DPv4leiwZ/CqPaLtYKe/yHKIHlTLsKSIBIIi76QmEVdGTrKuC9BAXngYCT3Tl0BqQHvXNTdVY6wCLWj5aKKUk6ozVRAWWqOC0atVjuf+zN3MHp0dVMq4H8PCi0hXFEg7PiVyVOQ1Mz5CMag1Sc2o+BKqdz0mcFfNwE5FsIqLfiIXGjYj/t6w9trqBpvSO1wLNiQfMS8JgXUZ6LaJ8gI3YWTxU09lFjJ5WVQspZ9FjKqld5bmCXitZI5d8BkBYTNHt8OLf7X4COL2NEcgNpqReKDvFl8ZftqcA3SoZ3xiM2G7jBnVAkfD5dx7O63PBB2KH8NHDpwFRb/iaLCBbvUJL3ZafXKbfAaP73atMP5vTJyyelxgVimvoDadzxyTEJeCInZc2sf8QyF2qy09/Ncojn1ILenzDMabm9KNWP/v/MXFrGqekAD64lNFjBP6h2Xt/CylfkrzqkfePRRS9+P8o5h9PtA99mvCINo6dEa2dEiyQT99HqiS1Styfa2BWg2eUMpjPNXhhI1fV2WZVODCLIg== 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData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O3Bzsk/ZnDZ4h8Ltqjytc68nOCqiHha5Da2YVyWNMAG3BDdL+RR4Y5pnfZlPqOgIq/YZrvDeYi3bd+v+hpBmvt7dBiDNZGo1EAOqf/S2L0P4rkYnTnyANwKUgethaxeeEPoMYyCxFiGlV5PEPE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31b9780a-7e65-4eca-787d-08dc954abb88 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:18.7167 (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: s4UPJssrBMFEdKzpU2KaubEg0Gf49c6duCKRrdG9SPu0wCiztM6gY6v8+zigYZ7BDVqDLgY3TgX55vTH1YzECA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7066 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-ORIG-GUID: eol9UYN4NX4KRhF6moniVmPqXSffVbOv X-Proofpoint-GUID: eol9UYN4NX4KRhF6moniVmPqXSffVbOv X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B511540021 X-Stat-Signature: oamcakpimpboerhkra9xxubd9swibm93 X-Rspam-User: X-HE-Tag: 1719345680-354847 X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sMVIAxZlJWhWINz6bcA16FxWRx2vLZytovs3lhCduvo+6l9etyMxmuDS0eKyyj3u1WvoIZdr5Dc0hp3AxIA95OnDTl0qfL32X9zf87L2nBft7WURA2vvqu/9UZHAFpncQVnt5uKUH/7/QBZJjp/Oz7WtmfqMF11BItHF7/XC2nREG0hVmaxA3ZtZdg0gT+kpw7zbCsaWL/CNR8vbKtgDWRcn5yXtwfoV8NBpO6eYqf8PcIFtzDSH95hUCDHScIdDRqq3NEZmvCfDr0bOnnkjVX00tono5SHqh5jWjTZP/FWscyIuo5SXCPdmPFk1MZ0p9SK0DfRnDVIRo6QPK4HKvqS7sMZYJPxBqHpssdOEGZHlMhnv9jSsRAfagj584jyiD6Qre 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 --- mm/mmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index b7f47964aaf0..f3edabf83975 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2925,7 +2925,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; @@ -2945,7 +2945,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; if (unlikely(!can_modify_mm(mm, addr, end))) @@ -2980,7 +2980,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; @@ -3144,14 +3144,14 @@ unsigned long mmap_region(struct file *file, unsigned long addr, if (vms.nr_pages) vms_complete_munmap_vmas(&vms, &mas_detach); - vm_stat_account(mm, vm_flags, len >> PAGE_SHIFT); + vm_stat_account(mm, vm_flags, pglen); if (vm_flags & VM_LOCKED) { if ((vm_flags & VM_SPECIAL) || vma_is_dax(vma) || is_vm_hugetlb_page(vma) || vma == get_gate_vma(current->mm)) vm_flags_clear(vma, VM_LOCKED_MASK); else - mm->locked_vm += (len >> PAGE_SHIFT); + mm->locked_vm += pglen; } if (file) From patchwork Tue Jun 25 19:11: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: 13711868 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 75C42C30653 for ; Tue, 25 Jun 2024 19:12:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77EC26B00C1; Tue, 25 Jun 2024 15:12:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68DDD6B00C2; Tue, 25 Jun 2024 15:12:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41EBB6B00C3; Tue, 25 Jun 2024 15:12:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1A0D36B00C1 for ; Tue, 25 Jun 2024 15:12:34 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3EC5BA057E for ; Tue, 25 Jun 2024 19:12:33 +0000 (UTC) X-FDA: 82270357386.06.4CAFFA8 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf15.hostedemail.com (Postfix) with ESMTP id DBFCEA001B for ; Tue, 25 Jun 2024 19:12:29 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=dnoxc4zH; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C1dFjlNX; 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=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342741; 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=bcNfRGlmtr+f6hLnJ3M5/LOiANFoVZKsDxZzPTfL0ks=; b=wtft33R8adgIZ3cd085XskjdsgJFsypf7RWqMbsJibe0W9bnCipjgzQEpt6YhAEL8F65S2 v27Xum3lf92jJoF5BKdcpvTh1s0sdHKRaebtkEvJoymUZEpBLB2TN4YxtjqrrMlFDlNJhR PKF1eUCDpuoiWTWjd3yUSNJ4WP1jwAI= ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=dnoxc4zH; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C1dFjlNX; 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=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342741; a=rsa-sha256; cv=pass; b=31t6YAVzegZXPU6Igk3V/5J9OCc2LbLqZ5Lyh+p/4q+IJE1ejuDBroXj/kLF+sn/KBebXB Ojf8WIVjzrZvSsemz5mtL5VXcWHefBWN+fc21meFRFsWVjSnybyHGNT03XoNjhhSySCNPo rac90p/rKEIMB9O5hiuY/CaGmyuO3QE= 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 45PIfWwm028638; Tue, 25 Jun 2024 19:12:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=bcNfRGlmtr+f6hLnJ3M5/LOiANFoVZKsDxZzPTfL0ks=; b= dnoxc4zHcudVBHWNhxkFCR5bG6VebdfJWLJOlMl8HT0RXHxmRkES5Y5B2uNB3FE3 Rey+9xpLwNQm+28ynJ4R2uyoV+ytNQy60SwJC33hxIjpsI/vEol96oCXNd+gyI8Z hQMwmElZSt+By/Ld4PIfYsODc1NsjpEjRDW9jChBXJKiaLrp6Ohgh7X3loMPZ0kR lT17zUn3I6LOb8y+tgJ1INpr3f6dwwYgEWMYDTCAPsqvjEUomIjBtEAMQbdj5pEb ricMYSDWMWUHVbcjDN/Pdsk1gWB7H2NNc+d7DPq71+3zoRhInyc5VcgzEQZFitey D67scj24nKg0NY1Vm3Y10Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywn709j69-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:23 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PJ2DjH023323; Tue, 25 Jun 2024 19:12:22 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn2ehgg8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZT+w5GLUC4jmdp87VWsVBTDL0oLsXEz1AWEyoF2werffQ0A2dxuqZw4KZz/z93SeMsW48gl66Dx+KkOwQA6B7PaWEOPqvEkGCMr0sLKu9wRdmtwAZotwKA8ty4/hqL2eh1EHNGF2/XWFDvGAqNLLL4kAgvY4pL80I0gOlJhGAM8emFCFUFiT4HhlZ1WUEdTwTspVOgfVvdUVi4qpQtOEhkEcHldt99/LJuyWUr61fdTkiEIFJVHMRjJ5XgiOu3miclGrOK6ZlQiRK1B1d7s50xXXUeEzWqoBe2ZpIYizfE7GimKZGSluAb9KkJm7Q3FUMzBDETcr+byf22P0/pA4Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=bcNfRGlmtr+f6hLnJ3M5/LOiANFoVZKsDxZzPTfL0ks=; b=gwfnv86HPGWHCpVlP1Q2J8spL+6+5hgz1/mWBt1U9Fj412NdDZnq+CowH26pAwUjukrGytT6ZaCs9gdz8eX+ffKBSE4L4ePXOX1G7L3QedDmRLrhTJCqpjL/F7/vIxDjpCELqMM8GTrZG3uJng7Lse4egMSfQe7L5GH5p+RK3t1Ute8utW0pkfiagWc7euC1SLIiKf+JJs0/n9YEUq/VL2A+ECicSNU+ZE1GILPBngJ4OE7jTXUYtKHeqCLbixdDVuaDCjWoPC9bj4CLln2sdfVCVbWZyufWpD/OAX7IqNiXj8wH0XLGpgxTj54zaj85FRXfgG1Kz3cUnOpAIvPzoA== 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=bcNfRGlmtr+f6hLnJ3M5/LOiANFoVZKsDxZzPTfL0ks=; b=C1dFjlNXQUalLRsUiJICYvdOqkVRkJ3OvvvroJujp+yLji/VaXKaXQZY6OL0FurfDBiY+iNl/NLbyDBhqADqJoK6FkdmuLKwmrGymtJw/u6Fgn0EiJbWNNkd3O+/799BNNuwyzJ6BA1v656pRCcfjjhkqkXIjWMMRVyLaifR6RE= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DS0PR10MB7066.namprd10.prod.outlook.com (2603:10b6:8:140::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Tue, 25 Jun 2024 19:12: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%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:20 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 14/15] mm/mmap: Use vms accounted pages in mmap_region() Date: Tue, 25 Jun 2024 15:11:44 -0400 Message-ID: <20240625191145.3382793-15-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0247.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10f::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_|DS0PR10MB7066:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d2c065a-2b4a-41b7-32f7-08dc954abca5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: QwBwg5CBpuiKKUBOTNzE4BIM1YgcPTt/iA5kJ0/rHI0zHuEGN4aqFR9hCeH2uOFyzKeLAPsS9yJWfd1egeV8lYcVA6SeIoYGxQSbYKrt690ZKM3iFmNf1xnquS/9hLo+qiu2ZZDz1ythBELxursg0q+WAQfVVqkX7U7ifjn/DWzwqrgwiqokEdR4UBwtzkeiGJ+fA5JDCCJ+MYdLCJU9YgPXBCkLgUgMyU6fTEgogCOMOhiR8Cg2bqsSCy1w9fkF6cZoVbFEcqCKU5JddKoJJCMp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P4rdKisGvGHqIUpNg== 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:(13230038)(366014)(376012)(7416012)(1800799022);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rtVbDsdnyd2AJ+wJDUpG6lUpYvDUI1Y7BHFStNxSgURqIEPY1XQKk37ZaAU5dIwUyvckW9pDdo+83Kfe5DhutDb3uuhuI5UOJNx0UJKM6yLJsPe7MuByVuyqmYj0TY5Rl3/3NYnWucErXdoGKNDmuRepKIZbG5FQLBvLS2WGNNSwhVeWEW0jpeYdbKPHgm3TMk9u3moO7n+1laLor4S1myLy2AKTLKQ+4gEkl7nBKXUOflfoSHeff2NZgYM7wwzCgeAT1DSiD0gWPK0nnTYbzI3pSEBOiXDMSWef7dD9tT4ZBs36gLQVZw7whjKFnWFQQUSCBPPEwULVs/OeDVl7D0UExN4A+B31AHOdBCrX1t1lRdbMSJ4wmi/XCu2/040bLx/rp1P/xQTJbSqJGir4ZaD76BgLq2aJZrsj1e0E0gqmUjREZC7hYcDA0NBGp6VV+qU6J4cPdr/yp8d/Pqr7eEFnDH8haLJf0wiH/qlNo7JZA9KdgEguYQ9AB78NiaK0KRFbyR2GqyU0pM0SyjANeIVHWj7QXiJyA5vFKQWjJ4wJRqc4o9EMzilr3x51Xbrmp037brrni3U/Z4F22a+ETyAYaITeSf23gfvEr3+RR1L21VcSX02aaYH92An1/BOOIsXylOZ2jgLfiGNkDIf2CSCYdGXbkFX8yGN1dmfV/mWAOHpc3DJpsf6vxQhDDOA9LNTMZeOH/U3o4sjdkTHmFjZzaddRoLss2Kh9SZES20pvdKeec+ZxwENNJ93EassBx2tI3sZTyRtRrohG4yej2TmN0aJsXInLTUDrfkF89eAhwKpQpPeC/wHCHpyyU2ZB25cckqD9r4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oGs9ERXvjcvQwLLdcmkBlr5S0QR9fBrcoQu50KuBiaaHx32ixWps/JNq7aNCelzW/vHUcqaWM7sL7kILiUZ98Shq0M8IdlcIrMgUVCJCMRhd3Pc18Bg58RDLAmL0f3Fyhy0L0l9MOQWP7mtRzJEpV0ZqvLAnZk/GB8XrkOOh8kTD8l2Rc+lYf/FNPSd/CbefGLaY3jXUDdWriM4PoYJ2oT3m05yOTcGAKnOfF7HbTNxywIAgQaGn1B0uGnk2ZP2lXjvnkEw3/oDRJlq+5p5cGp1uWCetHMoEWHfwXM0xFyfPwh39ea84TtpGECQSEnUnD+XUorERjlEKp0h1r6zzEydZLcdFNEmu7OfQlcx66mHnvzxwDrCvrOdVKB3tGEmNR4PWeJDH0Awv9aIgbiEN9D4j8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d2c065a-2b4a-41b7-32f7-08dc954abca5 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:20.5828 (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: oueB3we2m3KyNEp3ab7TkLBKT4ADGKcWIUTfv8aw6nwTNlGwebJvqSR3/l+I6QN2arilIz9QjkHTdbxiiUfhyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7066 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-ORIG-GUID: lLNtQOmyY7pePJyxxQzDEaY02vMZxRVE X-Proofpoint-GUID: lLNtQOmyY7pePJyxxQzDEaY02vMZxRVE X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: DBFCEA001B X-Stat-Signature: wst9wbkkzpfge6teupnoi96sr6huqoya X-Rspam-User: X-HE-Tag: 1719342749-486611 X-HE-Meta: U2FsdGVkX1/t5SQx5Kdum3Zaj4iwCmxJiVypsl3yRUKFxpRC4NhY77znqjjYZusQgt5zwIiE9MpQSUgveCBOUd8wz4d4gUci2LIngDm2jhqYee7m71JJzaoj4u5vNx9wxVBWqj5Vyr7LRbOnCjqXjx6uKzGrA/35kgHUJg6WeuLIfECQU3oNqEVmpabjV8elfijb9U2quQay98JJeyZ7tY+EKOUZzdN2Z4DYgdqW1Yq67sraq5eWX4CUDmEo60FSVmFH+pwzwyvHlAGv0sp5mnorNvDlAuhDPku1VKik7u2WmNorgB2/DWBp26+i4wM96T1FoTtnEuboLfnotPnOa/WiNQ+hUF4moEa748BxEafcR7bBpl0hkaEdDmlQ0AqbUDY0HXKclzeCWTudCpeWunBKy4HCwi7/6EbgcgL/lYycRgHNI4tSXCHWdzFoj+O1iFbyVWsIAdu1eZQWwzB77gJ1trICAK6uBDyOpkDN5qwHMjlwAwBuZ1E76n5QGs3GCUQUhJ7O51pRY8D8/lRgnm1CCom2JJ0OJhSmb4Tp/kld+HkxY6a68oKmTBZJsVliOr07Pkt/EHKThxKuVBm+VLID+64KyYykFVnRcGxNPCL4nPltzEKLaIdzrnC3nryZ3PCjT6IQUGGcvK1ytonEZ48e8BNlMv9pzwruu1HU28FvJcez5QFQAmCwgllFT2zZh+NwwmkqaiXje5rYcSFMIaSpKsxHIgVoxOPtWL+5zXdSkwuBScjCp5v8UB/DCWa1llv22iuh8NUnn/qTgP6rmfKXfb6Li2/hcoJc3NRS4wqru4MfhHo2ybEE46x0moXB4LN37bpCNU37S4F6pHUx7jiE72UmGhv+Jv5UzivNNWZYTCocJOCQDTRYCDqfsodUl/UzHHKgBoCKiE9ncLAS9hhBCRT6+2p7XNshvDI53bGxwZZURK9H3+x5MHZ95xH69L28GO+YTg7aE2oICG0 OYexZSMW VovdFOj1wma58TUj4iUDjaVaajLrCBMYfcLLcc8XvWAhAZu1eOPKW+0lN9RzxLj3vT8V0ueMMQI7zzebCbJujQP5kMxe9cyVBf2kWNv8HQ6SGQQuOjnG2wR9MrIAC1Cl733yf02WCFO2w3rR/v2tDburD9sB9Odj3FOvXvEs/GLYqjJAmrXD8ffLIjWjJ7SvYxZoF9eNPg+/yZseXcUjSswC7pM5BJ+GWujt4hZ1m6BL/hgUf57CBsG2b+9j+jbBXP4VQvFsD3Zf2H4G4CdIx1AzetAGM1oDEslhVvxvE/q6uUCgpph1K17nRB4Ybn6r2zpU9pgkY7tJL37za2OU39QLE9SRZAF0NTER0LJAWrU+nUtCnoZxW09CzNKX9zOsMATsXQI69vlPvKhq2TDgR93LSPafGqEIkZ3SLeqIbs4JnkcklqdsxLb26TWhigVu03D3FIMJWyyuRJF1qGU/9ranZ5VrS2+KyCXgj5iqJgaImey8Io6b44FV4GDROWF5KOLmySFOg0EuW1xE0shtxY8O9Rw== 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 Reviewed-by: Kees Cook --- mm/mmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index f3edabf83975..adb0bb5ea344 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2970,6 +2970,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, } else { /* Minimal setup of vms */ vms.nr_pages = 0; + vms.nr_accounted = 0; next = vma_next(&vmi); prev = vma_prev(&vmi); if (prev) @@ -2981,9 +2982,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, */ if (accountable_mapping(file, vm_flags)) { charged = pglen; - charged -= nr_accounted; - if (security_vm_enough_memory_mm(mm, charged)) + charged -= vms.nr_accounted; + if (charged && security_vm_enough_memory_mm(mm, charged)) goto abort_munmap; + vms.nr_accounted = 0; vm_flags |= VM_ACCOUNT; } From patchwork Tue Jun 25 19:11: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: 13711869 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 31717C2BBCA for ; Tue, 25 Jun 2024 19:12:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1D996B00C3; Tue, 25 Jun 2024 15:12:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA4F66B00C4; Tue, 25 Jun 2024 15:12:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5BB06B00C5; Tue, 25 Jun 2024 15:12:36 -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 A5F346B00C3 for ; Tue, 25 Jun 2024 15:12:36 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5D9E1805C8 for ; Tue, 25 Jun 2024 19:12:36 +0000 (UTC) X-FDA: 82270357512.05.5619139 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 1C070140011 for ; Tue, 25 Jun 2024 19:12:32 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=DvEmCSX2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=QBTG9ZjO; 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; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719342733; 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=tWeNqUha8Up1eRkUEoS52yWD3cYBN+Ju2CdS1+VKDw8=; b=3ct1c+6KTJ+VHUlKgfwKfDikRe2LhPFtWotPMjGlrDfFClUnhE7T3EtzbL+z4zg4lEGy0H lyLz6toKX+PAtmYFuMXpzDbPSwjBhds0lad9RNZw917S/pNNO3y3gv6yy/EnVpLLNCewVu qlg4ItelxzCEZ5er1tqblHOeonLJSII= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=DvEmCSX2; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=QBTG9ZjO; 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; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719342733; a=rsa-sha256; cv=pass; b=yJ/IMsPb2jRmJ4xnvFP/UlYVwqy/P86pAvplxetNKlv8ZV3URrO0fvt3/2fQoTY4lNZIFv 5aMTePg7DUiPdCss437wZa7zi1Ho2HQMBDVbqWUGpFCIbWzirdRIe2P64wr8aQSPa0FL43 397cuxy4n89D8TGJwo5twDZ3DPLYnEE= 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 45PIfXVb007432; Tue, 25 Jun 2024 19:12:25 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=tWeNqUha8Up1eRkUEoS52yWD3cYBN+Ju2CdS1+VKDw8=; b= DvEmCSX24jkVGARy83WJTc7JA9ZcLb8J/LeMuXpC3jwBolKzsSzcNADlXICDVdXa E/PL3gTSmizEVXPGHTULtwnpLGkUppWyOVemLJbGQm+o3SqT7YCztUWnhcZKR67W Rq3kQX6q2jy0fRDfDqKP0lTa6vbAZasIctgpg7Y1zrZ1cf2FO3axdBULSThbf5HS UBgE28Zt8FjS2DN2ZM+mXv9lKnQOl/f6q43mIkkbVy/v5yV0jTwJyvZNA0Itnzya B5nTYsDXfOMMnfyFtrWMAuZmuwd9/XTGNoT+VfJ8n2xHiNH8FoEhtABHXIXh/F4r HSuz8Yg+TgNVPY1umadwPw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ywn1d1dns-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:25 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45PHqkok037140; Tue, 25 Jun 2024 19:12:24 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ywn28fjkn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jun 2024 19:12:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wc0lJZN/7AFEqZf22cYf4g95io0rEdUr/Glfy+1j0BFOIyieEDfXIVnJqcUCJJeT+5Q+58cHgXPEv0Ni+lKwHWloF31UjDCttSwXIpVFbf0Eu9c1H2mP8YAJeE2XecS60Ku+SivFE0z0rsPd9U139p0SQbBx8mgeS6pi3SWQd/Utgbai+Z2xCZsB8KY2/VQDf2i83/oRp2igoJ1Zfog9MIqBGk0rUfJAuly1EOr/YGsj3kiz+ub3PGKLlk3qnFs0TbSkI4JowOuzj8GQ1lq2mbuhLGK+VCQzXKpopuwuLyiFY8aHqgYr4eG1ivXI442pllfkw/b5a+vYZXfdjNqVmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=tWeNqUha8Up1eRkUEoS52yWD3cYBN+Ju2CdS1+VKDw8=; b=ns+PI7k7E/4P7d7B2STABjDWdLUOLM3OVfs/o4KDcg8vfXpY90nPoPDKDTB77esdXc9iFX8PLvBn93zs3TnYDImMdeRBWsrYb2pV7mOjemrpKuq4Qan9Kv9222V4GEWh4Vl7gzVYn4zUl6C5+rmDstBRBRFMUkiBgHj/Kbfu1X6k/fa7uAcuw6HVn8sJ2DdtVARvpYnOiAgmGCKWhjHlkjsJqplGXMwgjUPKk3JniePXiD1Ipg7Gx+CvssvncL0nzWXOqCt+3l3pxYqDqQaOHsLJe9qXctRRLZSbGXC/KJDh6TB+++3MhwrXF0PErzLvfGLenc9raAgZGD0ygUPmvg== 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=tWeNqUha8Up1eRkUEoS52yWD3cYBN+Ju2CdS1+VKDw8=; b=QBTG9ZjOdby1WbkPHMGP9oZ2C1IZWd/TvjRyDWjhFjvyrEilEjQSH4d/npWMo2KaJmdBc8VZXjG8xNttg5BojHwOsk7dimh+YxgAh4z3hcdS5m5633NIQGbcXRqDSh92GjEmVAzL0FxrrTsQ64qjkPk/mTf3S1ECpAfFqV5dVP4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by DS0PR10MB7066.namprd10.prod.outlook.com (2603:10b6:8:140::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Tue, 25 Jun 2024 19:12:22 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 19:12:22 +0000 From: "Liam R. Howlett" To: linux-mm@kvack.org, Andrew Morton Cc: Suren Baghdasaryan , Vlastimil Babka , Lorenzo Stoakes , Matthew Wilcox , sidhartha.kumar@oracle.com, "Paul E . McKenney" , Bert Karwatzki , Jiri Olsa , linux-kernel@vger.kernel.org, Kees Cook , "Liam R. Howlett" Subject: [PATCH v2 15/15] mm/mmap: Move may_expand_vm() check in mmap_region() Date: Tue, 25 Jun 2024 15:11:45 -0400 Message-ID: <20240625191145.3382793-16-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625191145.3382793-1-Liam.Howlett@oracle.com> References: <20240625191145.3382793-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YTBP288CA0026.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:14::39) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|DS0PR10MB7066:EE_ X-MS-Office365-Filtering-Correlation-Id: a91fc411-bbc1-4898-dc5b-08dc954abdbe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|366014|376012|7416012|1800799022; X-Microsoft-Antispam-Message-Info: VLVtHGEQgkKPvHDM/8+NyPH8klJ4AtcPZbwKPn4qFlAszdhakyqBcEmCV9eGlKph+vDjNAR3tu44kIBzy41WSgzaI2erEWJjt2T3dlfOuQ0TTNVZ0dZL3cffpkar3eaU5V3Z8YRhEhBtNpc1E+d+IDwQpkmmz3P9EJ3wVdkV0kvSUrk3PFbwpRbCf3SK8l7sKG/wiExs3DBx9JvdlfigdacBiqzVg34U/p8gKrNeJ/cWY3VVhqMGc1h45vp9PiyYbJnr/M0qgtjfDUs7nrijLX0JmzCnyEja3EDVHI7lXUmlWw7q4Dwb3hL4ZOkXKeshfVZogK+ihlmD/RGFVxPJMijl3u/uTZDmxB78NxtsQ4Knr8zRRGhBFF+Nivgef5Jo5lUP5RMbqUGSF1Y+UN2y+tstYWtVjOnOqRq+FU08jY+xyf9n3nQagz22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O8huqDpG15aQH+rGar2nV+cZ6bVQq0oR5LEtyFS0op1iV4zEP4n8LwAVZEXzFooDI0/E46PmlIuijZ9s71I4ebCO9f3LSdpAOOo+mbw2Tfah56t6PPw7lm743letgmZR8v5PRUesXXbf/QPtjNtZpU+FlmiVCvDX/985leP2Tvwf6K7JBQwY1XNkriF3VSd0CG/2ltFSqBBMH+cEqFbkPRrb9XBb4A/zspzBkK+vImpuyA2I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a91fc411-bbc1-4898-dc5b-08dc954abdbe X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 19:12:22.4219 (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: 10/Ru7xxAP+NFp3SpwHoYAjTWI37cvxhKrczjU4HAQCHVgHYxrJoU2yxqr8ns4X6KzhilkIGOPK8BpOBLnQAhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7066 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-06-25_14,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2406250141 X-Proofpoint-GUID: YkfakiUomWIeKsJ98R73bpq7pu2zfHLO X-Proofpoint-ORIG-GUID: YkfakiUomWIeKsJ98R73bpq7pu2zfHLO X-Rspamd-Server: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7aiJyLKJ hKaaGuIJT//0UcAsuE/sneB2Z/pV+XrvdbQrIpgo4AlrGw6C9wOR/YlfozycL5g5qZgoWZU5L3mi3YZaWr+St/jGUCFSwp0pSaNv9aU926+OzXvqr+Qwnkl/uJdlZzFb0+asOipCyUc+YXgoRItMAwpIQZMhlFvjjqdG2ac8O7g//3HT/JXcDgYTEsH/ap3dfob9grB+ktq0YjI696I/p7yMETx07n9SAclZtgfXz5SFgKzQraMS3GAAtIITy7dAWLlVUzed7HXV9NNtHoz2LTXJm52LItKYmbvcBesBFDIaFieyVGQiRBdFp+vo7Ys6Bl9jZweJLrth12aA7KVZHRL5Bnrw0e8jB+pGFxQFa64ov0dqnmnITZ6rdMu1o6pgYvJTfJg0vw8rgsm7Clz7mRv4kcW2XoxWkXDoByOqjZOZmaskpw5HekJXz2BsNYYWa92mW2LWch1T9UR4fYGNDWo+h1A== 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 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 --- mm/mmap.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index adb0bb5ea344..a310b05a01c2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -405,27 +405,6 @@ anon_vma_interval_tree_post_update_vma(struct vm_area_struct *vma) anon_vma_interval_tree_insert(avc, &avc->anon_vma->rb_root); } -static 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 void __vma_link_file(struct vm_area_struct *vma, struct address_space *mapping) { @@ -2936,17 +2915,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; if (unlikely(!can_modify_mm(mm, addr, end))) return -EPERM; @@ -2977,6 +2945,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 */