From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796134758; b=QJSBENuU6EwH7PvPKTiEIAR34h44nUF/LserSTVqRx738qB96mbPlwcWlGxufM4oycz0 D7W7jZgDh1UFM01iLL99X6uow+bt1zDxXn9q/f1XkyA34jaTINAXUCj/5iu5h3FWpkadx 9xQS8IzcTOPjgpfRLqP7FREO0zIOnOUpLarwcXE0fSFQKwBwdJqjCnUseBegKPOvJ6xun 5bO5oJS6fnK1tBTJJntAIv7IgoAkNCc9J8SgIm/bU/RV6wpSB/20TwpigQXgGjc1dappB v4JB3zTNf8cJ4p16pxyGTjMGLijPtUMeBrB82dqVRrJKpyZzjMN/chtsyKHmlufnJbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796134758; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=+IiDmR940EbtFHlppZSW0PAAkWyPDTRKnNfDcCJE5E0=; b=TgkMBz2Sai685bYgIYZB3hst6OLmkl6Tw3MYrnMeEQRwvnZ39/Wk1IBUR/exKs3E30Df Esv+tmOrJJA+HO0S5AaOk89IVCRpz7w35Yeu+1Jh2ERdZLY06kpqBdcAwo8F2dbPEDgek nGKYnX0HboGY35iUM//dmc+3TmbKZZgzKu21Sh1j9gVpChFE9iH3tpKFKkKs8Ul8b5eWs gXPqgLomIZHMLiDy2/onJVkFKI+YsjEB+3KsVvhsYI2nn4hitlJ0qjJsRcnnAVkJr6Ge4 3pjYiHctsWH9i3Vp0yI5tHWYlBvntE3fSY/S6wE/Znavv1re3Hn4f4ZCMW2A+Yur+CA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=cWSEG+tf; arc=none smtp.remote-ip=198.175.65.18 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CC05606A322; Tue, 1 Dec 2026 14:19:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3CC05606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=cWSEG+tf DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796134758; x=1827670758; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+IiDmR940EbtFHlppZSW0PAAkWyPDTRKnNfDcCJE5E0=; b=cWSEG+tf1BI8L+zxLJgQaMTwAEXPCMbEyCzV4DPcHUVihIGuc7b4JKK5 BHGXDonsoytGmgxlXEvwFC/+/lPheZWk+pH3bQtBuVyxHFAQghj+XLSkU KxfnGxDzQvkEjNw/WD/LcspoSjzpqRrUzPhVSkURi/S6eBhlZLLWCnuaw WQar+fqO2Djl8h2KxSaY3lvoly5/qC7B9TKN/xBjpD2CyMFGUsYCySGoY DY10xh/lsf6e0oEMG3HoPTq/kgcBEvBto4NGQTB2zxY8oPWnNIodLdmDd Bd0roHpCvUaW3TJXsA+v1l4elF/HC0/7NTli6vCka5AxS5SB5ZtwAMH2c w==; X-CSE-ConnectionGUID: 7K4li6BqQvGDAn3OgMxiyw== X-CSE-MsgGUID: dvTWI749SpSxZGgbVN1gWw== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5019179" X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="5019179" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 06:19:16 -0800 X-CSE-ConnectionGUID: ttOFCl99TsSfTqAfu3uJZQ== X-CSE-MsgGUID: TkYNyW10TTu6GapNdIqo2A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="13380679" Received: from jf5300-15a101203tc.jf.intel.com (HELO meta-crater2c.jf.intel.com) ([10.54.113.49]) by fmviesa005.fm.intel.com with ESMTP; 01 Dec 2026 06:19:13 -0800 From: Daniel Byrne To: Shivank Garg , Ravi Jonnalagadda Cc: Andrew Morton , David Hildenbrand , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Karim Manaouil , Frank van der Linden , Teja Vojjala , Pravin Tamkhane , Kinsey Ho , Wei Xu , Matthew Wilcox , Davidlohr Bueso , Vinod Koul , Bharata B Rao , SeongJae Park , David Rientjes , Xuezheng Chu , Yiannis Nikolakopoulos , Dave Hansen , Johannes Weiner , John Hubbard , Peter Xu , Rik van Riel , Shakeel Butt , Tejun Heo , Fan Ni , Jonathan Cameron , "Aneesh Kumar K.V" , Nathan Lynch , Frank Li , Dan Williams , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Day , dmaengine@vger.kernel.org, Vinicius Costa Gomes , Frank Li , Dave Jiang , Daniel Byrne Subject: [RFC PATCH 00/10] mm/migrate: dcbm for Intel DSA, on top of the batch copy offload RFC v6 Date: Tue, 1 Dec 2026 06:12:49 -0800 Message-ID: <20261201141259.2124188-1-daniel1.byrne@intel.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is my implementation of dcbm for Intel DSA, on top of RFC v6 of "Accelerate page migration with batch copying and hardware offload" [1]. It is for reference and for testing next to Ravi's report on v6 [2]. It is not meant to be merged as it is. The first four patches are Shivank's, and the rest is meant to be taken into v7 where it can fit. What this RFC contains: - Patches 1 to 4 are patches 1 to 4 of RFC v6, rebased to v7.4-rc2 with no other change, so that the series applies. Patch 1 applies as posted. Patches 2 to 4 are rebased, and every line they change is as in the posting. - Patches 5 to 7 are fixes to those four, meant to be folded in: 5. FOLIO_CONTENT_COPIED is bit 2 of the word in which hugetlb keeps HPG_temporary, so a surplus hugetlb destination reads as already copied and its copy is skipped. This loses the data, with or without an offload driver, see "Testing". The marker gets a bit of its own on hugetlb, behind two helpers; 6. a folio with private data, or with a migrate_folio() callback of its own, stays off the batch copy, since a copy made ahead of the move phase bypasses what those rely on; 7. the provider is called with the folios of the batch locked, so it runs in a NOFS scope. - Patches 8 and 9 add to dmaengine what patch 10 uses: DMA_MEMCPY_SG again, and a prep flag for the provider's cache-control hint. - Patch 10 makes dcbm work on a provider that is shared and completes out of order, as DSA does: - every descriptor has its own completion, counted down on a pending counter, and an error result sends the folio to the CPU copy; - the channels are requested once, when offloading is enabled, and held. Concurrent batches share them through per-channel trylocks, and a batch that finds every channel busy is copied on the CPU; - source and destination are mapped per folio and paired by folio, without scatterlists that have to merge alike on both sides; - a batch keeps a bounded number of descriptors in flight on a channel, since a work queue has a fixed pool of them; - no timeout and no terminate. terminate_all acts on the whole channel and would end the other batches on it; - on a provider with DMA_MEMCPY_SG a slice goes out as scatter-gather transactions, and the copies ask for the cache-control hint unless a module parameter turns it off. Against the three topics of Ravi's report [2]: 1. Channel lifetime. Patch 10 holds the channels. A provider that goes away under them is not handled in this series. That needs the dmaengine side first. I have a series for it that is not posted yet: the core marks a channel that its provider removes under clients as detached, the channel takes no new work, and the client releases it when it sees dma_chan_detached(). It builds on the two helpers of [3]. The dcbm side that releases such a channel follows with it. 2. Completion order. Patch 10 counts every descriptor on every provider and does not test DMA_COMPLETION_NO_ORDER. That capability goes away in my polled-status series [4], whose v2 is in preparation. With it a client can also wait for a descriptor by its cookie, and a descriptor without DMA_PREP_INTERRUPT no longer stays allocated on DSA. 3. Timeouts and failed channels. Patch 10 only waits. What I am working on beyond it is not in this series: a device whose completions are overdue takes no new work until everything out on it has landed, and the CPU copies meanwhile. NUMA hinting faults stay out of the offload by default there. Also not in this RFC - the idxd side of patches 8 and 9, which turns a scatter-gather transaction into one DSA batch descriptor and supports the cache-control flag. It needs my idxd fixes, of which the third part is not posted yet. Without it patch 10 uses one descriptor per folio on DSA. Testing: The series ran on an Intel CPU with DSA and two NUMA nodes, on v7.4-rc2 with the idxd driver as it is there. Four DSA devices of one node had four shared work queues each, which gives 16 dmaengine channels. The load was move_pages() between the two nodes, and every run compared the data with its pattern afterwards. The comparisons below are between the rates of the move_pages() calls: - 2 MiB folios, one thread: dcbm is 5-6 times as fast as the CPU copy, on 1, 4 and 16 channels alike - 4 KiB folios, one thread: dcbm is about 1/3 slower than the CPU copy. Small folios are better left to the CPU, as in Ravi's report - batches of 2 MiB and 4 KiB folios together, on 4 channels and on 1 - 2 MiB folios with 8 and 32 threads on 16 channels: about 4 and 5 times the rate of one thread. With 32 threads about a fifth of the folios found every channel busy and were copied on the CPU. With 8 threads on one channel about half of them were - offloading switched off and on ten times under four threads of load, with another channel count each time, and the module unloaded and loaded again - anonymous and shared hugetlb folios, to surplus destinations and to pool pages (patch 5) - the page cache of an ext4 file, clean and dirtied through the mapping. None of its folios went through dcbm (patch 6) No page was left behind, no data differed, and the kernel log stayed clean. The same patches were tested on a kernel with KASAN, lockdep, DMA-API debugging and DEBUG_ATOMIC_SLEEP, with the same result and no report. For patch 5 a kernel with patches 1 to 4 only ran the hugetlb part, with the dcbm module not loaded. It moved 1 GiB of anonymous hugetlb pages to surplus destinations about 40 times faster than a move that copies them, and every word of it differed afterwards. With patch 5 the data remains the same. I did not run a provider that goes away under the held channels, and a channel that fails or times out. The series handles neither. [1] https://lore.kernel.org/all/20260630-shivank-batch-migrate-offload-v6-0-da95d7e8b8a2@amd.com/ [2] https://lore.kernel.org/all/20261128224616.66122-1-ravis.opensrc@gmail.com/ [3] https://lore.kernel.org/r/20261130195203.1901143-1-daniel1.byrne@intel.com [4] https://lore.kernel.org/dmaengine/20261019150632.4026424-1-daniel1.byrne@intel.com/ Tools: I used Claude Opus/Fable model to review (sashiko and local reviews) the code, suggest fixes, and edit the changelogs. I also used it to run the builds and the test rounds described above. I reviewed the results and fixes it suggested and I am responsible for them. Daniel Byrne (6): mm/migrate: give hugetlb its own bit for the content-copied marker mm/migrate: keep folios with private data off the batch copy mm/migrate: no filesystem reclaim under the batch's folio locks dmaengine: reintroduce DMA_MEMCPY_SG dmaengine: add DMA_PREP_CACHE_CONTROL drivers/migrate_offload: make dcbm correct on shared, out-of-order engines Shivank Garg (4): mm/migrate: skip data copy for already-copied folios mm/migrate: add batch-copy path in migrate_pages_batch mm/migrate: add copy offload registration infrastructure drivers/migrate_offload: add DMA batch copy driver (dcbm) .../driver-api/dmaengine/provider.rst | 10 + MAINTAINERS | 2 + drivers/Kconfig | 2 + drivers/Makefile | 2 + drivers/dma/dmaengine.c | 1 + drivers/migrate_offload/Kconfig | 9 + drivers/migrate_offload/Makefile | 1 + drivers/migrate_offload/dcbm/Makefile | 1 + drivers/migrate_offload/dcbm/dcbm.c | 785 ++++++++++++++++++ include/linux/dmaengine.h | 24 + include/linux/migrate.h | 84 ++ include/linux/migrate_copy_offload.h | 69 ++ mm/Kconfig | 6 + mm/Makefile | 1 + mm/migrate.c | 160 +++- mm/migrate_copy_offload.c | 258 ++++++ 16 files changed, 1383 insertions(+), 32 deletions(-) create mode 100644 drivers/migrate_offload/Kconfig create mode 100644 drivers/migrate_offload/Makefile create mode 100644 drivers/migrate_offload/dcbm/Makefile create mode 100644 drivers/migrate_offload/dcbm/dcbm.c create mode 100644 include/linux/migrate_copy_offload.h create mode 100644 mm/migrate_copy_offload.c base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb -- 2.43.0