Re: [PATCH] mm: mempolicy: fix automatic numa balancing for shmem
From: Gregory Price
Date: Thu Jul 23 2026 - 14:48:43 EST
On Thu, Jul 23, 2026 at 01:48:27PM -0400, Gregory Price wrote:
> On Thu, Jul 23, 2026 at 01:07:04PM -0400, Johannes Weiner wrote:
>
> So the default global mempolicy is effectively:
>
> (MPOL_PREFERRED | (MPOL_F_MOF | MPOL_F_MORON)
>
> which is just MPOL_F_NUMA_BALANCING without MPOL_F_NUMA_BALANCING.
>
> The user can't actually see that - because the MOF/MORON flags get
> stripped out when it's queried (because they're internal only).
>
> Maybe we should just set MPOL_F_NUMA_BALANCING in the default/preferred
> policies and document that the global preferred policy default-enables
> MPOL_F_NUMA_BALANCING - and that if a user (KVM) doesn't want to be
> affected by numa balancing it needs to set a policy to disable it.
>
Walking this all back:
- MPOL_DEFAULT is the default policy
- numa_balancing=on means enable NUMA_BALANCING on the defaul policy
- shmem was broken and did not respect this
Johannes' fix is correct, and there are no additional changes required.
Users enabling numa balancing while running KVM with shared regions are
not getting what they're asking for presently - that is a bug.
They should get the performance hit they're asking for (and then either
turn off numa balancing or set an explicit mempolicy for those tasks /
memfd's).
~Gregory