On Fri, Jul 29, 2022 at 12:42:14PM -0700, alexlzhu@xxxxxxxxxxxxxxxxxxxxxxxxxxx wrote: > From: alexlzhu <alexlzhu@xxxxxx> > > With CONFIG_READ_ONLY_THP_FOR_FS, the Linux kernel supports using THPs for > read-only mmapped files, such as shared libraries. However, on x86 the > kernel makes no attempt to actually align those mappings on 2MB boundaries, > which makes it impossible to use those THPs most of the time. This issue > applies to general file mapping THP as well as existing setups using > CONFIG_READ_ONLY_THP_FOR_FS. This is easily fixed by using the alignment > info passed to vm_unmapped_area. The problem can be seen in > /proc/PID/smaps where THPeligible is set to 0 on mappings to eligible > shared object files as shown below. Can't your filesystem just use thp_get_unmapped_area() like ext2/ext4/fuse/xfs do?