[PATCH] arm64/migration: Define arm64_hugetlb_valid_size()

Catalin Marinas catalin.marinas at arm.com
Wed Feb 9 10:34:37 PST 2022


On Mon, Feb 07, 2022 at 07:01:08AM +0530, Anshuman Khandual wrote:
> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
> index ffb9c229610a..dcdc4c0c3bd8 100644
> --- a/arch/arm64/mm/hugetlbpage.c
> +++ b/arch/arm64/mm/hugetlbpage.c
> @@ -56,24 +56,12 @@ void __init arm64_hugetlb_cma_reserve(void)
>  }
>  #endif /* CONFIG_CMA */
>  
> +static bool arm64_hugetlb_valid_size(unsigned long size);
> +
>  #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
>  bool arch_hugetlb_migration_supported(struct hstate *h)
>  {
> -	size_t pagesize = huge_page_size(h);
> -
> -	switch (pagesize) {
> -#ifndef __PAGETABLE_PMD_FOLDED
> -	case PUD_SIZE:
> -		return pud_sect_supported();
> -#endif
> -	case PMD_SIZE:
> -	case CONT_PMD_SIZE:
> -	case CONT_PTE_SIZE:
> -		return true;
> -	}
> -	pr_warn("%s: unrecognized huge page size 0x%lx\n",
> -			__func__, pagesize);
> -	return false;
> +	return arm64_hugetlb_valid_size(huge_page_size(h));
>  }
>  #endif
>  
> @@ -504,7 +492,7 @@ static int __init hugetlbpage_init(void)
>  }
>  arch_initcall(hugetlbpage_init);
>  
> -bool __init arch_hugetlb_valid_size(unsigned long size)
> +static bool arm64_hugetlb_valid_size(unsigned long size)
>  {
>  	switch (size) {
>  #ifndef __PAGETABLE_PMD_FOLDED
> @@ -517,5 +505,12 @@ bool __init arch_hugetlb_valid_size(unsigned long size)
>  		return true;
>  	}
>  
> +	pr_warn("%s: unrecognized huge page size 0x%lx\n",
> +		__func__, size);
>  	return false;
>  }

We already have the warnings in the caller of arch_hugetlb_valid_size(),
I wouldn't add another here. You can keep it in
arch_hugetlb_migration_supported() though.

> +
> +bool __init arch_hugetlb_valid_size(unsigned long size)
> +{
> +	return arm64_hugetlb_valid_size(size);
> +}

What's wrong with keeping the arch_hugetlb_valid_size() name and just
removing __init?

-- 
Catalin



More information about the linux-arm-kernel mailing list