Re: [PATCH v5 4/4] mm: Introduce per-thpsize swapin control policy
From: Huang, Ying
Date: Mon Aug 05 2024 - 02:13:49 EST
Matthew Wilcox <willy@xxxxxxxxxxxxx> writes:
> On Fri, Jul 26, 2024 at 09:46:18PM +1200, Barry Song wrote:
>> A user space interface can be implemented to select different swap-in
>> order policies, similar to the mTHP allocation order policy. We need
>> a distinct policy because the performance characteristics of memory
>> allocation differ significantly from those of swap-in. For example,
>> SSD read speeds can be much slower than memory allocation. With
>> policy selection, I believe we can implement mTHP swap-in for
>> non-SWAP_SYNCHRONOUS scenarios as well. However, users need to understand
>> the implications of their choices. I think that it's better to start
>> with at least always never. I believe that we will add auto in the
>> future to tune automatically, which can be used as default finally.
>
> I strongly disagree. Use the same sysctl as the other anonymous memory
> allocations.
I still believe we have some reasons for this tunable.
1. As Ryan pointed out in [1], swap-in with large mTHP orders may cause
long latency, which some users might want to avoid.
[1] https://lore.kernel.org/lkml/f0c7f061-6284-4fe5-8cbf-93281070895b@xxxxxxx/
2. We have readahead information available for swap-in, which is
unavailable for anonymous page allocation. This enables us to build
an automatic swap-in order policy similar to that for page cache
order based on readahead.
3. Swap-out/swap-in cycles present an opportunity to identify hot pages.
In many use cases, we can utilize mTHP for hot pages and order-0 page
for cold pages, especially under memory pressure. When an mTHP has
been swapped out, it indicates that it could be a cold page.
Converting it to order-0 pages might be a beneficial policy.
--
Best Regards,
Huang, Ying