linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] shmem: optimize shmem_huge_enabled() and shmem_is_huge() when !CONFIG_TRANSPARENT_HUGEPAGE
@ 2023-01-05 23:04 Yann Droneaud
  0 siblings, 0 replies; only message in thread
From: Yann Droneaud @ 2023-01-05 23:04 UTC (permalink / raw)
  To: Hugh Dickins, Andrew Morton; +Cc: linux-mm, linux-kernel, Yann Droneaud

When CONFIG_TRANSPARENT_HUGEPAGE is not set, shmem_is_huge() is not needed
outside of shmem.c.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
---
 include/linux/shmem_fs.h | 9 +++++++++
 mm/shmem.c               | 4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index d500ea967dc7..18a4968ded73 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -92,6 +92,7 @@ extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
 extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
 int shmem_unuse(unsigned int type);
 
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 extern bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode,
 			  pgoff_t index, bool shmem_huge_force);
 static inline bool shmem_huge_enabled(struct vm_area_struct *vma,
@@ -100,6 +101,14 @@ static inline bool shmem_huge_enabled(struct vm_area_struct *vma,
 	return shmem_is_huge(vma, file_inode(vma->vm_file), vma->vm_pgoff,
 			     shmem_huge_force);
 }
+#else /* !CONFIG_TRANSPARENT_HUGEPAGE */
+static inline bool shmem_huge_enabled(struct vm_area_struct *vma,
+				      bool shmem_huge_force)
+{
+	return false;
+}
+#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+
 extern unsigned long shmem_swap_usage(struct vm_area_struct *vma);
 extern unsigned long shmem_partial_swap_usage(struct address_space *mapping,
 						pgoff_t start, pgoff_t end);
diff --git a/mm/shmem.c b/mm/shmem.c
index c301487be5fb..9437c200a311 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -678,8 +678,8 @@ static long shmem_unused_huge_count(struct super_block *sb,
 
 #define shmem_huge SHMEM_HUGE_DENY
 
-bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode,
-		   pgoff_t index, bool shmem_huge_force)
+static inline bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode,
+				 pgoff_t index, bool shmem_huge_force)
 {
 	return false;
 }
-- 
2.37.2



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-05 23:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 23:04 [PATCH] shmem: optimize shmem_huge_enabled() and shmem_is_huge() when !CONFIG_TRANSPARENT_HUGEPAGE Yann Droneaud

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox