linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] mm/mempolicy,hugetlb: Checking hstate for hugetlbfs page in vma_migratable
@ 2020-01-16  4:11 Li Xinhai
  2020-01-16  9:56 ` Michal Hocko
  2020-01-22  6:05 ` Anshuman Khandual
  0 siblings, 2 replies; 21+ messages in thread
From: Li Xinhai @ 2020-01-16  4:11 UTC (permalink / raw)
  To: linux-mm; +Cc: akpm, Michal Hocko, Mike Kravetz

Checking hstate at early phase when isolating page, instead of during
unmap and move phase, to avoid useless isolation.

Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
---
 include/linux/hugetlb.h   | 10 ++++++++++
 include/linux/mempolicy.h | 29 +----------------------------
 mm/mempolicy.c            | 28 ++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 28 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 31d4920..c9d871d 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -598,6 +598,11 @@ static inline bool hugepage_migration_supported(struct hstate *h)
 	return arch_hugetlb_migration_supported(h);
 }
 
+static inline bool vm_hugepage_migration_supported(struct vm_area_struct *vma)
+{
+	return hugepage_migration_supported(hstate_vma(vma));
+}
+
 /*
  * Movability check is different as compared to migration check.
  * It determines whether or not a huge page should be placed on
@@ -809,6 +814,11 @@ static inline bool hugepage_migration_supported(struct hstate *h)
 	return false;
 }
 
+static inline bool vm_hugepage_migration_supported(struct vm_area_struct *vma)
+{
+	return false;
+}
+
 static inline bool hugepage_movable_supported(struct hstate *h)
 {
 	return false;
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 5228c62..8165278 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -173,34 +173,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from,
 extern void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol);
 
 /* Check if a vma is migratable */
-static inline bool vma_migratable(struct vm_area_struct *vma)
-{
-	if (vma->vm_flags & (VM_IO | VM_PFNMAP))
-		return false;
-
-	/*
-	 * DAX device mappings require predictable access latency, so avoid
-	 * incurring periodic faults.
-	 */
-	if (vma_is_dax(vma))
-		return false;
-
-#ifndef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
-	if (vma->vm_flags & VM_HUGETLB)
-		return false;
-#endif
-
-	/*
-	 * Migration allocates pages in the highest zone. If we cannot
-	 * do so then migration (at least from node to node) is not
-	 * possible.
-	 */
-	if (vma->vm_file &&
-		gfp_zone(mapping_gfp_mask(vma->vm_file->f_mapping))
-								< policy_zone)
-			return false;
-	return true;
-}
+extern bool vma_migratable(struct vm_area_struct *vma);
 
 extern int mpol_misplaced(struct page *, struct vm_area_struct *, unsigned long);
 extern void mpol_put_task_policy(struct task_struct *);
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 067cf7d..8a01fb1 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1714,6 +1714,34 @@ static int kernel_get_mempolicy(int __user *policy,
 
 #endif /* CONFIG_COMPAT */
 
+bool vma_migratable(struct vm_area_struct *vma)
+{
+	if (vma->vm_flags & (VM_IO | VM_PFNMAP))
+		return false;
+
+	/*
+	 * DAX device mappings require predictable access latency, so avoid
+	 * incurring periodic faults.
+	 */
+	if (vma_is_dax(vma))
+		return false;
+
+	if (is_vm_hugetlb_page(vma) &&
+		!vm_hugepage_migration_supported(vma))
+		return false;
+
+	/*
+	 * Migration allocates pages in the highest zone. If we cannot
+	 * do so then migration (at least from node to node) is not
+	 * possible.
+	 */
+	if (vma->vm_file &&
+		gfp_zone(mapping_gfp_mask(vma->vm_file->f_mapping))
+			< policy_zone)
+		return false;
+	return true;
+}
+
 struct mempolicy *__get_vma_policy(struct vm_area_struct *vma,
 						unsigned long addr)
 {
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2020-01-23  7:47 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16  4:11 [PATCH v4] mm/mempolicy,hugetlb: Checking hstate for hugetlbfs page in vma_migratable Li Xinhai
2020-01-16  9:56 ` Michal Hocko
2020-01-16 13:50   ` Li Xinhai
2020-01-16 15:18     ` Michal Hocko
2020-01-16 15:38       ` Li Xinhai
2020-01-17  3:16         ` Li Xinhai
2020-01-18  3:11           ` Li Xinhai
2020-01-18 15:27             ` Li Xinhai
2020-01-20 10:12             ` Michal Hocko
2020-01-20 15:37               ` Li Xinhai
2020-01-20 16:05                 ` Michal Hocko
2020-01-21  3:42                   ` Anshuman Khandual
2020-01-21 13:08                     ` Li Xinhai
2020-01-21 12:44                   ` Li Xinhai
2020-01-20  9:21       ` Anshuman Khandual
2020-01-20 11:32         ` Michal Hocko
2020-01-21  3:22           ` Anshuman Khandual
2020-01-20 14:19         ` Li Xinhai
2020-01-22  6:05 ` Anshuman Khandual
2020-01-22 13:21   ` Li Xinhai
2020-01-23  7:48     ` Anshuman Khandual

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).