Messages in this thread | | | Date | Tue, 6 Oct 1998 13:14:35 +0100 | From | "Stephen C. Tweedie" <> | Subject | Re: Out Of Memory in v. 2.1 |
| |
Hi,
On 4 Oct 1998 15:05:32 -0700, o.r.c@p.e.l.l.p.o.r.t.l.a.n.d.o.r.u.s (david parsons) said:
> That's one thing I've always wondered about. Why not have the system > keep track of total memory instead of wanting to mirror memory onto > swap? It seems to me that if you have 512mb of core and 128mb of > swap that you've got 640mb of memory and you should be able to do > allocations against that, since either a page will be in core or > on the swap device.
In general Linux does not always mirror memory onto swap. However, for efficiency it sometimes does so. There are two particular cases where it makes a big difference. First, if you read in a page from swap, then as long as the copy in memory hasn't been modified, it makes a lot of sense to keep the copy on disk around. That way, we can swap the page back out without writing it back to disk.
Secondly, if several processes share the same swap entry, then (for arcane magical VM reasons) VM gets enormously simplified if we don't have to update every process's page table on every swapin. This is especially true given that the page table entries are not necessarily at the same place in each process (due to mremap() calls). The swap cache allows some processes to swap a page into memory while others still retain their pointer to the copy on disk. They are still the same page as far as the VM is concerned: it's just a page of disk which happens to be cached in memory.
Other Unixen treat swap as a mirror of ram because they take this concept to its logical conclusion: *every* data page is treated just like a cache of some preallocated swap location.
--Stephen
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |