Re: [RFC PATCH v5 02/10] migrate: Add migrate_misplaced_folios_batch()

From: Bharata B Rao

Date: Fri Feb 27 2026 - 09:41:42 EST


On 27-Feb-26 2:10 AM, Joshua Hahn wrote:
>
> Hello Bharata, I hope you are doing well! Thank you for the series.
> I saw the numbers and they look great. I'm hoping to do some more testing
> myself as well : -) I'm also going through the series as well!!

Thanks Joshua for looking at the patchset and for your testing offer!

>
>> + if (nr_succeeded) {
>
> The single-folio case, migrate_misplaced_folio, has a guard here to
> check that the function performs more than just a migration, but a promotion.
> Specifically, it checks that the folio's node is not toptier, and the
> destination node is toptier. Should that also be included here?

Ideally yes, but right now the batch variant gets called only for promotion case.

>
> When this is called in kmigrated_walk_zone in the next patch, there is no
> check to make sure that the folios are actually on a lower tier, and the
> destination is on a higher tier. Maybe I'm missing something? But it
> wasn't entirely obvious to me that the migration is always a promotion.

Firstly the hotness is tracked only for lower tier pages. pghot_record_access()
ensures this.

Next, there is one kmigrated thread for each lower tier node and it looks at its
own PFNs. This ensures that only lower tier PFNs are considered for promotion.

>
> I want to note that we're also skipping the count_memcg_events, which
> I understand is much harder to do here becuase each folio might belong
> to a different memcg. Ying also noted this in his reply from v1 [1]
> but I don't think it ever got addressed.

Ying's suggestion about unifying single and batch versions of misplaced
migration routines is in my TODO list. memcg accounting looks harder, I will
give it a try.

Regards,
Bharata.