Re: Moving /tmp to tmpfs makes it useless
- To: Josselin Mouette <email@example.com>
- Cc: firstname.lastname@example.org
- Subject: Re: Moving /tmp to tmpfs makes it useless
- From: Goswin von Brederlow <email@example.com>
- Date: Fri, 01 Jun 2012 13:44:35 +0200
- Message-id: <[🔎] firstname.lastname@example.org>
- In-reply-to: <1337952290.14895.407.camel@pi0307572> (Josselin Mouette's message of "Fri, 25 May 2012 15:24:50 +0200")
- References: <email@example.com> <1337952290.14895.407.camel@pi0307572>
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.