Re: Moving /tmp to tmpfs makes it useless
Josselin Mouette <firstname.lastname@example.org> writes:
> Le vendredi 25 mai 2012 Ã 16:01 +0300, Uoti Urpala a Ã©crit :
>> There is one significant difference though. When you read data back to
>> memory from swap, the kernel does not remember that it already exists on
>> disk; when the data is evicted from memory again, it is unnecessarily
>> rewritten to disk rather than just dropped. Thus, if you do multiple
>> read iterations through a large set of data (which does not fit in
>> memory) on tmpfs, each iteration does disk read AND write rather than
>> just read.
> I donâ??t know enough of the kernel innards, but it sounds to me that if a
> previously swapped page hasnâ??t been modified, it should be kept on swap
> *and* memory as long as possible.
> If it does not, it sounds like a bug, but it would indeed lead to the
> behavior you describe for this specific usage pattern.
Linux certainly has a notion of cached swap, i.e. pages from swap that
are also unmodified in memory. As long as you have enough swap the
kernel should not reap the swapped data and know that it is already on
disk when it wants to evict the page.