Re: [PATCH] mm/hugetlb: Fix build failure with HUGETLB_PAGE but not HUGEBTLBFS

From: Mike Kravetz
Date: Tue Mar 17 2020 - 13:27:11 EST


On 3/17/20 1:04 AM, Christophe Leroy wrote:
> When CONFIG_HUGETLB_PAGE is set but not CONFIG_HUGETLBFS, the
> following build failure is encoutered:
>
> In file included from arch/powerpc/mm/fault.c:33:0:
> ./include/linux/hugetlb.h: In function 'hstate_inode':
> ./include/linux/hugetlb.h:477:9: error: implicit declaration of function 'HUGETLBFS_SB' [-Werror=implicit-function-declaration]
> return HUGETLBFS_SB(i->i_sb)->hstate;
> ^
> ./include/linux/hugetlb.h:477:30: error: invalid type argument of '->' (have 'int')
> return HUGETLBFS_SB(i->i_sb)->hstate;
> ^
>
> Gate hstate_inode() with CONFIG_HUGETLBFS instead of CONFIG_HUGETLB_PAGE.
>
> Reported-by: kbuild test robot <lkp@xxxxxxxxx>
> Link: https://patchwork.ozlabs.org/patch/1255548/#2386036
> Fixes: a137e1cc6d6e ("hugetlbfs: per mount huge page sizes")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxx>

As hugetlb.h evolved over time, I suspect nobody imagined a configuration
with CONFIG_HUGETLB_PAGE and not CONFIG_HUGETLBFS. This patch does address
the build issues. So,

Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>

However, there are many definitions in that file not behind #ifdef
CONFIG_HUGETLBFS that make no sense unless CONFIG_HUGETLBFS is defined.
Such cleanup is way beyond the scope of this patch/effort. I will add
it to the list of hugetlb/hugetlbfs things that can be cleaned up.
--
Mike Kravetz