History

mm/migrate: introduce a standard migration target allocation function

There are some similar functions for migration target allocation. Since there is no fundamental difference, it's better to keep just one rather than keeping all variants. This patch implements base migration target allocation function. In the following patches, variants will be converted to use this function. Changes should be mechanical, but, unfortunately, there are some differences. First, some callers' nodemask is assgined to NULL since NULL nodemask will be considered as all available nodes, that is, &node_states[N_MEMORY]. Second, for hugetlb page allocation, gfp_mask is redefined as regular hugetlb allocation gfp_mask plus __GFP_THISNODE if user provided gfp_mask has it. This is because future caller of this function requires to set this node constaint. Lastly, if provided nodeid is NUMA_NO_NODE, nodeid is set up to the node where migration source lives. It helps to remove simple wrappers for setting up the nodeid. Note that PageHighmem() call in previous function is changed to open-code "is_highmem_idx()" since it provides more readability. [akpm@linux-foundation.org: tweak patch title, per Vlastimil] [akpm@linux-foundation.org: fix typo in comment]

Joonsoo Kim committed 6 years ago

Commit 19fc7be1 parent 9933a0c7 files · +61 −22Browse files

Showing the changes to include/linux (2 of 7 files). Show all

Unified · Split

2 files
  1. include/linux/hugetlb.h +15 −0
  2. include/linux/migrate.h +5 −4
include/linux/hugetlb.h+15−0
@@ -703,6 +703,16 @@ static inline gfp_t htlb_alloc_mask(struct hstate *h) · 702 unmodified lines
703703 return GFP_HIGHUSER;
704704 }
705705
706+static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask)
707+{
708+ gfp_t modified_mask = htlb_alloc_mask(h);
709+
710+ /* Some callers might want to enforce node */
711+ modified_mask |= (gfp_mask & __GFP_THISNODE);
712+
713+ return modified_mask;
714+}
715+
706716 static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
707717 struct mm_struct *mm, pte_t *pte)
708718 {
@@ -890,6 +900,11 @@ static inline gfp_t htlb_alloc_mask(struct hstate *h) · 181 unmodified lines
890900 return 0;
891901 }
892902
903+static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask)
904+{
905+ return 0;
906+}
907+
893908 static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
894909 struct mm_struct *mm, pte_t *pte)
895910 {
include/linux/migrate.h+5−4
@@ -10,6 +10,8 @@ · 9 unmodified lines
1010 typedef struct page *new_page_t(struct page *page, unsigned long private);
1111 typedef void free_page_t(struct page *page, unsigned long private);
1212
13+struct migration_target_control;
14+
1315 /*
1416 * Return values from addresss_space_operations.migratepage():
1517 * - negative errno on page migration failure;
@@ -39,8 +41,7 @@ extern int migrate_page(struct address_space *mapping, · 23 unmodified lines
3941 enum migrate_mode mode);
4042 extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free,
4143 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);
44+extern struct page *alloc_migration_target(struct page *page, unsigned long private);
4445 extern int isolate_movable_page(struct page *page, isolate_mode_t mode);
4546 extern void putback_movable_page(struct page *page);
4647
@@ -59,8 +60,8 @@ static inline int migrate_pages(struct list_head *l, new_page_t new, · 12 unmodified lines
5960 free_page_t free, unsigned long private, enum migrate_mode mode,
6061 int reason)
6162 { return -ENOSYS; }
62−static inline struct page *new_page_nodemask(struct page *page,
63− int preferred_nid, nodemask_t *nodemask)
63+static inline struct page *alloc_migration_target(struct page *page,
64+ unsigned long private)
6465 { return NULL; }
6566 static inline int isolate_movable_page(struct page *page, isolate_mode_t mode)
6667 { return -EBUSY; }