diff mbox series

[1/2] mm/mempolicy: Checking hstate for hugetlbfs page in vma_migratable

Message ID 1578993378-10860-1-git-send-email-lixinhai.lxh@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] mm/mempolicy: Checking hstate for hugetlbfs page in vma_migratable | expand

Commit Message

Li Xinhai Jan. 14, 2020, 9:16 a.m. UTC
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/mempolicy.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Mike Kravetz Jan. 14, 2020, 7:12 p.m. UTC | #1
On 1/14/20 1:16 AM, Li Xinhai wrote:
> 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/mempolicy.h | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
> index 5228c62..986e51d 100644
> --- a/include/linux/mempolicy.h
> +++ b/include/linux/mempolicy.h
> @@ -185,10 +185,9 @@ static inline bool vma_migratable(struct vm_area_struct *vma)
>  	if (vma_is_dax(vma))
>  		return false;
>  
> -#ifndef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
> -	if (vma->vm_flags & VM_HUGETLB)
> +	if (is_vm_hugetlb_page(vma) &&
> +		!hugepage_migration_supported(hstate_vma(vma)))
>  		return false;
> -#endif
>  
>  	/*
>  	 * Migration allocates pages in the highest zone. If we cannot
> 

Thanks!  It is indeed better to perform the check early.

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Andrew Morton Jan. 15, 2020, 1:25 a.m. UTC | #2
On Tue, 14 Jan 2020 09:16:17 +0000 Li Xinhai <lixinhai.lxh@gmail.com> wrote:

> Checking hstate at early phase when isolating page, instead of during
> unmap and move phase, to avoid useless isolation.
> 
> ...
>
> --- a/include/linux/mempolicy.h
> +++ b/include/linux/mempolicy.h
> @@ -185,10 +185,9 @@ static inline bool vma_migratable(struct vm_area_struct *vma)
>  	if (vma_is_dax(vma))
>  		return false;
>  
> -#ifndef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
> -	if (vma->vm_flags & VM_HUGETLB)
> +	if (is_vm_hugetlb_page(vma) &&
> +		!hugepage_migration_supported(hstate_vma(vma)))
>  		return false;
> -#endif
>  
>  	/*
>  	 * Migration allocates pages in the highest zone. If we cannot

x86_64 allmodconfig:

In file included from ./include/linux/hugetlb.h:26:0,
                 from arch/x86/mm/fault.c:15:
./include/linux/mempolicy.h: In function vma_migratable:
./include/linux/mempolicy.h:190:4: error: implicit declaration of function hugepage_migration_supported; did you mean thp_migration_supported? [-Werror=implicit-function-declaration]
   !hugepage_migration_supported(hstate_vma(vma)))
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

the obvious fix didn't work.
diff mbox series

Patch

diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 5228c62..986e51d 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -185,10 +185,9 @@  static inline bool vma_migratable(struct vm_area_struct *vma)
 	if (vma_is_dax(vma))
 		return false;
 
-#ifndef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
-	if (vma->vm_flags & VM_HUGETLB)
+	if (is_vm_hugetlb_page(vma) &&
+		!hugepage_migration_supported(hstate_vma(vma)))
 		return false;
-#endif
 
 	/*
 	 * Migration allocates pages in the highest zone. If we cannot