Re: [PATCH] mm: mempolicy: fix automatic numa balancing for shmem

From: Gregory Price

Date: Mon Jul 06 2026 - 13:39:24 EST


On Mon, Jul 06, 2026 at 07:27:57PM +0800, Huang, Ying wrote:
> >
> > I considered proposing MPOL_F_MOVABLE_ONLY to mean (roughly) "userland
> > memory only" - and then slowly trying to migrate numactl to make this
> > the default.
>
> What is the right mempolicy for these random kernel allocations? If the
> pages are used privately by the task (not the case in your example, but
> is it possible?), is it OK to use the mempolicy of the task? If the
> pages are shared, what is the correct mempolicy? Will it be fixed? Or
> can we find a way to change the policy?
>

I submitted a recommendation[1], but I think it got swalled by the kvack
outage, i'll probably need to re-send.

At the very least, these allocations should just use the system default
(local node) instead of the task.

I left the page-cache affected by this (so inode data DOES follow this)
but after some testing I found this amounts to around ~0.4% of total
memory usage when you have many small files (~64kb files, 512GB cached).

I think we can probably drop the first commit and just ship the second.

The fun result - when you combine this fix + private nodes [2] you can
reliably hotplug a private node in ZONE_NORMAL so long as all tasks that
were using the private node were reaped prior to hotplug.

This is a legitimately useful improvement in my opinion.

~Gregory

[1] https://lore.kernel.org/all/20260701222112.2820098-1-gourry@xxxxxxxxxx/
[2] https://lore.kernel.org/all/20260222084842.1824063-1-gourry@xxxxxxxxxx/