Re: Avoiding OOM on overcommit...?

From: Linda Walsh (law@sgi.com)
Date: Thu Mar 30 2000 - 20:35:24 EST


Marco Colombo wrote:
> So you can run only 256 'ls', while I (on my overcommitting system)
> run 25600 of them.

---
	*and*?  Is this a problem?  Remember -- we are talking about what support
the kernel gives to allowing you to configure as you wish.  With the same kernel setup,
I can run 256 'ls', you can allocate your 1T of *virtual* swap (swap that exists only
for 'accounting' but has no physical backing -- allowing a user to define how much
overcommit they want to allow on their system).

> What? You're assuming that page-in frees swap? What for? Swap space > remains allocated after a page-in, i think. I hope! I really hope > the kernel DOES NOT allocted / deallocate disk blocks at EVERY page-out/ > page-in. It allocates swap only once. Either at brk() or fork() time > (non overcommitting) or at the first page-out (overcommitting). > Swap gets deallocated only when a process exits. That why, in a OOS > situation, the only solution is killing. --- There are two swap model systems that I'm aware of. One, an older model that I don't see so often is to have each physical page in memory backed by a physical page on disk. This was how SunOS functioned back in the 3.x days (circa 1989). I always thought that was silly -- but if you had 48 Meg of memory, you had to have 48 Meg of swap -- and you could only run a total of 48 Meg of stuff (OS included).

In IRIX -- as well as in Linux (correct me if I'm wrong), memory on disk is *added* memory space in which to run programs. It's a 'virtual memory' size = physical + swap. If you only have 64Mb of physical memory and you have two 60 meg processes, you'd better hope the kernel only takes 8 Meg (assume the backing of 64M you mentioned).

When a page is read in off disk, the swap page should be marked as 'free'. If no writes occur to the page in memory and the page needs to be paged out, ideally it could first be checked if it was on the 'free' disk-swap list and hadn't been recycled yet. If so you can simply reclaim it and not even write the clean page to swap. If the in-memory page is dirty, you have to do a disk write -- you can still reclaim the same disk-page if available, otherwise, off of the 'unused' queue, if that is empty then claim on a page that would have been reclaimable by another in-memory page.

Anyway -- not sure how much of that is done in Linux -- but I'm pretty sure -- you read a page in off disk, then it's location is in memory and the swap page is freed.

You are still going to have mondo-page swapping (thrashing) activity if both of your 60M processes touch all their pages during their run cycle.

> The above example was just to state that you should ignore RAM when you > preallocate. Do all computations over free *swap* space. Do not count > free RAM as free VM. --- But it *is* free VM. Suppose I have a 1G of physical mem and zero swap. If I 'preallocate', it will only be out of RAM -- since I have no swap.

-- Linda A Walsh | Trust Technology, Core Linux, SGI law@sgi.com | Voice: (650) 933-5338

- 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 : Fri Mar 31 2000 - 21:00:28 EST