Re: [patch 1/2] mm, page_alloc: extend kernelcore and movablecore for percent

From: David Rientjes
Date: Thu Feb 15 2018 - 15:47:46 EST


On Thu, 15 Feb 2018, Michal Hocko wrote:

> > When the amount of kernel
> > memory is well bounded for certain systems, it is better to aggressively
> > reclaim from existing MIGRATE_UNMOVABLE pageblocks rather than eagerly
> > fallback to others.
> >
> > We have additional patches that help with this fragmentation if you're
> > interested, specifically kcompactd compaction of MIGRATE_UNMOVABLE
> > pageblocks triggered by fallback of non-__GFP_MOVABLE allocations and
> > draining of pcp lists back to the zone free area to prevent stranding.
>
> Yes, I think we need a proper fix. (Ab)using zone_movable for this
> usecase is just sad.
>

It's a hard balance to achieve between a fast page allocator with per-cpu
pagesets, reducing fragmentation of unmovable memory, and the performance
impact of any fix to reduce that fragmentation for users currently
unaffected. Our patches to kick kcompactd for MIGRATE_UNMOVABLE
pageblocks on fallback would be a waste unless you have a ton of anonymous
memory you want backed by thp.

If hugepages is the main motivation for reducing the fragmentation,
hugetlbfs could be suggested because it would give us more runtime control
and we could leave surplus pages sitting in the free pool unless reclaimed
under memory pressure. That works fine in dedicated environments where we
know how much hugetlb to reserve; if we give it back under memory pressure
it becomes hard to reallocate the high number of hugepages we want (>95%
of system memory). It's much more sloppy in shared environments where the
amount of hugepages are unknown.

And of course this doesn't address when a pin prevents memory from being
migrated during memory compaction that is __GFP_MOVABLE at allocation but
later pinned in place, which can still be a problem with ZONE_MOVABLE. It
would nice to have a solution where this memory can be annotated to want
to come from a non-MIGRATE_MOVABLE pageblock, if possible.