mm: distinguish CMA and MOVABLE isolation in has_unmovable_pages()
authorMichal Hocko <[email protected]>
Thu, 16 Nov 2017 01:33:26 +0000 (17:33 -0800)
committerLinus Torvalds <[email protected]>
Thu, 16 Nov 2017 02:21:02 +0000 (18:21 -0800)
commit4da2ce250f986060750fcc5b29112914e31803ba
tree779c48d833cfea11124b1e57f8082372d0a156a6
parentd7b236e10cedd95373a79fd53b7e9c105bea4f08
mm: distinguish CMA and MOVABLE isolation in has_unmovable_pages()

Joonsoo has noticed that "mm: drop migrate type checks from
has_unmovable_pages" would break CMA allocator because it relies on
has_unmovable_pages returning false even for CMA pageblocks which in
fact don't have to be movable:

 alloc_contig_range
   start_isolate_page_range
     set_migratetype_isolate
       has_unmovable_pages

This is a result of the code sharing between CMA and memory hotplug
while each one has a different idea of what has_unmovable_pages should
return.  This is unfortunate but fixing it properly would require a lot
of code duplication.

Fix the issue by introducing the requested migrate type argument and
special case MIGRATE_CMA case where CMA page blocks are handled
properly.  This will work for memory hotplug because it requires
MIGRATE_MOVABLE.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Michal Hocko <[email protected]>
Reported-by: Joonsoo Kim <[email protected]>
Tested-by: Stefan Wahren <[email protected]>
Tested-by: Ran Wang <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Igor Mammedov <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Reza Arbab <[email protected]>
Cc: Vitaly Kuznetsov <[email protected]>
Cc: Xishi Qiu <[email protected]>
Cc: Yasuaki Ishimatsu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/page-isolation.h
mm/page_alloc.c
mm/page_isolation.c