Skip to content

Commit a097631

Browse files
JoonsooKimtorvalds
authored andcommitted
mm/mempolicy: use a standard migration target allocation callback
There is a well-defined migration target allocation callback. Use it. Signed-off-by: Joonsoo Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Michal Hocko <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Roman Gushchin <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 19fc7be commit a097631

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
lines changed

mm/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,6 @@ static inline bool is_migrate_highatomic_page(struct page *page)
613613
}
614614

615615
void setup_zone_pageset(struct zone *zone);
616-
extern struct page *alloc_new_node_page(struct page *page, unsigned long node);
617616

618617
struct migration_target_control {
619618
int nid; /* preferred node id */

mm/mempolicy.c

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,29 +1065,6 @@ static int migrate_page_add(struct page *page, struct list_head *pagelist,
10651065
return 0;
10661066
}
10671067

1068-
/* page allocation callback for NUMA node migration */
1069-
struct page *alloc_new_node_page(struct page *page, unsigned long node)
1070-
{
1071-
if (PageHuge(page)) {
1072-
struct hstate *h = page_hstate(compound_head(page));
1073-
gfp_t gfp_mask = htlb_alloc_mask(h) | __GFP_THISNODE;
1074-
1075-
return alloc_huge_page_nodemask(h, node, NULL, gfp_mask);
1076-
} else if (PageTransHuge(page)) {
1077-
struct page *thp;
1078-
1079-
thp = alloc_pages_node(node,
1080-
(GFP_TRANSHUGE | __GFP_THISNODE),
1081-
HPAGE_PMD_ORDER);
1082-
if (!thp)
1083-
return NULL;
1084-
prep_transhuge_page(thp);
1085-
return thp;
1086-
} else
1087-
return __alloc_pages_node(node, GFP_HIGHUSER_MOVABLE |
1088-
__GFP_THISNODE, 0);
1089-
}
1090-
10911068
/*
10921069
* Migrate pages from one node to a target node.
10931070
* Returns error or the number of pages not migrated.
@@ -1098,6 +1075,10 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest,
10981075
nodemask_t nmask;
10991076
LIST_HEAD(pagelist);
11001077
int err = 0;
1078+
struct migration_target_control mtc = {
1079+
.nid = dest,
1080+
.gfp_mask = GFP_HIGHUSER_MOVABLE | __GFP_THISNODE,
1081+
};
11011082

11021083
nodes_clear(nmask);
11031084
node_set(source, nmask);
@@ -1112,8 +1093,8 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest,
11121093
flags | MPOL_MF_DISCONTIG_OK, &pagelist);
11131094

11141095
if (!list_empty(&pagelist)) {
1115-
err = migrate_pages(&pagelist, alloc_new_node_page, NULL, dest,
1116-
MIGRATE_SYNC, MR_SYSCALL);
1096+
err = migrate_pages(&pagelist, alloc_migration_target, NULL,
1097+
(unsigned long)&mtc, MIGRATE_SYNC, MR_SYSCALL);
11171098
if (err)
11181099
putback_movable_pages(&pagelist);
11191100
}

mm/migrate.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,9 +1598,13 @@ static int do_move_pages_to_node(struct mm_struct *mm,
15981598
struct list_head *pagelist, int node)
15991599
{
16001600
int err;
1601+
struct migration_target_control mtc = {
1602+
.nid = node,
1603+
.gfp_mask = GFP_HIGHUSER_MOVABLE | __GFP_THISNODE,
1604+
};
16011605

1602-
err = migrate_pages(pagelist, alloc_new_node_page, NULL, node,
1603-
MIGRATE_SYNC, MR_SYSCALL);
1606+
err = migrate_pages(pagelist, alloc_migration_target, NULL,
1607+
(unsigned long)&mtc, MIGRATE_SYNC, MR_SYSCALL);
16041608
if (err)
16051609
putback_movable_pages(pagelist);
16061610
return err;

0 commit comments

Comments
 (0)