Re: Page cache and swapping

Marc Lehmann (
Thu, 26 Jun 1997 23:18:09 +0200 (CEST)

1. to the one saying qsort'ing mmaped file would be agood idea:

if you qsort a file that does not fit in memory, your program
is nearly broken - qsort has almost no locality, so you
get what you deserve... slow performance. qsort is one
of the worst sorting algorithms for this case.

>> 1. If page->count = 1 and the page is in page cache, it belongs exactly
>> to one process. Right? Why is it simply freed by shrink_mmap and why
>> it can't be freed, if page->count > 1?. Where is it removed from the process
>> page table? Or rather the "present" bit is set to zero for page cache
>> pages.
>This is the difficult point - you need to walk the page tables of all
>processes to find out which ones are using the page - a very costly
>operation. This is why the current system doesn't do this.

One point: when linux has started swapping, you have 50-95% IDLE time,
because almost NO process can run. In this (quite normal scenario), you
*do* have quite enough time to do almost any operation you want.

Imagine the time it needs to write a single page to swap.. in that time
you can do many thousands of memory accesses - and would still
be faster when only saving ONE page form swapping.


for a pentium-optimizing gcc, look at

----==-- _
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ /
-=====/_/_//_/\_,_/ /_/\_\
The choice of a GNU generation