blob: 0697a5aff958b2894951e9f6c0f05c9a1a42c725 [file] [log] [blame]
From dc54142d8c9bbed186e20a782d07fb90f37767f8 Mon Sep 17 00:00:00 2001
From: Christophe Leroy <>
Date: Wed, 1 Apr 2020 21:11:54 -0700
Subject: [PATCH] mm/hugetlb: fix build failure with HUGETLB_PAGE but not
commit bb297bb2de517e41199185021f043bbc5d75b377 upstream.
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.
Fixes: a137e1cc6d6e ("hugetlbfs: per mount huge page sizes")
Reported-by: kbuild test robot <>
Signed-off-by: Christophe Leroy <>
Signed-off-by: Andrew Morton <>
Reviewed-by: Mike Kravetz <>
Cc: Baoquan He <>
Cc: Nishanth Aravamudan <>
Cc: Nick Piggin <>
Cc: Adam Litke <>
Cc: Andi Kleen <>
Signed-off-by: Linus Torvalds <>
[PG: no-op is a macro and not a stub fcn back in v5.2.x code base.]
Signed-off-by: Paul Gortmaker <>
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index edf476c8cfb9..aa0553357534 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -316,10 +316,15 @@ static inline bool is_file_hugepages(struct file *file)
return is_file_shm_hugepages(file);
+static inline struct hstate *hstate_inode(struct inode *i)
+ return HUGETLBFS_SB(i->i_sb)->hstate;
#define is_file_hugepages(file) false
+#define hstate_inode(i) NULL
static inline struct file *
hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag,
struct user_struct **user, int creat_flags,
@@ -397,11 +402,6 @@ extern unsigned int default_hstate_idx;
#define default_hstate (hstates[default_hstate_idx])
-static inline struct hstate *hstate_inode(struct inode *i)
- return HUGETLBFS_SB(i->i_sb)->hstate;
static inline struct hstate *hstate_file(struct file *f)
return hstate_inode(file_inode(f));
@@ -616,7 +616,6 @@ struct hstate {};
#define hstate_file(f) NULL
#define hstate_sizelog(s) NULL
#define hstate_vma(v) NULL
-#define hstate_inode(i) NULL
#define page_hstate(page) NULL
#define huge_page_size(h) PAGE_SIZE
#define huge_page_mask(h) PAGE_MASK