Re: Overcomittable memory

From: James Sutherland (jas88@cam.ac.uk)
Date: Tue Mar 21 2000 - 08:44:00 EST


On Tue, 21 Mar 2000 13:57:07 +0100 (CET), you wrote:
>On Tue, 21 Mar 2000, James Sutherland wrote:
>
>[...[
>> So? If you touch the memory, overcommit doesn't come into play.
>
>All processes should do that for it to work. Example (you have 128MB of swap):
>
>you malloc() 1MB of space, and touch every page on it. Does swap gets
>allocated at this time? Assume it is (I'm not sure: the pages are dirty,
>but get written on swap when needed, at later time).
>
>Another process malloc 128MB of space. It does not touch the pages,
>overcommiting allows malloc() to succeed.
>
>RAM gets used up by some one else. Your pages get swapped out.

No - you haven't allocated (touched) the pages yet. They are purely
imaginary pages until then.

>Later, you access one page of yours. It's not in RAM. The system has to
>fetch it from swap. First, it has to locate a free page-frame. There is none.
>So, it has to swap-out some other page. But, wait, swap space is full.
>What happens? It's your process causing the page fault.
>
>Even if your process has all swap space allocated, it's not enough.
>Overcommiting for other processes still hits you.

You seem to misunderstand. Basically, malloc() allocates ADDRESS
SPACE, not memory. USING that address space then allocates VM (RAM or
swap). Problems only arise if you haven't really allocated your memory
yet, you only think you have (because you misunderstand the malloc()
implementation.)

If YOU touch memory when malloc()ed (i.e. you REALLY allocate memory,
not just address space to put memory in) you're fine. Only the other
processes can be hit.

James.

-
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/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:32 EST