Re: [PATCHv14 5/9] efi: Add unaccepted memory support

From: Kirill A. Shutemov
Date: Tue Jul 04 2023 - 10:37:55 EST


On Mon, Jul 03, 2023 at 02:25:18PM +0100, Mel Gorman wrote:
> On Tue, Jun 06, 2023 at 05:26:33PM +0300, Kirill A. Shutemov wrote:
> > efi_config_parse_tables() reserves memory that holds unaccepted memory
> > configuration table so it won't be reused by page allocator.
> >
> > Core-mm requires few helpers to support unaccepted memory:
> >
> > - accept_memory() checks the range of addresses against the bitmap and
> > accept memory if needed.
> >
> > - range_contains_unaccepted_memory() checks if anything within the
> > range requires acceptance.
> >
> > Architectural code has to provide efi_get_unaccepted_table() that
> > returns pointer to the unaccepted memory configuration table.
> >
> > arch_accept_memory() handles arch-specific part of memory acceptance.
> >
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> > Reviewed-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
> > Reviewed-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
>
> By and large, this looks ok from the page allocator perspective as the
> checks for unaccepted are mostly after watermark checks. However, if you
> look in the initial fast path, you'll see this
>
> /*
> * Forbid the first pass from falling back to types that fragment
> * memory until all local zones are considered.
> */
> alloc_flags |= alloc_flags_nofragment(ac.preferred_zoneref->zone, gfp);
>
> While checking watermarks should be fine from a functional perspective and
> the fast paths are unaffected, there is a risk of premature fragmentation
> until all memory has been accepted. Meeting watermarks does not necessarily
> mean that fragmentation is avoided as pageblocks can get mixed while still
> meeting watermarks.

Could you elaborate on this scenario?

Current code checks the watermark, if it is met, try rmqueue().

If rmqueue() fails anyway, try to accept more pages and retry the zone if
it is successful.

I'm not sure how we can get to the 'if (no_fallback) {' case with any
unaccepted memory in the allowed zones.

I see that there's preferred_zoneref and spread_dirty_pages cases, but
unaccepted memory seems change nothing for them.

Hm?

--
Kiryl Shutsemau / Kirill A. Shutemov