summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorVlastimil Babka <vbabka@suse.cz>2017-11-15 20:38:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 21:21:07 -0500
commitb050e3769c6b4013bb937e879fc43bf1847ee819 (patch)
treed354258b43f44c3efe9944ebf4cc67a7fea4e3e8 /mm
parent72b03fcd5d515441d4aefcad01c1c4392c8099c9 (diff)
mm, page_alloc: fix potential false positive in __zone_watermark_ok
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. Link: http://lkml.kernel.org/r/20171102125001.23708-1-vbabka@suse.cz Fixes: 97a16fc82a7c ("mm, page_alloc: only enforce watermarks for order-0 allocations") Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Mel Gorman <mgorman@techsingularity.net> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Rik van Riel <riel@redhat.com> Cc: David Rientjes <rientjes@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 67f523c4711a..04bf1ad50144 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3041,9 +3041,6 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
3041 if (!area->nr_free) 3041 if (!area->nr_free)
3042 continue; 3042 continue;
3043 3043
3044 if (alloc_harder)
3045 return true;
3046
3047 for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) { 3044 for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) {
3048 if (!list_empty(&area->free_list[mt])) 3045 if (!list_empty(&area->free_list[mt]))
3049 return true; 3046 return true;
@@ -3055,6 +3052,9 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
3055 return true; 3052 return true;
3056 } 3053 }
3057#endif 3054#endif
3055 if (alloc_harder &&
3056 !list_empty(&area->free_list[MIGRATE_HIGHATOMIC]))
3057 return true;
3058 } 3058 }
3059 return false; 3059 return false;
3060} 3060}