Commit 723a0644 authored by Minchan Kim's avatar Minchan Kim Committed by Linus Torvalds

mm/page_alloc: refactor out __alloc_contig_migrate_alloc()

__alloc_contig_migrate_alloc() can be used by memory-hotplug so refactor
it out (move + rename as a common name) into page_isolation.c.

[akpm@linux-foundation.org: checkpatch fixes]
Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: default avatarYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Acked-by: default avatarMichal Nazarewicz <mina86@mina86.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Wen Congyang <wency@cn.fujitsu.com>
Acked-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3f6d4cae
...@@ -41,6 +41,7 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn); ...@@ -41,6 +41,7 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn);
*/ */
int set_migratetype_isolate(struct page *page); int set_migratetype_isolate(struct page *page);
void unset_migratetype_isolate(struct page *page, unsigned migratetype); void unset_migratetype_isolate(struct page *page, unsigned migratetype);
struct page *alloc_migrate_target(struct page *page, unsigned long private,
int **resultp);
#endif #endif
...@@ -5667,18 +5667,6 @@ static unsigned long pfn_max_align_up(unsigned long pfn) ...@@ -5667,18 +5667,6 @@ static unsigned long pfn_max_align_up(unsigned long pfn)
pageblock_nr_pages)); pageblock_nr_pages));
} }
static struct page *
__alloc_contig_migrate_alloc(struct page *page, unsigned long private,
int **resultp)
{
gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE;
if (PageHighMem(page))
gfp_mask |= __GFP_HIGHMEM;
return alloc_page(gfp_mask);
}
/* [start, end) must belong to a single zone. */ /* [start, end) must belong to a single zone. */
static int __alloc_contig_migrate_range(struct compact_control *cc, static int __alloc_contig_migrate_range(struct compact_control *cc,
unsigned long start, unsigned long end) unsigned long start, unsigned long end)
...@@ -5714,7 +5702,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, ...@@ -5714,7 +5702,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
reclaim_clean_pages_from_list(cc->zone, &cc->migratepages); reclaim_clean_pages_from_list(cc->zone, &cc->migratepages);
ret = migrate_pages(&cc->migratepages, ret = migrate_pages(&cc->migratepages,
__alloc_contig_migrate_alloc, alloc_migrate_target,
0, false, MIGRATE_SYNC); 0, false, MIGRATE_SYNC);
} }
......
...@@ -255,3 +255,14 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn) ...@@ -255,3 +255,14 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn)
spin_unlock_irqrestore(&zone->lock, flags); spin_unlock_irqrestore(&zone->lock, flags);
return ret ? 0 : -EBUSY; return ret ? 0 : -EBUSY;
} }
struct page *alloc_migrate_target(struct page *page, unsigned long private,
int **resultp)
{
gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE;
if (PageHighMem(page))
gfp_mask |= __GFP_HIGHMEM;
return alloc_page(gfp_mask);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment