the correct place should be: @@ -1329,6 +1326,10 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, if (anon_vma) put_anon_vma(anon_vma); folio_unlock(src); + + if (folio_test_anon(src)) + mod_mthp_stat(folio_order(src), MTHP_STAT_NR_ANON, 1); + migrate_folio_done(src, reason); return rc; Without this modification in migration code, my tests fail, anon_num can become negative.
I was wondering if we should do it in __folio_migrate_mapping(). There, we set newfolio->mapping. -- Cheers, David / dhildenb