From patchwork Wed Jan 29 18:16:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13954035 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 C95B9C0218D for ; Wed, 29 Jan 2025 18:16:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58ACB6B00A8; Wed, 29 Jan 2025 13:16:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 51366280267; Wed, 29 Jan 2025 13:16:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FC77280263; Wed, 29 Jan 2025 13:16:59 -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 0A1646B00A8 for ; Wed, 29 Jan 2025 13:16:59 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B60A1AECC5 for ; Wed, 29 Jan 2025 18:16:58 +0000 (UTC) X-FDA: 83061295716.15.06B4FA7 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf19.hostedemail.com (Postfix) with ESMTP id D55D91A0007 for ; Wed, 29 Jan 2025 18:16:54 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=V9pILdTv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="NvF/g3r0"; spf=pass (imf19.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=1738174615; 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=xA4gZ9w/va1zf05DIuTP0c45SbSoox/E5exGi8usm5U=; b=XVhfLZh49LfsGHxnE8fYWJpfKD48/TiBtGWqvVM9Noyr+QGpWSANtgJNK8Usd9yNbKKNQ2 HfFgceze7HZaLQTi+hagVmadIjF517Hx/KKoQo1gzyxop4awbjgVIPX0NW59FVqNjIvfW7 zpjC88YLhfbEzlypkmTlyi9/TZ5UhCk= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=V9pILdTv; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="NvF/g3r0"; spf=pass (imf19.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=1738174615; a=rsa-sha256; cv=pass; b=06Vl2NlE31uHOaazsQZLIPnHa/lDzMX9RBmML8ukgVRrbiYh/5smt4Dq+sMLE3GT06J5+j /rWCWFMzNiUpWAuzwe2MBtLCyZ9Rgk5blogiIHuYT3X2mmOmRPxl2/bBb5Tu07QRVt2Y7W M/jvbV0wWQqLGTrlVjk4Kg++BNvuD+4= 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 50THZ2cw016238; Wed, 29 Jan 2025 18:16:52 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=xA4gZ9w/va1zf05DIuTP0c45SbSoox/E5exGi8usm5U=; b= V9pILdTvdqdMg3haBh+2CmclrXizJIjoIO1sXjlVt9TC1mIulJMOtH6UZwDDNmK5 dlvwd4Qc3o7I2f39D94BRNgIkxVawrrPVVDLBHZ93t188CT8GF9yRmjsqzlcYPAI XO3zdYrrh+1IWnBvUFIctkLeCgc11ZqmJyJtw0J8lEgR037fAqZrCSTD1/3kFgpD QgQzgy4VL7Exk3nu+0/HXjc3QhUjg10Qt25FS99dMy0evnOjraUe72C2/Aa/QwwF 8WVXHNM/rVLkUGWFi0k13nmHBcnUWWlf64pg9K7MVFOyN0qxI9ZHevLIFohfreMa HqNJouI0+8q5aqCl2BuFiA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 44frus03yw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jan 2025 18:16:52 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50TI2Ina013779; Wed, 29 Jan 2025 18:16:51 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2048.outbound.protection.outlook.com [104.47.57.48]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44cpd9tvn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jan 2025 18:16:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M3yj0y268QrXAnyK7zH04XR2uxa1UvSvsEeAQWIQOhXZ3LH3ccU+7i4WgxMbw9GU9qBDc3isqRJ+AO176ZMvD071y72P7fOTszfqBI+lgwS2SoFWEtfqs9rzBPWMjqxhy02ec7OEaubzlPS76ergNvRvy3KbOKoVZek9xDmZ2eVbysStOjqzgLVH3VLg1FOB54NOonoSkOBQuD55E/Z8yB6QK97JplVJhfW/a6kbvVZpmWjxlLnui23/02ELYjf7lJ/ODdzaRbBVmvMZaQSEHC5EhJKkLLAaFNo5ODMj9bLXoFzjiZUeJC+wwGtTlx7th9Ml98jDz763u7jwgqrRRg== 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=xA4gZ9w/va1zf05DIuTP0c45SbSoox/E5exGi8usm5U=; b=PDlrSvKPcVbGlbQhxnVOHfzhLW1WDT2lU/dQraA/q2+VO+a9UpyrIR5Mqjhuq88ij3AyPVRPCxSfsiaSv4x0VXyXdrKXJ+Jc/kEWOznjB+jVhA8fDnBFC0PKAF2wfTXba/28XzRBGn+7jYDwW6kDyKbXcYTI2WtHTXSdpCXqMfb5WAM8Oxupts0QIeLSi/avrYNd1BNL2lpmquR+edUCj3sxLToLR1OJg3XN2UGscCUNhoNA8yBPWimjPo/l9qtfUgMYMpEiKNE1SkqIcPxkUIpClW2Ahm0PkQRwdgoiW5ci9G7L/w/+YkBK39HSXBebToaTMJjnDCBA1tWMbiig+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=xA4gZ9w/va1zf05DIuTP0c45SbSoox/E5exGi8usm5U=; b=NvF/g3r0br2KFzz+c/lMFDATFad31eX4LlSsPbNMisHZfDGH0ird7ZBmMcNwy/PMyeQgIm11T1HgtUZXNhmgFZcStX4UTLyDVs5dUqUAEwqYD5Jf+DWg1Nc6+Ra8Ctpe+NbwHlXCiGNOD3ha2vXhoaHR91YYo02q1ELxtenVA6c= Received: from MN2PR10MB3374.namprd10.prod.outlook.com (2603:10b6:208:12b::29) by DM6PR10MB4314.namprd10.prod.outlook.com (2603:10b6:5:216::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.18; Wed, 29 Jan 2025 18:16:49 +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.8398.014; Wed, 29 Jan 2025 18:16:49 +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 v2 2/5] mm: further refactor commit_merge() Date: Wed, 29 Jan 2025 18:16:36 +0000 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: X-ClientProxiedBy: LO6P123CA0041.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:2fe::12) To MN2PR10MB3374.namprd10.prod.outlook.com (2603:10b6:208:12b::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB3374:EE_|DM6PR10MB4314:EE_ X-MS-Office365-Filtering-Correlation-Id: 8693c3ed-46d0-4538-b672-08dd409118de 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: C/mC4ePDDKqwhazD2BN5EFWAJOXNLk2UcF/icnSqExFokGONOE9OHZzNPCsKLC8v4dD6seUZJXEhqlDqFLr4WUqWsHpWixoV+ERNKulIbE76Q4GJx3mOiBAvt3aPe0Ldbbd33dDiX52k1K5ZLpyLrObNoZmhhRyyPU5UWQYBaiXyVNFFnoxw283ljkDkCaVc513wccAWW2PjGKBP4NMscqAmGdzuqf+90mMH/gO25mPp9yeOB2mj6Foj4s25xxTe3wAw0dLS0xaN9UzYr9S2Yg9jiaOSs+zdB7QG5E3/GWciYV6z1dCwt7xXMUMsyknvID9JfCnkShyXpvHxmyJaWbAo0Y3/o/FMLvzMCYsSjVFgD2BFvZrM+9G5G9wZetpgQQUh28zfH/LQOQD4GGad29kJzeD6+A7rw0SULnPrZO0dmCZgUM0DbEj3F9MdL/mL+E72LH8nilcZNvD18WxOqfIlk2+39oqaqKHMtktzCrUBe3FLbGTN4F7xfPr6xSMOlOyIxszACN1MGf5+FsUP8PPrNOgo17G/rVL7kA1SyJOUfZ4JI6zbz9o7IzPU9zVQ2u4KrPB3Re7oji2HmiBagEk60Z7e09PGsD1PTz5c4wNLEDXJCOY/wmkEh4Iqgfoer0wOXPSQExkPDqAYXAnbhZkZ4jPubg8K58+FO9ZLyzL8+ww60+R5HFEdMVnpkM8oKPYxXld9HtBFLgeNyamDypfHNZ2d5jbZ7ilzj7wbsJKBFRqXebUmqBi+rG1ucb4bjz+EtMhA0PCMzlR85HE7ejGaNqZJ4Ck0aUK9tyV28HPcgoflaQlx0o42s/e9sosyfvT1339RNMds8XX+oTT9wd9a86wM3L6n2hNJLXDcIrVJTBVCm/afYj0k71MjwipKbbV5FQsgGgle0SijlamblUcvtO360G6BL6AvrWLNi8WtPpLSxWpgo/V1O8AJHV4AdqjRf02HFxpCDhubDPw/+ib3h0/5Khbv4U7Q1FatjgxmbkiFq++wHH7mm/+bZybWBrQgJZvnopuukiEqgPtNFxNLllN6r4FT777m5hPGCj+2kQOvRi5ya6udEwpx1iX1LxZQOCOLRDhp1P7yBfQezBfMZPsif1khbJ8HoS0aF443vS5T7VdEXWJ3z/p6MM5TgO/OOTM0u0iOjOG57XSbQmATE0sAvMQApD4dFSmM2u08wUxEeHec1ipdcHBjaxdrIrgRpvh+uFy9TQOWoCScxCrcWOYIPWRA0Si1pil9CxIgXOZ3nsYqh7LltgD22vmZ8a69LmXqv0BiMOwe4qyqhidUZgOpyLUxuAUSp5El966BWVHvEU3Cpr+j7fhWvfdjCngASl1xXkLDfbRTNwx3Ng4E5eYPM5NKTRgJLtgmaJamZ6UUzst9fTQE+zElj/AM 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: t6MFV2AbX1F9DbMlfgWPgT8x176+xTzXV4wUPIPKk6yMEnb+QJKrvcbFFVQQf9ASe+SzRoEnVzNhciKaSnuDjlv0AeYpN4OK7hofA77PZWKTMgikKkNIqd+VJzn1Nm/yVxMha0WrLi/lv5scghRLsmB96Uaq1lF0EhTNirCc0PA+yWtOEytj/YsbYZIjG/rQscRcz7CzGnjdgEVUiYWqMKhdzkzaZ4N33sjlhufrIixj0MLvXWJzLgiVJcLcoPqiA9QTlvk+zJ/CzPnRnTwmFfTbcGtciBMun/fdb5jYuh3QjQ80WoCL/wN0WZ15Dhsh3aJeOafEW1qltywZxaWqphpkTKUQRgjLuAU9SRMhKqHH0zibdPHOlo9obD72Ba849itaE12EFL0AfFVv+DD0jBQShzV+Ky3SzyQCFBmVLhttRsy55UpKdN8alMHC/GDoX/z12gbpKdHR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MQFDnranQUm4H+FGeNUO7Hif2d04L/3q6bLzbuJpaj6251nnmG7JBiCWeDidzLzWEEyKeJm6/rK/h5YBmSyg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: M8eNZuK2F1ZNP36Rxye7iFYWNuw+atNmEtCxD4vc8tTbQRKpGZJSUtInltQaBKZ0Nu3VTM8XP69qwYN9YeN2Exc2PetqjcrKNrf64KCjH4cz72/WUieTvwbz/7YPJNOcq+VZd+LVFNAu0uXnKBkOtiAiRB208oO/w9O0f8Ugu67zxp//eJzsb2Dm/TuBIP5FaS8UpjfLJmIaZP35g45sQ+WZ6srhvjX+tlUt6U4UvphFlc99Ynnhagu/9+jMRVkoB6pETvgvfW/O0v9PbgDZHay3NhAz/TTtrH7sMGV9tM1nsZ5byoFUMoov4OwSySsPIk5saZphg0pujafCS04sF3EM7SUi3IpGDuCl+9MPxgWtlpL7Jq39kUUR8vjfen0bkoNjHxUyzmIkRa2yyXf12HAFF96HTswb6TgsSzB409umAFpAzNQvQ7NbFy1qU1fj4VWAtyQp6CFbgs2LPcdNFxX8pzJHEPk0hbvQZSuQDYAN6qipUy2UgNrguQnZfqkoMQQLxOIR15sY9ikcJDUtJCsN3za8zh5hvU7rJCsJdlGhtvDXNF/diup4hO30eA6bY8O0wWpb62LAigFJiRX63/WGu43U7HR4YkI3GR+nr1w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8693c3ed-46d0-4538-b672-08dd409118de X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3374.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2025 18:16:49.4896 (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: dh2RR12cbJpHyhj5UZ5hR68nNEz1dYnBpj9iLiqYAbvQ5i9GUbPYQaIF1q7VVcCP5G2IrzM2IAq2C0LrNVlCoQOsXRHSoikE9nkKrhn5Ezc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4314 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-29_03,2025-01-29_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501290143 X-Proofpoint-GUID: zaZq_0I9gP537w9k2Werwo5uK8MpHFYv X-Proofpoint-ORIG-GUID: zaZq_0I9gP537w9k2Werwo5uK8MpHFYv X-Rspamd-Queue-Id: D55D91A0007 X-Stat-Signature: mws7n9ah88z93pi897r6rxm1rduuu18c X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1738174614-976101 X-HE-Meta: U2FsdGVkX19y4yjaq9pzXK/0VVSViCZut4vau2WUJA2CYPiI+3wcyRebvk/RFLkjnCmtY75lhet9J2VjDfyUGUlC4PMzwa2sy5deqynFNq7Z0AoaCp20a3ckx6Eg07SWtCwnEI6HscIqwNKcKK82KKRtJrfK6f9v3YAxvjYo/axOOJkW/9mtaVF0RIzUjuFletlwX65hcvp3uaWZ1LLkQnK9u7Zv26EfbaFN0n4oOCmOq/4ShVEzV14VEapCk11F9r4NOzkHMRwiMz6KnuJuyv252WBAgxnwINW8Mt5G/OxkZxbBuhm2y1fbD9kQ5wbTtU/bFQREDWW8U+q7SR5MqC91qKM4b4G4MXcqrIMQGvS8d303QnO7iWnEi2KWkTv/zEaj5mhlIuOvfzSeuO1+WIx2phfJxCMKATkhZQ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HMg1jqGwrHfTyThnI0mMDF7hni0T/SJW7HWl+ogs35zomzPveJH3/x2gDAJsJMHKHsnozse0uB/YRK12BgCaIVwFWCZ2O4zC 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. We additionally move from the slightly odd use of a bitwise-flag enum vmg->merge_flags field to vmg bitfields. This patch has no change in functional behaviour. Signed-off-by: Lorenzo Stoakes Reviewed-by: Vlastimil Babka --- mm/debug.c | 6 ++- mm/vma.c | 101 +++++++++++++++++++++------------------- mm/vma.h | 38 +++++++++------ tools/testing/vma/vma.c | 9 +++- 4 files changed, 87 insertions(+), 67 deletions(-) diff --git a/mm/debug.c b/mm/debug.c index c9e07651677b..92936908ed0f 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -266,7 +266,8 @@ void dump_vmg(const struct vma_merge_struct *vmg, const char *reason) "file %px anon_vma %px policy %px\n" "uffd_ctx %px\n" "anon_name %px\n" - "merge_flags %x state %x\n", + "state %x\n" + "just_expand %b __remove_middle %b __remove_next %b\n", vmg, vmg->mm, vmg->pgoff, vmg->vmi, vmg->vmi ? vma_iter_addr(vmg->vmi) : 0, vmg->vmi ? vma_iter_end(vmg->vmi) : 0, @@ -279,7 +280,8 @@ void dump_vmg(const struct vma_merge_struct *vmg, const char *reason) (void *)0, #endif vmg->anon_name, - (int)vmg->merge_flags, (int)vmg->state); + (int)vmg->state, + vmg->just_expand, vmg->__remove_middle, vmg->__remove_next); if (vmg->mm) { pr_warn("vmg %px mm:\n", vmg); diff --git a/mm/vma.c b/mm/vma.c index 68a301a76297..206e3523cf38 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -55,7 +55,6 @@ struct mmap_state { .middle = vma_, \ .next = (vma_) ? NULL : (map_)->next, \ .state = VMA_MERGE_START, \ - .merge_flags = VMG_FLAG_DEFAULT, \ } static inline bool is_mergeable_vma(struct vma_merge_struct *vmg, bool merge_next) @@ -120,8 +119,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 +128,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 +627,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->__remove_middle) + remove = vmg->middle; + if (vmg->__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 +669,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,16 +733,13 @@ 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; bool right_side = middle && end == middle->vm_end; int err = 0; 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. */ @@ -779,27 +791,27 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( merge_both = merge_left && merge_right; /* If we span the entire VMA, a merge implies it will be deleted. */ - merge_will_delete_middle = left_side && right_side; + vmg->__remove_middle = left_side && right_side; /* * If we need to remove middle in its entirety but are unable to do so, * we have no sensible recourse but to abort the merge. */ - if (merge_will_delete_middle && !can_merge_remove_vma(middle)) + if (vmg->__remove_middle && !can_merge_remove_vma(middle)) return NULL; /* * If we merge both VMAs, then next is also deleted. This implies * merge_will_delete_vma also. */ - merge_will_delete_next = merge_both; + vmg->__remove_next = merge_both; /* * If we cannot delete next, then we can reduce the operation to merging * prev and middle (thereby deleting middle). */ - if (merge_will_delete_next && !can_merge_remove_vma(next)) { - merge_will_delete_next = false; + if (vmg->__remove_next && !can_merge_remove_vma(next)) { + vmg->__remove_next = false; merge_right = false; merge_both = false; } @@ -846,10 +858,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 (!vmg->__remove_middle) adj_start = vmg->end - middle->vm_start; - } err = dup_anon_vma(prev, middle, &anon_dup); } else { /* merge_right */ @@ -867,7 +880,7 @@ static __must_check struct vm_area_struct *vma_merge_existing_range( /* If we are offset into a VMA, then prev must be middle. */ VM_WARN_ON_VMG(vmg->start > middle->vm_start && prev && middle != prev, vmg); - if (merge_will_delete_middle) { + if (vmg->__remove_middle) { vmg->target = next; vmg->end = next->vm_end; vmg->pgoff = next->vm_pgoff - pglen; @@ -883,7 +896,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 +905,8 @@ 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 (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 +914,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; @@ -974,7 +975,6 @@ struct vm_area_struct *vma_merge_new_range(struct vma_merge_struct *vmg) struct vm_area_struct *next = vmg->next; unsigned long end = vmg->end; bool can_merge_left, can_merge_right; - bool just_expand = vmg->merge_flags & VMG_FLAG_JUST_EXPAND; mmap_assert_write_locked(vmg->mm); VM_WARN_ON_VMG(vmg->middle, vmg); @@ -988,7 +988,7 @@ struct vm_area_struct *vma_merge_new_range(struct vma_merge_struct *vmg) return NULL; can_merge_left = can_vma_merge_left(vmg); - can_merge_right = !just_expand && can_vma_merge_right(vmg, can_merge_left); + can_merge_right = !vmg->just_expand && can_vma_merge_right(vmg, can_merge_left); /* If we can merge with the next VMA, adjust vmg accordingly. */ if (can_merge_right) { @@ -1011,7 +1011,7 @@ struct vm_area_struct *vma_merge_new_range(struct vma_merge_struct *vmg) vmg->end = end; /* In expand-only case we are already positioned at prev. */ - if (!just_expand) { + if (!vmg->just_expand) { /* Equivalent to going to the previous range. */ vma_prev(vmg->vmi); } @@ -1076,7 +1076,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->__remove_next = true; + + if (!commit_merge(vmg, 0)) goto nomem; return 0; @@ -2588,7 +2591,7 @@ int do_brk_flags(struct vma_iterator *vmi, struct vm_area_struct *vma, vmg.prev = vma; /* vmi is positioned at prev, which this mode expects. */ - vmg.merge_flags = VMG_FLAG_JUST_EXPAND; + vmg.just_expand = true; if (vma_merge_new_range(&vmg)) goto out; diff --git a/mm/vma.h b/mm/vma.h index 5b5dd07e478c..7935681a2db8 100644 --- a/mm/vma.h +++ b/mm/vma.h @@ -58,17 +58,6 @@ enum vma_merge_state { VMA_MERGE_SUCCESS, }; -enum vma_merge_flags { - VMG_FLAG_DEFAULT = 0, - /* - * If we can expand, simply do so. We know there is nothing to merge to - * the right. Does not reset state upon failure to merge. The VMA - * iterator is assumed to be positioned at the previous VMA, rather than - * at the gap. - */ - VMG_FLAG_JUST_EXPAND = 1 << 0, -}; - /* * Describes a VMA merge operation and is threaded throughout it. * @@ -117,8 +106,31 @@ struct vma_merge_struct { struct mempolicy *policy; struct vm_userfaultfd_ctx uffd_ctx; struct anon_vma_name *anon_name; - enum vma_merge_flags merge_flags; enum vma_merge_state state; + + /* Flags which callers can use to modify merge behaviour: */ + + /* + * If we can expand, simply do so. We know there is nothing to merge to + * the right. Does not reset state upon failure to merge. The VMA + * iterator is assumed to be positioned at the previous VMA, rather than + * at the gap. + */ + bool just_expand :1; + + /* Internal flags set during merge process: */ + + /* + * Internal flag used during the merge operation to indicate we will + * remove vmg->middle. + */ + bool __remove_middle :1; + /* + * Internal flag used during the merge operationr to indicate we will + * remove vmg->next. + */ + bool __remove_next :1; + }; static inline bool vmg_nomem(struct vma_merge_struct *vmg) @@ -142,7 +154,6 @@ static inline pgoff_t vma_pgoff_offset(struct vm_area_struct *vma, .flags = flags_, \ .pgoff = pgoff_, \ .state = VMA_MERGE_START, \ - .merge_flags = VMG_FLAG_DEFAULT, \ } #define VMG_VMA_STATE(name, vmi_, prev_, vma_, start_, end_) \ @@ -162,7 +173,6 @@ static inline pgoff_t vma_pgoff_offset(struct vm_area_struct *vma, .uffd_ctx = vma_->vm_userfaultfd_ctx, \ .anon_name = anon_vma_name(vma_), \ .state = VMA_MERGE_START, \ - .merge_flags = VMG_FLAG_DEFAULT, \ } #ifdef CONFIG_DEBUG_VM_MAPLE_TREE diff --git a/tools/testing/vma/vma.c b/tools/testing/vma/vma.c index 3c0572120e94..7728498b2f7e 100644 --- a/tools/testing/vma/vma.c +++ b/tools/testing/vma/vma.c @@ -149,11 +149,16 @@ static void vmg_set_range(struct vma_merge_struct *vmg, unsigned long start, vmg->prev = NULL; vmg->middle = NULL; vmg->next = NULL; + vmg->target = NULL; vmg->start = start; vmg->end = end; vmg->pgoff = pgoff; vmg->flags = flags; + + vmg->just_expand = false; + vmg->__remove_middle = false; + vmg->__remove_next = false; } /* @@ -1546,7 +1551,7 @@ static bool test_expand_only_mode(void) /* * Place a VMA prior to the one we're expanding so we assert that we do * not erroneously try to traverse to the previous VMA even though we - * have, through the use of VMG_FLAG_JUST_EXPAND, indicated we do not + * have, through the use of the just_expand flag, indicated we do not * need to do so. */ alloc_and_link_vma(&mm, 0, 0x2000, 0, flags); @@ -1558,7 +1563,7 @@ static bool test_expand_only_mode(void) vma_iter_set(&vmi, 0x3000); vma_prev = alloc_and_link_vma(&mm, 0x3000, 0x5000, 3, flags); vmg.prev = vma_prev; - vmg.merge_flags = VMG_FLAG_JUST_EXPAND; + vmg.just_expand = true; vma = vma_merge_new_range(&vmg); ASSERT_NE(vma, NULL);