From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011009.outbound.protection.outlook.com [52.101.62.9]) (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 1AB0E2561A7 for ; Sun, 12 Jul 2026 07:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.9 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783842060; cv=fail; b=c7SfNckzrI7DZ1WjWo/ZJnJJXWEAcjdpkbdehivBxlSqEbVblnDOu38LXva8urC1AscO+bJ5o76pPVFiWXYVHtM43XZVFs+A9s4WFEkKflH+zfwPJjJQCYy/RMvVtTvkmmBIHO6qevRhGuIx9SgmD89bBQDH6SpS3ym98SPQaJw= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783842060; c=relaxed/simple; bh=JaWvTqPDVb50vASsYrb/KTWrSaLeUDGTlaOCse6oj0w=; h=From:Subject:Date:Message-ID:MIME-Version:Content-Type:To:CC; b=n24JXXflHaEKMv/ABESRvwOLVH/3Fb1LppX4F4FQLQSsbYcNlIcA/ycxJZ8vK23O7WauC/8QUE5CJmQeu62n7J0Uz2X/MTX9AB2gHgMjTOVUMhPcdNgU+XtcbYM9SXkQxlpAxtMvbLd3HujFkiRgoDFyF8sOrU275yDwxsuydxk= 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=msn/BWK6; arc=fail smtp.client-ip=52.101.62.9 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="msn/BWK6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JkuYrLFX+3nUZTIGiN1E6kxEc4TbXZbZ/iiIGe0PAHFDkjkclH6yj7w7Z3Q5lBADvjtn25jlZu7yDIqTqWLEP1W7ioNMwv7SB65JSlc7p3KmIQyOOmJIyVh4RxWTlP5AOWXQSc2OTMHgUtKQXsYY528yZLWq7sOIxnu3pBoZip0Ag4Ul4qsgV1QEZxQy+AQPTc6GIsLLsb65hqo0RiP6rQ4fO8fT4nPRYRWVXp6ZweBM3vjKK9zuU7oAZPCaZirxUPYZ0XfLRu3SMWxFg/VSO03DTwQsR9wKC4u/aQft9ysaeVRY44lBcmhiBmTpIroukK/+aeD9SCAYn2BSg69xRw== 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=fyz4ctdhor70uMG2b2egvjPOetCEM34n6i2B+bcaLeg=; b=mV7JnTL4jNxvhBBhsYNPA3yYNXNkWdlWvuzyQBWL44MFS55uqkysWWXqVeBmpihcTLrWeW7Ll+6to3RhK1Oouxdn1V85N8tPRmdai+IzGa4aAvdPwjbmpk/1lsFuBsp27C93EUaBR+GVb+EmfmA4Ctha1Cu9swzCSmbecu8QCBUS9eu94l1IufUY5glR0F2QYQV/raW/Lmzlt5hTfUgQeK0lZPx2bKnuIO2JJ+2FKQ9ruFRzLbi7jyYmRIoc8x7DJdTjPAnng/mB1M2mQ+LrLTm6sEmnAp+kJJJmT0F/WbwD/CpcCUdrbl0KgJ0JfqSEC3KsoeAlvMU0300eiLO4dw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com 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=fyz4ctdhor70uMG2b2egvjPOetCEM34n6i2B+bcaLeg=; b=msn/BWK6/zai91Hr4oS6r9wVKBOE3pe0VkDrn9XQaHcZVoCKXAyqUnoTTKNcZ9QqrD8JvVFnN7A5GRmmvUEshLx6GY/s7otw54uVldKyrxpL9id80Dv8srV8rBDMOYGVTWXjopIzBgkLLX+Bj8Ri4RHvpnjSp7itNdAIBMMfz28= Received: from MN0PR04CA0011.namprd04.prod.outlook.com (2603:10b6:208:52d::7) by DS7PR12MB6119.namprd12.prod.outlook.com (2603:10b6:8:99::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.19; Sun, 12 Jul 2026 07:40:52 +0000 Received: from BL02EPF0001A108.namprd05.prod.outlook.com (2603:10b6:208:52d:cafe::14) by MN0PR04CA0011.outlook.office365.com (2603:10b6:208:52d::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.202.18 via Frontend Transport; Sun, 12 Jul 2026 07:40:51 +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 BL02EPF0001A108.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9 via Frontend Transport; Sun, 12 Jul 2026 07:40:51 +0000 Received: from [127.0.1.1] (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.41; Sun, 12 Jul 2026 02:40:44 -0500 From: Shivank Garg Subject: [PATCH 0/6] mm: batch rmap walks during large folio migration Date: Sun, 12 Jul 2026 07:38:46 +0000 Message-ID: <20260712-migrate-rmap-batch-v1-0-872a734431d1@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-B4-Tracking: v=1; b=H4sIAIZEU2oC/y3MwQ6CMBCE4Vche3aTLREFX8VwKGWEPYC4rcaE8 O406PGbZP6VIkwR6VasZPho1Oec4U4FhdHPA1j7bCqlvMhVHE86mE9gm/zCnU9h5BohyLmHa6S ifFwMD/0e0Xv7s+H1zu30H7dtB9nNMNN5AAAA X-Change-ID: 20260701-migrate-rmap-batch-8ecc04de1905 To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , Rik van Riel , "Liam R. Howlett" , Vlastimil Babka , Harry Yoo , Jann Horn , Lance Yang , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , "Alistair Popple" CC: Karim Manaouil , Frank van der Linden , Kinsey Ho , Wei Xu , Bharata B Rao , David Rientjes , Dev Jain , , , Shivank Garg X-Mailer: b4 0.15-dev-47d62 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783842044; l=3176; i=shivankg@amd.com; s=20260518; h=from:subject:message-id; bh=JaWvTqPDVb50vASsYrb/KTWrSaLeUDGTlaOCse6oj0w=; b=7f+y52xOewLwCYemlCFsPtwxeHTDGiYPaP8RC5UFxeq4+tqH/VwkIiViBzDXo28tokOOhWDZa h2YFWh4hUTpAVxXJMGt1s87tPKGji+2+jqt3tTxK/xXW7+RnGF2JsUb X-Developer-Key: i=shivankg@amd.com; a=ed25519; pk=2l2QGTeXuGkZTtfmx0nPQU8iFZfjYmX/ymMojitevx4= X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A108:EE_|DS7PR12MB6119:EE_ X-MS-Office365-Filtering-Correlation-Id: bb5e532f-b09e-4e91-9da0-08dedfe8e604 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700016|82310400026|23010399003|921020|13003099007|18002099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: 7qIBSmWlCxUE1jXUxbeEDqKqhZMRLkuJGJJTGZ5e9YhTOnxXCePJDNV2zUUarr+XsuqQGgfyzrG1vgKYelMh2r5H8zP8CWoPRbYHVHua5TWai8iOrwcY7+z1XJdLwFJQc4aCa+xDzrVbqYzNXQjPZTKEclynckf+hIw0RDiEgVQI8ZxzXp1YISih2i9XC4sBvjEAAnQpt/6MsZV6qc0uCr+KL8Zpa9HhLTrO2B8315k3a4JYwXimi8o/bzCsk6R5zqdB1WaILDDl/d1mHLMRlm36YUjkesjk7HR8j16jIZAfO4A2MRhCR9mN+KFoLeMlsM+7QDQ/NhfMB6OAbeXbiip2UK64CLU7bgMyl6WTFt0hqtXbO8V8gymXw3K4yOOl2GvcqScMKdIV26SdDdjs0CmAhKWk0iQSQKLSZVU4i3U+Tovm2kLe4TAuEpfMpMI1fVhauRWOSzwHIB6rEPS5JaYDqeW9qEGyG2sKpnp2bcQfdfNJIq+SNYijMLKo61Lo+YokNuuBrERVOOFRMmq+hjnKWn12+yaaZmlccw4Eajd/G6bNGFYH0Ux+NiRF5sC4mALg80CscDadDUk0V/HQAFoLpNacOnihZnxTk6SYS3zaKmGdrU5aU9unUvp+hpmAoBHFx0Qo8mEXrB8Y650m/ALaPuWDfc+XKrtXgcnnlmLYAupMgcUja4/JBXfm2H11r6da6Yg6RfXTyKoieZAR0+Uwg7SV/cXQbsaC6HnD3Q54kZNc1Z3/OXcdLzbBcngX 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)(1800799024)(376014)(7416014)(36860700016)(82310400026)(23010399003)(921020)(13003099007)(18002099003)(56012099006)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: brOrSDkyVc0JLjoYHUiVPIZajSCwy62/9WgL8qXvVPJ27BHob9qQBEE5E3waog3N4M+1UlHwIXKIgGBd9DtNUm9MZ8B24VVmj77z6HYlL2VDB1+eoKRH/aFPhbqIxCeMTNlzldXRzQAZsu9vtrARr7Lw3d0o+l1HCSNObLIyEWvdkF5iq7hYhxoIYbP4U3Lexj1Mk3ZehXUYpjgv4QRz1emncIiMdxwyl4MPs5NMYNOenX9vU8PqBYFs9eEtnQtOvchDiMXbYILjywLaOwrbpB7Ny9hJBitN0ZkOsjQx8NqrI91MKDpHlXLOBSPk9jEMIsSqOS3AJPSW69QZUDT84SjthDmU4wB4qZbXIeYPYHrwiCfe1kS016q+PXhhRpDwWxxI11V3b4fsrpM/4Il8xUd4LZC1p+CVDg/IX3cFJnwRIue7qUUrlyky6rDytwJ+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2026 07:40:51.7237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb5e532f-b09e-4e91-9da0-08dedfe8e604 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: BL02EPF0001A108.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6119 Migrating a PTE-mapped large folio currently walks the folio's rmap one page at a time. It does so twice per migration: 1. try_to_migrate_one(): Replace present PTEs with migration entries 2. remove_migration_pte(): Restore migration entries to working PTEs. For a folio with N contiguous PTEs, each walk repeats page_vma_mapped_walk() and the associated operation per subpage of the folio. (256 iterations for 1M folio). This series enables both walks to process a batch of consecutive PTEs that map the same large folio and do some refactoring and clean up on the way. Performance: AMD EPYC ZEN 3, 2-socket system (1 node per socket). move_pages() migrating 1 GB from node 0 -> node 1, throughput in GB/s: batch- batch-restore + folio vanilla restore unmap restore% restore+unmap% 4K 2.98±0.09 2.95±0.07 3.06±0.05 -1.0% +2.6% 64K 6.16±0.09 6.24±0.08 7.80±0.08 +1.3% +26.6% 256K 6.85±0.06 6.85±0.09 9.54±0.19 +0.0% +39.3% 1M 7.06±0.09 7.17±0.09 9.89±0.06 +1.5% +40.1% 2M 10.97±0.17 10.67±0.13 10.69±0.15 -2.7% -2.6% In plain migration, the folio copy itself dominate the cost, so these rmap walk savings are only partly visible end-to-end. When the folio copy is batched-copy and offloaded to DMA engine [1], the copy is no longer the bottlneck and rmap-walk batching translates into much larger gains: This series + [1], DMA Offload on PTDMA (DCBM), 16 channels: batch-copy folio vanilla -offload(dcbm) dcbm+restore dcbm+restore+unmap 4K 3.36 ± 0.10 4.16 ± 0.18 4.10 ± 0.14 4.12 ± 0.13 64K 6.16 ± 0.47 9.63 ± 0.23 10.00 ± 0.33 14.63 ± 0.14 256K 6.70 ± 0.09 12.98 ± 0.18 13.52 ± 0.15 32.30 ± 0.65 (2.38x) 1M 6.99 ± 0.02 14.32 ± 0.67 14.84 ± 0.17 38.97 ± 1.03 (2.62x) 2M 10.74 ± 0.29 64.25 ± 1.48 65.36 ± 1.00 64.97 ± 1.75 [1] https://lore.kernel.org/linux-mm/20260630-shivank-batch-migrate-offload-v6-0-da95d7e8b8a2@amd.com Applies cleanly on mm-new 10-07-26 (61cccb8363f). Signed-off-by: Shivank Garg --- Dev Jain (1): mm/rmap: Add batched version of folio_try_share_anon_rmap_pte Shivank Garg (5): mm: factor out generic PTE batch detection from swap_pte_batch() mm/migrate: split remove_migration_pte_hugetlb() out of remove_migration_pte() mm/migrate: batch the restore-side migration rmap walk mm/rmap: split try_to_migrate_hugetlb_one() out of try_to_migrate_one() mm/rmap: batch the unmap of large folios in try_to_migrate_one() include/linux/rmap.h | 52 +++++-- mm/internal.h | 36 +++-- mm/migrate.c | 190 ++++++++++++++++------- mm/rmap.c | 427 +++++++++++++++++++++++++++++++++------------------ 4 files changed, 464 insertions(+), 241 deletions(-) --- base-commit: 61cccb8363fcc282d4ae0555b8739dd227f5ad0b change-id: 20260701-migrate-rmap-batch-8ecc04de1905 Best regards, -- Shivank Garg