From patchwork Thu Aug 22 19:25:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 13774120 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E76EC52D7C for ; Thu, 22 Aug 2024 19:27:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D206F80054; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCC698004F; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94BC580054; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5EC6A80054 for ; Thu, 22 Aug 2024 15:26:56 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 014D41A0804 for ; Thu, 22 Aug 2024 19:26:55 +0000 (UTC) X-FDA: 82480864032.25.ED5A52B Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf16.hostedemail.com (Postfix) with ESMTP id 9CA7B180005 for ; Thu, 22 Aug 2024 19:26:52 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nm5rvLNa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TMTzKMoo; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf16.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724354732; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0LLZ3RbsTLjZoi+XWRh7T3mXeaSWkQv5kP+Gqd3u8CI=; b=xYDmX8zLPDI1vjysfDaX29EsU8BqSnYFoOx+/EuW0Bq2wESbBlfBzN6RZ0rzS9objPSAos VlLO7LrnFoJseOhUDukuLtRy90YKJvHx+QxJX1ZFLwpfXP4FX8Xu2MhskYEg0k9XnlK4jq /ucYWw1Y9Bfbk+sO0AZF+ak3GZS2UaU= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724354732; a=rsa-sha256; cv=pass; b=pIYoQCMhKPc88qCnGgrdDfxGpGTIv+79IGdkmW2t6Pt1eydwJqasat+SzO5HWPbtHQ8Ff7 l3RFVsFUSAi7/0UXfPapx0IC0ton28YdyCkx/eDXS2KiI/xzLxdQo9OvIxqT89xodc0/0Y Yg8VBFW7X4il9aI1aTJu4H1NsmQOLb8= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=nm5rvLNa; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TMTzKMoo; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf16.hostedemail.com: domain of liam.howlett@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47MIMUY8021045; Thu, 22 Aug 2024 19:26:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=0LLZ3RbsTLjZoi+XWRh7T3mXeaSWkQv5kP+Gqd3u8CI=; b= nm5rvLNayggSx6nNjcRrDvawcS4XkwMeNKVRXBV5pLN0idtarfv0G4WOiMyA5OaX nKe2LSskSPQWIioWWkjprn8bP7EgBh6rpmw/bgAZ8iRMvOzQy298WsVs+5kBh7Ys RfUiIN5t3dKom6TEqH3Ffn8Bxu8/D5oVoQu6aXvxp8DUtf9tjHsOEB5dWrKEnaGM XQ3oShKDTh9cOZ7fMhoP38tRwCa0XmKNktRhqgMnEE8HXZ3Yqcs6cg5vtLJ6UWyg vBnuv08J8bgW5vIrC7I6wzzxx5LEOjVS+IqF9Fr0Jv/I7DanpPdsYac7mWeRsJ3L cLm/vqpXjSYeGx1hUJdpSA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412mdt2w0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:36 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47MIqaPx019453; Thu, 22 Aug 2024 19:26:35 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 416b0b9ckf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 19:26:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RCwiZ1hYkklBzckBckEyK45sYFUprp15FzFx1smCgA2qz+bucH9UdNBTaD9vDMCSk2uFh2mKzEO29uKMkbOOauXncD0VKd3/qtec04ST/mzqAibxekNobnRfM5nqeFWL6pXHcITF9B1I4ax0PqYrheFDLWFJOZyrl1GFEZakj6JMSDTORKjHp9MVi9SA9M8KdmNfIa/m/M4yR4nH/+UGkdQnQC410mmBvx3Cg0nKMBKlktjzzY/hPjls61EQhmN/5P8dDB2ylF5R0O29x12wjCG7BJrzLN8gWj5hhVEFrEUuuIyfxqCBeYBfMthM2baTRmENZD80fXenTYT74N7hBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0LLZ3RbsTLjZoi+XWRh7T3mXeaSWkQv5kP+Gqd3u8CI=; b=BCHRsie2uTQgp/fuiBRPJB7M5LoN8lSM/2MWITTDdnX9M9GSqLm4Qcb2G5FLdXvhKkMiEiMJm5cAvSJRRW975WZUMGfPFZgu7Q3df/gWM8zQgIqiI75kZDqWmp39TmXSMPBhdg+lV767iXTCjd/i6sopJ/XZZbF5G4M+REnWnADp62u9XYLOM6tQewWvIBq9/6GdHv8Q1M22dCrc/rIHxSXZleWB+mF+nxrAlkQDX/v7LTDma8vdtPGWD1BKYEzY95MuKplLeg3iu4+BSpi7w2Q6V97vn7c3hmkGtj3zSGuGmYZ2k0LaDi13KtRCOARLoboMUI1hpQsyhXp1PyLD9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0LLZ3RbsTLjZoi+XWRh7T3mXeaSWkQv5kP+Gqd3u8CI=; b=TMTzKMooAPFdflTd8A8AsonJpVk4knAhvgzdxWP8H20skpZ/uI0cJ0+0RGG8bWQPlXPjVRicy2d3b1O5Te1/Oc6yuHM/+Ytr/BoNBEsnWam+Xjv0AC3QyXSdlK1ycUaa1y+ltPyRPUWomhvDRSNiZoauExoeVunzQP7wiz6PgM4= Received: from DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) by CH3PR10MB7761.namprd10.prod.outlook.com (2603:10b6:610:1bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Thu, 22 Aug 2024 19:26:32 +0000 Received: from DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490]) by DS0PR10MB7933.namprd10.prod.outlook.com ([fe80::2561:85b0:ae8f:9490%3]) with mapi id 15.20.7897.014; Thu, 22 Aug 2024 19:26:31 +0000 From: "Liam R. Howlett" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan , Lorenzo Stoakes , Matthew Wilcox , Vlastimil Babka , sidhartha.kumar@oracle.com, Bert Karwatzki , Jiri Olsa , Kees Cook , "Paul E . McKenney" , "Liam R. Howlett" Subject: [PATCH v7 11/21] mm/mmap: Reposition vma iterator in mmap_region() Date: Thu, 22 Aug 2024 15:25:33 -0400 Message-ID: <20240822192543.3359552-12-Liam.Howlett@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822192543.3359552-1-Liam.Howlett@oracle.com> References: <20240822192543.3359552-1-Liam.Howlett@oracle.com> X-ClientProxiedBy: YT3PR01CA0054.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:82::25) To DS0PR10MB7933.namprd10.prod.outlook.com (2603:10b6:8:1b8::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR10MB7933:EE_|CH3PR10MB7761:EE_ X-MS-Office365-Filtering-Correlation-Id: 79d22c16-ff67-4ee4-ed3c-08dcc2e05376 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: wVbN9qBbEX2Yr34+iAkSQkwMjF1XhPNlvnKbkWQo9bmeXCKZxr3Im/zkHSnz45oXFuhsHiR2b20v94xs19atH582zP+xvVD+tQNq9ufAT7gdJJtZyjlXsF3rBRY6i5OFIm+jg3rBC0nTCUUgeC+v1e+bDJD09Oq5vbQPjrrdJaH68aYNmqDwMi1RyWNVTfHa+hw9oalZshWSwjhxrbk3Ae+qwWqayiWkHuNGDTHV/LExtnYWvGEPgzk+lXNZuN1/G1s7tHOke5agGzlD2nMrXR57KnQdCWkgmiem4gUmomrqbGA/Y39xmkFe2JEzcT4UmIhMW3IIqrM2oaL+U6ylFnrehSDmcgcjDtLO5bavaDSrwKkiG03RQCU9UGGQyTxswNGRQVXTh4oabD8LFOOn7o5Ji+Q7NwoZ7s1loFk9zqjqEoicPBY1VEV6xnKqFYBdoUs5DIpPBm8VdPlbf5xtO2Rts7NhxTM8NUGtmpVxvgaFTrdAJzvbelDso8sOOM5Xhll8en44gFlI/j337+ByYoNnvqE+dV/aOeu/eQf7G0jHwnlCsa4J6Hnf/5NY5MP4ha6cXwFOoW0lSeo8sPsOOh7/1lvF+UQpYQX1URj6AJlbjbGS8lbc0iPIyD8ya+CoqtHxrMUiAD0B/R58YR699i+m2euDfE2FxGKol70pV9SC/PuBlFsG73KlUIEJtco7yCNIqq59kNpmso1IHIMw0Oad9vrFNLuUE22jBbgmvZHWSIZ0Xoekcd0S6N5Vq6j9SShFTtizbHLwUX38lq4yRBzFMfLzJAsTo4munul2/agvMkYg7IBjpMPyEsyjKuyc+yN9xlSJ3F53O2k2MaTCCZDBZit2ow9FrNMSCZOrXjLd7acUP+MaF/lq0NDNuNmvJLl+C80N8GYMh8g6QLs/NiRFnj/snSzoU+HTGsdYNJWa5muO2EyDbY9j/XpwMV/LysjtfDBHtsJYusubEXZsw4utGL8/pOPGUw/qIidMzt0cySgBi/XvgB+5dGoHEMoL7WGj7nELNeskQ9EqLn+VkGeSxj1Q4MZxBh4K0gGTFzIeu9vR258Ra+3iCTZ8Gdoa/iM2yFUDOY4vFvnCWBoWBOt38gfkornJ55rHZiNivHb/dAR4vSqNJrBuBsuw9R8HBHqlfD6IPrQ1BIe7/vzqp9/FF2PzFW7IRehkpvj1LzTIHqbqeCWXuQGUqJ8n7yntFGhaAGDIVkHVW1JKhKWWvxEBfYxXpZGcQCWHKoGOT7UuwlzUemPnl0ZDVMuKzEyvz5O92ewxeVpoDbcsMagz6Y0MvXQikb+RUYFDvVSGMkES90k1ePg2kHsyWeogNUAmB/tShDUgujc3gS9CVXvWPg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR10MB7933.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tpveRwNbbGb7QrFm1Jz2/6m1MJnoMZjWfHO1KsHy/ie0Qm/ChxWHi5qDewAqhdEolTr3ufq88jaV4bKkKsHeLtvVmdmpsra/pNsWSZnnJULm7d5fJagikayxLGYThg8CBg7Mfe/ZmmWmuQf8L8mU9gQ3jRfJtEF/pHCL1oe4IM+Al6hBgDfkT+c9tVZiq+Le6/tTLvA5+eMq78a8o/9kRBrDp2pK7R/C6Wt5r9ExIKY9SXVdKbazpM4f/dDmhP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+YRwhhPolYj6EDjcKNCAygAGDULWbaGfv3xpl3PDYDq2O+jVqGc7DadCBIk0ugL63F4hfadJV7B1vE+gIWAYoz2945Mrj156rKyrRmZBT02jpWHWSmZsjkiV+9DnShvRwYny6/gcpIeRz3gxexSRX9UQ6CStysAxuLnWcctMoeBeNQDW6LwDwPkKbXjv3jyjsAjmP+3RdRPOWVhz/7MOyqU4THG+FpZ0mZ9X5iKrrRlhiNcGrD5NppuoJ5fDwy6FhixRtmXDjse4pOkOA4552vAOsDLD0Znw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: gR0bK7kbp09HQ+SokgaPc78U+YdWyPseakTQOiCbBTYRHVWARSos4RjAnW5LEvs/TZyNgi1fqwyrn/dgYTOJkoro2Iyq+kuKjO6KqOpbm9zghX3L/RvIzYc50LIyu9prKnU6Ebl0JW7PIXpwAZy6i20Fz9WG26mKWn8toPHFz12+bNMH7Z4Tiq/DrS3bUvOiyWWxRg3c4oPAxiwpWj7TUNmlPLsw8eTZFeJ1qp5QZpSxwZQ2S3ZsoNDG8WB5/LzXWyv5Ohl8yb4odl6TQ+h56cSHQmANf9p0FoL2kPv9c/UoQoTtBS3q1/TZnQ9OI7ubv0oCKpXfn5gnX0ndF2X/KbggVeZwWdqMYTFbRU2Rkfne9h35acUmzn0DqjcpM13RmVHrBpVljupf3NkP9/7mliLNw4lcMLOo5wgeFA/xTvtKJ5ds0d8vf+zVPIZYqREeAL6Gp0uRxmi+pB4PAbQfFSRf0+tOQ116F2/nqOmzRuiGGKytYjlPEExIS4bu2JdfUfx7E0wWuOpJkarSd9bwSECK17VWHsRrRxJQbjnbs6ITYgfFTkNcB5Ga0iIRK9ldjntvvgspdtDC2qtyoa8Rr7T8yWmWUIrd29Xpmya0ha8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79d22c16-ff67-4ee4-ed3c-08dcc2e05376 X-MS-Exchange-CrossTenant-AuthSource: DS0PR10MB7933.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 19:26:30.9921 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cnoWFhziwzOaUOy3ptztsGgaMlcSzAjZbVhJXGMpIB1k2wrSnhpRfk9freonrWOkzPDHdlQ52BYCmGQ4nUn15Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7761 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220146 X-Proofpoint-ORIG-GUID: FXYv3_2sO_CnkqvU7CMsW2o6DeTEKatc X-Proofpoint-GUID: FXYv3_2sO_CnkqvU7CMsW2o6DeTEKatc X-Rspamd-Queue-Id: 9CA7B180005 X-Stat-Signature: 5czku8ekyabydrxannctit7imjqtucc1 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724354812-21030 X-HE-Meta: U2FsdGVkX18Qps0e5tQ+CNqTF4aGSJ+zDe98Jk6jdxzEd3VIXD0jIMGnhu3vB17Qrk4tUTtsCnVNeb2If8MV+gUVHOg3xf5XcgegpMJ5OVjebnfbVQfC0jQ2esurqRYV/fbvVAAf4QwNeaZsgYdU8itphBvcJju4FnzDwzVpTV3WxHGqF7iW7DPeZI0OJTNtoTTseUnhuxwhYTbVl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AXoBBq0+HSDLmpBzb5HD7p1NJHQpdW52xnmY7p7+VJTu4wcHOLEsm45gBWl/BJILrzOr8Psagg1do4Tdxlg9RUeB/aLCPKjBEYfHvjS92LumzH8xB0PALeYXIVkCOZB3f5EV56WbQm3Dm3SxUsARhvZon4NBdPpOz5RgN2mM+lZovLJrfU07cd7g7s+B0uAUdOTAjruAOKZJB5hOa/F/0i/zlXuC6cdJI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Liam R. Howlett" Instead of moving (or leaving) the vma iterator pointing at the previous vma, leave it pointing at the insert location. Pointing the vma iterator at the insert location allows for a cleaner walk of the vma tree for MAP_FIXED and the no expansion cases. The vma_prev() call in the case of merging the previous vma is equivalent to vma_iter_prev_range(), since the vma iterator will be pointing to the location just before the previous vma. This change needs to export abort_munmap_vmas() from mm/vma. Signed-off-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/mmap.c | 38 ++++++++++++++++++++++---------------- mm/vma.c | 16 ---------------- mm/vma.h | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 2b7445a002dc..9285bdf14c4f 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1400,21 +1400,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr, mas_init(&mas_detach, &mt_detach, /* addr = */ 0); /* Prepare to unmap any existing mapping in the area */ if (vms_gather_munmap_vmas(&vms, &mas_detach)) - return -ENOMEM; + goto gather_failed; /* Remove any existing mappings from the vma tree */ if (vma_iter_clear_gfp(&vmi, addr, end, GFP_KERNEL)) - return -ENOMEM; + goto clear_tree_failed; /* Unmap any existing mapping in the area */ vms_complete_munmap_vmas(&vms, &mas_detach); next = vms.next; prev = vms.prev; - vma_prev(&vmi); vma = NULL; } else { next = vma_next(&vmi); prev = vma_prev(&vmi); + if (prev) + vma_iter_next_range(&vmi); } /* @@ -1427,11 +1428,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_flags |= VM_ACCOUNT; } - if (vm_flags & VM_SPECIAL) { - if (prev) - vma_iter_next_range(&vmi); + if (vm_flags & VM_SPECIAL) goto cannot_expand; - } /* Attempt to expand an old mapping */ /* Check next */ @@ -1452,19 +1450,21 @@ unsigned long mmap_region(struct file *file, unsigned long addr, merge_start = prev->vm_start; vma = prev; vm_pgoff = prev->vm_pgoff; - } else if (prev) { - vma_iter_next_range(&vmi); + vma_prev(&vmi); /* Equivalent to going to the previous range */ } - /* Actually expand, if possible */ - if (vma && - !vma_expand(&vmi, vma, merge_start, merge_end, vm_pgoff, next)) { - khugepaged_enter_vma(vma, vm_flags); - goto expanded; + if (vma) { + /* Actually expand, if possible */ + if (!vma_expand(&vmi, vma, merge_start, merge_end, vm_pgoff, next)) { + khugepaged_enter_vma(vma, vm_flags); + goto expanded; + } + + /* If the expand fails, then reposition the vma iterator */ + if (unlikely(vma == prev)) + vma_iter_set(&vmi, addr); } - if (vma == prev) - vma_iter_set(&vmi, addr); cannot_expand: /* @@ -1625,6 +1625,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_unacct_memory(charged); validate_mm(mm); return error; + +clear_tree_failed: + abort_munmap_vmas(&mas_detach); +gather_failed: + validate_mm(mm); + return -ENOMEM; } static int __vm_munmap(unsigned long start, size_t len, bool unlock) diff --git a/mm/vma.c b/mm/vma.c index 6b30f9748187..9de41e1bf3b2 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -646,22 +646,6 @@ void vma_complete(struct vma_prepare *vp, uprobe_mmap(vp->insert); } -/* - * abort_munmap_vmas - Undo any munmap work and free resources - * - * Reattach any detached vmas and free up the maple tree used to track the vmas. - */ -static inline void abort_munmap_vmas(struct ma_state *mas_detach) -{ - struct vm_area_struct *vma; - - mas_set(mas_detach, 0); - mas_for_each(mas_detach, vma, ULONG_MAX) - vma_mark_detached(vma, false); - - __mt_destroy(mas_detach->tree); -} - /* * vms_complete_munmap_vmas() - Finish the munmap() operation * @vms: The vma munmap struct diff --git a/mm/vma.h b/mm/vma.h index 0e214bbf443e..c85fc7c888a8 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -116,6 +116,22 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms, void vms_complete_munmap_vmas(struct vma_munmap_struct *vms, struct ma_state *mas_detach); +/* + * abort_munmap_vmas - Undo any munmap work and free resources + * + * Reattach any detached vmas and free up the maple tree used to track the vmas. + */ +static inline void abort_munmap_vmas(struct ma_state *mas_detach) +{ + struct vm_area_struct *vma; + + mas_set(mas_detach, 0); + mas_for_each(mas_detach, vma, ULONG_MAX) + vma_mark_detached(vma, false); + + __mt_destroy(mas_detach->tree); +} + int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start,