From nobody Fri Dec 19 15:00:29 2025 Received: from PH0PR06CU001.outbound.protection.outlook.com (mail-westus3azon11011027.outbound.protection.outlook.com [40.107.208.27]) (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 BA9E0224B01 for ; Sat, 6 Dec 2025 10:15:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.208.27 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765016123; cv=fail; b=gNqlxMCqcHm55iYzDmMnUtIcqlu+eFCtey7iTWm2Dq7Cq6JjVMafK9w5U+wATkTVcy1KuT9XKuIMdUpReOb1R0o1H+1wuge3ncTikQ3kGwvHGdJFI0KOz3vLKF3PlZXw3XT/BADzuLO5axVfsWOeuhurhjcYyEWdQ1Iu181Terg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765016123; c=relaxed/simple; bh=3KdAxd7WKauYcI2Rzz5W33ayFi+hck8naHHEYbQAXsg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d2P9qJuNxx4qADqdZFEbMG1XcuOOiSerr1q1c1ehQtK/V98vG1NpFR06HIcCItfzzyJLn90OsqtwzPjPNL0LfPsf2+UvNvNo+H8BXcvNacX5nRIKIoiUSDklZUeqhzIbbhgdwNUttJGJ/jveITX1k/fCMToNbmf5PpuuFAQykeM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=MVnIu3L4; arc=fail smtp.client-ip=40.107.208.27 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MVnIu3L4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DaNjvorKuKqv1mqX1+UPBqPDqrrEuyh1x/9lV1olv4Fhc16w+vPHJglVy/L6zgTKPv3WTSWvWmC32dsoaMmOksJO36usv/wmJ1tHkdJEE4WV5OzVunT2r6bGJRiZsI1LRKGzE4I00fbkXTFIpJyuqoSgtkkjvQdp0WloSb16ELKAwXNH87QhQjGbwsSC5bBw35iw+Jh/OGOJOW1pROLXFLLknqCq7tIiHVKoeTOJyjH+in7nAbAdrRwA2aiWuqMMjp4Q9AQkFp1mtPN/jh5A5dY4pVuqsWhoOylyz+ceAXCBfMdXC4RRReqWLEMJxsLslN6xLi1+kM+2A48l+Y+ebg== 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=Csunv4ay0ersKu9D+/xbcPqUb4eanrv3W4tEcydndrs=; b=yYwPfjOEv2StYuSyWiNy5N9ksM0z3BHmHcuCUArcSFJCT15yotXqBvH2XCyF0E511r4KurGv8gOkVSH5hXJcu19r1b4Lrdt7LhoO0HEnlZJNmYsol2E4nPT5WmCkiRRg7F9xnjexFYJp7/kgg1rVR1LSpcxorYPYpHrgoTR4X8JufhoG4xz4xZKNLPSemQO/l4B+15ls5OpCz81RGknND26wWczD13kRFOd63GPnBY3tDBQ71h5IOQjDDK4lruZtEPoemfVq/CvD646YYqeXcRHvN04F+K3i2h13TiGaLJNBi0K9MI5kxx4gDK/XmJwQhOGhnT0LKcQkedgrCe5XIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Csunv4ay0ersKu9D+/xbcPqUb4eanrv3W4tEcydndrs=; b=MVnIu3L4750LNJGDAZy7+Xw11rS/Xyj/1J5DzXlhQ+KeIEsCtHcKjrDi9KKC4eIdt14dC2iF+JVSg1jo6FOpIDsVnMemDH/FchazwUdnDbd6uO7M4K0/TY0ds+2m5kiorfOxpvsoIbITWkoVWZ/7vQ/GHTfvnrpgyxoP5BM4M4g= Received: from PH0PR07CA0103.namprd07.prod.outlook.com (2603:10b6:510:4::18) by PH7PR12MB5975.namprd12.prod.outlook.com (2603:10b6:510:1da::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9388.12; Sat, 6 Dec 2025 10:15:18 +0000 Received: from CY4PEPF0000EE37.namprd05.prod.outlook.com (2603:10b6:510:4:cafe::fe) by PH0PR07CA0103.outlook.office365.com (2603:10b6:510:4::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9388.12 via Frontend Transport; Sat, 6 Dec 2025 10:15:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000EE37.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.4 via Frontend Transport; Sat, 6 Dec 2025 10:15:17 +0000 Received: from BLR-L-BHARARAO.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Sat, 6 Dec 2025 04:15:10 -0600 From: Bharata B Rao To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , Bharata B Rao Subject: [RFC PATCH v4 1/9] mm: migrate: Allow misplaced migration without VMA too Date: Sat, 6 Dec 2025 15:44:15 +0530 Message-ID: <20251206101423.5004-2-bharata@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251206101423.5004-1-bharata@amd.com> References: <20251206101423.5004-1-bharata@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE37:EE_|PH7PR12MB5975:EE_ X-MS-Office365-Filtering-Correlation-Id: eee0e76f-8f70-4023-631e-08de34b05b05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?49QlquUi8ou4X057+H1TnfXZXvfIjXTbyp4yCfOrzDowdBrwdAQJD0eMdTW3?= =?us-ascii?Q?etad2v5mMxmYYIv3sqCZyx4yuGAVbhaDObuu7a2t/kpCu3icszujS7zesKmZ?= =?us-ascii?Q?mhQUO4p5EGNJ6r4jj/OitYuikRVo1g/d7ckV0A0RDAz0LHHAb4BJM7LqW7Oh?= =?us-ascii?Q?8VWlx/hvL+b/vw66z+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XsUcRxF6yVP6SGz5HwwOqW0pwI4OJRTCNtT5cbWkpNUeFVcwlOZdKhERtaV?= =?us-ascii?Q?6nXVY87+DG9E7EU1bbc9GdGyXTuj2DuQR+ydGZbsULs7gHaCUwTy0BpKGStS?= =?us-ascii?Q?waEB2WNUZQmt0J7R2h/INhOSdVtoOvc9W3pQIhSfAl7/jrgxW81V92S5GsFC?= =?us-ascii?Q?EiXTfAS1F0lcAA2j5PlymX3ONEy7KxBlsG0vpR22TkQqwop2woizqcajGwvz?= =?us-ascii?Q?0S0EThPV1HwtF37+Ao59SmPyxv1yZ5U/8LvnzLuwanOfA5bEQ7UArbe698zf?= =?us-ascii?Q?gnmr5pAioy0vojbbCzPF9guzL/9QCzfZK+P50KSXlP5ezBP20IhMQu98kKE1?= =?us-ascii?Q?UP0/RA2suGzRiPHt8589O9a/5t/Icnj6+kDyyTSvxDUVmwrZDydfZd9ZY8f1?= =?us-ascii?Q?zb1xd2H8Ttc4Viy7u8jeVmyoxRDeXA+lRfH4A7mBxQXfCiR1e374KkK9dJjG?= =?us-ascii?Q?5l2YIMWUaz6b/Cz5iyU=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2025 10:15:17.8264 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eee0e76f-8f70-4023-631e-08de34b05b05 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE37.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5975 Content-Type: text/plain; charset="utf-8" We want isolation of misplaced folios to work in contexts where VMA isn't available, typically when performing migrations from a kernel thread context. In order to prepare for that allow migrate_misplaced_folio_prepare() to be called with a NULL VMA. When migrate_misplaced_folio_prepare() is called with non-NULL VMA, it will check if the folio is mapped shared and that requires holding PTL lock. This path isn't taken when the function is invoked with NULL VMA (migration outside of process context). Hence for such cases, it is not necessary this function be called with PTL lock held. Signed-off-by: Bharata B Rao --- mm/migrate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index c0e9f15be2a2..189d0548d4ce 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2644,7 +2644,8 @@ static struct folio *alloc_misplaced_dst_folio(struct= folio *src, =20 /* * Prepare for calling migrate_misplaced_folio() by isolating the folio if - * permitted. Must be called with the PTL still held. + * permitted. Must be called with the PTL still held if called with a non-= NULL + * vma. */ int migrate_misplaced_folio_prepare(struct folio *folio, struct vm_area_struct *vma, int node) @@ -2661,7 +2662,7 @@ int migrate_misplaced_folio_prepare(struct folio *fol= io, * See folio_maybe_mapped_shared() on possible imprecision * when we cannot easily detect if a folio is shared. */ - if ((vma->vm_flags & VM_EXEC) && folio_maybe_mapped_shared(folio)) + if (vma && (vma->vm_flags & VM_EXEC) && folio_maybe_mapped_shared(folio)) return -EACCES; =20 /* --=20 2.34.1