Skip to content

Commit 1f73784

Browse files
sumanthkorikkarakpm00
authored andcommitted
mm/shmem: inline shmem_is_huge() for disabled transparent hugepages
In order to minimize code size (CONFIG_CC_OPTIMIZE_FOR_SIZE=y), compiler might choose to make a regular function call (out-of-line) for shmem_is_huge() instead of inlining it. When transparent hugepages are disabled (CONFIG_TRANSPARENT_HUGEPAGE=n), it can cause compilation error. mm/shmem.c: In function `shmem_getattr': ./include/linux/huge_mm.h:383:27: note: in expansion of macro `BUILD_BUG' 383 | #define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; }) | ^~~~~~~~~ mm/shmem.c:1148:33: note: in expansion of macro `HPAGE_PMD_SIZE' 1148 | stat->blksize = HPAGE_PMD_SIZE; To prevent the possible error, always inline shmem_is_huge() when transparent hugepages are disabled. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Sumanth Korikkar <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Ilya Leoshkevich <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0b2cf0a commit 1f73784

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

include/linux/shmem_fs.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,17 @@ extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
110110
extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
111111
int shmem_unuse(unsigned int type);
112112

113+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
113114
extern bool shmem_is_huge(struct inode *inode, pgoff_t index, bool shmem_huge_force,
114115
struct mm_struct *mm, unsigned long vm_flags);
116+
#else
117+
static __always_inline bool shmem_is_huge(struct inode *inode, pgoff_t index, bool shmem_huge_force,
118+
struct mm_struct *mm, unsigned long vm_flags)
119+
{
120+
return false;
121+
}
122+
#endif
123+
115124
#ifdef CONFIG_SHMEM
116125
extern unsigned long shmem_swap_usage(struct vm_area_struct *vma);
117126
#else

mm/shmem.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -748,12 +748,6 @@ static long shmem_unused_huge_count(struct super_block *sb,
748748

749749
#define shmem_huge SHMEM_HUGE_DENY
750750

751-
bool shmem_is_huge(struct inode *inode, pgoff_t index, bool shmem_huge_force,
752-
struct mm_struct *mm, unsigned long vm_flags)
753-
{
754-
return false;
755-
}
756-
757751
static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
758752
struct shrink_control *sc, unsigned long nr_to_split)
759753
{

0 commit comments

Comments
 (0)