Re: Compressed files & the page cache

Qu Wenruo
2025-07-21T13:20:15Z

在 2025/7/21 19:55, Jan Kara 写道:
> On Mon 21-07-25 11:14:02, Gao Xiang wrote:
>> Hi Barry,
>>
>> On 2025/7/21 09:02, Barry Song wrote:
>>> On Wed, Jul 16, 2025 at 8:28 AM Gao Xiang <hsiangkao@linux.alibaba.com> wrote:
[...]
>>> Given the difficulty of allocating large folios, it's always a good
>>> idea to have order-0 as a fallback. While I agree with your point,
>>> I have a slightly different perspective — enabling large folios for
>>> those devices might be beneficial, but the maximum order should
>>> remain small. I'm referring to "small" large folios.
>>
>> Yeah, agreed. Having a way to limit the maximum order for those small
>> devices (rather than disabling it completely) would be helpful. At
>> least "small" large folios could still provide benefits when memory
>> pressure is light.
>
> Well, in the page cache you can tune not only the minimum but also the
> maximum order of a folio being allocated for each inode. Btrfs and ext4
> already use this functionality. So in principle the functionality is there,
> it is "just" a question of proper user interfaces or automatic logic to
> tune this limit.
>
> Honza

And enabling large folios doesn't mean all fs operations will grab an
unnecessarily large folio.

For buffered write, all those filesystem will only try to get folios as
large as necessary, not overly large.

This means if the user space program is always doing buffered IO in a
power-of-two unit (and aligned offset of course), the folio size will
match the buffer size perfectly (if we have enough memory).

So for properly aligned buffered writes, large folios won't really cause
unnecessarily large folios, meanwhile brings all the benefits.

Although I'm not familiar enough with filemap to comment on folio read
and readahead...

Thanks,
Qu