From nobody Fri Dec 19 17:33:13 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65F50238C36 for ; Wed, 16 Apr 2025 10:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744799963; cv=fail; b=uAvVlg5AL4ylSxk7OuXv0jCsoL5Q9S4+xX7TSR+zsxSEF47UF2b5wfYZ+6pyQcUH/UABIfO7e7FREPnWIavlt8W7j+/LGdS4hXqbsXU+Bpa+7sySxKTxO5yD0p81C5ZaY6Oj/CLM3umB1v939nE3Oum592S3SxHQGUj7KLJyjB4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744799963; c=relaxed/simple; bh=U0cYx5Lu+rkWpxA7+d6Pnin8sJyizVoJAxakRNDIe2A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Y069kQNJSp/KAsQ/tupIDT3alf+NEGRIAGMx6wQHyMzSZlNXyqqKKcTJ3nJK7miCgPG79eh6MPLpFf4kxeJr1iFe2C1SwZiJ96F3BF89YY+m2FIZ4svPdFwzbW0Ghn/xPQ/fohwyFe6py/fRUSWZiJPhk0L7gah9c/DyGcLrWts= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=JmJ+3Xh7; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Mf+cCTfH; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="JmJ+3Xh7"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Mf+cCTfH" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 53G9Mp7W031339; Wed, 16 Apr 2025 10:38:56 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=fDKk1GjDgLOi28YjcTBzkc8QK0HIn4cA/j68CeRKKL4=; b= JmJ+3Xh719cw63hNak6NLrRgKBMKLDxPyAKrfa47h3p1Lr7tUnPEwqD974bH3MXt 34hRTvHcBc/MVkj1+DISQJgu8+RXUKbgvklBprOJwDNYV1XqlQld3u/MIuI+SlUM EcFMjPMPCOtdKx6TTNazyMvwQwn7KlhPIq2w+D7I4yNLH5FCT5H3pihEVZrw3z5v 0VCkUazuhvEkTf8s19TEbNjHVxy2QZPc18cVhcQO0mBoR0r331c3pw4Tajzt3Ew4 umf28HLhUXOlNivq33XAy/D5C1EtGWVs5I7Vwp8dXW60Ogt+YDXNzycwW8wzzOYq 2EUJ7lFrBXnJzWqzbo0vrA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4617jubv2r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Apr 2025 10:38:55 +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 53G9i5MT038859; Wed, 16 Apr 2025 10:38:55 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2049.outbound.protection.outlook.com [104.47.70.49]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 460d4sq062-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Apr 2025 10:38:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oDruz/I/UE6GPLwUCTy3gOuQlsICkbZVn/nw+HsiH2WTxPEEiyJCQ9ZyR+9Li2ifeFMIANQxO5+SzjrC7WRMRWrPswfQ1sCyD0uNT6p2S8UCrNPpLptHPvzADYqPkBVb2JsQVo7FWgkg077NDyMncxS9P4pHU1TdfdmXY8I0GkBB9++ovP8bBVmIuMlI5oWHJbJznxdumm4aIiW9nMk7GT+kB98wo/LueYwEaAawtmUK8UN4pPJ7pkGAuL12u7Me4WV31kWyEd3Z7Vp6E6HmFOBPgYhPh5PgrJX9n/rK4/jMOXdXm0oWjY2KXMbdEkWFIgsx+vaWbNfqxLFIsc7BcQ== 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=fDKk1GjDgLOi28YjcTBzkc8QK0HIn4cA/j68CeRKKL4=; b=CXHWmS2ZcQCxi2I91/Zb+oHzr2b79fR7jvy1IOXesaSsQuJ7A5KOEgWIUJD/VRPEgxLv3FweyIm+h0Roo/gmYQwNMszlhCixT0ccCVQTWx4pcApixY7KoazMXyGNSRhOsWgjJOVdO/4LzitgPV8VV0wPDxywPop5lVKlBJF3ger//3LSCj7WNkrxtVr6Cp4/WKcCf8cVxK5nSOj1+u2RgYDfJ3Iod1dNfGvU/6MiBWexFPkDLSw3yhWLckBJk8eQy4iUlW8fhXwj1JPtVqItlhO69Uq5TKfOhmxSS4ksinZoUY0ia6rD8VmHpZYbs5a1hETqz0Rh8P+YWaTE+z4x/Q== 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=fDKk1GjDgLOi28YjcTBzkc8QK0HIn4cA/j68CeRKKL4=; b=Mf+cCTfHc9CGT7ncztLONZsl9cl9rRIBtpXn3JBdSrlEFdaxoe5TB9CQTeM7ahy7eeuC79JTc8MxuUzUg090AELiG/4fCbo7TAYSc75stPxs3/P9v/dnuuSWrSKPEkvYfj4F7AGYAuZT6no+XILz8exIVw9ur8HmU1PD7BdjPzw= Received: from DM4PR10MB8218.namprd10.prod.outlook.com (2603:10b6:8:1cc::16) by CY5PR10MB5916.namprd10.prod.outlook.com (2603:10b6:930:2c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.22; Wed, 16 Apr 2025 10:38:53 +0000 Received: from DM4PR10MB8218.namprd10.prod.outlook.com ([fe80::2650:55cf:2816:5f2]) by DM4PR10MB8218.namprd10.prod.outlook.com ([fe80::2650:55cf:2816:5f2%5]) with mapi id 15.20.8632.036; Wed, 16 Apr 2025 10:38:53 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: Suren Baghdasaryan , "Liam R . Howlett" , Vlastimil Babka , Matthew Wilcox , "Paul E . McKenney" , SeongJae Park , Shakeel Butt , David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 1/2] mm: move mmap/vma locking logic into specific files Date: Wed, 16 Apr 2025 11:38:36 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P265CA0133.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c4::8) To DM4PR10MB8218.namprd10.prod.outlook.com (2603:10b6:8:1cc::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR10MB8218:EE_|CY5PR10MB5916:EE_ X-MS-Office365-Filtering-Correlation-Id: 95c9673d-3a22-4f6e-2bc6-08dd7cd2e1a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?HZrSLcBB7pG0AijNKn0UTGMzsCAR0grIiDFksdTFqVjveEKkNlZKQIwqWJ1e?= =?us-ascii?Q?STVpwJ9J8bjwWd5oQQWoHLA3lluI56EH4VJ09p3WynyQW2XBlVzL9hX3MGTA?= =?us-ascii?Q?yvlnAUVPF72whhyySU91IP0nbHu3Z/Xj/y3LIufZNbXf7ckKj95APBpoH+Ng?= =?us-ascii?Q?zE7zYJsoCd9Xs3eShobYEppqFJRbgDWdqbR2bjC4PToQ5x+zp8vVyn849Rkd?= =?us-ascii?Q?GQKi9YHlvCjdjAGRUS98Q/oJ33MzK2K8Za8yh79qI1Dxmc5YcnherxqGYvH6?= =?us-ascii?Q?W397VvJG1jQOQPIitfeqxqcvczQmJfLbgGNqus5CQ/2ailHJAnrvLd0qh9gX?= =?us-ascii?Q?S6LWuCSIFGfFIGFfccWTLkhoRuCA4H4wDTh0TKfy0fVOCvrC+Z1Vu/328jUg?= =?us-ascii?Q?J99lqRcgwdnc4jMk6uEzcRzJP8H8I89TKbSwCWrlE/0fCbko7XNV5FxkE8Ow?= =?us-ascii?Q?Vy9nnez1q3FKTApgaq9eqHmHrg4mVDuqZ/hLSLRZNVySoHXgzYskFXMzEuV3?= =?us-ascii?Q?m+2QQtTA92R/smoJS6euhev0ex2Q4wqzlhR45XC5slMeAo7ZGdeOHaoao4rt?= =?us-ascii?Q?AfHS3AET/cCv2RfCbjr8eAurepMbRkcRG+YCYjp9jtBuEcwMDeCrQ4PEPAZD?= =?us-ascii?Q?jLgbsJ/JO+F34iJDZIDbtEs3F5HGYQXlhdCN7+kTmnGqKbKAaq3ee8DLZzbs?= =?us-ascii?Q?O17gnt5IgkosJIBaiKW1nWiUWQkLSpPKuSuobW3X2FdJHx9icZYCmqdJNDD2?= =?us-ascii?Q?wsM/BryYH8efo3FbO3gU+mjNvvUUMmsceZJAMzoqokNvKsjHYsEVPoYhc5X0?= =?us-ascii?Q?OibR8ZujUa2uCwyLEHiL9QwpjzDJk8EQRAatBLAiBz1Md6NAOlsIxlq08V+K?= =?us-ascii?Q?fly7TPXqHON8lEJu21zDCaQjTRI91AI7ThaagOK6iiq/mfGJEKztGscXlSEz?= =?us-ascii?Q?IujCx6RQYEBTp0CU6qCZsolGw72cQVj+fSDCGpmCuu8W1mrn1p2tznSDpRlR?= =?us-ascii?Q?SEfTPoYRtlf5jQLPAVgsCLEvil2rU/dd58isedIaos6cPKHNSU5cQZVISOO8?= =?us-ascii?Q?ln+gRjJ9iIqEstJAe89gflnEr7d3NtUb5J7YY0tLkYubg8wxbGv3a33W2Jxk?= =?us-ascii?Q?eg2ksd1Y8bOIVZHTuceTNLk0KI7jFiJYaCsluzsjv348kayKmzFXNddjfS+i?= =?us-ascii?Q?bdRjQpUEQXD50IeX8exNjlllGZpeDlOReM5kZd3OoYQ1tSDGCLBj6+SDpZdB?= =?us-ascii?Q?XwcjJmwDAKN5jESzaso+PEcp8Rif+HhdLYctfhbQdFWoyTHGjnmHg07xb986?= =?us-ascii?Q?i9xNQ3jcJSAt++RQOBh1nLcynZsyAwUcha6qiO3Y47mb853dv3cd9nUCwd5W?= =?us-ascii?Q?4kPSa1tfKMt4beo94hmDun6uM5KQmljQReAzWLvFNg/vx4TUoWc5ybI8W8Y1?= =?us-ascii?Q?599Gy1O0Y00=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR10MB8218.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?vFmBdxmAeocEu/eqz62RojNPPrG3V1P7OzQLcqYMFCSgOG/ZV2mkE5kNa/eI?= =?us-ascii?Q?HACXgZT93eGpp3HdxzRwleErcMVnKXybE8E53Fmk7Edxh7QiqHssRpIeHL+2?= =?us-ascii?Q?FMBatr/Nao7IUrLAUmLQdRsWUTGSKggKS8AOoRdRsNHIVzbI8GYpbzczwWvP?= =?us-ascii?Q?aD9lvvAXHgpeOslVe4HlF/6T4WRfLzj9KWpeAG4Y0hEsSbLJOaSl4tYrhly2?= =?us-ascii?Q?Nja+EHRUmNkGTPHAae8vpH3WxSEMxV7MoBlNOnSLs3wyzth7u6B7NmfYehaH?= =?us-ascii?Q?SVnQlqgPpe1ASe7X4WQd3jJt0W038kp5+4wgj3s1K4fHnGhxIoMtoRn94nKt?= =?us-ascii?Q?f6XiAqi6z53yKoRe9mSOntCVwNP2ceXFXUATmaaV1hEZtdOdfUU88hrHIXZ9?= =?us-ascii?Q?ed1TzjrtWHtxfladZ0yhhPm7Wh1LgewGgCpczpA1Jr+ceGyfNV87W94PCQ3X?= =?us-ascii?Q?Tz/3EZ2Job/VprvENBu+VpvPk3MJgmCeK6phL7jjgf4d4Ft0bREvqlnKCR8O?= =?us-ascii?Q?+0vXln3hRfrL7afzBZ31dvgrC1JYFnLvDDLO16K9niIyVDIjENld8DCiZnXG?= =?us-ascii?Q?/XUwVytmcVXpUCdwFFLrEO1Tqa6DkTL1p6Iu6B0/ucsiPPlAMDf9slW4Xtgq?= =?us-ascii?Q?YQnX5keBHM9Q/O6mcJBUBz7tsVAl9U1F0s6nS6ybcjJo82+SW1wF7K3m416s?= =?us-ascii?Q?C00BJRAVU98vxPWX+6KSFLDe4xqbCuKv8XYzVM4c/CgRjYV3Tnd8UtY9ZdSA?= =?us-ascii?Q?CAeFVhP0wG+9ZvUrZ+KkVBMk59RKXj+byrc0nwP8C11zyCWBunqgdAEJQuRx?= =?us-ascii?Q?Hn+p1OlOKJYU+7vepdvpq9lEPj1SvBs5VFdUEI9VzQhUGr23F4gA+pwt1Fs3?= =?us-ascii?Q?fMx6RoliGPx4Fj0S3nNxX0u08o6c5WoYtcVkwkriutNy5qCEqH6BL0lDN4Xk?= =?us-ascii?Q?3l7ztlAGN6AQIX+Ah8ik5B7G1ZC8fAZf7aPCP6L5h1Y/Zrwwd/3mOJX/SbGk?= =?us-ascii?Q?K1ipAWtADJxwUUfAanjHEt7kepirpu/lKgqIeFUsq7TCnMd1tkOQ0gv9LhSY?= =?us-ascii?Q?IIeUVeFm2i9oFu6Dr0AceUFht+HnG47GIXPRhBik7R1ODruozHms0COiZN0j?= =?us-ascii?Q?N34lptNG20XUHk7O82A37VIQLmgZdyUUoqpAwl8fHroEKNO7zQLccGQ9FaiR?= =?us-ascii?Q?cSznN8VL2noaBYPlyO2dNS+e5l9PUkA++xzpXHHf0Usp/+YELfy2XHmWDsrf?= =?us-ascii?Q?Z/1qMZaj2YLMmhlzYw1r+Sl8LjQdP9V8LIuD/U3+5YCbOjeXtgR0y2uIQu/9?= =?us-ascii?Q?au69JniwVGrCQvlkKnmmSHh3t46llRdXAj2Wa/IkzVJMNVYvZgD4QRuxGcN2?= =?us-ascii?Q?bAHYXw3ztY/A5Bo1I3uBEqho4Cb9qDf/o1EDYOCyGNYtX+ZraUwhS3pLJ9gU?= =?us-ascii?Q?1LxZAPfUvsj+aDAz823CkunuZQnFX1rw2u7O/ucu6tjGhSENpT+Ovb8cRIAL?= =?us-ascii?Q?jHBdtWEQqQ8Ca4nFBH+KUD+OFqgG1ejoTaxAbkcydbZ6na7Rrc0yxWdaVWnP?= =?us-ascii?Q?DxlLxGyI3DTJ/+7uyYyPfy5MciTDm7xjkQEP8JHqnRCVQjG9uLwMr57+3Kfn?= =?us-ascii?Q?aQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: KINauEIZlk0ec/4dCfvvk3+bxExUHgiMeZmhMkHiuzcrRjmR/Joli0EhS4jHPFRV8ajIN6teZd5UtMbfP4/pkatSBcswIUH38nPR3NnahcAp6VhCIVcTr85l5L9iesD7Gh7aAgOe7qrIieeAloR8krJSGWjfTl/rPRZXQEwJB82FtMlaDiVEdxFixVnIp37SYXinWNGZYhR7y4z/pZyVDO68OswfLns7Yl+3DIvfTfjiQEapXJUYBgKLDBL7/bccCPE16MXWg4q1V0wTkihAdgX8kkMepICBJTO7t69Ab2EqIINTYB0nHs8X8oGNqjIBJfk948FQHZFcGkaTjNgDl1hO2PxnNvVsIGUm6mPeXxKPpIRx9xfSuS9qqCkQkq6pZ+KiEoy3n84hR1o/0DuYLGlusREfoWnTiIzPqtkiQrygCeI+y277c6EnDa6hiINd5b5Tr4eF0AWmbpHtlOReShS/iOyFFh6Zvf8GDjdFYNFkbzSP+Ceh7gbRGdxSG0B+UguWRNQrOojvtpZGhLpTgYQzEH6p7SMqa+fa46gnphNvqoVBnO+W+BdYyRUqz0Wb/ytcWJQTzCDrreL5CyrNsZd0cIdTxKo1ANrfoZAzPDw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95c9673d-3a22-4f6e-2bc6-08dd7cd2e1a9 X-MS-Exchange-CrossTenant-AuthSource: DM4PR10MB8218.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2025 10:38:53.0095 (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: JFu2zwnD339LoiEO+5ubJHcAMrW8ovYZ7vpUWdCAX+5SwnkehQBsZwB1gNN8R3GTAZZmWgiWOBwdn+b0GrlgX8YvUUY7Cpc83hyn0VYZMSw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB5916 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-16_04,2025-04-15_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504160087 X-Proofpoint-GUID: ey8D22yoFqj7zr1fZE26lvY8F-4spWRP X-Proofpoint-ORIG-GUID: ey8D22yoFqj7zr1fZE26lvY8F-4spWRP Content-Type: text/plain; charset="utf-8" Currently the VMA and mmap locking logic is entangled in two of the most overwrought files in mm - include/linux/mm.h and mm/memory.c. Separate this logic out so we can more easily make changes and create an appropriate MAINTAINERS entry that spans only the logic relating to locking. This should have no functional change. Care is taken to avoid dependency loops, we must regrettably keep release_fault_lock() and assert_fault_locked() in mm.h as a result due to the dependence on the vm_fault type. Additionally we must declare rcuwait_wake_up() manually to avoid a dependency cycle on linux/rcuwait.h. Additionally move the nommu implementatino of lock_mm_and_find_vma() to mmap_lock.c so everything lock-related is in one place. Signed-off-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan Reviewed-by: Liam R. Howlett Reviewed-by: Vlastimil Babka --- include/linux/mm.h | 231 +------------------------------- include/linux/mmap_lock.h | 227 +++++++++++++++++++++++++++++++ mm/memory.c | 252 ----------------------------------- mm/mmap_lock.c | 273 ++++++++++++++++++++++++++++++++++++++ mm/nommu.c | 16 --- 5 files changed, 504 insertions(+), 495 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5eb0d77c4438..9b701cfbef22 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -671,204 +671,11 @@ static inline void vma_numab_state_init(struct vm_ar= ea_struct *vma) {} static inline void vma_numab_state_free(struct vm_area_struct *vma) {} #endif /* CONFIG_NUMA_BALANCING */ =20 -#ifdef CONFIG_PER_VMA_LOCK -static inline void vma_lock_init(struct vm_area_struct *vma, bool reset_re= fcnt) -{ -#ifdef CONFIG_DEBUG_LOCK_ALLOC - static struct lock_class_key lockdep_key; - - lockdep_init_map(&vma->vmlock_dep_map, "vm_lock", &lockdep_key, 0); -#endif - if (reset_refcnt) - refcount_set(&vma->vm_refcnt, 0); - vma->vm_lock_seq =3D UINT_MAX; -} - -static inline bool is_vma_writer_only(int refcnt) -{ - /* - * With a writer and no readers, refcnt is VMA_LOCK_OFFSET if the vma - * is detached and (VMA_LOCK_OFFSET + 1) if it is attached. Waiting on - * a detached vma happens only in vma_mark_detached() and is a rare - * case, therefore most of the time there will be no unnecessary wakeup. - */ - return refcnt & VMA_LOCK_OFFSET && refcnt <=3D VMA_LOCK_OFFSET + 1; -} - -static inline void vma_refcount_put(struct vm_area_struct *vma) -{ - /* Use a copy of vm_mm in case vma is freed after we drop vm_refcnt */ - struct mm_struct *mm =3D vma->vm_mm; - int oldcnt; - - rwsem_release(&vma->vmlock_dep_map, _RET_IP_); - if (!__refcount_dec_and_test(&vma->vm_refcnt, &oldcnt)) { - - if (is_vma_writer_only(oldcnt - 1)) - rcuwait_wake_up(&mm->vma_writer_wait); - } -} - -/* - * Try to read-lock a vma. The function is allowed to occasionally yield f= alse - * locked result to avoid performance overhead, in which case we fall back= to - * using mmap_lock. The function should never yield false unlocked result. - * False locked result is possible if mm_lock_seq overflows or if vma gets - * reused and attached to a different mm before we lock it. - * Returns the vma on success, NULL on failure to lock and EAGAIN if vma g= ot - * detached. - */ -static inline struct vm_area_struct *vma_start_read(struct mm_struct *mm, - struct vm_area_struct *vma) -{ - int oldcnt; - - /* - * Check before locking. A race might cause false locked result. - * We can use READ_ONCE() for the mm_lock_seq here, and don't need - * ACQUIRE semantics, because this is just a lockless check whose result - * we don't rely on for anything - the mm_lock_seq read against which we - * need ordering is below. - */ - if (READ_ONCE(vma->vm_lock_seq) =3D=3D READ_ONCE(mm->mm_lock_seq.sequence= )) - return NULL; - - /* - * If VMA_LOCK_OFFSET is set, __refcount_inc_not_zero_limited_acquire() - * will fail because VMA_REF_LIMIT is less than VMA_LOCK_OFFSET. - * Acquire fence is required here to avoid reordering against later - * vm_lock_seq check and checks inside lock_vma_under_rcu(). - */ - if (unlikely(!__refcount_inc_not_zero_limited_acquire(&vma->vm_refcnt, &o= ldcnt, - VMA_REF_LIMIT))) { - /* return EAGAIN if vma got detached from under us */ - return oldcnt ? NULL : ERR_PTR(-EAGAIN); - } - - rwsem_acquire_read(&vma->vmlock_dep_map, 0, 1, _RET_IP_); - /* - * Overflow of vm_lock_seq/mm_lock_seq might produce false locked result. - * False unlocked result is impossible because we modify and check - * vma->vm_lock_seq under vma->vm_refcnt protection and mm->mm_lock_seq - * modification invalidates all existing locks. - * - * We must use ACQUIRE semantics for the mm_lock_seq so that if we are - * racing with vma_end_write_all(), we only start reading from the VMA - * after it has been unlocked. - * This pairs with RELEASE semantics in vma_end_write_all(). - */ - if (unlikely(vma->vm_lock_seq =3D=3D raw_read_seqcount(&mm->mm_lock_seq))= ) { - vma_refcount_put(vma); - return NULL; - } - - return vma; -} - -/* - * Use only while holding mmap read lock which guarantees that locking wil= l not - * fail (nobody can concurrently write-lock the vma). vma_start_read() sho= uld - * not be used in such cases because it might fail due to mm_lock_seq over= flow. - * This functionality is used to obtain vma read lock and drop the mmap re= ad lock. - */ -static inline bool vma_start_read_locked_nested(struct vm_area_struct *vma= , int subclass) -{ - int oldcnt; - - mmap_assert_locked(vma->vm_mm); - if (unlikely(!__refcount_inc_not_zero_limited_acquire(&vma->vm_refcnt, &o= ldcnt, - VMA_REF_LIMIT))) - return false; - - rwsem_acquire_read(&vma->vmlock_dep_map, 0, 1, _RET_IP_); - return true; -} - -/* - * Use only while holding mmap read lock which guarantees that locking wil= l not - * fail (nobody can concurrently write-lock the vma). vma_start_read() sho= uld - * not be used in such cases because it might fail due to mm_lock_seq over= flow. - * This functionality is used to obtain vma read lock and drop the mmap re= ad lock. - */ -static inline bool vma_start_read_locked(struct vm_area_struct *vma) -{ - return vma_start_read_locked_nested(vma, 0); -} - -static inline void vma_end_read(struct vm_area_struct *vma) -{ - vma_refcount_put(vma); -} - -/* WARNING! Can only be used if mmap_lock is expected to be write-locked */ -static bool __is_vma_write_locked(struct vm_area_struct *vma, unsigned int= *mm_lock_seq) -{ - mmap_assert_write_locked(vma->vm_mm); - - /* - * current task is holding mmap_write_lock, both vma->vm_lock_seq and - * mm->mm_lock_seq can't be concurrently modified. - */ - *mm_lock_seq =3D vma->vm_mm->mm_lock_seq.sequence; - return (vma->vm_lock_seq =3D=3D *mm_lock_seq); -} - -void __vma_start_write(struct vm_area_struct *vma, unsigned int mm_lock_se= q); - -/* - * Begin writing to a VMA. - * Exclude concurrent readers under the per-VMA lock until the currently - * write-locked mmap_lock is dropped or downgraded. - */ -static inline void vma_start_write(struct vm_area_struct *vma) -{ - unsigned int mm_lock_seq; - - if (__is_vma_write_locked(vma, &mm_lock_seq)) - return; - - __vma_start_write(vma, mm_lock_seq); -} - -static inline void vma_assert_write_locked(struct vm_area_struct *vma) -{ - unsigned int mm_lock_seq; - - VM_BUG_ON_VMA(!__is_vma_write_locked(vma, &mm_lock_seq), vma); -} - -static inline void vma_assert_locked(struct vm_area_struct *vma) -{ - unsigned int mm_lock_seq; - - VM_BUG_ON_VMA(refcount_read(&vma->vm_refcnt) <=3D 1 && - !__is_vma_write_locked(vma, &mm_lock_seq), vma); -} - /* - * WARNING: to avoid racing with vma_mark_attached()/vma_mark_detached(), = these - * assertions should be made either under mmap_write_lock or when the obje= ct - * has been isolated under mmap_write_lock, ensuring no competing writers. + * These must be here rather than mmap_lock.h as dependent on vm_fault typ= e, + * declared in this header. */ -static inline void vma_assert_attached(struct vm_area_struct *vma) -{ - WARN_ON_ONCE(!refcount_read(&vma->vm_refcnt)); -} - -static inline void vma_assert_detached(struct vm_area_struct *vma) -{ - WARN_ON_ONCE(refcount_read(&vma->vm_refcnt)); -} - -static inline void vma_mark_attached(struct vm_area_struct *vma) -{ - vma_assert_write_locked(vma); - vma_assert_detached(vma); - refcount_set_release(&vma->vm_refcnt, 1); -} - -void vma_mark_detached(struct vm_area_struct *vma); - +#ifdef CONFIG_PER_VMA_LOCK static inline void release_fault_lock(struct vm_fault *vmf) { if (vmf->flags & FAULT_FLAG_VMA_LOCK) @@ -884,36 +691,7 @@ static inline void assert_fault_locked(struct vm_fault= *vmf) else mmap_assert_locked(vmf->vma->vm_mm); } - -struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm, - unsigned long address); - -#else /* CONFIG_PER_VMA_LOCK */ - -static inline void vma_lock_init(struct vm_area_struct *vma, bool reset_re= fcnt) {} -static inline struct vm_area_struct *vma_start_read(struct mm_struct *mm, - struct vm_area_struct *vma) - { return NULL; } -static inline void vma_end_read(struct vm_area_struct *vma) {} -static inline void vma_start_write(struct vm_area_struct *vma) {} -static inline void vma_assert_write_locked(struct vm_area_struct *vma) - { mmap_assert_write_locked(vma->vm_mm); } -static inline void vma_assert_attached(struct vm_area_struct *vma) {} -static inline void vma_assert_detached(struct vm_area_struct *vma) {} -static inline void vma_mark_attached(struct vm_area_struct *vma) {} -static inline void vma_mark_detached(struct vm_area_struct *vma) {} - -static inline struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *= mm, - unsigned long address) -{ - return NULL; -} - -static inline void vma_assert_locked(struct vm_area_struct *vma) -{ - mmap_assert_locked(vma->vm_mm); -} - +#else static inline void release_fault_lock(struct vm_fault *vmf) { mmap_read_unlock(vmf->vma->vm_mm); @@ -923,7 +701,6 @@ static inline void assert_fault_locked(struct vm_fault = *vmf) { mmap_assert_locked(vmf->vma->vm_mm); } - #endif /* CONFIG_PER_VMA_LOCK */ =20 extern const struct vm_operations_struct vma_dummy_vm_ops; diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h index 4706c6769902..7983b2efe9bf 100644 --- a/include/linux/mmap_lock.h +++ b/include/linux/mmap_lock.h @@ -1,6 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _LINUX_MMAP_LOCK_H #define _LINUX_MMAP_LOCK_H =20 +/* Avoid a dependency loop by declaring here. */ +extern int rcuwait_wake_up(struct rcuwait *w); + #include #include #include @@ -104,6 +108,206 @@ static inline bool mmap_lock_speculate_retry(struct m= m_struct *mm, unsigned int return read_seqcount_retry(&mm->mm_lock_seq, seq); } =20 +static inline void vma_lock_init(struct vm_area_struct *vma, bool reset_re= fcnt) +{ +#ifdef CONFIG_DEBUG_LOCK_ALLOC + static struct lock_class_key lockdep_key; + + lockdep_init_map(&vma->vmlock_dep_map, "vm_lock", &lockdep_key, 0); +#endif + if (reset_refcnt) + refcount_set(&vma->vm_refcnt, 0); + vma->vm_lock_seq =3D UINT_MAX; +} + +static inline bool is_vma_writer_only(int refcnt) +{ + /* + * With a writer and no readers, refcnt is VMA_LOCK_OFFSET if the vma + * is detached and (VMA_LOCK_OFFSET + 1) if it is attached. Waiting on + * a detached vma happens only in vma_mark_detached() and is a rare + * case, therefore most of the time there will be no unnecessary wakeup. + */ + return refcnt & VMA_LOCK_OFFSET && refcnt <=3D VMA_LOCK_OFFSET + 1; +} + +static inline void vma_refcount_put(struct vm_area_struct *vma) +{ + /* Use a copy of vm_mm in case vma is freed after we drop vm_refcnt */ + struct mm_struct *mm =3D vma->vm_mm; + int oldcnt; + + rwsem_release(&vma->vmlock_dep_map, _RET_IP_); + if (!__refcount_dec_and_test(&vma->vm_refcnt, &oldcnt)) { + + if (is_vma_writer_only(oldcnt - 1)) + rcuwait_wake_up(&mm->vma_writer_wait); + } +} + +/* + * Try to read-lock a vma. The function is allowed to occasionally yield f= alse + * locked result to avoid performance overhead, in which case we fall back= to + * using mmap_lock. The function should never yield false unlocked result. + * False locked result is possible if mm_lock_seq overflows or if vma gets + * reused and attached to a different mm before we lock it. + * Returns the vma on success, NULL on failure to lock and EAGAIN if vma g= ot + * detached. + */ +static inline struct vm_area_struct *vma_start_read(struct mm_struct *mm, + struct vm_area_struct *vma) +{ + int oldcnt; + + /* + * Check before locking. A race might cause false locked result. + * We can use READ_ONCE() for the mm_lock_seq here, and don't need + * ACQUIRE semantics, because this is just a lockless check whose result + * we don't rely on for anything - the mm_lock_seq read against which we + * need ordering is below. + */ + if (READ_ONCE(vma->vm_lock_seq) =3D=3D READ_ONCE(mm->mm_lock_seq.sequence= )) + return NULL; + + /* + * If VMA_LOCK_OFFSET is set, __refcount_inc_not_zero_limited_acquire() + * will fail because VMA_REF_LIMIT is less than VMA_LOCK_OFFSET. + * Acquire fence is required here to avoid reordering against later + * vm_lock_seq check and checks inside lock_vma_under_rcu(). + */ + if (unlikely(!__refcount_inc_not_zero_limited_acquire(&vma->vm_refcnt, &o= ldcnt, + VMA_REF_LIMIT))) { + /* return EAGAIN if vma got detached from under us */ + return oldcnt ? NULL : ERR_PTR(-EAGAIN); + } + + rwsem_acquire_read(&vma->vmlock_dep_map, 0, 1, _RET_IP_); + /* + * Overflow of vm_lock_seq/mm_lock_seq might produce false locked result. + * False unlocked result is impossible because we modify and check + * vma->vm_lock_seq under vma->vm_refcnt protection and mm->mm_lock_seq + * modification invalidates all existing locks. + * + * We must use ACQUIRE semantics for the mm_lock_seq so that if we are + * racing with vma_end_write_all(), we only start reading from the VMA + * after it has been unlocked. + * This pairs with RELEASE semantics in vma_end_write_all(). + */ + if (unlikely(vma->vm_lock_seq =3D=3D raw_read_seqcount(&mm->mm_lock_seq))= ) { + vma_refcount_put(vma); + return NULL; + } + + return vma; +} + +/* + * Use only while holding mmap read lock which guarantees that locking wil= l not + * fail (nobody can concurrently write-lock the vma). vma_start_read() sho= uld + * not be used in such cases because it might fail due to mm_lock_seq over= flow. + * This functionality is used to obtain vma read lock and drop the mmap re= ad lock. + */ +static inline bool vma_start_read_locked_nested(struct vm_area_struct *vma= , int subclass) +{ + int oldcnt; + + mmap_assert_locked(vma->vm_mm); + if (unlikely(!__refcount_inc_not_zero_limited_acquire(&vma->vm_refcnt, &o= ldcnt, + VMA_REF_LIMIT))) + return false; + + rwsem_acquire_read(&vma->vmlock_dep_map, 0, 1, _RET_IP_); + return true; +} + +/* + * Use only while holding mmap read lock which guarantees that locking wil= l not + * fail (nobody can concurrently write-lock the vma). vma_start_read() sho= uld + * not be used in such cases because it might fail due to mm_lock_seq over= flow. + * This functionality is used to obtain vma read lock and drop the mmap re= ad lock. + */ +static inline bool vma_start_read_locked(struct vm_area_struct *vma) +{ + return vma_start_read_locked_nested(vma, 0); +} + +static inline void vma_end_read(struct vm_area_struct *vma) +{ + vma_refcount_put(vma); +} + +/* WARNING! Can only be used if mmap_lock is expected to be write-locked */ +static bool __is_vma_write_locked(struct vm_area_struct *vma, unsigned int= *mm_lock_seq) +{ + mmap_assert_write_locked(vma->vm_mm); + + /* + * current task is holding mmap_write_lock, both vma->vm_lock_seq and + * mm->mm_lock_seq can't be concurrently modified. + */ + *mm_lock_seq =3D vma->vm_mm->mm_lock_seq.sequence; + return (vma->vm_lock_seq =3D=3D *mm_lock_seq); +} + +void __vma_start_write(struct vm_area_struct *vma, unsigned int mm_lock_se= q); + +/* + * Begin writing to a VMA. + * Exclude concurrent readers under the per-VMA lock until the currently + * write-locked mmap_lock is dropped or downgraded. + */ +static inline void vma_start_write(struct vm_area_struct *vma) +{ + unsigned int mm_lock_seq; + + if (__is_vma_write_locked(vma, &mm_lock_seq)) + return; + + __vma_start_write(vma, mm_lock_seq); +} + +static inline void vma_assert_write_locked(struct vm_area_struct *vma) +{ + unsigned int mm_lock_seq; + + VM_BUG_ON_VMA(!__is_vma_write_locked(vma, &mm_lock_seq), vma); +} + +static inline void vma_assert_locked(struct vm_area_struct *vma) +{ + unsigned int mm_lock_seq; + + VM_BUG_ON_VMA(refcount_read(&vma->vm_refcnt) <=3D 1 && + !__is_vma_write_locked(vma, &mm_lock_seq), vma); +} + +/* + * WARNING: to avoid racing with vma_mark_attached()/vma_mark_detached(), = these + * assertions should be made either under mmap_write_lock or when the obje= ct + * has been isolated under mmap_write_lock, ensuring no competing writers. + */ +static inline void vma_assert_attached(struct vm_area_struct *vma) +{ + WARN_ON_ONCE(!refcount_read(&vma->vm_refcnt)); +} + +static inline void vma_assert_detached(struct vm_area_struct *vma) +{ + WARN_ON_ONCE(refcount_read(&vma->vm_refcnt)); +} + +static inline void vma_mark_attached(struct vm_area_struct *vma) +{ + vma_assert_write_locked(vma); + vma_assert_detached(vma); + refcount_set_release(&vma->vm_refcnt, 1); +} + +void vma_mark_detached(struct vm_area_struct *vma); + +struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm, + unsigned long address); + #else /* CONFIG_PER_VMA_LOCK */ =20 static inline void mm_lock_seqcount_init(struct mm_struct *mm) {} @@ -119,6 +323,29 @@ static inline bool mmap_lock_speculate_retry(struct mm= _struct *mm, unsigned int { return true; } +static inline void vma_lock_init(struct vm_area_struct *vma, bool reset_re= fcnt) {} +static inline struct vm_area_struct *vma_start_read(struct mm_struct *mm, + struct vm_area_struct *vma) + { return NULL; } +static inline void vma_end_read(struct vm_area_struct *vma) {} +static inline void vma_start_write(struct vm_area_struct *vma) {} +static inline void vma_assert_write_locked(struct vm_area_struct *vma) + { mmap_assert_write_locked(vma->vm_mm); } +static inline void vma_assert_attached(struct vm_area_struct *vma) {} +static inline void vma_assert_detached(struct vm_area_struct *vma) {} +static inline void vma_mark_attached(struct vm_area_struct *vma) {} +static inline void vma_mark_detached(struct vm_area_struct *vma) {} + +static inline struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *= mm, + unsigned long address) +{ + return NULL; +} + +static inline void vma_assert_locked(struct vm_area_struct *vma) +{ + mmap_assert_locked(vma->vm_mm); +} =20 #endif /* CONFIG_PER_VMA_LOCK */ =20 diff --git a/mm/memory.c b/mm/memory.c index 688f3612e16d..35cfc91d5a2e 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -6378,258 +6378,6 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *v= ma, unsigned long address, } EXPORT_SYMBOL_GPL(handle_mm_fault); =20 -#ifdef CONFIG_LOCK_MM_AND_FIND_VMA -#include - -static inline bool get_mmap_lock_carefully(struct mm_struct *mm, struct pt= _regs *regs) -{ - if (likely(mmap_read_trylock(mm))) - return true; - - if (regs && !user_mode(regs)) { - unsigned long ip =3D exception_ip(regs); - if (!search_exception_tables(ip)) - return false; - } - - return !mmap_read_lock_killable(mm); -} - -static inline bool mmap_upgrade_trylock(struct mm_struct *mm) -{ - /* - * We don't have this operation yet. - * - * It should be easy enough to do: it's basically a - * atomic_long_try_cmpxchg_acquire() - * from RWSEM_READER_BIAS -> RWSEM_WRITER_LOCKED, but - * it also needs the proper lockdep magic etc. - */ - return false; -} - -static inline bool upgrade_mmap_lock_carefully(struct mm_struct *mm, struc= t pt_regs *regs) -{ - mmap_read_unlock(mm); - if (regs && !user_mode(regs)) { - unsigned long ip =3D exception_ip(regs); - if (!search_exception_tables(ip)) - return false; - } - return !mmap_write_lock_killable(mm); -} - -/* - * Helper for page fault handling. - * - * This is kind of equivalent to "mmap_read_lock()" followed - * by "find_extend_vma()", except it's a lot more careful about - * the locking (and will drop the lock on failure). - * - * For example, if we have a kernel bug that causes a page - * fault, we don't want to just use mmap_read_lock() to get - * the mm lock, because that would deadlock if the bug were - * to happen while we're holding the mm lock for writing. - * - * So this checks the exception tables on kernel faults in - * order to only do this all for instructions that are actually - * expected to fault. - * - * We can also actually take the mm lock for writing if we - * need to extend the vma, which helps the VM layer a lot. - */ -struct vm_area_struct *lock_mm_and_find_vma(struct mm_struct *mm, - unsigned long addr, struct pt_regs *regs) -{ - struct vm_area_struct *vma; - - if (!get_mmap_lock_carefully(mm, regs)) - return NULL; - - vma =3D find_vma(mm, addr); - if (likely(vma && (vma->vm_start <=3D addr))) - return vma; - - /* - * Well, dang. We might still be successful, but only - * if we can extend a vma to do so. - */ - if (!vma || !(vma->vm_flags & VM_GROWSDOWN)) { - mmap_read_unlock(mm); - return NULL; - } - - /* - * We can try to upgrade the mmap lock atomically, - * in which case we can continue to use the vma - * we already looked up. - * - * Otherwise we'll have to drop the mmap lock and - * re-take it, and also look up the vma again, - * re-checking it. - */ - if (!mmap_upgrade_trylock(mm)) { - if (!upgrade_mmap_lock_carefully(mm, regs)) - return NULL; - - vma =3D find_vma(mm, addr); - if (!vma) - goto fail; - if (vma->vm_start <=3D addr) - goto success; - if (!(vma->vm_flags & VM_GROWSDOWN)) - goto fail; - } - - if (expand_stack_locked(vma, addr)) - goto fail; - -success: - mmap_write_downgrade(mm); - return vma; - -fail: - mmap_write_unlock(mm); - return NULL; -} -#endif - -#ifdef CONFIG_PER_VMA_LOCK -static inline bool __vma_enter_locked(struct vm_area_struct *vma, bool det= aching) -{ - unsigned int tgt_refcnt =3D VMA_LOCK_OFFSET; - - /* Additional refcnt if the vma is attached. */ - if (!detaching) - tgt_refcnt++; - - /* - * If vma is detached then only vma_mark_attached() can raise the - * vm_refcnt. mmap_write_lock prevents racing with vma_mark_attached(). - */ - if (!refcount_add_not_zero(VMA_LOCK_OFFSET, &vma->vm_refcnt)) - return false; - - rwsem_acquire(&vma->vmlock_dep_map, 0, 0, _RET_IP_); - rcuwait_wait_event(&vma->vm_mm->vma_writer_wait, - refcount_read(&vma->vm_refcnt) =3D=3D tgt_refcnt, - TASK_UNINTERRUPTIBLE); - lock_acquired(&vma->vmlock_dep_map, _RET_IP_); - - return true; -} - -static inline void __vma_exit_locked(struct vm_area_struct *vma, bool *det= ached) -{ - *detached =3D refcount_sub_and_test(VMA_LOCK_OFFSET, &vma->vm_refcnt); - rwsem_release(&vma->vmlock_dep_map, _RET_IP_); -} - -void __vma_start_write(struct vm_area_struct *vma, unsigned int mm_lock_se= q) -{ - bool locked; - - /* - * __vma_enter_locked() returns false immediately if the vma is not - * attached, otherwise it waits until refcnt is indicating that vma - * is attached with no readers. - */ - locked =3D __vma_enter_locked(vma, false); - - /* - * We should use WRITE_ONCE() here because we can have concurrent reads - * from the early lockless pessimistic check in vma_start_read(). - * We don't really care about the correctness of that early check, but - * we should use WRITE_ONCE() for cleanliness and to keep KCSAN happy. - */ - WRITE_ONCE(vma->vm_lock_seq, mm_lock_seq); - - if (locked) { - bool detached; - - __vma_exit_locked(vma, &detached); - WARN_ON_ONCE(detached); /* vma should remain attached */ - } -} -EXPORT_SYMBOL_GPL(__vma_start_write); - -void vma_mark_detached(struct vm_area_struct *vma) -{ - vma_assert_write_locked(vma); - vma_assert_attached(vma); - - /* - * We are the only writer, so no need to use vma_refcount_put(). - * The condition below is unlikely because the vma has been already - * write-locked and readers can increment vm_refcnt only temporarily - * before they check vm_lock_seq, realize the vma is locked and drop - * back the vm_refcnt. That is a narrow window for observing a raised - * vm_refcnt. - */ - if (unlikely(!refcount_dec_and_test(&vma->vm_refcnt))) { - /* Wait until vma is detached with no readers. */ - if (__vma_enter_locked(vma, true)) { - bool detached; - - __vma_exit_locked(vma, &detached); - WARN_ON_ONCE(!detached); - } - } -} - -/* - * Lookup and lock a VMA under RCU protection. Returned VMA is guaranteed = to be - * stable and not isolated. If the VMA is not found or is being modified t= he - * function returns NULL. - */ -struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm, - unsigned long address) -{ - MA_STATE(mas, &mm->mm_mt, address, address); - struct vm_area_struct *vma; - - rcu_read_lock(); -retry: - vma =3D mas_walk(&mas); - if (!vma) - goto inval; - - vma =3D vma_start_read(mm, vma); - if (IS_ERR_OR_NULL(vma)) { - /* Check if the VMA got isolated after we found it */ - if (PTR_ERR(vma) =3D=3D -EAGAIN) { - count_vm_vma_lock_event(VMA_LOCK_MISS); - /* The area was replaced with another one */ - goto retry; - } - - /* Failed to lock the VMA */ - goto inval; - } - /* - * At this point, we have a stable reference to a VMA: The VMA is - * locked and we know it hasn't already been isolated. - * From here on, we can access the VMA without worrying about which - * fields are accessible for RCU readers. - */ - - /* Check if the vma we locked is the right one. */ - if (unlikely(vma->vm_mm !=3D mm || - address < vma->vm_start || address >=3D vma->vm_end)) - goto inval_end_read; - - rcu_read_unlock(); - return vma; - -inval_end_read: - vma_end_read(vma); -inval: - rcu_read_unlock(); - count_vm_vma_lock_event(VMA_LOCK_ABORT); - return NULL; -} -#endif /* CONFIG_PER_VMA_LOCK */ - #ifndef __PAGETABLE_P4D_FOLDED /* * Allocate p4d page table. diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c index e7dbaf96aa17..5f725cc67334 100644 --- a/mm/mmap_lock.c +++ b/mm/mmap_lock.c @@ -42,3 +42,276 @@ void __mmap_lock_do_trace_released(struct mm_struct *mm= , bool write) } EXPORT_SYMBOL(__mmap_lock_do_trace_released); #endif /* CONFIG_TRACING */ + +#ifdef CONFIG_MMU +#ifdef CONFIG_PER_VMA_LOCK +static inline bool __vma_enter_locked(struct vm_area_struct *vma, bool det= aching) +{ + unsigned int tgt_refcnt =3D VMA_LOCK_OFFSET; + + /* Additional refcnt if the vma is attached. */ + if (!detaching) + tgt_refcnt++; + + /* + * If vma is detached then only vma_mark_attached() can raise the + * vm_refcnt. mmap_write_lock prevents racing with vma_mark_attached(). + */ + if (!refcount_add_not_zero(VMA_LOCK_OFFSET, &vma->vm_refcnt)) + return false; + + rwsem_acquire(&vma->vmlock_dep_map, 0, 0, _RET_IP_); + rcuwait_wait_event(&vma->vm_mm->vma_writer_wait, + refcount_read(&vma->vm_refcnt) =3D=3D tgt_refcnt, + TASK_UNINTERRUPTIBLE); + lock_acquired(&vma->vmlock_dep_map, _RET_IP_); + + return true; +} + +static inline void __vma_exit_locked(struct vm_area_struct *vma, bool *det= ached) +{ + *detached =3D refcount_sub_and_test(VMA_LOCK_OFFSET, &vma->vm_refcnt); + rwsem_release(&vma->vmlock_dep_map, _RET_IP_); +} + +void __vma_start_write(struct vm_area_struct *vma, unsigned int mm_lock_se= q) +{ + bool locked; + + /* + * __vma_enter_locked() returns false immediately if the vma is not + * attached, otherwise it waits until refcnt is indicating that vma + * is attached with no readers. + */ + locked =3D __vma_enter_locked(vma, false); + + /* + * We should use WRITE_ONCE() here because we can have concurrent reads + * from the early lockless pessimistic check in vma_start_read(). + * We don't really care about the correctness of that early check, but + * we should use WRITE_ONCE() for cleanliness and to keep KCSAN happy. + */ + WRITE_ONCE(vma->vm_lock_seq, mm_lock_seq); + + if (locked) { + bool detached; + + __vma_exit_locked(vma, &detached); + WARN_ON_ONCE(detached); /* vma should remain attached */ + } +} +EXPORT_SYMBOL_GPL(__vma_start_write); + +void vma_mark_detached(struct vm_area_struct *vma) +{ + vma_assert_write_locked(vma); + vma_assert_attached(vma); + + /* + * We are the only writer, so no need to use vma_refcount_put(). + * The condition below is unlikely because the vma has been already + * write-locked and readers can increment vm_refcnt only temporarily + * before they check vm_lock_seq, realize the vma is locked and drop + * back the vm_refcnt. That is a narrow window for observing a raised + * vm_refcnt. + */ + if (unlikely(!refcount_dec_and_test(&vma->vm_refcnt))) { + /* Wait until vma is detached with no readers. */ + if (__vma_enter_locked(vma, true)) { + bool detached; + + __vma_exit_locked(vma, &detached); + WARN_ON_ONCE(!detached); + } + } +} + +/* + * Lookup and lock a VMA under RCU protection. Returned VMA is guaranteed = to be + * stable and not isolated. If the VMA is not found or is being modified t= he + * function returns NULL. + */ +struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm, + unsigned long address) +{ + MA_STATE(mas, &mm->mm_mt, address, address); + struct vm_area_struct *vma; + + rcu_read_lock(); +retry: + vma =3D mas_walk(&mas); + if (!vma) + goto inval; + + vma =3D vma_start_read(mm, vma); + if (IS_ERR_OR_NULL(vma)) { + /* Check if the VMA got isolated after we found it */ + if (PTR_ERR(vma) =3D=3D -EAGAIN) { + count_vm_vma_lock_event(VMA_LOCK_MISS); + /* The area was replaced with another one */ + goto retry; + } + + /* Failed to lock the VMA */ + goto inval; + } + /* + * At this point, we have a stable reference to a VMA: The VMA is + * locked and we know it hasn't already been isolated. + * From here on, we can access the VMA without worrying about which + * fields are accessible for RCU readers. + */ + + /* Check if the vma we locked is the right one. */ + if (unlikely(vma->vm_mm !=3D mm || + address < vma->vm_start || address >=3D vma->vm_end)) + goto inval_end_read; + + rcu_read_unlock(); + return vma; + +inval_end_read: + vma_end_read(vma); +inval: + rcu_read_unlock(); + count_vm_vma_lock_event(VMA_LOCK_ABORT); + return NULL; +} +#endif /* CONFIG_PER_VMA_LOCK */ + +#ifdef CONFIG_LOCK_MM_AND_FIND_VMA +#include + +static inline bool get_mmap_lock_carefully(struct mm_struct *mm, struct pt= _regs *regs) +{ + if (likely(mmap_read_trylock(mm))) + return true; + + if (regs && !user_mode(regs)) { + unsigned long ip =3D exception_ip(regs); + if (!search_exception_tables(ip)) + return false; + } + + return !mmap_read_lock_killable(mm); +} + +static inline bool mmap_upgrade_trylock(struct mm_struct *mm) +{ + /* + * We don't have this operation yet. + * + * It should be easy enough to do: it's basically a + * atomic_long_try_cmpxchg_acquire() + * from RWSEM_READER_BIAS -> RWSEM_WRITER_LOCKED, but + * it also needs the proper lockdep magic etc. + */ + return false; +} + +static inline bool upgrade_mmap_lock_carefully(struct mm_struct *mm, struc= t pt_regs *regs) +{ + mmap_read_unlock(mm); + if (regs && !user_mode(regs)) { + unsigned long ip =3D exception_ip(regs); + if (!search_exception_tables(ip)) + return false; + } + return !mmap_write_lock_killable(mm); +} + +/* + * Helper for page fault handling. + * + * This is kind of equivalent to "mmap_read_lock()" followed + * by "find_extend_vma()", except it's a lot more careful about + * the locking (and will drop the lock on failure). + * + * For example, if we have a kernel bug that causes a page + * fault, we don't want to just use mmap_read_lock() to get + * the mm lock, because that would deadlock if the bug were + * to happen while we're holding the mm lock for writing. + * + * So this checks the exception tables on kernel faults in + * order to only do this all for instructions that are actually + * expected to fault. + * + * We can also actually take the mm lock for writing if we + * need to extend the vma, which helps the VM layer a lot. + */ +struct vm_area_struct *lock_mm_and_find_vma(struct mm_struct *mm, + unsigned long addr, struct pt_regs *regs) +{ + struct vm_area_struct *vma; + + if (!get_mmap_lock_carefully(mm, regs)) + return NULL; + + vma =3D find_vma(mm, addr); + if (likely(vma && (vma->vm_start <=3D addr))) + return vma; + + /* + * Well, dang. We might still be successful, but only + * if we can extend a vma to do so. + */ + if (!vma || !(vma->vm_flags & VM_GROWSDOWN)) { + mmap_read_unlock(mm); + return NULL; + } + + /* + * We can try to upgrade the mmap lock atomically, + * in which case we can continue to use the vma + * we already looked up. + * + * Otherwise we'll have to drop the mmap lock and + * re-take it, and also look up the vma again, + * re-checking it. + */ + if (!mmap_upgrade_trylock(mm)) { + if (!upgrade_mmap_lock_carefully(mm, regs)) + return NULL; + + vma =3D find_vma(mm, addr); + if (!vma) + goto fail; + if (vma->vm_start <=3D addr) + goto success; + if (!(vma->vm_flags & VM_GROWSDOWN)) + goto fail; + } + + if (expand_stack_locked(vma, addr)) + goto fail; + +success: + mmap_write_downgrade(mm); + return vma; + +fail: + mmap_write_unlock(mm); + return NULL; +} +#endif /* CONFIG_LOCK_MM_AND_FIND_VMA */ + +#else /* CONFIG_MMU */ + +/* + * At least xtensa ends up having protection faults even with no + * MMU.. No stack expansion, at least. + */ +struct vm_area_struct *lock_mm_and_find_vma(struct mm_struct *mm, + unsigned long addr, struct pt_regs *regs) +{ + struct vm_area_struct *vma; + + mmap_read_lock(mm); + vma =3D vma_lookup(mm, addr); + if (!vma) + mmap_read_unlock(mm); + return vma; +} + +#endif /* CONFIG_MMU */ diff --git a/mm/nommu.c b/mm/nommu.c index 617e7ba8022f..2b4d304c6445 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -626,22 +626,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, = unsigned long addr) } EXPORT_SYMBOL(find_vma); =20 -/* - * At least xtensa ends up having protection faults even with no - * MMU.. No stack expansion, at least. - */ -struct vm_area_struct *lock_mm_and_find_vma(struct mm_struct *mm, - unsigned long addr, struct pt_regs *regs) -{ - struct vm_area_struct *vma; - - mmap_read_lock(mm); - vma =3D vma_lookup(mm, addr); - if (!vma) - mmap_read_unlock(mm); - return vma; -} - /* * expand a stack to a given address * - not supported under NOMMU conditions --=20 2.49.0 From nobody Fri Dec 19 17:33:13 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FE3D23537A for ; Wed, 16 Apr 2025 10:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744799955; cv=fail; b=rrgTpkNxRvoQCtfYkQ2bXM8VXL9oYGt8w/hpyidqpO75J95KCk7GdmjDiwPwtH2yFdPQNHazJ6gZjQcRBou2uavZw4YFNyzK2ajdl+L4XXcPk9DsbizyqRYvRoMY4KsBC77N6lg9zD0i/QuYiIAzFDMYhf5icX9uCN/WofFSt+g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744799955; c=relaxed/simple; bh=hRT5QTq30KB9UIg82DDLlTTjyzLJ/GQLNEaUaDo2Vbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=XUeMoMtapRrjXqxM1/4vMPuqmRIdgiQ73aa+Gkm/XM0PTcAs26O3HuIgR9cOsQljSt3aTL4b4VHokp3F4zE2VpWNIc/1KIabb1n5K+fHjEp++i9woICIP7Lm4YUvYyMgMa+A+mzT/oWK6EL1b/2McLOPnmYgf3ii28r+3rBC2gQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Js3IBAqx; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=TQc2OpcP; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Js3IBAqx"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="TQc2OpcP" 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 53G9N1QV016690; Wed, 16 Apr 2025 10:38:59 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=nhFsUZ/l4K5outNHYvPGoBQnM3PKaNYMXgf5kYSMCyQ=; b= Js3IBAqxnOxB/w5YIEeEkd7mXeQryt7C73tHqTBP1z4zSKzE6nVG/fHEPZBPBajq RlTOqM2QD/UOxxEupOelBpQb3zCXOqD0LsWYlBbFZu4FNMaJbfWKpb1Urb+IguU4 0VwkQXF9QXk/iFBGjp7V3h+1EhTBNv/5dkVudzYhswKYwqXtlDsDXiyV2GUutDk8 0AMGjqpeMtjO4PNiwJ6dIGwaGkRrznQHbegtifcQBfyO8qOzQ2RtuyIeay2/vPsW 96QXPk5Y4xEClb+LoutFmPn3xjPnJ6m90tle3wLZ430P67O56jENiAoi3glkScjL HHFWyGwz7qH1Yu2XX1OrWg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 46185muqgr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Apr 2025 10:38:58 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53G8g0Ni024673; Wed, 16 Apr 2025 10:38:58 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2040.outbound.protection.outlook.com [104.47.70.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 460d51nre2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Apr 2025 10:38:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qYQXAHjrYPRRZLaU2zUSg9NKOqhLgLkTd5kyZJCa15jvGgeyLukPnFCyqot3fgSXMJlP41NESCf4D1XX/4Ai3xYyogOGjjwWGMSeoDJgv7UY0G9wbcdMweOHLtdMceK+PcKaBAN8BJFvdPZKBB2YbwkMhsAakNu4K1pxiA/rqaEK733rmP9Xf/pazxleg1Kvz7TISpGZaxzdzW3U2wY8H3F7ah+QXd48LuC8g3bIpgvLpbLx/xPiPY5fWdiMHXlw+G8s4VONc0fC72IsJYrHtsJQSneBLtrXVR8HJ8TiZyq0CIea6eAchOR/tYTXPY/G51MXRc2VvfXa52NSxJVugg== 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=nhFsUZ/l4K5outNHYvPGoBQnM3PKaNYMXgf5kYSMCyQ=; b=tzStjzMlWLWEy0NLR45X1addr2pvpBwy9pF5Xzh+cBPLPnskKBJeym7o07L/GXfu5uJ9vFjo5C1RBI1rajwz9nLRM8Zd9Q8zRl33L+u66zzkVPp8lQ4YyVdLb0UGMG+bhWZnyeUlEZFliLZZo+qKzguaM2PdOc+iUuVl4WSXAy/WmIugGN98US78o6onm2bY2HMAAIvc9W90DPTMWkhX/vCvH0Zt1tiZrXBrLljrawnm6PkTEw4I/nQGK3niApeYMYaDE2sMMyvyMtTivJQjPgovpMJbVBwyjwbBMqNwfu5JtVE3r1cnm5mZeoxIUwmr44yyAUGtBQTHu2j+Xo3lMw== 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=nhFsUZ/l4K5outNHYvPGoBQnM3PKaNYMXgf5kYSMCyQ=; b=TQc2OpcPQ/oRzWkduMJ3gTuX9B9gMoL8X6iAChUDVe8V5n0wEsT070DfA6QUe+Q6Xh0RLR1u1ZjsO7QNaM0SW/l4lgEQAmlLZC9+lb0O5/JW8dRNhG2GyoS3oZJ3V8YsT1t3Yvx3cM8m1Pfw/ode0BEie9CpRxDpJ1dY8NMoTSc= Received: from DM4PR10MB8218.namprd10.prod.outlook.com (2603:10b6:8:1cc::16) by CY5PR10MB5916.namprd10.prod.outlook.com (2603:10b6:930:2c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.22; Wed, 16 Apr 2025 10:38:55 +0000 Received: from DM4PR10MB8218.namprd10.prod.outlook.com ([fe80::2650:55cf:2816:5f2]) by DM4PR10MB8218.namprd10.prod.outlook.com ([fe80::2650:55cf:2816:5f2%5]) with mapi id 15.20.8632.036; Wed, 16 Apr 2025 10:38:55 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: Suren Baghdasaryan , "Liam R . Howlett" , Vlastimil Babka , Matthew Wilcox , "Paul E . McKenney" , SeongJae Park , Shakeel Butt , David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 2/2] MAINTAINERS: add section for locking of mm's and VMAs Date: Wed, 16 Apr 2025 11:38:37 +0100 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P123CA0354.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18d::17) To DM4PR10MB8218.namprd10.prod.outlook.com (2603:10b6:8:1cc::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR10MB8218:EE_|CY5PR10MB5916:EE_ X-MS-Office365-Filtering-Correlation-Id: 7256aca4-70f4-4d30-8de1-08dd7cd2e32b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7416014|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yvEPKUJS18qTayKiEpJXFhdgjXXoSBcwE7NDrkinDDk0keaGJLTEjTPFiYeJ?= =?us-ascii?Q?Ht46lqUMIxg+ahazpO/UG7Vf0jN2eSpc3VjIZiJquGU2WjEp40mUYUrrvOov?= =?us-ascii?Q?5RNid5Hfrvwe6AP/Ymq1j4EsWikcbNYiKV2VW1gQqvRe13Rr3vzaWRZm+I83?= =?us-ascii?Q?pF4B75wPGtdiMnkYq4YPS6s4Dvbyq3cWlknfvsd497Bbfg0rrEzusVgXAzFu?= =?us-ascii?Q?2tsQfE1iPamgJNIlD5e3DWHTif/bn1yDgoV632t8J3EW7laWY6YTaIl0+01I?= =?us-ascii?Q?+02iLlrHMrjV7bEYlr3GZa8QtEXM28wTMTCzMbfsKeITZ8OxTPEv5bMtIkSi?= =?us-ascii?Q?h5wGFQjUlQxzbKonpQLplrTdNK3/xU2ImjOzsrPnZfbbd6YglV+vIbkos7wN?= =?us-ascii?Q?/Adve8oERwqzaP0B6nptc+jDzhXYM/FQZvsDeJ7KrvBejm2tWTk1ZX/swhPv?= =?us-ascii?Q?UFH9KflblCbC0p0/01sDmhuudPFnpD5e0V498F2zyE/v4KslxXGXzkc1J6ZR?= =?us-ascii?Q?V8U6MkTefPz0JpnEyJCsiYwi77xzvOZLaSKEIIEUuzAG9fjGstZSlufWIn4W?= =?us-ascii?Q?wy4GXhPu+p/PWzpDrIM6ki0cksCDN/6wywZtynoCDc3d4akiROD7yGfLRk0J?= =?us-ascii?Q?M3qZ4+leFvfEwJSkeygnirsZPLKoGrW5LfpkvenqjChgzT6yKrRGRMsvbgNp?= =?us-ascii?Q?k/94TmIN/uY3S0XGXL8LZsILbY5jNqpG+pq7NgTg98kEmzHQ3uUPR6o3P9Tq?= =?us-ascii?Q?twRz6k+fmvEappvEnONMK3ThLD5kttgDUp5UvsCuiFPabv7rIV1TEbQtfkec?= =?us-ascii?Q?husp919XQS85ih9W7NQ62+ROD4HYujUhe/2ArC0lWs4vBXfj1tv30Vzzwetu?= =?us-ascii?Q?mB+f4gRk15RfkatoO2JMVNPjzdhtZk0G+x8jgkMJ2TykhocmL/vChnlz+Ikk?= =?us-ascii?Q?aP7h6mNaOnhxVGNLC4CTsaF/ZH/wA7sguj1LYHw/pVgPlOCwDiBI/QAtL1NP?= =?us-ascii?Q?XsGJVGKRJhNKFscTKftxkIGhxo4T35yoF5/i0ZIpM1Nu+PcR0mbC/U8foAZT?= =?us-ascii?Q?GRWKg1De825fcoNKQr1MlL/nZDCCumkpdlW5HKE7mSOJTX6Cch9U0HAhh4Gc?= =?us-ascii?Q?tkqEZ7/Yw6luLuuWuIcCuR8wKDBrLxursUt7a4dOLGe4nmNEYz7pFRCN/NK1?= =?us-ascii?Q?llv06SLyPMaRTnR7mjVofCMWIxFVHUczNqNZFtk0NUsVPoALbxZaLHi5WlAI?= =?us-ascii?Q?gCkOXPHzpnGrx3uLm7pTOwhQ91s3uWqBaoBka/tLre8O8tEL4has4FWYSEF2?= =?us-ascii?Q?SbOZKxdlFB+Sd2Q5WwipEXeWApIoubRpUmZ0uKaOb+TKPKVERVO2pIp1cLSb?= =?us-ascii?Q?Mu0k87o=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR10MB8218.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(7416014)(7053199007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iSnCncwBtcn2aDWP1ZFrtG+JVUhmeGu/LWNbCiEXAjgoGQvDYUubJiT+D26n?= =?us-ascii?Q?yAxeIntMLJKAw/352WxWwYIO4HAAfVxtNdzMbAjYmbfLjkllRIcSb9ClE/G2?= =?us-ascii?Q?knhULQ4FJf764l7t0zI9z6lJThBKj0EArzj1ld/AtD8v7EJy9yKQgZdhGXT9?= =?us-ascii?Q?/iZJGvQccDat0d9YpBGVQGLTOud2eTkcAShR6Qgh1BDK5d29eBWh2C1ssbg6?= =?us-ascii?Q?mzQcpUk1xuSjgmveq7GTo7fnNzQigb4x01BOAISFWjH9H/lNn4KhV+zF8zvT?= =?us-ascii?Q?QCPMvFI+k7mStvNUpWdIjY//LhA8umYpdqL2Mt0LEDcr8mE+f5IGnTb6oynA?= =?us-ascii?Q?SNBC+y6afz5gNyomqbeaVyLMpaR1qh8nsrH8Uz2l5poxjFVKyzHexplGJ9UC?= =?us-ascii?Q?Twk+NkwGVLOTp3sn/PHDopbtDNn6MbeZwSWR8JjOJUdP5/f65QYdZBxNLGmW?= =?us-ascii?Q?HFLWJNokiw0yYvere7WedauEy8i3ZdoXoXvPO1Zu5M+OvV97mEKPhg4hs1Qc?= =?us-ascii?Q?zZnon0MrdvKTXOhhAO+1vyH727NZRBw5yGAx+H+7zV2E956TNDZ6lBU2iCb7?= =?us-ascii?Q?kbEpp6Ce/FM0Ge95dnKU4/sPosGlOu+qqL9JZGWUjXMNoHfYznlX5WukEDrQ?= =?us-ascii?Q?d/C5hZ3UBPyFHw9vY37YeNM+WMxDL9uW9lGVJlxVeD/zjPEyA2phvw7gN4FW?= =?us-ascii?Q?pandW5ysElOhMfWVcPeghrRRjwY+QiEjcmnEdu6Rmc+RBeZZcUPO7UFHuJtw?= =?us-ascii?Q?szHp7oXM3CeiWzEmzeJ4CnY0Hp81IGyAFQBmd1lAiZ1soeGsRQL7AKQ/8FJ/?= =?us-ascii?Q?xFyszNpWBx/SRxOlABI9UOR67oPRnyLfkHiCm5Y5OwLlud0aN+zoFiNiY0Ay?= =?us-ascii?Q?4V8MfB6VD0mF0lYNjGQ8+z3c8lzWxD9d95GFGJD72VheVHUjC4Y7hpbE5WTl?= =?us-ascii?Q?YAGCj9BkseEE3N7YLR7fJpYyAkBaxCisyyyLIHDa+4YAbtIRevJU5w6oTphc?= =?us-ascii?Q?Z+8Lc441V9s4i5+R+u3uYrTw8r76ZzEJB694+PhgLxQmf2YDY6egEEdC322N?= =?us-ascii?Q?Jw+asZkAWzTgnVSR6inzlryPWu9pOWpVddTVz8ht6mH7ATr5q8qqf4IRnuIF?= =?us-ascii?Q?H9Sp1QcW8kxGDSn30slGzCDdn9CuIsCeQBuCiwU6x1M1EtGA6+vmsd8tBTIR?= =?us-ascii?Q?D2ABTzCdglycT+eSBVoZlTB/rgF8JqfRECTI6ef3AVOqnrxzMDKUSo+tO9jw?= =?us-ascii?Q?qt8BKBgyx9Bb1psHfYQgB5h6A/VlBeJwKobJC4UIqIl3BToQuJ1ZrRBUAZQa?= =?us-ascii?Q?KrSJPQhSlFMByJF0J9fywPt0Sp7WH/gT1ke2FFBfLRHxMi8EtG6zgMX8Dozf?= =?us-ascii?Q?KeWWE8tJus9b/K/gfiwPuCXapiq3anD/H7y0N2ddQfdmhUFoM77XADGENVMC?= =?us-ascii?Q?CeaAGjYLlMWEzUUE+rKxUcXJgAmTXIiWW0svjCGAxC4FdtUExa9JrppDU0F6?= =?us-ascii?Q?DWfzMHmsnUqx0DP2FGNHKHbYJFBPmpt9wt2v7s6g3Csi3AMvvU/zgh1kgelk?= =?us-ascii?Q?iR5adZit+pujKZ05FKgW/dIMXcOglPrqFzmrHNrzhiKWbAeZ7dPTq2rumASy?= =?us-ascii?Q?2A=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6PJJJpwembcCmXCI3wtzo3w8rXir23Wnf1wUBojiYnCBCPC7jMnGPUiSfM5MyWPJFRKMSCkciYw+zv8I/hh8nCBv3pnBt9zlb/32QEyW2T8FLOHLvguvQVbCRuumdl729RUFy8QYLRpaUlwNQ1j2UGwiAvSGzHeswKQfstj6O2bISbNQsPZ3oX1+HOC3yP+uFyDTmwcSLZhmpeMHJANel15vfM02Jx2P/34LrVx3rXGWhVPK7XV4n3DGVFSVr04Jd8c9oLD6NElXheatCTsvOhYjbleCmMlNwGxq5NX1Qs+t25FSgJBTV4NWE2JBtDM66T+mc4bUSxHJNOyxo7Ayp+atwNiq3OXSjMCVsG5u2g+2fBKYrTpgtZGXV4rQUDegyylgr6v99lK219E9yw8xq9FAxa7tKMmMycT2mO8ocdp3xsysQsJatcoKubW4S6BzgGI5kbbUePOcA53tXH3FJ/1ZwnILrgPtDOUU4QEfcPavutrIdW4V23fLfnrBRo9qYmAVkXEYaEOvgcvQCOZ9RibWr+SGjv8RXHcmTv33paSAtDYxnyUfRngd3qdLMdoU37KVWarbg3lCUjVYKO135FJBmyEueU84Kqbu9Q2b+24= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7256aca4-70f4-4d30-8de1-08dd7cd2e32b X-MS-Exchange-CrossTenant-AuthSource: DM4PR10MB8218.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2025 10:38:55.3559 (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: r+Ysudv/Cw/qg4oUhZA4umw0Uyf2sfUbeUblkRiQkuu8rIqaz3D6eYRsUjD6ORo0zLChkEtSWStMOmbjQIjt9ny3x30v5WyxeXTVLrZw/2w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB5916 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-16_04,2025-04-15_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504160087 X-Proofpoint-ORIG-GUID: rFVY46f3Ab8GRZztBqcrk_1L5gtrKX8z X-Proofpoint-GUID: rFVY46f3Ab8GRZztBqcrk_1L5gtrKX8z Content-Type: text/plain; charset="utf-8" We place this under memory mapping as related to memory mapping abstractions in the form of mm_struct and vm_area_struct (VMA). Now we have separated out mmap/vma locking logic into the mmap_lock.c and mmap_lock.h files, so this should encapsulate the majority of the mm locking logic in the kernel. Suren is best placed to maintain this logic as the core architect of VMA locking as a whole. Signed-off-by: Lorenzo Stoakes Reviewed-by: Suren Baghdasaryan Reviewed-by: Shakeel Butt Acked-by: David Hildenbrand Acked-by: Vlastimil Babka Reviewed-by: Liam R. Howlett --- MAINTAINERS | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 8d834514a047..03bbc41138c9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15595,6 +15595,22 @@ F: mm/vma_internal.h F: tools/testing/selftests/mm/merge.c F: tools/testing/vma/ =20 +MEMORY MAPPING - LOCKING +M: Andrew Morton +M: Suren Baghdasaryan +M: Liam R. Howlett +M: Lorenzo Stoakes +R: Vlastimil Babka +R: Shakeel Butt +L: linux-mm@kvack.org +S: Maintained +W: http://www.linux-mm.org +T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm +F: Documentation/mm/process_addrs.rst +F: include/linux/mmap_lock.h +F: include/trace/events/mmap_lock.h +F: mm/mmap_lock.c + MEMORY MAPPING - MADVISE (MEMORY ADVICE) M: Andrew Morton M: Liam R. Howlett --=20 2.49.0