From patchwork Mon Jan 27 15:50:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13951577 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 0DE9CC0218C for ; Mon, 27 Jan 2025 15:51:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13190280171; Mon, 27 Jan 2025 10:51:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BB2E28016F; Mon, 27 Jan 2025 10:51:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1A62280173; Mon, 27 Jan 2025 10:51:22 -0500 (EST) 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 3E94828016F for ; Mon, 27 Jan 2025 10:51:22 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7C94B802F4 for ; Mon, 27 Jan 2025 15:51:21 +0000 (UTC) X-FDA: 83053671162.03.B0B8149 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf11.hostedemail.com (Postfix) with ESMTP id 2CCB840009 for ; Mon, 27 Jan 2025 15:51:18 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mI4FqxgK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GpEd4AR3; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf11.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1737993078; a=rsa-sha256; cv=pass; b=yjr27DS9JbL8WIRZ6l21X1u/K6cIa+Un9HPm7BV/DiGKC7Jh686Sy78/zPuglTtIcITqQx kY3VwvwglvEO3hmkkcVpzVhZJCw+PKwBZHqFvm7zPK+oLRJfIPew5CLh+kJOWgiXWW+toa iihM+Ywck32M/ED1ldElLE9D1aVw0o0= ARC-Authentication-Results: i=2; imf11.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=mI4FqxgK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GpEd4AR3; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf11.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737993078; 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=yYt6stsxYImVpnilc4jHtHIA4DfFcWVogY7BkE17NV4=; b=DA7/b5D/2nVgXMbGas2jWAEuXv/0cHGslBk1lG4/paD4ZOXYk68EzOV6L6Myx9crbO0Az8 OFyCH4tHOm6FGESf9MP7E7hDRqpk4x0cIs+W1H/RthcwJdJ7CXP669vl1UZCFXxzbajBeB rb4jAlXgeMHUFFsUJ0gs5fayzYlf2d8= 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 50RFVhVg028428; Mon, 27 Jan 2025 15:51:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=yYt6stsxYImVpnilc4jHtHIA4DfFcWVogY7BkE17NV4=; b= mI4FqxgK8Hsd2uLXcvK1Bn2K5tmAmBmGTTgoqBaB38ZWnFY+6sCbnkygPzkzYv0G /bjcRNnOETiUm3pkQug0wtLV7O5LkYZouN0iDSR/zKt0qjj3zpgFvoRUMJKv/Ry+ 6/ImzzvxFcPUJYrCQDuwsiabqGxSyQigK/ZSZvVk9GQFppo8Y9GtP9ePlTc2SVxU OnIUoPw0SqcYlge/596Ef0GklcZl6z7ojkIbtai/JjTFWgycB1XbMJOB/iWM3Y8e 7Z4bcR6HwQyXXcHSKLZ9RBSlEU5K/xDfoB6cyFbKjDShT+C3SuMBsOCSIefJFCQc tm9HSIVsKIk3/LPCRgi7yQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44ecv581ku-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Jan 2025 15:51:16 +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 50REwTt2035833; Mon, 27 Jan 2025 15:51:15 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2040.outbound.protection.outlook.com [104.47.51.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 44cpdd4vuq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Jan 2025 15:51:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nwOeG5lpoPaN+h0wcsD5wRN7eY99SW9EJVWfkiJxytsNEy82ogvpkNYn5W8V38R+Nx8pee+qgnHsyhqU7dgtzpID2snRZ9GBWMs1skY1tBD2wrDRJ34X3fT++Iggs3rtH9fPlM7QW3x1XOItOjvoxqgHtNelmxCFIviv1HB9zsgCW6FGE1VBEX/afywS8FYjoJpb+K0SX+uknIPd2v09dNwBZxt3sfffuIFT02Dq6fCxNQxRbhICMv/9HrBtAkOX8G05C474nvuM8YjEMfBf2qCQkujpQV3yhEwU2xCHKepdDaohyNX0zY2K5p/swdpbD0E62IPAvbPpCjA/LGbA/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yYt6stsxYImVpnilc4jHtHIA4DfFcWVogY7BkE17NV4=; b=bSPu5FLk5KEZGruOFsYjhY1qIWX1xwA7S/J54UE6jU/Zmz60O68QmQS6bPPYCLwywCZYd0H5qJVjkArg9YaWB06W95oziUZhdjxSRY3CKB1Ert0T+JfABCY/jVzvlZ874VZkQi5VSgbm4yUTT4lDEeK83jRm1aVC4eQFP3lbtb41jp/epX5Ie83OlfQwvyYsQy0ZDTVowU0zhSpFoB2jpuHtSoJAWJcDrX8PslWmcWK/8dBFYH7ZmolKPHFZGjOOUCMnvAlQa1gbT1kQU1VHa1Tn+XYlPlDn3KKO01G8Cx63KiCLKvQeEr+hI934+myXPONILoQghpwlUKocX9sRaw== 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=yYt6stsxYImVpnilc4jHtHIA4DfFcWVogY7BkE17NV4=; b=GpEd4AR38CrNFs6/q3zGc223idN8cwrlEfBbOJJLd8CU/Hu8mOzNMfMGlSfLGDM4pYLuf3WtyhPNiHdAhDxkct9S2BDh6ndy4fAOy8cPBeA8lJ2iZGpgNF32ivn4SSJomVaqTNwODGO1RFEUiVYjbvNZLC7EA7pwMd4UNT/3cNU= Received: from MN2PR10MB3374.namprd10.prod.outlook.com (2603:10b6:208:12b::29) by PH8PR10MB6339.namprd10.prod.outlook.com (2603:10b6:510:1ce::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.19; Mon, 27 Jan 2025 15:51:12 +0000 Received: from MN2PR10MB3374.namprd10.prod.outlook.com ([fe80::eab5:3c8c:1b35:4348]) by MN2PR10MB3374.namprd10.prod.outlook.com ([fe80::eab5:3c8c:1b35:4348%3]) with mapi id 15.20.8377.021; Mon, 27 Jan 2025 15:51:12 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] mm: make vmg->target consistent and further simplify commit_merge() Date: Mon, 27 Jan 2025 15:50:43 +0000 Message-ID: <829048d075d18dd34572f330d17af66b8cff8441.1737929364.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.48.0 In-Reply-To: References: X-ClientProxiedBy: LO4P265CA0191.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:311::19) To MN2PR10MB3374.namprd10.prod.outlook.com (2603:10b6:208:12b::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB3374:EE_|PH8PR10MB6339:EE_ X-MS-Office365-Filtering-Correlation-Id: ba52fbe6-036b-46d4-f849-08dd3eea6ccc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: wBs+8UhJaPIdRHU8PXpirdLxcrXBapCmrhu1f8yCfliuheFIDsvvqnb76ZLNUxO5uaWHnWGyS4/LnC5vdY0XN05zFrXpMM3/00DXr5T4YXegKl7Vd+7q7a0eGlzdPpZ2KDefOoe3elbYMuy08GZatMww53amZjs4gbo9I7w4LxioBLVCgcYD82uYKcGydvWq67p2ZjHlDGaFMDlbbuIhk6aKJN5iMg3xWaS9o7MseRfhYf0EVja1C3JT+3vLRphk3XAvTNbwR9ZQ4lHnBB6NvkK6J1IbjtN1RUNkrRndewfD1Ddb8qep4imJglF8I8XcVWAEkaoYAJ0+IKkaYq0KehM9skjqSTl4n10Ouv0hYoBwN5MNd+4Lu8hFLBiPbPBxLj7QllzVnZSUPmlmAqubAWtYztWLBILfZtp76/e4xdpiLgPEAeRT0VO7BRGXFyhKd0gxN2ff2kxP/dJ5iEmG4LdSZ/osqLtDyVALfspXPSIRU1CACAoc1P3V3+zgUt5jpiUZPlt4tsPDsYqaxj9USQoMfSwhvYkfUF0P79cvm+mpKnOs06RD0Z9gvJvcQJMkrN/VhLwUnhOj0Erp5TeFnceQfR4yPKC/BopN4DoSY7rMoISVOf0sAFqm1GNoLaW7lxRNdecew7/cI/kH/KzNjcRvg78T+4gMZrixz2KTh3FVtvEJSkPAcdmgaW/br3i5KW3aa7w/QLSiZplKMibjmohwVObcJCNTuPpVFuOOrYhWFuKCyW4h8mPyryR1F4ToO/eZ218GtTWE20wly/ZqMj77AE3rA4w/c1CRmhUo7L/cNUKUcBbdHcBiDs9GqQ40Qb8VkMb5v384b2nUrb63nWi5aa1vJGTBiloC5gasRKHaDo07xpPR0trppz4PD1CAaO7jND+P2IQinwNclMBs7YZ/8W516saHWqz0GJGVaUpNg57Mfbw5V6XtPBUspC0vlmP55GAECum2M9uV8AiNQiOdyErmIUOeTi4RtTItei1JGp7d5MX2Hb348GySLOdCvizJnI7eZM1b1GLW6QSy8K9apzCcQzNn+a2ht2h3wVjOyvF7vTOfTAPE4rj1ctEgoYYdwvmOalXIIXg9DL+CWyk9eC23x7xnMTtZIS7pxN3gD2BPL2jpJCBPoIR/xgPX2sbhW6qSZA6Yf4hJchjz4pjvDwSDku/2d7Dr/DL64sQIIVAlsc4+lCdZ3253dlrgP40fY8WZIJaY928VCZQjxnDcYPF2anCA7qbk8qxV7t1V/qZ0Yuh73g8IPv0Gic8OK6KyKCRaobeGCZdftu9QI45RHiy3lraLGrPCdJWDRhR/dYuvGzZGOEov4LJm+GlQVZehz8/ZM1ovTpBcmsgChfuRW0Rd8wbR1VYk4Dnojq6+2EFT6GGAi5K41NJS67R2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB3374.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0oY/exZg46M7Pb4poOQunHp28PjOMcn3Pmj/UToIZlj7CzDXB7+NfvZxV96aGk4R4aM849NY0yNQ+sDcrT7vjE9xoGvabixN2JxwOkQ5wXDKYdnhpk9pDwPJpqKWd/9tRI73W7y2NB7oA/ZAYU2dR0YXOAnOWPdGu0ugpCwjEDWdAzqhnLszkCHkz/KSg7dClCJhYGsgJFHT5rqU32l/5NN4kHUJyI5qTEaPg9d7Sz30aic3l+FchHRWubKTpPA+cohdSAOdEAG3Rwwz/8d0dZFtauzLR0jFm1qudnacwssi9+Z5mULvVjrytmNxFYNDiJQLULxe6L9q1cUDFgTBtShS0XtAETHJD8TbiA1RB/aBuoMvSBfUPeTnQ+WYJj3IGb2AtmTsemT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HPw2CtmCO57vX6hgkp9/20qXP5i12++qu6QehmyM+cGd30F1T8P1fB90o6inHckPI2DbDXPqtERiHxeEOT/YOQxv54zK5yBiC4zSlg25DcksNcrJKKt6JRGe9jKx0+fp3QqT3/VegbADNftMztGg4nOwSpVsOeeFahjanQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ep61TUuYyFL1RQzXUvT/SZA5ga5qfkz+mRcJ0DFhkkuByxZyYOnLHK8S8PDl8jx/IY49qccI5+dmsGyc0Y1BHyOxbrVZ8sdbxqs7THkI+K28ng/Kc+1tbmL9Zm1AupljhoGjr5rBZ49kQ4LM4CSyRnjqWjVNvByIytA6XdPl91yOoU++c1FUrTeQJezDBVFOtoUiloovDvZaupG4+HlkvUT/8GRv/9NVvyW0aAOhmK3FtjELsdwU7C8HmkDPdBiTw7R3Dc+Tw47+fXvGgK41TkPQ7dN1wpqYy+rGq+6m0U3ndIPO9G0AdSste4VJUdL2GloSEZ/lxKygxR3LFpiMCq4KgtG0028+0vCD15q5/6K8g3EzUlo+Ab8qUWXEamXZTREZK+5CuD/8grTFLrjqriuZ+Ut6fwQGG5/H+UCTdN8DNWYgTc3UmcsJyoHWlRG7EqEki45uuehdwWdyxiv/X4rr8pnOIvGGfT7CIP3dVFgZprB7qdvYu1zUJUQGY7qiw65DibEeAupz9BRiSSve+GfX3H98vkTh1CibexsMBdWUOIymFgFde+AFR9m1kpz3C/LG1CZoj1/X7AvYTNYgOwzKL8oC+vHBm8CRPSzUSxo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba52fbe6-036b-46d4-f849-08dd3eea6ccc X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3374.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2025 15:51:12.6898 (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: FG2fWeUhD7OGjQnjT8lkdFrEpkHqt78tAn+gRIlaHSDm1YiKrfUJGG2uLOu4+FkYsH9TYeXukRIiq3N5sGPrc1abxv6nxc/lNksTg/d6D+U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6339 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-27_07,2025-01-27_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 phishscore=0 suspectscore=0 adultscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501270126 X-Proofpoint-ORIG-GUID: nmxaFjJfenhCpPO_-RXR807U4uOcaFYX X-Proofpoint-GUID: nmxaFjJfenhCpPO_-RXR807U4uOcaFYX X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 2CCB840009 X-Stat-Signature: gam8qr99xttg6o8e77duipqscp6afpc6 X-HE-Tag: 1737993078-972383 X-HE-Meta: U2FsdGVkX18G8Bl3fLDLtERSDONcrzyRKn9KYVd6AM3vyeLleFToYI9UTIau/wZx2oT/8IidSpqhGNA81A+hjZHwv5Z38v5MxJtf0bT00oR1iqUz3gnzqnkGw4GPRtCBQhQ4asI4ylYnte2t+Vg4yVSHtskFKGRnYbVq9Wes6oWSt4av6eA/9nNdquoiHnHTBdWkv/JtEysBsACqB29lLtmZ+a0Y3vWyzIFr06wclbltO4KKRJrj0M0Dq/6rEGdmyVSm70l3BI1BPcHE1Y5HUj1f8wZ6RRdBwT4vMrIElMyO71Mh3evjmeZHoU7tYbNZvAL9DNYGnO54dSmm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ndb694MWpRajh26BplL+N4whbhfcgJU8Aek1ndpb/mHnYFzpCCuUzWFtR3sx4YmHE+Zen+yhSOLKrxr+dJcG4uk1TNt1YeXDyyHLA4zTUzsSkW8vZ7KJpccPagqeKkNYEqILogztDkea3fLfp3LqYFYqiW4dS9YOOONfRNB8iFRTC6rEsm8= 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: It is confusing for vmg->target to sometimes be the target merged VMA and in one case not. Fix this by having commit_merge() use its awareness of the __VMG_FLAG_ADJUST_NEXT_START case to know that it is manipulating a separate vma, abstracted in the 'vma' local variable. Place removal and adjust VMA determination logic into init_multi_vma_prep(), as the flags give us enough information to do so, and since this is the function that sets up the vma_prepare struct it makes sense to do so here. Doing this significantly simplifies commit_merge(), allowing us to eliminate the 'merge_target' handling, initialise the VMA iterator in a more sensible place and simply return vmg->target consistently. This also allows us to simplify setting vmg->target in vma_merge_existing_range() since we are then left only with two cases - merge left (or both) where the target is vmg->prev or merge right in which the target is vmg->next. This makes it easy for somebody reading the code to know what VMA will actually be the one returned and merged into and removes a great deal of the confusing 'adjust' nonsense. This patch has no change in functional behaviour. Signed-off-by: Lorenzo Stoakes Reviewed-by: Vlastimil Babka --- mm/vma.c | 122 ++++++++++++++++++++++++++++--------------------------- mm/vma.h | 6 +-- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index e78d65de734b..cfcadca7b116 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -107,24 +107,41 @@ static inline bool are_anon_vmas_compatible(struct vm_area_struct *vma1, * init_multi_vma_prep() - Initializer for struct vma_prepare * @vp: The vma_prepare struct * @vma: The vma that will be altered once locked - * @next: The next vma if it is to be adjusted - * @remove: The first vma to be removed - * @remove2: The second vma to be removed + * @vmg: The merge state that will be used to determine adjustment and VMA + * removal. */ static void init_multi_vma_prep(struct vma_prepare *vp, struct vm_area_struct *vma, - struct vm_area_struct *next, - struct vm_area_struct *remove, - struct vm_area_struct *remove2) + struct vma_merge_struct *vmg) { + struct vm_area_struct *adjust; + struct vm_area_struct **remove = &vp->remove; + unsigned long flags = vmg ? vmg->merge_flags : 0; + memset(vp, 0, sizeof(struct vma_prepare)); vp->vma = vma; vp->anon_vma = vma->anon_vma; - vp->remove = remove ? remove : remove2; - vp->remove2 = remove ? remove2 : NULL; - vp->adj_next = next; - if (!vp->anon_vma && next) - vp->anon_vma = next->anon_vma; + + if (flags & __VMG_FLAG_REMOVE_MIDDLE) { + *remove = vmg->middle; + remove = &vp->remove2; + } + if (flags & __VMG_FLAG_REMOVE_NEXT) + *remove = vmg->next; + + if (flags & __VMG_FLAG_ADJUST_MIDDLE_START) + adjust = vmg->middle; + else if (flags & __VMG_FLAG_ADJUST_NEXT_START) + adjust = vmg->next; + else + adjust = NULL; + + vp->adj_next = adjust; + if (!vp->anon_vma && adjust) + vp->anon_vma = adjust->anon_vma; + + VM_WARN_ON(vp->anon_vma && adjust && adjust->anon_vma && + vp->anon_vma != adjust->anon_vma); vp->file = vma->vm_file; if (vp->file) @@ -361,7 +378,7 @@ static void vma_complete(struct vma_prepare *vp, struct vma_iterator *vmi, */ static void init_vma_prep(struct vma_prepare *vp, struct vm_area_struct *vma) { - init_multi_vma_prep(vp, vma, NULL, NULL, NULL); + init_multi_vma_prep(vp, vma, NULL); } /* @@ -635,77 +652,64 @@ void validate_mm(struct mm_struct *mm) */ static struct vm_area_struct *commit_merge(struct vma_merge_struct *vmg) { - struct vm_area_struct *remove = NULL; - struct vm_area_struct *remove2 = NULL; - unsigned long flags = vmg->merge_flags; + struct vm_area_struct *vma; struct vma_prepare vp; - struct vm_area_struct *adjust = NULL; + struct vm_area_struct *adjust; long adj_start; - bool merge_target; + unsigned long flags = vmg->merge_flags; /* * If modifying an existing VMA and we don't remove vmg->middle, then we * shrink the adjacent VMA. */ if (flags & __VMG_FLAG_ADJUST_MIDDLE_START) { + vma = vmg->target; adjust = vmg->middle; /* The POSITIVE value by which we offset vmg->middle->vm_start. */ adj_start = vmg->end - vmg->middle->vm_start; - merge_target = true; + + /* Note: vma iterator must be pointing to 'start'. */ + vma_iter_config(vmg->vmi, vmg->start, vmg->end); } else if (flags & __VMG_FLAG_ADJUST_NEXT_START) { + /* + * In this case alone, the VMA we manipulate is vmg->middle, but + * we ultimately return vmg->next. + */ + vma = vmg->middle; adjust = vmg->next; /* The NEGATIVE value by which we offset vmg->next->vm_start. */ adj_start = -(vmg->middle->vm_end - vmg->end); - /* - * In all cases but this - merge right, shrink next - we write - * vmg->target to the maple tree and return this as the merged VMA. - */ - merge_target = false; + + vma_iter_config(vmg->vmi, vmg->next->vm_start + adj_start, + vmg->next->vm_end); } else { + vma = vmg->target; adjust = NULL; adj_start = 0; - merge_target = true; - } - - if (flags & __VMG_FLAG_REMOVE_MIDDLE) - remove = vmg->middle; - if (vmg->merge_flags & __VMG_FLAG_REMOVE_NEXT) - remove2 = vmg->next; - - init_multi_vma_prep(&vp, vmg->target, adjust, remove, remove2); - - VM_WARN_ON(vp.anon_vma && adjust && adjust->anon_vma && - vp.anon_vma != adjust->anon_vma); - if (merge_target) { - /* Note: vma iterator must be pointing to 'start'. */ + /* Note: vma iterator must be pointing to 'start'. */ vma_iter_config(vmg->vmi, vmg->start, vmg->end); - } else { - vma_iter_config(vmg->vmi, adjust->vm_start + adj_start, - adjust->vm_end); } - if (vma_iter_prealloc(vmg->vmi, vmg->target)) + init_multi_vma_prep(&vp, vma, vmg); + + if (vma_iter_prealloc(vmg->vmi, vma)) return NULL; vma_prepare(&vp); - vma_adjust_trans_huge(vmg->target, vmg->start, vmg->end, adj_start); - vma_set_range(vmg->target, vmg->start, vmg->end, vmg->pgoff); - - if (merge_target) - vma_iter_store(vmg->vmi, vmg->target); + vma_adjust_trans_huge(vma, vmg->start, vmg->end, adj_start); + vma_set_range(vma, vmg->start, vmg->end, vmg->pgoff); if (adj_start) { adjust->vm_start += adj_start; adjust->vm_pgoff += PHYS_PFN(adj_start); - - if (!merge_target) - vma_iter_store(vmg->vmi, adjust); } - vma_complete(&vp, vmg->vmi, vmg->target->vm_mm); + vma_iter_store(vmg->vmi, vmg->target); + + vma_complete(&vp, vmg->vmi, vma->vm_mm); - return merge_target ? vmg->target : vmg->next; + return vmg->target; } /* We can only remove VMAs when merging if they do not have a close hook. */ @@ -836,11 +840,15 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( /* No matter what happens, we will be adjusting middle. */ vma_start_write(middle); - if (merge_left) - vma_start_write(prev); - - if (merge_right) + if (merge_right) { vma_start_write(next); + vmg->target = next; + } + + if (merge_left) { + vma_start_write(prev); + vmg->target = prev; + } if (merge_both) { /* @@ -850,7 +858,6 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( * extend delete delete */ - vmg->target = prev; vmg->start = prev->vm_start; vmg->end = next->vm_end; vmg->pgoff = prev->vm_pgoff; @@ -871,7 +878,6 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( * extend shrink/delete */ - vmg->target = prev; vmg->start = prev->vm_start; vmg->pgoff = prev->vm_pgoff; @@ -895,7 +901,6 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( VM_WARN_ON_VMG(vmg->start > middle->vm_start && prev && middle != prev, vmg); if (merge_will_delete_middle) { - vmg->target = next; vmg->end = next->vm_end; vmg->pgoff = next->vm_pgoff - pglen; } else { @@ -906,7 +911,6 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( * merged VMA is NOT vmg->target, but rather vmg->next. */ vmg->merge_flags |= __VMG_FLAG_ADJUST_NEXT_START; - vmg->target = middle; vmg->start = middle->vm_start; vmg->end = start; vmg->pgoff = middle->vm_pgoff; diff --git a/mm/vma.h b/mm/vma.h index ddf567359880..5be43e2bba3f 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -113,11 +113,7 @@ struct vma_merge_struct { struct vm_area_struct *prev; struct vm_area_struct *middle; struct vm_area_struct *next; - /* - * This is the VMA we ultimately target to become the merged VMA, except - * for the one exception of merge right, shrink next (for details of - * this scenario see vma_merge_existing_range()). - */ + /* This is the VMA we ultimately target to become the merged VMA. */ struct vm_area_struct *target; /* * Initially, the start, end, pgoff fields are provided by the caller