Re: [PATCH 3/3] mm/numa_balancing:Allow migrate on protnone reference with MPOL_PREFERRED_MANY policy

From: Michal Hocko
Date: Tue Feb 20 2024 - 03:49:08 EST


On Tue 20-02-24 09:27:25, Aneesh Kumar K.V wrote:
[...]
> case MPOL_PREFERRED_MANY:
> if (pol->flags & MPOL_F_MORON) {
> if (!mpol_preferred_should_numa_migrate(thisnid, curnid, pol))
> goto out;
> break;
> }
>
> /*
> * use current page if in policy nodemask,
> * else select nearest allowed node, if any.
> * If no allowed nodes, use current [!misplaced].
> */
> if (node_isset(curnid, pol->nodes))
> goto out;
> z = first_zones_zonelist(
> node_zonelist(thisnid, GFP_HIGHUSER),
> gfp_zone(GFP_HIGHUSER),
> &pol->nodes);
> polnid = zone_to_nid(z->zone);
> break;
> ....
> ..
> }
>
> /* Migrate the folio towards the node whose CPU is referencing it */
> if (pol->flags & MPOL_F_MORON) {
> polnid = thisnid;
>
> if (!should_numa_migrate_memory(current, folio, curnid,
> thiscpu))
> goto out;
> }
>
> if (curnid != polnid)
> ret = polnid;
> out:
> mpol_cond_put(pol);
>
> return ret;
> }

Ohh, right this code is confusing as hell. Thanks for the clarification.
With this in mind. There should be a comment warning about MPOL_F_MOF
always being unset as the userspace cannot really set it up.

Thanks!

--
Michal Hocko
SUSE Labs