Re: [PATCH v10] mm: vmscan: try to reclaim swapcache pages if no swap space

From: Huang, Ying
Date: Mon Nov 27 2023 - 20:34:50 EST


Michal Hocko <mhocko@xxxxxxxx> writes:

> On Mon 27-11-23 10:34:46, Huang, Ying wrote:
>> Michal Hocko <mhocko@xxxxxxxx> writes:
>>
>> > On Thu 23-11-23 14:15:59, Huang, Ying wrote:
>> >> Michal Hocko <mhocko@xxxxxxxx> writes:
>> > [...]
>> >> > Yes swapcache pages are indeed more complicated but most of the time
>> >> > they just go away as well, no?
>> >>
>> >> When we swapin a page, we will put it in swapcache too. And the page
>> >> can be in that state for long time if there is more than 50% free space
>> >> in the swap device.
>> >
>> > True, but why is that a problem? If you encounter such a swapped in page
>> > on the file LRU then the page should be referened and as such should be
>> > activated, no?
>>
>> This just means that anonymous pages in file LRU aren't temporary or
>> short-term. So we need to consider that.
>
> Right. On the other hand we could be more aggressive when dropping the
> swapcache. Is there any actual reason why we cannot try to folio_free_swap
> even when mem_cgroup_swap_full == F?

If there are plenty free space in swap device, why not take advantage of
it? If the page is in swap cache and clean, we can discard it when it
is reclaimed, or avoid to allocate swap entry for it.

--
Best Regards,
Huang, Ying