[PATCH v2 0/2] mm/migrate: speed up move_pages() node queries

From: Qiliang Yuan

Date: Thu Oct 01 2026 - 21:25:36 EST


move_pages() with a NULL node list reports the node of each page, and
RDMA and KV-cache engines call it on every page of buffers spanning
hundreds of gigabytes. do_pages_stat_array() walks the page tables from
the top for every address, at about 105 ns per page.

Patch 1 walks runs of consecutive pages with walk_page_range(). Patch 2
raises the do_pages_stat() chunk from 16 to 512 pages so that a run can
cover a whole PTE table. Together they bring the per-page cost from
104 ns to 12.3 ns with 4K pages and from 90.6 ns to 2.0 ns with THP,
and a 16 GiB buffer of 4K pages from 486 ms to 52 ms.

Signed-off-by: Qiliang Yuan <odys.yuan@xxxxxxxxx>
---
V1 -> V2:
- Walk the runs with walk_page_range() and a pmd_entry callback instead
of extending folio_walk_start() by hand (Zi Yan)
- Raise DO_PAGES_STAT_CHUNK_NR from 16 to 512 in a separate patch, with
numbers for each chunk size (Zi Yan)
- Re-measure everything in one run on a VM that now has two NUMA nodes,
with the test bound to CPU 0, so the baselines differ from v1 (16 GiB
of 4K pages: 486 ms instead of 440 ms)

v1: https://lore.kernel.org/r/20261001-bug-mm-move-pages-stat-batch-v1-1-255b7e915744@xxxxxxxxx

---
Qiliang Yuan (2):
mm/migrate: walk runs of consecutive pages in do_pages_stat_array()
mm/migrate: raise the do_pages_stat() chunk to 512 pages

mm/migrate.c | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 177 insertions(+), 29 deletions(-)
---
base-commit: 551c722f40809618230001baccf219193e22fc5a
change-id: 20261001-bug-mm-move-pages-stat-batch-f62a29ea5867

Best regards,
--
Qiliang Yuan <odys.yuan@xxxxxxxxx>