From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012060.outbound.protection.outlook.com [52.101.53.60]) (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 3D084466B7D for ; Thu, 11 Jun 2026 18:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.60 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781203481; cv=fail; b=VlkknfNZhdvdpu/CljoEGvws8QaKOGhi2RhAWSV15Z1M5WqvLj2Ka5CbChT4XlY4DsEdHWSl14/T7AuY/yvjutiFRLa7aLXPVQEANrD7sroLQhkOaddu2cbTRwNU1yR9dR7nItkif6VtpbSWWUPoydvsSpEheVZXFH6UoUUcf1Y= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781203481; c=relaxed/simple; bh=wgmrHvqlktHM5Sx5tmsS3O4XMQ2POdhEbGvkjqhvWS8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=MmP/Td51Q+dm/WDQgHlwei3G++vApWVPu0ojos6eXCyp5gC9M5MNZGb0GcCylZ6L6D729vpEvb7BiLu2tLyVC2mxeL05JQUbyC1iiCZ+VpsIG/0Xhq2K/r/+J4DJRL8Q9YI303EfFctTkp+njHUdOAiNqTWODl+B1BBPluAra3Q= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=nP3JuLd3; arc=fail smtp.client-ip=52.101.53.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="nP3JuLd3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lIWW9JehwTB61Tp63sSKl9gTiTZ1gPM3E8F5yA5tPXssVuIWVFjsgB92e8LxgEHzXa7U5UFjI4LcuCVfq4LKvIlxB5jdZ3dkO8t4IL0m65Z2ET6s/fEAHOpDnckhjM+m6j0j1C1E8M/9J4spMam4LCMpbP9toa0KSKFLL7EgJ55OR8yya9ypZgUamIAVOp+nevJhrOjJ/ggRMvDH0BCHImoiHSmcjHg8jPegjU2Wc0QNzm7UVbnohcf/n5kLVBi3NO1xrk/Zq72Xmr3VeBMnoMTTTYS9jPyHeASCPJXX5AVNibRzq6v7NlxCWENz0hudedBtohqqMvEDTIwImFCPmg== 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=50pmpMkiyb8VL87ydQG/hNCE0l8OGczBOWVY5zMAy/M=; b=MW/P5li6TIAz4ug+jDDlfrh+gK5AMzVHaFfdB1bZh22NgYTJA4sKrHuPrEpEVXL5DMT1DGpfV0AtFvXuDaOC04uRuRArmvtEvlaOp6/RK6LtlBacV09KQiL7ghlow9msJCpAMWh+brgywYaKuF7zyJndgZYkCPVVuO1qmf4S339eXWZlzXzrEgtb04umPFzN60VH01r+vYXELuZ72kBh/PV9yFTQJXCqD7HQzbGCwOWE3IuTs/k6hK9pA9mHW5Ag6ncov+7aVMCrvLL6HXY4JR+Bs/p/Q+eZqLoNcwTpbCOMG1b4oDXs3+3RrTnofmd/6Noenxm0BvnmbNJGZRaNug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=50pmpMkiyb8VL87ydQG/hNCE0l8OGczBOWVY5zMAy/M=; b=nP3JuLd3RKB6WixiDgOXhlOHJ3iRCWUasKcowkAl+/Z10GtibfUoz0sjOaqUslcQjgX+jZGTvt81lAqyEEpIwfYg+z+18ulY49UsoEw9KIt6yycQidEDSGjTXPPS8j9cZnsz94YLxL5oRkqgDTX6JtmDUqyD+uQTLP7oQHbPUbHHPWYDLvp/nrH499sGwNk9vzMAYFrsqk4rBV6XRDgZZUDYgKbf1oX1gSZ+62ZBej0C1ipqbr/Ynv13rp/Vbf4NIbZLTQ+iu1eYnaQm3HFm6bRlJpq5MWC+T7uVuvM4Yy/sVY756Yl2h8pHUX4SSCDbLfSBYdxXkZ9cfmJuaidH3A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BL4PR12MB9478.namprd12.prod.outlook.com (2603:10b6:208:58e::9) by PH0PR12MB7981.namprd12.prod.outlook.com (2603:10b6:510:26c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.17; Thu, 11 Jun 2026 18:44:32 +0000 Received: from BL4PR12MB9478.namprd12.prod.outlook.com ([fe80::4d08:451e:a51e:33a1]) by BL4PR12MB9478.namprd12.prod.outlook.com ([fe80::4d08:451e:a51e:33a1%6]) with mapi id 15.21.0113.013; Thu, 11 Jun 2026 18:44:31 +0000 From: Zi Yan To: Karim Manaouil Cc: David Rientjes , "Garg, Shivank" , "David Hildenbrand (Arm)" , akpm@linux-foundation.org, kinseyho@google.com, weixugc@google.com, ljs@kernel.org, Liam.Howlett@oracle.com, vbabka@kernel.org, willy@infradead.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net, ying.huang@linux.alibaba.com, apopple@nvidia.com, dave@stgolabs.net, Jonathan.Cameron@huawei.com, rkodsara@amd.com, vkoul@kernel.org, bharata@amd.com, sj@kernel.org, xuezhengchu@huawei.com, yiannis@zptcorp.com, dave.hansen@intel.com, hannes@cmpxchg.org, jhubbard@nvidia.com, peterx@redhat.com, riel@surriel.com, shakeel.butt@linux.dev, stalexan@redhat.com, tj@kernel.org, nifan.cxl@gmail.com, jic23@kernel.org, aneesh.kumar@kernel.org, nathan.lynch@amd.com, Frank.li@nxp.com, djbw@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 5/7] mm/migrate: add copy offload registration infrastructure Date: Thu, 11 Jun 2026 14:44:27 -0400 X-Mailer: MailMate (2.0r6290) Message-ID: In-Reply-To: <20260611095537.cyljpqekjbjc5jqw@wrangler> References: <20260428155043.39251-2-shivankg@amd.com> <20260428155043.39251-12-shivankg@amd.com> <9145ae5b-a33e-4092-8cb5-efa18ae61287@kernel.org> <70ee3800-0469-4c3d-8a1c-bb6594c64f42@amd.com> <20260611095537.cyljpqekjbjc5jqw@wrangler> Content-Type: text/plain X-ClientProxiedBy: MN2PR14CA0012.namprd14.prod.outlook.com (2603:10b6:208:23e::17) To BL4PR12MB9478.namprd12.prod.outlook.com (2603:10b6:208:58e::9) 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: BL4PR12MB9478:EE_|PH0PR12MB7981:EE_ X-MS-Office365-Filtering-Correlation-Id: 9111f055-4750-460a-269b-08dec7e9799e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|7416014|376014|1800799024|11063799006|56012099006|4143699003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: GxKdF50VlYJEoBHV3UBxXAzc7VMGUE0l+any/ikx84G+P3ClJzayPu+2sCITz4sILk0pcE3zVWwTZW7a8nXn0ZksUkKx38sw1n12h/UQHsMQs6J+ylJYZxsSJa48pPNXafuAuLgQkyAiLAZqvjCqOWKaVc1KV3mNcQyzcQQUxy2NKGEjYtnzdo2w+E5+NSbZH/fDdhXD5bGqB0fGegqAS0+nztpC4lcgYgNylLz/9KrmvoV2iYH7WD7Cu0wCcuJvp5ABCsy6/9ApoFQOahe+Fs97EfvkKvJq5WzQQoEgM0o2o2UetE2tchtrHvUv1omKN1bc1vYLkFU9BO8RG93i2FkvOlavW7CGFKLyniyj7tV1UJ3D+OMAxpSfjkAOVWAIclJ18ziUmcSbzfjiuwJ5kyPIBV+XwWAXdrTplHXpiRoF59zoLa3ZaywgvA6K0aLkXVR2B0pxrwJ2ONoDqlWeaceR1hZkqGMwFGB+cF56NJNjnenf+ZjJG+CeHvAQtoeM8FNn5Waos3BMyZF+K86jRKT1vS5chgjBvurE6Ltf8F1S5o+UK0aJiURCwNJXrAjC71qriZoFwzSu6+cpjhZMHf3CVavp1a+5g0IKYA1h4Skw7lCDeatiYs9Z7Eu9r5qWaJSHucPoh0Rm//POcK9G+nKE8oCsMs2kH63K8EgBrpwRtRhGdB/NemDh1udfXqxd X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL4PR12MB9478.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(23010399003)(7416014)(376014)(1800799024)(11063799006)(56012099006)(4143699003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iLI99fiT5aD2QZlcGok6Q9vtq7KICJ8dZftyXnN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?kRLqP9B8y5C5dPuMXrtYw+50i/n4cdKPw5kzhPwhg7OIfBFYQQwX5T3mUAP4?= =?us-ascii?Q?aLSeqRF6AdCgoHBjq3ErZyWr3WwpG/p1LO9a73kVQJICWz8fN7vU55mwXEqZ?= =?us-ascii?Q?U31TYDDMIucBXvmc6G7TPgbiBLczZtpJ1My7MYePcyXxVDYFRLLXnEA8SF1P?= =?us-ascii?Q?ed9PFUtk23K3+VRZ1iwzpPjZCzx86YOlLJYH3YR9LUUmeylS4eEhbKm7qr1K?= =?us-ascii?Q?1Fb15xyAeIdp4Bi8LtR/jyHgPbtDVTcPwwTpsaoO1fjACcvHdXmPXh3kweLd?= =?us-ascii?Q?FAdjV79sZbAIuZQiKwvRQCS1smZv+2/OTgqWWRNLPQ2XOgnaUF1voLZKcWee?= =?us-ascii?Q?3NYCYfqSdKpsdvAAYJU6ingregojSaQqT7oWpx+1u31O5K9fd4jCWJQkI6tR?= =?us-ascii?Q?+f5R7o1DK5kLwVxqAJeHO9AWUwqB528wRZ44XPHnYhmQ9dph94T+OZ4kCF0u?= =?us-ascii?Q?hmmantvFxQ8bNbNR7VKuGZG2Qnh9LntoWtohm+QRXyFV1fq4kM5TvO0PT6oI?= =?us-ascii?Q?xfIlpcsJSzfsEKV4EiMmDaDpab62ZoxMLMIU9MNVVofMNjQ+9Ree3l2qGYhK?= =?us-ascii?Q?ucKJksxu/AqAyV60O+Dbcpbnv7T54alIHe0z7PAhrO3Xn6ohRjxH74dCN3Dv?= =?us-ascii?Q?sujUCi3ItxzkPjKeb0eqnqCg4aw/nlJMrLi788EqoifLpo/oe6H1AxG9k84C?= =?us-ascii?Q?OhOxRfbvVKCHkvjCKT29Y/OwC1eIKm9I7KKrbWPu+6GPVCrzB6g01/hJ26R7?= =?us-ascii?Q?qdgcArNmVmbT7d7EV1NjyLlrve6F5wWXktoCkgsFemmGyvK1?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9111f055-4750-460a-269b-08dec7e9799e X-MS-Exchange-CrossTenant-AuthSource: BL4PR12MB9478.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2026 18:44:31.7116 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4aw2rp/rL/7lZv/VMOVHBJeD8iZvIs8Dp2lj0mRVD7jIFri4C8+QQGjqpBauQtL0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7981 On 11 Jun 2026, at 5:55, Karim Manaouil wrote: > On Sun, May 24, 2026 at 07:16:55PM -0700, David Rientjes wrote: >> On Wed, 20 May 2026, Garg, Shivank wrote: >> >>>>> +static bool migrate_offload_do_batch(int reason) >>>>> +{ >>>>> + if (!static_branch_unlikely(&migrate_offload_enabled)) >>>>> + return false; >>>>> + >>>>> + switch (reason) { >>>>> + case MR_COMPACTION: >>>>> + case MR_SYSCALL: >>>>> + case MR_DEMOTION: >>>>> + case MR_NUMA_MISPLACED: >>>>> + return true; >>>>> + default: >>>>> + return false; >>>> >>>> >>>> What's the exact reason we don't do this for hotunplug etc? IOW, why do we make >>>> this depend on a reason? >>> >>> Reason-based filtering could be a requirement for some users who want only specific >>> use cases to go through DMA offload. >>> >> >> +1, I think this makes a lot of sense; not all DMA offloads are created >> equally and we may prefer to unburden them from being contended by >> migrations that they are not intending to accelerate. >> >>> For the RFC, I introduced a placeholder to enable further discussion on which use cases >>> should allow migration offload and whether offload users actually need this control? >>> >>> Your other point also makes sense: "If someone migrates a handful of folios, latency is >>> likely more important (and batching less beneficial)." >>> Based on this, we could either fully rely on batch size. I'll think more about this. >>> >> >> There are, or will be, some offloads that must be used for certain types >> of page migrations, like Confidential Computing. That's for functional >> reasons, not a heuristic. >> >> We want to use certain hardware assists solely for promotion and demotion >> of memory for tiering. We certainly wouldn't want those hardware assists >> to be inundated by users doing tons of move_pages(2) on their own or by >> best effort memory compaction in the kernel. > > One of the biggest arguments against using memory-offload accelerators for > generic page migration is that user-mapped memory migration is dominated > by rmap (unmapping before migration) and remove_migration_ptes() after > memory copy. In my experiments with Intel DSA on Sapphire Rapid, > assuming you're copying 4KiB pages at a deep queue depth (64/128 pages). > > 1. A single instance can achieve up to 30GB/s when counting > only descriptor submission and polling for completion. > > 2. With DMA mapping overhead, which you usually have to do when you > are behind an IOMMU, it's about 23GB/s in IOMMU passthrough mode, > and 17GB/s in translated mode. That's still more than double the > throughput achieved by a single CPU core at around 9GB/s. > > 3. The throughput drops significantly when measuring the > completetion of the entire migrate_pages() at barely 1GB/s. > > Unmapping is about 50% of the total time and remove_migration_ptes() is > about 40/45% in my experiments, which leaves only 5/10% on the table for Do you have a breakdown of unmapping and remove_migration_ptes()? Are these 4KB pages shared or private? I can see that a shared page can cost more during rmap. BTW, I assume your measurements are done with migrate_pages_batch(), which performs TLB shootdown once for all these pages, otherwise TLB shootdown cost would dominate. > the actual page data copy. You're not bottlenecked by memory bandwidth > to justify using a memory-offload accelerators and the CPU cycles you > save from offloading is too small to matter. > > So any discussion on accelerating promotion/demotion using these > accelerators is useless to me, unless I am missing something. > > Like what kind of use cases do you have in mind? What kind of workloads > and pages you're thinking? Especially, via migrate_pages() which is > largely involved in scenarios involving user-mapped memory (anonymous and > file pages) and thus heavy rmap involvment. A paper[1] shows that using DSA can improve memory compaction speed and memory compaction should migrate <2MB folios. [1] https://ieeexplore.ieee.org/document/10841986 > >> I think the use cases should be configurable by the user if at all >> possible so we can control what has access to being offloaded. These are >> often shared system resources and can be contended like any other >> resource, so configuring which migrations can use them vs not use them >> seems important. > > -- > ~karim Best Regards, Yan, Zi