Re: [PATCH] arm64/migration: Define arm64_hugetlb_valid_size()

From: Catalin Marinas
Date: Thu Feb 10 2022 - 05:42:34 EST


On Thu, Feb 10, 2022 at 10:17:17AM +0530, Anshuman Khandual wrote:
> On 2/10/22 12:04 AM, Catalin Marinas wrote:
> > On Mon, Feb 07, 2022 at 07:01:08AM +0530, Anshuman Khandual wrote:
> >> +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?
>
> When arch_hugetlb_migration_supported() calls arch_hugetlb_valid_size(),
>
> With __init for arch_hugetlb_valid_size(), there is a build problem.
>
> WARNING: modpost: vmlinux.o(.text.unlikely+0xf18): Section mismatch in
> reference from the function arch_hugetlb_migration_supported() to the
> function .init.text:arch_hugetlb_valid_size()
> The function arch_hugetlb_migration_supported() references
> the function __init arch_hugetlb_valid_size().
> This is often because arch_hugetlb_migration_supported lacks a __init
> annotation or the annotation of arch_hugetlb_valid_size is wrong.

This is expected.

> Without __init for arch_hugetlb_valid_size(), there is the same problem.
>
> WARNING: modpost: vmlinux.o(.text.unlikely+0xf18): Section mismatch in
> reference from the function arch_hugetlb_migration_supported() to the
> function .init.text:arch_hugetlb_valid_size()
> The function arch_hugetlb_migration_supported() references
> the function __init arch_hugetlb_valid_size().
> This is often because arch_hugetlb_migration_supported lacks a __init
> annotation or the annotation of arch_hugetlb_valid_size is wrong.
>
> This might be because generic prototype for arch_hugetlb_valid_size() has
> __init attribute, which arch_hugetlb_migration_supported() does not have.
>
> Hence a local static helper arm64_hugetlb_valid_size() which both these
> generic functions can call into, looked appropriate.

Ah, I did not realise the generic prototype is __init already. So fine
by me but maybe just use __hugetlb_valid_size() as it's a local function
only (static).

--
Catalin