From: Yann Droneaud <ydroneaud@opteya.com>
To: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Yann Droneaud <ydroneaud@opteya.com>
Subject: [PATCH] shmem: optimize shmem_huge_enabled() and shmem_is_huge() when !CONFIG_TRANSPARENT_HUGEPAGE
Date: Fri, 6 Jan 2023 00:04:17 +0100 [thread overview]
Message-ID: <20230105230417.966438-1-ydroneaud@opteya.com> (raw)
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
reply other threads:[~2023-01-05 23:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230105230417.966438-1-ydroneaud@opteya.com \
--to=ydroneaud@opteya.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox