From patchwork Mon Jan 27 15:50:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13951576 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 3502AC02188 for ; Mon, 27 Jan 2025 15:51:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9731280172; Mon, 27 Jan 2025 10:51:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ACCC3280171; Mon, 27 Jan 2025 10:51:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A935280172; Mon, 27 Jan 2025 10:51:22 -0500 (EST) 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 63359280171 for ; Mon, 27 Jan 2025 10:51:22 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1F9D014030D for ; Mon, 27 Jan 2025 15:51:22 +0000 (UTC) X-FDA: 83053671204.18.2F4E1FB Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 44446C0020 for ; Mon, 27 Jan 2025 15:51:11 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=EtljPBpJ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="yx4dmS/Y"; spf=pass (imf28.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737993072; 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=1Mpx68EWduciawJBGblFrr1WVvICto8g1LTm3oOxpWY=; b=blBR1At3KVnH0P/clt9iEKnJlGHEVy6k4Q9z76TeqkK63hoi0FTTdf7smR906zF/vFN4Zu AyM5crCAYto5MxzwYFNymELGI0OVGDw/DisTSooVl24Kgti7PQFuWtfZArDA4wGiw3h3MQ 1TyKwxSAgn0DzQm00XW2q+NNOsKn1QM= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=EtljPBpJ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="yx4dmS/Y"; spf=pass (imf28.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1737993072; a=rsa-sha256; cv=pass; b=OZxLcP5Jm4IScb12tpmq1Dn+5Bx9NB692YYhBwUvuuM4xFHiHbkJyYda8I2YqoR/qETB/P UWqTp78+g2RzlPNO3jD5XXOYonuCJrosp99JRNhsrcAKk3j2Mqp8dCtjJ3HJcuILAR0rr9 Htu8+Q8DQmGbm5Etemze1tEHf6EtCLQ= 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 50RF7DYx009169; Mon, 27 Jan 2025 15:51:09 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=1Mpx68EWduciawJBGblFrr1WVvICto8g1LTm3oOxpWY=; b= EtljPBpJIgyLT2ZLRdNFxcj1A3tzCKJTjNL9yGgkswzILwRs3H7sqBYYYOgYhHZ+ jo7mWhHwJizpO5u1IBvWZBRcrnGjRUH6YEfCmZkI5Owv44HWO00ULD0+D150bIsu 1RsgOICyeHHveVJbULkSK+vBKfT3Ngnu0PBQIYuMpZT1g/xul6KRT1pefRAJyYWZ 5lCgkDLmpEPLN4LGdsOb8qoIZwe6SJJ2w2zIHpFr2M1sqV4a0A2UvT7Gd9IpwiBV /dCCgpmTKkied1jzy95JK8gFUcpOFiK/6CfHAnxE3+DuTBxURbvNgy4BsBR+SN4y kooBcHbxPFi7b947hLiu+A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44ecgf83qh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Jan 2025 15:51:09 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50RFSOpF005390; Mon, 27 Jan 2025 15:51:07 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 44cpd75syr-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Jan 2025 15:51:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bCE3RNG1Nd5N0n/DpMCdnMpWgdMh9dwwfWaRlnuMUXv9BMmWhVglKZkTpOzKaOi+IWvWj6B3i0zMVFVMnNGxyuAG+f6eeK3EQ3NwhutjRLxUvwvG1fOZkM8n+EO/TQdO3ig3sssFGP/Z8e+rhbfe8ecQNyyd4My5vYFkT1qMLD8VXNLzaenJJkP4MqFSsgopVvEdEIRTvAoBImedCoEbNGnzEmj19wxy6jPnwK5SXXhFFOr1AtN0UewYD+Fysn3Th9S2I6UsvjeoWqFLerwh3P9I21fIfhz7xExpv9ysxwq3CVLOPrkbzUnVzm0dFAenkq1z6EuNASy2TO/oAD998g== 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=1Mpx68EWduciawJBGblFrr1WVvICto8g1LTm3oOxpWY=; b=SdQWAyHB7oMQrYy4zfdV8vzx7f3KWJtV8IZ+oo23cYkR2cLay351MNKAoSR+HZWq+WKKvP8hOZ1AV/dNAaBnUl60e67a/5BoMfuorhUxXwaLw4taoq2rEbu1YNlIx1KJq1PI1cLnQ+ys31IJZ7wlDadBObvcdysgA2BVrc4/CtgbkHj+k0vb8sf7tNq37jkVp6xeWDqEUHezfqoJ1zzd8kfbEoCiuODg2ySbWkdqK33mR7IxyBnvI+n0V/zRgy++cvlBMe7jYXjLsthzYKhVtQ4/+J7IWvYsZajUPopk6KcK4O8buyoGU3cUmmIQhDOlCNxq4cO/0TuHaDgZWrgeAg== 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=1Mpx68EWduciawJBGblFrr1WVvICto8g1LTm3oOxpWY=; b=yx4dmS/YKKPxlYDmXmJFhkC1I+757QSONbzcqZtiK4t0AYGMERuqFbp12/64t/yfMMnYn1+f7aG+1F/fOLeyLpbICyDvHCqFXlKmdiHIRZbyJexP/fWbjbGFDXguZNEi879UJylDvEwOQBNxiwP/8STm/4E9lt+yQEX1T4QHemM= Received: from MN2PR10MB3374.namprd10.prod.outlook.com (2603:10b6:208:12b::29) by SA3PR10MB6949.namprd10.prod.outlook.com (2603:10b6:806:319::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.18; Mon, 27 Jan 2025 15:51:05 +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:05 +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 2/5] mm: further refactor commit_merge() Date: Mon, 27 Jan 2025 15:50:41 +0000 Message-ID: <0bbb2efbdc2ac2af2f6d73679cbb0811544d0647.1737929364.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.48.0 In-Reply-To: References: X-ClientProxiedBy: LO2P265CA0426.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::30) To MN2PR10MB3374.namprd10.prod.outlook.com (2603:10b6:208:12b::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB3374:EE_|SA3PR10MB6949:EE_ X-MS-Office365-Filtering-Correlation-Id: 94d045d5-3b3e-4444-11bc-08dd3eea68be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: tmLS0eagWC/8n4hLGwUxsxnK5EMLZk/HA+AVXwQPUpdh41PeYKTGPGMGMzPQPO6SOqsMcTCehA3eLSv3puQGk+HV1yU/3e8u5eMSWxHNTAEVEy0DWM29426Jzwu1mcXEjFivKkeF0iONTckJ+g4oZrxN4cbOc+f7GnTETh49xb70UPX32o9uWnm6Pii5NiKheq3Akex1XBCHoRT5k/nMOe4BUeZ9ahDTF0NzVfaPlJ1qmELjl6cwxgoLgp8NdZwffgTO/z9bo85IO6cBdd/jSgLPOqO32OL/T0Te8tNhXA637X9wwXVdACt19X8l0lEWoFlmyPGZcr0UyjWO4x5oSBkzB2BeyR5/Ctx/AdZdNjGvos3n6hhOGPLyX3qptvC1hLgYFTPthQUNc9x5TfDg8By4e+MCTd0wTc51jTB93O+4cOgYwpZoqygZgPhxIYxHYzb5g7ilckAtzHZJYNRUT/7jvWXaBWIt9z8bq0aZJ+nx0kw2Lj9QyRKkIaa7YOBjN/im4bwQxSOCF4jVBzJ+47oBy2/OqEuxtaCh1JPGffq/VfUVg/4sD7c1VRfosGp0xcXR6cdoh2yVOzpHTLGaespzYCSW/xa8fHa1fXszyVsu8h9ut+i2utn0JUfCwPyoZYWSPAbASbtzZn4huaElUS29QNtpt5/NrXoXPf/fSJ9/gJat9JV8n+H1fW35ax8+srKJr7LmLw5ujn3BkHJ2qT9hnl+m+zyozxtzKpuIU2/DeJlnf4n0LBKAKW2I4eBahIbG3I7OPaCGR8vF7simk8l8Ph/dWfJ6q/Rvyo68nl1Vi+g8aw23Cwo77uowfsDKRmh30d2ms/YDB1zKbdKJnGErgcsIZ4AL6W9VCBHlJbiqOQiCgdxkCtBySVPawhH4BFabjiilWP3rMB/9+u0bPGq4Qklt2a6gLn34bjTuNZHcLXQYzCZyqMktNuGUeBo9qlsDCynaWrW4Hy+Bix3dBxoSPsjs4GHSEQIaGkl6yhNL1d0nk0VTz1RQb924fUk3kbvObJ281ONXXrdCaqyzCzE1Z5VODav0AIfbtu8HOnfYe1mOJlLY9+yHcGHvX/hssXAFIrJD+3vqya4KrWHWJIHRBHQvhAYuRoDoCI+hdnZC0tC1XND+OWY3EwcaGFIXUrrijr6lZ2fGiZ+c10ssN+UDwq6hTXFvoBjHja5BV0yPUasq6ZEJC4P3kObUl6+genjfeckGxOouffmFRfAU6Q+nNC/u2i5dGJ+FLkxqUB3XngXOir82p0I6PzOxpb5r+iW1z2Jz0ZjQ64Vy0abt/uLFil3mneftErRVGcflsNEZ0d5/OPShq1YSp2HoHBAbbsRNKiTnfO3nTI07QTQJnR+XVcW8vvuoJX0AoO7YpXiXc16PAiBE57ekNKW5rGiY 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y2GRUHsaMmiSmCn9DUIrx5PYKtyMW3Su6wkigFoJZQ23OXyvYXh+bkKdOnyzvuPYu34Y6YGFlEo7jWjWf7RGa7nyo2tPHtgFXLDiCLHnvz0CIGsoV1REUiQFijlnieEO20nZKkK+EoF0MTPx46wX3FsNAH5rgG2NGRVxmBDAHH6WqlwMWmspBVsNLOmy3ilEOyQN6nqAMhneU0CKC/dvGOVka4PoLVHvLCeIGo8Em/SjAOtvgYo3vAbhYhTiaW6Q4brXD/1w3hxd/G9jewJAGdGJAY8rHxfWE2y+/emPEQSxImzpS+fpWHA9uYcHDMC6slOelAyzz2bWDsa18FRjXEUP4aPfZ5qqlAP/Wb7oRiolyFQBCpFaN+DVVKCaAh21HTqXyC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VOBd3LIkUZiglQ9++Lj/UykYtcS5IksofIwEnAxYeAWtu9kgYEKisaXlYDTslW6/d8VE5mP+hL3v7PAswEOLddzS/Fs1xuEGjSnsOkOknKxCqEl4PNZmw9Y8n1+KbOda7IfgcudyyyPjX6s15Ew5DQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5UaaQ+jS42s7RSjFk+x9JQgE3uTdQ1LEO3I/RuNxJt5XyaMPKxo+FV8WcaYyceEyOGU6mskRavhb88h58KUwP2Cpi2fBw/WSb7bNRXyhJUeqycj7tn4Hdn5VhBDQtVLAglSVTSieChuSkQ4FF5qGHyzmdpD47dvbSTPuUhyhPS8mxeiDmkqFnw8TVNtVlY0FNJpksqcGgfUrRDyhxT1IFqDYVDoijdxWXJIhVMuKE1IUULZJJfAa1Wg1jukcuJmyyu0Pnf4J1lptiBHY5+Cw2On1IFXAhqIx/8qIzr+nAt6VZTu2JYRXW17A6lHOJJ3daYqrLywY6T9v5k6W4rLh9b060X5V/VBVcITtHQpEdRo5N8BbsaHDrE4BqFdbb6MgucMkTeOi5nwHrQYOsHJEFqGXE/82FZ7ncEvvus2Mx/R/W29NJWS62eRsEmLQ11sraWViy4KuWyZGHNUimmS2NbYtjlQrva1Rcg0UZPPs1n0toYSRL24gDUc/MMadE5SaEJRG3nQBWV4CF0vbp8SdUV+6/zXOKX7cmAkcGOGjGynmtoQwhc48lR03POh10Sov/wvvyVfRgB+YBao3QaqLA2LZ3kz8yvyPdYxPn7KnuUc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94d045d5-3b3e-4444-11bc-08dd3eea68be 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:05.8284 (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: 7bB5fU0aLhB/y3RLSTc/r355B4Bj7YmzNBFTzo4RkqH3yxOT2q7j8LeyoMOzj6QYm2B4A4oUxw57jPQD21UR+4oQsnqysdkP4SpU5nvvTQo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB6949 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 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501270126 X-Proofpoint-GUID: miA__8bdjv4EOrO_16t3WpT8iDY42JOv X-Proofpoint-ORIG-GUID: miA__8bdjv4EOrO_16t3WpT8iDY42JOv X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 44446C0020 X-Stat-Signature: t4ostgcnzrwq5eo34qxtyafzpqx8awsw X-HE-Tag: 1737993071-943979 X-HE-Meta: U2FsdGVkX18BwaPLzBQs+jv2B+tTo2z/jvYeMBvSW6609DdozgwMdxfley0jTwE8xxJQMrVv2yeZiLCDiE7xaHcW15fpHvumFeQsw1osOGWEPm0/96vjIwtRWsaReGOnUjZWhAdUmyGMXljsViFeg12/ceWQtDEu7yjnyVLi4x3aMpzxE4i913zjjs55laF4uY77z7UDVvy3IoAyRo6NkIyEttxCxxfnwvbJtIWB3eRjAy8qiOEnzXZZbzqXQn3frufnuwDTjB4sshpiJbM+IAxfUGMkrv9gcfKzcbg7Tfs0VsChJk7S3ZZJItGdUlDCZNHJ3xXQ0IkQIdQVoogXWA5MC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ZhV2s4QSQ47VXnFKixwBEqCbs1lcsvdxfjuIGz8GoLaWdqF/KgxzbkEiANSfau+s70N1UkmJRy9+SENr7bicRHVcbT/Ln9EvhBWGucQKtzvYz2kA668KmqKRgMN8qAU3/WNJse8A7HIa4OSTarn0iKBfRijMInTd7Xosb4gE1KH8K/FIqKMlIuRFsNpIc= 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 current VMA merge mechanism contains a number of confusing mechanisms around removal of VMAs on merge and the shrinking of the VMA adjacent to vma->target in the case of merges which result in a partial merge with that adjacent VMA. Since we now have a STABLE set of VMAs - prev, middle, next - we are now able to have the caller of commit_merge() explicitly tell us which VMAs need deleting, using newly introduced internal VMA merge flags. Doing so allows us to embed this state within the VMG and remove the confusing remove, remove2 parameters from commit_merge(). We additionally are able to eliminate the highly confusing and misleading 'expanded' parameter - a parameter that in reality refers to whether or not the return VMA is the target one or the one immediately adjacent. We can infer which is the case from whether or not the adj_start parameter is negative. This also allows us to simplify further logic around iterator configuration and VMA iterator stores. Doing so means we can also eliminate the adjust parameter, as we are able to infer which VMA ought to be adjusted from adj_start - a positive value implies we adjust the start of 'middle', a negative one implies we adjust the start of 'next'. We are then able to have commit_merge() explicitly return the target VMA, or NULL on inability to pre-allocate memory. Errors were previously filtered so behaviour does not change. This patch has no change in functional behaviour. Signed-off-by: Lorenzo Stoakes Reviewed-by: Vlastimil Babka --- mm/vma.c | 83 +++++++++++++++++++++++------------------ mm/vma.h | 10 +++++ tools/testing/vma/vma.c | 3 ++ 3 files changed, 60 insertions(+), 36 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 68a301a76297..955c5ebd5739 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -120,8 +120,8 @@ static void init_multi_vma_prep(struct vma_prepare *vp, memset(vp, 0, sizeof(struct vma_prepare)); vp->vma = vma; vp->anon_vma = vma->anon_vma; - vp->remove = remove; - vp->remove2 = remove2; + 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; @@ -129,7 +129,6 @@ static void init_multi_vma_prep(struct vma_prepare *vp, vp->file = vma->vm_file; if (vp->file) vp->mapping = vma->vm_file->f_mapping; - } /* @@ -629,22 +628,40 @@ void validate_mm(struct mm_struct *mm) } #endif /* CONFIG_DEBUG_VM_MAPLE_TREE */ -/* Actually perform the VMA merge operation. */ -static int commit_merge(struct vma_merge_struct *vmg, - struct vm_area_struct *adjust, - struct vm_area_struct *remove, - struct vm_area_struct *remove2, - long adj_start, - bool expanded) +/* + * Actually perform the VMA merge operation. + * + * On success, returns the merged VMA. Otherwise returns NULL. + */ +static struct vm_area_struct *commit_merge(struct vma_merge_struct *vmg, + long adj_start) { struct vma_prepare vp; + struct vm_area_struct *remove = NULL; + struct vm_area_struct *remove2 = NULL; + struct vm_area_struct *adjust = NULL; + /* + * In all cases but that of merge right, shrink next, we write + * vmg->target to the maple tree and return this as the merged VMA. + */ + bool merge_target = adj_start >= 0; + + if (vmg->merge_flags & __VMG_FLAG_REMOVE_MIDDLE) + remove = vmg->middle; + if (vmg->merge_flags & __VMG_FLAG_REMOVE_NEXT) + remove2 = vmg->next; + + if (adj_start > 0) + adjust = vmg->middle; + else if (adj_start < 0) + adjust = 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 (expanded) { + if (merge_target) { /* Note: vma iterator must be pointing to 'start'. */ vma_iter_config(vmg->vmi, vmg->start, vmg->end); } else { @@ -653,27 +670,26 @@ static int commit_merge(struct vma_merge_struct *vmg, } if (vma_iter_prealloc(vmg->vmi, vmg->target)) - return -ENOMEM; + 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 (expanded) + if (merge_target) vma_iter_store(vmg->vmi, vmg->target); if (adj_start) { adjust->vm_start += adj_start; adjust->vm_pgoff += PHYS_PFN(adj_start); - if (adj_start < 0) { - WARN_ON(expanded); + + if (!merge_target) vma_iter_store(vmg->vmi, adjust); - } } vma_complete(&vp, vmg->vmi, vmg->target->vm_mm); - return 0; + return merge_target ? vmg->target : vmg->next; } /* We can only remove VMAs when merging if they do not have a close hook. */ @@ -718,7 +734,6 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( struct vm_area_struct *prev = vmg->prev; struct vm_area_struct *next, *res; struct vm_area_struct *anon_dup = NULL; - struct vm_area_struct *adjust = NULL; unsigned long start = vmg->start; unsigned long end = vmg->end; bool left_side = middle && start == middle->vm_start; @@ -727,7 +742,6 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( long adj_start = 0; bool merge_will_delete_middle, merge_will_delete_next; bool merge_left, merge_right, merge_both; - bool expanded; mmap_assert_write_locked(vmg->mm); VM_WARN_ON_VMG(!middle, vmg); /* We are modifying a VMA, so caller must specify. */ @@ -846,10 +860,11 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( vmg->start = prev->vm_start; vmg->pgoff = prev->vm_pgoff; - if (!merge_will_delete_middle) { - adjust = middle; + /* + * We both expand prev and shrink middle. + */ + if (!merge_will_delete_middle) adj_start = vmg->end - middle->vm_start; - } err = dup_anon_vma(prev, middle, &anon_dup); } else { /* merge_right */ @@ -883,7 +898,6 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( vmg->end = start; vmg->pgoff = middle->vm_pgoff; - adjust = next; adj_start = -(middle->vm_end - start); } @@ -893,17 +907,13 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( if (err) goto abort; - /* - * In nearly all cases, we expand vmg->middle. There is one exception - - * merge_right where we partially span the VMA. In this case we shrink - * the end of vmg->middle and adjust the start of vmg->next accordingly. - */ - expanded = !merge_right || merge_will_delete_middle; + if (merge_will_delete_middle) + vmg->merge_flags |= __VMG_FLAG_REMOVE_MIDDLE; + if (merge_will_delete_next) + vmg->merge_flags |= __VMG_FLAG_REMOVE_NEXT; - if (commit_merge(vmg, adjust, - merge_will_delete_middle ? middle : NULL, - merge_will_delete_next ? next : NULL, - adj_start, expanded)) { + res = commit_merge(vmg, adj_start); + if (!res) { if (anon_dup) unlink_anon_vmas(anon_dup); @@ -911,9 +921,7 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( return NULL; } - res = merge_left ? prev : next; khugepaged_enter_vma(res, vmg->flags); - vmg->state = VMA_MERGE_SUCCESS; return res; @@ -1076,7 +1084,10 @@ int vma_expand(struct vma_merge_struct *vmg) middle->vm_end > vmg->end, vmg); vmg->target = middle; - if (commit_merge(vmg, NULL, remove_next ? next : NULL, NULL, 0, true)) + if (remove_next) + vmg->merge_flags |= __VMG_FLAG_REMOVE_NEXT; + + if (!commit_merge(vmg, 0)) goto nomem; return 0; diff --git a/mm/vma.h b/mm/vma.h index 5b5dd07e478c..ffbfefb9a83d 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -67,6 +67,16 @@ enum vma_merge_flags { * at the gap. */ VMG_FLAG_JUST_EXPAND = 1 << 0, + /* + * Internal flag used during the merge operation to indicate we will + * remove vmg->middle. + */ + __VMG_FLAG_REMOVE_MIDDLE = 1 << 1, + /* + * Internal flag used during the merge operationr to indicate we will + * remove vmg->next. + */ + __VMG_FLAG_REMOVE_NEXT = 1 << 2, }; /* diff --git a/tools/testing/vma/vma.c b/tools/testing/vma/vma.c index 3c0572120e94..8cce67237d86 100644 --- a/tools/testing/vma/vma.c +++ b/tools/testing/vma/vma.c @@ -154,6 +154,9 @@ static void vmg_set_range(struct vma_merge_struct *vmg, unsigned long start, vmg->end = end; vmg->pgoff = pgoff; vmg->flags = flags; + + vmg->merge_flags = VMG_FLAG_DEFAULT; + vmg->target = NULL; } /*