Re: [RFC PATCH v5 03/10] mm: Hot page tracking and promotion
From: Gregory Price
Date: Wed Feb 11 2026 - 11:09:25 EST
On Wed, Feb 11, 2026 at 09:10:23PM +0530, Bharata B Rao wrote:
> 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
>
Also relevant note from other work I'm doing, we may want a fast-out for
zone-device folios here. We should not bother tracking those at all.
(this may also become relevant for private-node memory as well, but I
may try to generalize zone_device & private-node checks as the
conditions are very similar).
~Gregory