Skip to content

Commit b4b3822

Browse files
JoonsooKimtorvalds
authored andcommitted
mm/migrate: move migration helper from .h to .c
It's not performance sensitive function. Move it to .c. This is a preparation step for future change. Signed-off-by: Joonsoo Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Vlastimil Babka <[email protected]> Acked-by: Mike Kravetz <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Christoph Hellwig <[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 c7073ba commit b4b3822

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

include/linux/migrate.h

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,6 @@ enum migrate_reason {
3131
/* In mm/debug.c; also keep sync with include/trace/events/migrate.h */
3232
extern const char *migrate_reason_names[MR_TYPES];
3333

34-
static inline struct page *new_page_nodemask(struct page *page,
35-
int preferred_nid, nodemask_t *nodemask)
36-
{
37-
gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL;
38-
unsigned int order = 0;
39-
struct page *new_page = NULL;
40-
41-
if (PageHuge(page))
42-
return alloc_huge_page_nodemask(page_hstate(compound_head(page)),
43-
preferred_nid, nodemask);
44-
45-
if (PageTransHuge(page)) {
46-
gfp_mask |= GFP_TRANSHUGE;
47-
order = HPAGE_PMD_ORDER;
48-
}
49-
50-
if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE))
51-
gfp_mask |= __GFP_HIGHMEM;
52-
53-
new_page = __alloc_pages_nodemask(gfp_mask, order,
54-
preferred_nid, nodemask);
55-
56-
if (new_page && PageTransHuge(new_page))
57-
prep_transhuge_page(new_page);
58-
59-
return new_page;
60-
}
61-
6234
#ifdef CONFIG_MIGRATION
6335

6436
extern void putback_movable_pages(struct list_head *l);
@@ -67,6 +39,8 @@ extern int migrate_page(struct address_space *mapping,
6739
enum migrate_mode mode);
6840
extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free,
6941
unsigned long private, enum migrate_mode mode, int reason);
42+
extern struct page *new_page_nodemask(struct page *page,
43+
int preferred_nid, nodemask_t *nodemask);
7044
extern int isolate_movable_page(struct page *page, isolate_mode_t mode);
7145
extern void putback_movable_page(struct page *page);
7246

@@ -85,6 +59,9 @@ static inline int migrate_pages(struct list_head *l, new_page_t new,
8559
free_page_t free, unsigned long private, enum migrate_mode mode,
8660
int reason)
8761
{ return -ENOSYS; }
62+
static inline struct page *new_page_nodemask(struct page *page,
63+
int preferred_nid, nodemask_t *nodemask)
64+
{ return NULL; }
8865
static inline int isolate_movable_page(struct page *page, isolate_mode_t mode)
8966
{ return -EBUSY; }
9067

mm/migrate.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,35 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
15381538
return rc;
15391539
}
15401540

1541+
struct page *new_page_nodemask(struct page *page,
1542+
int preferred_nid, nodemask_t *nodemask)
1543+
{
1544+
gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL;
1545+
unsigned int order = 0;
1546+
struct page *new_page = NULL;
1547+
1548+
if (PageHuge(page))
1549+
return alloc_huge_page_nodemask(
1550+
page_hstate(compound_head(page)),
1551+
preferred_nid, nodemask);
1552+
1553+
if (PageTransHuge(page)) {
1554+
gfp_mask |= GFP_TRANSHUGE;
1555+
order = HPAGE_PMD_ORDER;
1556+
}
1557+
1558+
if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE))
1559+
gfp_mask |= __GFP_HIGHMEM;
1560+
1561+
new_page = __alloc_pages_nodemask(gfp_mask, order,
1562+
preferred_nid, nodemask);
1563+
1564+
if (new_page && PageTransHuge(new_page))
1565+
prep_transhuge_page(new_page);
1566+
1567+
return new_page;
1568+
}
1569+
15411570
#ifdef CONFIG_NUMA
15421571

15431572
static int store_status(int __user *status, int start, int value, int nr)

0 commit comments

Comments
 (0)