Re: [PATCH] mm, page_alloc: fix potential false positive in __zone_watermark_ok

From: Mel Gorman
Date: Thu Nov 02 2017 - 09:23:26 EST


On Thu, Nov 02, 2017 at 01:50:01PM +0100, Vlastimil Babka wrote:
> Since commit 97a16fc82a7c ("mm, page_alloc: only enforce watermarks for order-0
> allocations"), __zone_watermark_ok() check for high-order allocations will
> shortcut per-migratetype free list checks for ALLOC_HARDER allocations, and
> return true as long as there's free page of any migratetype. The intention is
> that ALLOC_HARDER can allocate from MIGRATE_HIGHATOMIC free lists, while normal
> allocations can't.
>
> However, as a side effect, the watermark check will then also return true when
> there are pages only on the MIGRATE_ISOLATE list, or (prior to CMA conversion
> to ZONE_MOVABLE) on the MIGRATE_CMA list. Since the allocation cannot actually
> obtain isolated pages, and might not be able to obtain CMA pages, this can
> result in a false positive.
>
> The condition should be rare and perhaps the outcome is not a fatal one. Still,
> it's better if the watermark check is correct. There also shouldn't be a
> performance tradeoff here.
>
> Fixes: 97a16fc82a7c ("mm, page_alloc: only enforce watermarks for order-0 allocations")
> Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx>

That outcome shouldn't be fatal or even misleading as the subsequent
allocation attempt should fail due to not finding pages on an
appropriate list. Still, as you say, the watermark check should not be
misleading.

Acked-by: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx>

--
Mel Gorman
SUSE Labs