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
703 return GFP_HIGHUSER;703 return GFP_HIGHUSER;
704}704}
705 705
706static 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
706static inline spinlock_t *huge_pte_lockptr(struct hstate *h,716static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
707 struct mm_struct *mm, pte_t *pte)717 struct mm_struct *mm, pte_t *pte)
708{718{
@@ -890,6 +900,11 @@ static inline gfp_t htlb_alloc_mask(struct hstate *h) · 181 unmodified lines
890 return 0;900 return 0;
891}901}
892 902
903static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask)
904{
905 return 0;
906}
907
893static inline spinlock_t *huge_pte_lockptr(struct hstate *h,908static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
894 struct mm_struct *mm, pte_t *pte)909 struct mm_struct *mm, pte_t *pte)
895{910{
include/linux/migrate.h+5−4
@@ -10,6 +10,8 @@ · 9 unmodified lines
10typedef struct page *new_page_t(struct page *page, unsigned long private);10typedef struct page *new_page_t(struct page *page, unsigned long private);
11typedef void free_page_t(struct page *page, unsigned long private);11typedef void free_page_t(struct page *page, unsigned long private);
12 12
13struct migration_target_control;
14
13/*15/*
14 * Return values from addresss_space_operations.migratepage():16 * Return values from addresss_space_operations.migratepage():
15 * - negative errno on page migration failure;17 * - negative errno on page migration failure;
@@ -39,8 +41,7 @@ extern int migrate_page(struct address_space *mapping, · 23 unmodified lines
39 enum migrate_mode mode);41 enum migrate_mode mode);
40extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free,42extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free,
41 unsigned long private, enum migrate_mode mode, int reason);43 unsigned long private, enum migrate_mode mode, int reason);
42extern struct page *new_page_nodemask(struct page *page,44extern struct page *alloc_migration_target(struct page *page, unsigned long private);
43 int preferred_nid, nodemask_t *nodemask);
44extern int isolate_movable_page(struct page *page, isolate_mode_t mode);45extern int isolate_movable_page(struct page *page, isolate_mode_t mode);
45extern void putback_movable_page(struct page *page);46extern void putback_movable_page(struct page *page);
46 47
@@ -59,8 +60,8 @@ static inline int migrate_pages(struct list_head *l, new_page_t new, · 12 unmodified lines
59 free_page_t free, unsigned long private, enum migrate_mode mode,60 free_page_t free, unsigned long private, enum migrate_mode mode,
60 int reason)61 int reason)
61 { return -ENOSYS; }62 { return -ENOSYS; }
62static inline struct page *new_page_nodemask(struct page *page,63static inline struct page *alloc_migration_target(struct page *page,
63 int preferred_nid, nodemask_t *nodemask)64 unsigned long private)
64 { return NULL; }65 { return NULL; }
65static inline int isolate_movable_page(struct page *page, isolate_mode_t mode)66static inline int isolate_movable_page(struct page *page, isolate_mode_t mode)
66 { return -EBUSY; }67 { return -EBUSY; }