History

mm/mempolicy: check hugepage migration is supported by arch in vma_migratable()

vma_migratable() is called to check if pages in vma can be migrated before go ahead to further actions. Currently it is used in below code path: - task_numa_work - mbind - move_pages For hugetlb mapping, whether vma is migratable or not is determined by: - CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION - arch_hugetlb_migration_supported Issue: current code only checks for CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION alone, and no code should use it directly. (note that current code in vma_migratable don't cause failure or bug because unmap_and_move_huge_page() will catch unsupported hugepage and handle it properly) This patch checks the two factors by hugepage_migration_supported for impoving code logic and robustness. It will enable early bail out of hugepage migration procedure, but because currently all architecture supporting hugepage migration is able to support all page size, we would not see performance gain with this patch applied. vma_migratable() is moved to mm/mempolicy.c, because of the circular reference of mempolicy.h and hugetlb.h cause defining it as inline not feasible.

Li Xinhai committed 6 years ago

Commit 20ca87f1 parent dcf17632 files · +29 −28Browse files

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

Unified · Split

include/linux/mempolicy.h+1−28
@@ -173,34 +173,7 @@ extern int mpol_parse_str(char *str, struct mempolicy **mpol); · 172 unmodified lines
173extern void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol);173extern void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol);
174 174
175/* Check if a vma is migratable */175/* Check if a vma is migratable */
176static inline bool vma_migratable(struct vm_area_struct *vma)176extern bool vma_migratable(struct vm_area_struct *vma);
177{
178 if (vma->vm_flags & (VM_IO | VM_PFNMAP))
179 return false;
180
181 /*
182 * DAX device mappings require predictable access latency, so avoid
183 * incurring periodic faults.
184 */
185 if (vma_is_dax(vma))
186 return false;
187
188#ifndef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
189 if (vma->vm_flags & VM_HUGETLB)
190 return false;
191#endif
192
193 /*
194 * Migration allocates pages in the highest zone. If we cannot
195 * do so then migration (at least from node to node) is not
196 * possible.
197 */
198 if (vma->vm_file &&
199 gfp_zone(mapping_gfp_mask(vma->vm_file->f_mapping))
200 < policy_zone)
201 return false;
202 return true;
203}
204 177
205extern int mpol_misplaced(struct page *, struct vm_area_struct *, unsigned long);178extern int mpol_misplaced(struct page *, struct vm_area_struct *, unsigned long);
206extern void mpol_put_task_policy(struct task_struct *);179extern void mpol_put_task_policy(struct task_struct *);