From patchwork Tue Aug 20 23:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13770670 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B47A4C3DA4A for ; Tue, 20 Aug 2024 23:58:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 917D66B009F; Tue, 20 Aug 2024 19:58:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89F526B00A0; Tue, 20 Aug 2024 19:58:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6583C6B00A2; Tue, 20 Aug 2024 19:58:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 31EED6B009F for ; Tue, 20 Aug 2024 19:58:20 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DFB72A074E for ; Tue, 20 Aug 2024 23:58:19 +0000 (UTC) X-FDA: 82474290318.14.E9D5B35 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf19.hostedemail.com (Postfix) with ESMTP id 94B691A0004 for ; Tue, 20 Aug 2024 23:58:16 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=kpc1Fwnc; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=sTu1qh0+; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf19.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724198208; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/kF+vqo7I9bVt8ivw+hZvg/8Iz+49RUF+0LtjGzT6d8=; b=ezxoHW7AaIgKIde48hjzxXogTbUl2YjsTLhz1q5rAavw2sRX+tOprN3j04WwxBSEMfDH7Z 0OgsiB3rLRez13TfuWAITPgsHpAW7QXtKSDE7P+Hj5rV9IlNQ7cUa7Aw1wT7Un3HXrnjim S3CMJ36WKo1m4x1a6/Xk+H3rIGptnwY= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724198208; a=rsa-sha256; cv=pass; b=IdJ8phHPl0Nv/ibbHmirhx7tzhUS9n0YkOQw2/K+hHbtN1gRq/yfhPfFX0GMOrGIJQWCLs HsensnZUbY3PVcgpBela9qsK3f4SL2ToqnBR42Gmu7o6dmwOAlEec+nDejqvY69qRDiW4G WXmHLiIE+AB9YWDIvFB/pypXGJGgSJY= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=kpc1Fwnc; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=sTu1qh0+; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf19.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47KMBm9f020641; Tue, 20 Aug 2024 23:58:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=/kF+vqo7I9bVt8ivw+hZvg/8Iz+49RUF+0LtjGzT6d8=; b= kpc1FwnczDzqhF4J6n6TiMHzJ0Lt8tAg0s7K634Pr7ugX3JO3dB+kcYd7Gg3D6Gr UoZXumdh91wJxd0BUtpWjAfsHgXSQfXzacPatPp0b4N9MhsFXk9R03XoKKAOtehN jY6L4OVIeyocAZiJwre2EDXzjgUutqswLuNxMEZKWhqpHvVezB7Q6v4iX5uJFqDW +T/sxxPSfe8Vg5dor0nAU8swTfYAevUD3Axlpu0vq1OGqJN9gAP53UKI9hpEQb7u 3rYda5gthuMZm+P5r2azQSmjvwE3srTKGQfW8BpOk2Q1V7dTFibs4/fyx31vGiLl gYczfq0DDPVkRgxjFp5z8w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m6ged20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:10 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47KMiKu0036831; Tue, 20 Aug 2024 23:58:09 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41546yhqxp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2024 23:58:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b72HiDp+DfnHL9hwBnlvz3961VkD38hrAkmHBo37WRiSsGaC38RB5M3FO8WnSp5SQ8pjjQMcQ1mtxpRpQv4+YYLhe+Ub6F/yG3UgSgO0XnsXJaLUpo5OaJ7h1F+Vn541FVkORnBv1x06d6VU0pIv/P6NxkyBtPylWe7+T/2abY/2IMJrTroi1zlEjWZg+v9QyNW61m2++8oWtd9VM3QbmjAyJZ7KoQI0zGxGbu+Vk9ogFp2o5n312WeY08ElyhL3PUYQRESnD5vTQXR9iQQmfA60JArdAlqkbHolM7cAyzXaARuIlfvkGDXNaLOVkDm9Xzhf8T4FFfYX4CO2guzJUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/kF+vqo7I9bVt8ivw+hZvg/8Iz+49RUF+0LtjGzT6d8=; b=Q1jBZwGGcocFcDENxio01LOnf8A3BdZ8/4J5pRItH2bbAdbL/soStKHh2FCEBRe2OXYCIgKs58PXwjg9+HMKeimpTbUrCg1zVWAlwzRM51ivuvxj6lHWz8D7mfSn7Wyybs1idLw27+tTAsCkmWVACcCq/7D4HR3PJGIAt6xE9KahNqi3uRsRCiArVdZarUVYxcG2fGP2heO2J/FOLSW0BILWcvO/svBslFNB3FMDDaaBIrpfiBSkCei71FBI52Jc59uasT/wpXHFxWs3Hz2qwSj9oyEWEIvfSiZYhkCK4HrJBk0wj7fZb2NNsFuTHdtBI/qITo4XchdBo9J7fnB1sA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/kF+vqo7I9bVt8ivw+hZvg/8Iz+49RUF+0LtjGzT6d8=; b=sTu1qh0+aJ/DhNMdCqH23sxz+XAotidlw9LBUqaZCTQ3cpD0WCCBjyhDmgnpFdNNGiK4Aidyg7LqpHHhOU8hxInIFPI0HojxZgfctCrPxNXwv+MfYfXpLR0UPUYjNmlbomHFgzOvzB3Px/5ebX09+77nkMnQumuOqBM97PsP7iU= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by PH0PR10MB7099.namprd10.prod.outlook.com (2603:10b6:510:26d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.13; Tue, 20 Aug 2024 23:58:07 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.010; Tue, 20 Aug 2024 23:58:07 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" Subject: [PATCH v6 11/20] mm/mmap: Reposition vma iterator in mmap_region() Date: Tue, 20 Aug 2024 19:57:20 -0400 Message-ID: <20240820235730.2852400-12-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240820235730.2852400-1-Liam.Howlett@oracle.com> References: <20240820235730.2852400-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT4PR01CA0391.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:108::9) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|PH0PR10MB7099:EE_ X-MS-Office365-Filtering-Correlation-Id: cb6ba69e-b179-4660-135d-08dcc173f01d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: ZDwf26jTixkqPxA287NL3hWqipzMnnaXtFzOydyBFP2k+VYW3jjdrlQOK4RGGWyw9yhRgERqcRo6cp5Qv/thpbSCRh/nlrSjsibCY7kJcmeZztJVX86YhxQXnAbGtSkxiNjqYW/+21bkQCb1fG8cFPQ6UsXd/N7A9Ak3M9VeuKGh61ZOJE652vFg5HF7thw2LYYoUXmYhPiUoEJJWZeS6PwsDjPkcWAiUH/6zocnJV7vN7Zp/HggXF3oKWD0bcfbbH/6i33FEW+l2HMiiqwuxttiUZI+wkELWFPoS2D4McbwGYMIMZ+FLcrz/SrLDL/ces32L7NbqyeEQSEQ3YSVxuDz+iuRNJeWGHaHJJz4rr7revhLzGScpwwalooRogGeHCUBwGC0aKXMSb2V41Y3JuM50biiJghfggCklaG4X6g461MLb8XtxsU3SY+9fPZ+6OqrV+K2ALVkZVls7ZFfCy4g7zwH9ZmjV/Icy6Y8H35dHZ1Qw97w7tPyX1Y/k+9c9QumrNLtOzUQMj+rdpMCtkF9bwbTgWNvcpF8AaiJmwj2z/rsJSKvb5G6OBkhKsACc+uA9UHgS9F3AlprKH74wMlUGW6Z//jm+r99eHZwwj2msmcTV7qf2jXPAkUuPrGaIg/ZMR5T1DXGO6oXnf4ZCjAWVOOgdEUxgC9gEqDa8gaGNN1uFaaNJtF/m9UBVLlUE2+Ajq/8I6MvlyIzXdDLPUVFcZImcwEpoMZM466QRBQCtjatm9ZF6+c2LHAx0r7otEE2jhJHXpif0RadKy3N7t2GfyTWqeQSEpUT09Lzbrp5lJLTgHsSPb1wq4fRFoGnD2p5GoI177cwnKXPZVUTOc0x9jyyNCd4bwDDVIn7UMDWNbKZ4l6rBBUnFQl6RiAE4Zj7OdEwRazAjkrEQrF+Ix8imMKF+1RmVor+5fMbwtVKgQY7RQT5lthcX436pokirdHnwGWSLYP7buhWwBCsc0PTH4YfQ5PT9D9R4LRKYYgX/hfuhKS3xuUI9pFWyfAWhc8oBBMFUxsDSm9SAgCtaJBKiGPiZZ6p399dLoDf97pARyZo5KwwUWFCkKeVSq++olDobehyGEgrRLqxG1YFlflx4WGl9wWgXpQuffOXx1XYOQP7h73TTPvX+4viHnzlQUTCXEmaWULXtUfR06bU0Q4igx99+8DKF4GE4PSrfNLp7TA1XmwYvYBAPNqHXf+oEYMV+NjEwOIQBJRKbZiz5lMvO65hH1WgxYUk1vOkEmaltgKuiwo6UQO46hOd7uMptwQ1XPhbOKLY8EOLjGDQj4ZE55alFb+tKZYUydJL4zQN/i7DuhguA6sp8+hUMe3wp83ORs6Mna1aS4YjGQHXig== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1y3Ur1rnxkryp/XCIHbrAleVjIBy+0n7ODM1lxXnomMLHCLCse4WD4IyUFhPso0Olefm/CtBzGaigp3+c0t4l/6iYP9d5vhqFhMtySWldTQX/LS70+1k3z+VsFWlCRjjQLm8i0bza/y3M2C4yoP70dUuiLx7MM04AI7SU8oUlY7cXP03iBwHd5eNvORLpxwi76x5RsOMpV8Leunfc7lSx2Bk3mJm2+y495K2wbReTnLAzVMcm8GSutlZaWF6w8xITC2eBjViIE/wWaSggxj4CQ8Wq6lPP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AwBaGY3EjAOSuMnEvuAFowy2QQELZ5u+EqvcWsmMAV3N8QYg8vCswYPu8SqTOe0Mpw/dvLVY05k7khj2AE3OoO4E8ClZghQB4awPmMZEUHbrqd49EhmoGMZ5I9NGWjFz13ySNCapvvKMr8of+8i5oDmXYmE6Vj24UH58tXKdv1Ik3L0d7sQLHNiovzctqFp3QPNBHFEBHmGpb9mZbMDDfri8pv/nl8laSZxgNdIgyRWHQsM6KbIGYsDZLEvbVYpLYwdG3ivQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: gAzegGg5AF/C3W/oAHHm5NtD1wS7RojqclYuFIBc6ERl4sXEPabtZsOmazpW09orRzlfwSLlutEPqZszmZoYdbl5fmv7KG/+Lxf25x3zqb9T1hXvlV/mu9bXtann+e+upaFG5Ikby2EWnZYL2qfJqeh4dQ/xyeHHGxu4QSawlr05/B0uHCITGyseia7w7QIhY8tzuFlXB4r1Q1pre6Ud7/rrGQSiFhIv6KCZPXlTXuuV+lMesZJ6+SCuGzga6ch1hpiggVtMnSrQvqarA0NcBK+g0/D1Y9/D0FK5a+wR5M2E7ye52qG4i+zUkrQZD6vYWNMQccMQ28Ki5rI7CPE6VZM9QrJrBWIhLcNodmvNCWdyW+RZw0bIWuK2X+IRRZhJfnGzMlSbQwJUF/mmFWq++SC+A80bEhbTg+BS25fmYm6cbvkt35RpDdDkprPJCLRiUwuUz2PzQwgIS53m8wfWqAIO+6IiuLzInf4Am0k96TrEHBofw5uwnpEwnzJMDOZvKn+OWdzhz0iU9Wq+i4v376iRGOGOp/a41uw40CuOF0TvaxfevBQLthUd52HFYN9dbadPWNOSUPtDoIQd9BPnuSpJoV58qTxZbqmq1kuHuEM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb6ba69e-b179-4660-135d-08dcc173f01d X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 23:58:07.4763 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 44TB+bCAWQBSmm4aeAodMKm7HEfJ3aY4EUNirjI9gV+Ilv09jCMpwG/Oi/ZqYdPgVcAeCxlG0z1xpH7zK567Hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7099 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_18,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408200176 X-Proofpoint-ORIG-GUID: MORbhZ9uJsX2wbPTYmwHqrh0LQ6K_kjC X-Proofpoint-GUID: MORbhZ9uJsX2wbPTYmwHqrh0LQ6K_kjC X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 94B691A0004 X-Stat-Signature: buhmfxdn5yn9mzji4e1dy76o4e9gapws X-Rspam-User: X-HE-Tag: 1724198296-155562 X-HE-Meta: U2FsdGVkX195wAVDaSWfCuuO9wZMvGFDTw9KyNka/mY4orp9U2aIoKPnAEOOrcIUaCfUTK3RwMD2oMT08h9kHQIICZUZ+yQ7qmf0AIwj6nOg3pGMoBeCFZYXpZI0lKwo9LWjDUQtQWf8wbTRDLDwVo/gEI/X3zaVPFltALVxMMBNl0XdQCeo/8ySZrQ0eVvSwqcUK0oyEdUeJbK1pJQNgmiSkgX491mwBt9VRKHqMYrHnOB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r8bJYYYEyqT6uYXnAI2AVKFxhdABj2uMFta6gg+RyPMy0J0mSgmGT8UufyJxfIuKisLaV4pHJd91+MWJ+rckODqqwpS/vxO/RP7hhwDl7/iS00XZ/RssLhqEyclj/Tb2X/KGm8LGFfffHqYi7wOsBlm7EWVp4Ku2X0SlhwxLGkZyn3H3YNgKzX3ecOyUNwbtw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Instead of moving (or leaving) the vma iterator pointing at the previous vma, leave it pointing at the insert location. Pointing the vma iterator at the insert location allows for a cleaner walk of the vma tree for MAP_FIXED and the no expansion cases. The vma_prev() call in the case of merging the previous vma is equivalent to vma_iter_prev_range(), since the vma iterator will be pointing to the location just before the previous vma. This change needs to export abort_munmap_vmas() from mm/vma. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 38 ++++++++++++++++++++++---------------- mm/vma.c | 16 ---------------- mm/vma.h | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 2b7445a002dc..9285bdf14c4f 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1400,21 +1400,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr, mas_init(&mas_detach, &mt_detach, /* addr = */ 0); /* Prepare to unmap any existing mapping in the area */ if (vms_gather_munmap_vmas(&vms, &mas_detach)) - return -ENOMEM; + goto gather_failed; /* Remove any existing mappings from the vma tree */ if (vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL)) - return -ENOMEM; + goto clear_tree_failed; /* Unmap any existing mapping in the area */ vms_complete_munmap_vmas(&vms, &mas_detach); next = vms.next; prev = vms.prev; - vma_prev(&vmi); vma = NULL; } else { next = vma_next(&vmi); prev = vma_prev(&vmi); + if (prev) + vma_iter_next_range(&vmi); } /* @@ -1427,11 +1428,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_flags |= VM_ACCOUNT; } - if (vm_flags & VM_SPECIAL) { - if (prev) - vma_iter_next_range(&vmi); + if (vm_flags & VM_SPECIAL) goto cannot_expand; - } /* Attempt to expand an old mapping */ /* Check next */ @@ -1452,19 +1450,21 @@ unsigned long mmap_region(struct file *file, unsigned long addr, merge_start = prev->vm_start; vma = prev; vm_pgoff = prev->vm_pgoff; - } else if (prev) { - vma_iter_next_range(&vmi); + vma_prev(&vmi); /* Equivalent to going to the previous range */ } - /* Actually expand, if possible */ - if (vma && - !vma_expand(&vmi, vma, merge_start, merge_end, vm_pgoff, next)) { - khugepaged_enter_vma(vma, vm_flags); - goto expanded; + if (vma) { + /* Actually expand, if possible */ + if (!vma_expand(&vmi, vma, merge_start, merge_end, vm_pgoff, next)) { + khugepaged_enter_vma(vma, vm_flags); + goto expanded; + } + + /* If the expand fails, then reposition the vma iterator */ + if (unlikely(vma == prev)) + vma_iter_set(&vmi, addr); } - if (vma == prev) - vma_iter_set(&vmi, addr); cannot_expand: /* @@ -1625,6 +1625,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_unacct_memory(charged); validate_mm(mm); return error; + +clear_tree_failed: + abort_munmap_vmas(&mas_detach); +gather_failed: + validate_mm(mm); + return -ENOMEM; } static int __vm_munmap(unsigned long start, size_t len, bool unlock) diff --git a/mm/vma.c b/mm/vma.c index 2840cbaeff8b..a8d716c39db2 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -646,22 +646,6 @@ void vma_complete(struct vma_prepare *vp, uprobe_mmap(vp->insert); } -/* - * abort_munmap_vmas - Undo any munmap work and free resources - * - * Reattach any detached vmas and free up the maple tree used to track the vmas. - */ -static inline void abort_munmap_vmas(struct ma_state *mas_detach) -{ - struct vm_area_struct *vma; - - mas_set(mas_detach, 0); - mas_for_each(mas_detach, vma, ULONG_MAX) - vma_mark_detached(vma, false); - - __mt_destroy(mas_detach->tree); -} - /* * vms_complete_munmap_vmas() - Finish the munmap() operation * @vms: The vma munmap struct diff --git a/mm/vma.h b/mm/vma.h index 0e214bbf443e..c85fc7c888a8 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -116,6 +116,22 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach); +/* + * abort_munmap_vmas - Undo any munmap work and free resources + * + * Reattach any detached vmas and free up the maple tree used to track the vmas. + */ +static inline void abort_munmap_vmas(struct ma_state *mas_detach) +{ + struct vm_area_struct *vma; + + mas_set(mas_detach, 0); + mas_for_each(mas_detach, vma, ULONG_MAX) + vma_mark_detached(vma, false); + + __mt_destroy(mas_detach->tree); +} + int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start,