Skip to content

Commit b050e37

Browse files
tehcastertorvalds
authored andcommitted
mm, page_alloc: fix potential false positive in __zone_watermark_ok
Since commit 97a16fc ("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. Link: http://lkml.kernel.org/r/[email protected] Fixes: 97a16fc ("mm, page_alloc: only enforce watermarks for order-0 allocations") Signed-off-by: Vlastimil Babka <[email protected]> Acked-by: Mel Gorman <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Rik van Riel <[email protected]> Cc: David Rientjes <[email protected]> Cc: Johannes Weiner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 72b03fc commit b050e37

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mm/page_alloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,9 +3041,6 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
30413041
if (!area->nr_free)
30423042
continue;
30433043

3044-
if (alloc_harder)
3045-
return true;
3046-
30473044
for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) {
30483045
if (!list_empty(&area->free_list[mt]))
30493046
return true;
@@ -3055,6 +3052,9 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
30553052
return true;
30563053
}
30573054
#endif
3055+
if (alloc_harder &&
3056+
!list_empty(&area->free_list[MIGRATE_HIGHATOMIC]))
3057+
return true;
30583058
}
30593059
return false;
30603060
}

0 commit comments

Comments
 (0)