Replace it with a check on the max folio order of the file's address space
mapping, making sure PMD THP is supported. Also remove the read-only fd
check, since collapse_file() now makes sure all to-be-collapsed folios are
clean and the created PMD file THP can be handled by FSes properly.

Signed-off-by: Zi Yan <[email protected]>
Reviewed-by: Baolin Wang <[email protected]>
---
 mm/huge_memory.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 1f0d0b780943..f0db1390a18f 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -86,9 +86,6 @@ 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;
 
@@ -97,7 +94,10 @@ static inline bool file_thp_enabled(struct vm_area_struct 
*vma)
        if (IS_ANON_FILE(inode))
                return false;
 
-       return !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode);
+       if (!mapping_pmd_thp_support(inode->i_mapping))
+               return false;
+
+       return S_ISREG(inode->i_mode);
 }
 
 /* If returns true, we are unable to access the VMA's folios. */
-- 
2.43.0


Reply via email to