Since commit a4aeaa06d45e ("mm: khugepaged: skip huge page collapse for special files"), khugepaged just collapses THP for regular file which is the intended usecase for readonly fs THP. Only show regular file as THP eligible accordingly. And make file_thp_enabled() available for khugepaged too in order to remove duplicate code.
Showing the changes to include (1 of 3 files). Show all
Unified · Split
| @@ -173,6 +173,20 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) · 172 unmodified lines | ||
| 173 | 173 | return false; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | +static inline bool file_thp_enabled(struct vm_area_struct *vma) | |
| 177 | +{ | |
| 178 | + struct inode *inode; | |
| 179 | + | |
| 180 | + if (!vma->vm_file) | |
| 181 | + return false; | |
| 182 | + | |
| 183 | + inode = vma->vm_file->f_inode; | |
| 184 | + | |
| 185 | + return (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS)) && | |
| 186 | + (vma->vm_flags & VM_EXEC) && | |
| 187 | + !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode); | |
| 188 | +} | |
| 189 | + | |
| 176 | 190 | bool transparent_hugepage_active(struct vm_area_struct *vma); |
| 177 | 191 | |
| 178 | 192 | #define transparent_hugepage_use_zero_page() \ |