Re: [PATCH v7 2/7] mm: migrate: Add promote_misplaced_memcg_folios()

Donet Tom
2026-05-04T18:16:07Z

Hi Bharata

On 5/4/26 11:39 AM, Bharata B Rao wrote:
> +int promote_misplaced_memcg_folios(struct list_head *folio_list, int node)
> +{
> + struct mem_cgroup *memcg = NULL;
> + unsigned int nr_succeeded = 0;
> + struct folio *first;
> + int nr_remaining;
> +
> + if (list_empty(folio_list))
> + return 0;
> +
> + first = list_first_entry(folio_list, struct folio, lru);
> +#ifdef CONFIG_DEBUG_VM
> + {
> + struct folio *f;
> + list_for_each_entry(f, folio_list, lru)
> + VM_WARN_ON_ONCE(folio_memcg(f) != folio_memcg(first));

It looks like the indentation might be off here.

> + }
> +#endif
> + memcg = get_mem_cgroup_from_folio(first);
> +
> + nr_remaining = migrate_pages(folio_list, alloc_misplaced_dst_folio,
> + NULL, node, MIGRATE_ASYNC,
> + MR_NUMA_MISPLACED, &nr_succeeded);
> + if (nr_remaining)
> + putback_movable_pages(folio_list);
> +
> + if (nr_succeeded) {
> + count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded);
> + count_memcg_events(memcg, NUMA_PAGE_MIGRATE, nr_succeeded);
> + mod_lruvec_state(mem_cgroup_lruvec(memcg, NODE_DATA(node)),
> + PGPROMOTE_SUCCESS, nr_succeeded);
> + }
> +
> + mem_cgroup_put(memcg);
> + WARN_ON(!list_empty(folio_list));
> + return nr_remaining ? -EAGAIN : 0;
> +}
> #endif /* CONFIG_NUMA_BALANCING */