Re: [RFC 0/3] mm: Discard lazily freed pages when migrating

From: Michal Hocko
Date: Wed Mar 04 2020 - 06:26:57 EST


On Wed 04-03-20 19:15:20, Huang, Ying wrote:
> Michal Hocko <mhocko@xxxxxxxxxx> writes:
>
> > On Tue 03-03-20 19:49:53, Huang, Ying wrote:
[...]
> >> Because the penalty difference is so large, I
> >> think it may be a good idea to always put clean MADV_FREE pages at the
> >> tail of the inactive file LRU list?
> >
> > You are again making assumptions without giving any actual real
> > examples. Reconstructing MADV_FREE pages cost can differ a lot.
>
> In which situation the cost to reconstruct MADV_FREE pages can be higher
> than the cost to allocate file cache page and read from disk? Heavy
> contention on mmap_sem?

Allocating a page might be really costly but even without that.
Reconstructnig the content of the page can be really high and actually
much larger than an IO to get a page from the storage. Consider
decompression or some other transformations to get the content.
Userspace has means to detect that the content is still up-to-date as
already has been mentioned so all those steps can be avoided.

--
Michal Hocko
SUSE Labs