Re: [RFC PATCH v5 03/10] mm: Hot page tracking and promotion

From: Bharata B Rao

Date: Wed Feb 11 2026 - 21:11:49 EST



On 11-Feb-26 9:38 PM, Gregory Price wrote:
> 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.

Yes, zone device folios aren't not tracked by pghot. They get discarded
by pghot_record_access() itself.

>
> (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).

Good.

Regards,
Bharata.