Re: [RFC PATCH v5 03/10] mm: Hot page tracking and promotion
From: Bharata B Rao
Date: Wed Feb 11 2026 - 10:41:10 EST
On 29-Jan-26 8:10 PM, Bharata B Rao wrote:
> +
> +/*
> + * Walks the PFNs of the zone, isolates and migrates them in batches.
> + */
> +static void kmigrated_walk_zone(unsigned long start_pfn, unsigned long end_pfn,
> + int src_nid)
> +{
> + int cur_nid = NUMA_NO_NODE;
> + LIST_HEAD(migrate_list);
> + int batch_count = 0;
> + struct folio *folio;
> + struct page *page;
> + unsigned long pfn;
> +
> + pfn = start_pfn;
> + do {
> + int nid = NUMA_NO_NODE, nr = 1;
> + int freq = 0;
> + unsigned long time = 0;
> +
> + if (!pfn_valid(pfn))
> + goto out_next;
> +
> + page = pfn_to_online_page(pfn);
> + if (!page)
> + goto out_next;
> +
> + folio = page_folio(page);
> + nr = folio_nr_pages(folio);
> + if (folio_nid(folio) != src_nid)
> + goto out_next;
> +
> + if (!folio_test_lru(folio))
> + goto out_next;
> +
> + if (pghot_get_hotness(pfn, &nid, &freq, &time))
> + goto out_next;
> +
> + if (nid == NUMA_NO_NODE)
> + nid = pghot_target_nid;
> +
> + if (folio_nid(folio) == nid)
> + goto out_next;
> +
> + if (migrate_misplaced_folio_prepare(folio, NULL, nid))
> + goto out_next;
We should hold a folio reference before the above call which will isolate the
folio from LRU. Otherwise we may hit
VM_BUG_ON_FOLIO(!folio_ref_count(folio), folio)
in folio_isolate_lru().
I hit this only when running Graph500 benchmark and have fixed it in
the github at: https://github.com/AMDESE/linux-mm/tree/bharata/pghot-rfcv6-pre
The numbers that I have posted for micro-benchmarks and redis-memtier are
without this fix while Graph500 numbers are with this fix.
Regards,
Bharata.