* [PATCH] bcachefs: fix alignment of VMA for memory mapped files on THP
@ 2024-06-20 1:22 Youling Tang
2024-06-20 12:51 ` Kent Overstreet
0 siblings, 1 reply; 4+ messages in thread
From: Youling Tang @ 2024-06-20 1:22 UTC (permalink / raw)
To: Kent Overstreet; +Cc: linux-bcachefs, linux-kernel, youling.tang, Youling Tang
From: Youling Tang <tangyouling@kylinos.cn>
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").
Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
---
fs/bcachefs/fs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index 96040a95cf46..b99a961b9f8f 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -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,
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] bcachefs: fix alignment of VMA for memory mapped files on THP
2024-06-20 1:22 [PATCH] bcachefs: fix alignment of VMA for memory mapped files on THP Youling Tang
@ 2024-06-20 12:51 ` Kent Overstreet
2024-06-21 1:11 ` Youling Tang
0 siblings, 1 reply; 4+ messages in thread
From: Kent Overstreet @ 2024-06-20 12:51 UTC (permalink / raw)
To: Youling Tang; +Cc: linux-bcachefs, linux-kernel, Youling Tang
On Thu, Jun 20, 2024 at 09:22:42AM +0800, Youling Tang wrote:
> From: Youling Tang <tangyouling@kylinos.cn>
>
> 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").
>
> Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
Thanks - applied
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] bcachefs: fix alignment of VMA for memory mapped files on THP
2024-06-20 12:51 ` Kent Overstreet
@ 2024-06-21 1:11 ` Youling Tang
2024-06-21 1:41 ` Kent Overstreet
0 siblings, 1 reply; 4+ messages in thread
From: Youling Tang @ 2024-06-21 1:11 UTC (permalink / raw)
To: Kent Overstreet; +Cc: linux-bcachefs, linux-kernel, Youling Tang
Hi, Kent
Sorry to bother you, BTW, are the following patches still needed?
https://lore.kernel.org/linux-bcachefs/20240604084610.94558-1-youling.tang@linux.dev/
https://lore.kernel.org/linux-bcachefs/20240418083103.66703-1-youling.tang@linux.dev/
https://lore.kernel.org/linux-bcachefs/20240418005055.45482-1-youling.tang@linux.dev/
Thanks,
Youling.
On 20/06/2024 20:51, Kent Overstreet wrote:
> On Thu, Jun 20, 2024 at 09:22:42AM +0800, Youling Tang wrote:
>> From: Youling Tang <tangyouling@kylinos.cn>
>>
>> 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").
>>
>> Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
> Thanks - applied
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] bcachefs: fix alignment of VMA for memory mapped files on THP
2024-06-21 1:11 ` Youling Tang
@ 2024-06-21 1:41 ` Kent Overstreet
0 siblings, 0 replies; 4+ messages in thread
From: Kent Overstreet @ 2024-06-21 1:41 UTC (permalink / raw)
To: Youling Tang; +Cc: linux-bcachefs, linux-kernel, Youling Tang
On Fri, Jun 21, 2024 at 09:11:52AM +0800, Youling Tang wrote:
> Hi, Kent
>
> Sorry to bother you, BTW, are the following patches still needed?
>
> https://lore.kernel.org/linux-bcachefs/20240604084610.94558-1-youling.tang@linux.dev/
> https://lore.kernel.org/linux-bcachefs/20240418083103.66703-1-youling.tang@linux.dev/
> https://lore.kernel.org/linux-bcachefs/20240418005055.45482-1-youling.tang@linux.dev/
Yep, sorry I missed those - applied!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-21 1:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-20 1:22 [PATCH] bcachefs: fix alignment of VMA for memory mapped files on THP Youling Tang
2024-06-20 12:51 ` Kent Overstreet
2024-06-21 1:11 ` Youling Tang
2024-06-21 1:41 ` Kent Overstreet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox