Re: [PATCH] mm: mempolicy: fix automatic numa balancing for shmem
From: Johannes Weiner
Date: Thu Jul 23 2026 - 13:15:37 EST
On Thu, Jul 23, 2026 at 11:58:27AM -0400, Gregory Price wrote:
> On Thu, Jul 23, 2026 at 10:54:06AM -0400, Johannes Weiner wrote:
> > >
> > > My stance is that using NUMA balancing with KVM guests is a terrible idea, and
> > > that anyone that insists on using such a setup gets to suffer the consequences.
> >
> > I agree. Surely we cannot leave shmem balancing broken due to
> > that. It's also not clear to me how many people even enable numa
> > balancing.
> >
>
> I lean towards Johannes' stance here that consistency is better, and if
> KVM has a known-poor interaction with numa balancing, maybe KVM should
> simply set a default policy (when none are present) to avoid this.
>
> That said, this is painful because MPOL_F_MOF / MPOL_F_MORON are already
> a silently inherited policy on boot (added during init). This will be
> confusing for users.
>
> This is not documented anywhere. Maybe this change should come with a
> docs addition that says the default global policy is ACTUALLY:
>
> MPOL_LOCAL + (MPOL_F_MOF | MPOL_F_MORON)
>
> Instead of just MPOL_LOCAL and letting that silent implementation
> detail bite people.
Hm, where do you see "Instead of just MPOL_LOCAL"?
Documentation/filesystems/tmpfs.rst says it defaults to "default" and
points me to set_mempolicy(2). That in turn in general makes little
mention of numa balancing and doesn't mention MPOL_F_MOF/MPOL_F_MORON.
In fact these are documented as internal flags.
The numa_balancing entry in
Documentation/admin-guide/sysctl/kernel.rst however DOES say plainly
that enabling this feature will sample and migrate mapped process
memory to where it's used, and that this has a performance penalty.
It seems there is a general lack of documented interactions between
user-requested policies and the system-wide numa-balancing behavior.