bcachefs: fix alignment of VMA for memory mapped files on THP
PATCH 1/1 bcachefs: fix alignment of VMA for memory mapped files on THP
From: Youling Tang <[email protected]>
With CONFIG_READ_ONLY_THP_FOR_FS, the Linux kernel supports using THPs for read-only mmapped files, such as shared libraries. However, 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 thp_get_unmapped_area for the unmapped_area function in bcachefs, which is what ext2, ext4, fuse, xfs and btrfs all use.
Similar to commit b0c582233a85 ("btrfs: fix alignment of VMA for memory mapped files on THP").
--- fs/bcachefs/fs.c | 1 + 1 file changed, 1 insertion(+)
fs/bcachefs/fs.c +1 -0
@@ -1155,6 +1155,7 @@ static const struct file_operations bch_file_operations = { .read_iter = bch2_read_iter, .write_iter = bch2_write_iter, .mmap = bch2_mmap, + .get_unmapped_area = thp_get_unmapped_area, .fsync = bch2_fsync, .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write,
Signature · 1 line
2.34.1
Quoted 11 lines · Youling Tang
From: Youling Tang <[email protected]>
With
CONFIG_READ_ONLY_THP_FOR_FS, the Linux kernel supports using THPs for read-only mmapped files, such as shared libraries. However, 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 usingCONFIG_READ_ONLY_THP_FOR_FS. This is easily fixed by usingthp_get_unmapped_areafor theunmapped_areafunction in bcachefs, which is what ext2, ext4, fuse, xfs and btrfs all use.
Quoted 4 lines
Similar to commit
b0c582233a85("btrfs: fix alignment of VMA for memory mapped files on THP").Signed-off-by Youling Tang <[email protected]>
Thanks - applied
Hi, Kent
Sorry to bother you, BTW, are the following patches still needed?
https://lore.kernel.org/linux-bcachefs/[email protected]/
https://lore.kernel.org/linux-bcachefs/[email protected]/
https://lore.kernel.org/linux-bcachefs/[email protected]/
Thanks,
Youling.
Quoted 17 lines · Kent Overstreet
Quoted 11 lines · Youling Tang
From: Youling Tang <[email protected]>
With
CONFIG_READ_ONLY_THP_FOR_FS, the Linux kernel supports using THPs for read-only mmapped files, such as shared libraries. However, 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 usingCONFIG_READ_ONLY_THP_FOR_FS. This is easily fixed by usingthp_get_unmapped_areafor theunmapped_areafunction in bcachefs, which is what ext2, ext4, fuse, xfs and btrfs all use.Quoted 4 lines
Similar to commit
b0c582233a85("btrfs: fix alignment of VMA for memory mapped files on THP").Signed-off-by Youling Tang <[email protected]>Thanks - applied
Quoted 7 lines · Youling Tang
Hi, Kent
Sorry to bother you, BTW, are the following patches still needed?
https://lore.kernel.org/linux-bcachefs/[email protected]/
https://lore.kernel.org/linux-bcachefs/[email protected]/
https://lore.kernel.org/linux-bcachefs/[email protected]/
Yep, sorry I missed those - applied!