diff options
author | Kefeng Wang <wangkefeng.wang@huawei.com> | 2024-10-17 22:14:56 +0800 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2024-11-06 20:11:15 -0800 |
commit | 9884efd795cc2f71ef3b7f42df32420b0b7ce34f (patch) | |
tree | 2753866911fd969ee9821b80b328dbd642d5bcc1 /mm/huge_memory.c | |
parent | 5a90c155defa684f3a21f68c3f8e40c056e6114c (diff) | |
download | linux-9884efd795cc2f71ef3b7f42df32420b0b7ce34f.tar.gz linux-9884efd795cc2f71ef3b7f42df32420b0b7ce34f.tar.bz2 linux-9884efd795cc2f71ef3b7f42df32420b0b7ce34f.zip |
mm: huge_memory: move file_thp_enabled() into huge_memory.c
file_thp_enabled() is only used in __thp_vma_allowable_orders(), so move
it into huge_memory.c, also check READ_ONLY_THP_FOR_FS ahead to avoid
unnecessary code if config disabled.
Link: https://lkml.kernel.org/r/20241017141457.1169092-1-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/huge_memory.c')
-rw-r--r-- | mm/huge_memory.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 73194aa0544c..492c16eaf147 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -83,6 +83,21 @@ unsigned long huge_anon_orders_madvise __read_mostly; unsigned long huge_anon_orders_inherit __read_mostly; static bool anon_orders_configured __initdata; +static inline bool file_thp_enabled(struct vm_area_struct *vma) +{ + struct inode *inode; + + if (!IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS)) + return false; + + if (!vma->vm_file) + return false; + + inode = file_inode(vma->vm_file); + + return !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode); +} + unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags, unsigned long tva_flags, |