lkml.org 
[lkml]   [2000]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Avoiding OOM on overcommit...?
Date
"A month of sundays ago David Whysong wrote:"
>[ptb wrote]
> >And I arrived later too. But while we're on the subject of swap space,
> >doesn't "reserve me 8MB of disk-based swap as backing for my stack" cure
> >everyones OOM blues? I propose that that's a fair use for swap nowadays.
>
> I don't know; what happens now if you use more than 8 MB of stack? Do "bad
> things" happen, or does the kernel grow the stack?

I don't believe you can grow beyond your rlimit.

I also think that you start off with less stack than that and libc
or stuff embedded in your code by gcc makes sbrk() calls to grow the
stack up to your rlimit as necessary.

> If the stack can grow, this doesn't really help. And I'm not sure I like
> the idea anyway; it's like optimizing for the worst case instead of the
> common case.

I am suggesting only that programs/systems which need guarantees start up
with real swap space backing processes stacks.

> >I don't _actually_ want to use swap myself, and having it there only
> >as the "gold-standard" at the back of the IOU seems the best use.
> >
> >That only leaves malloc and fork overhead as candidates for unexpected
> >segfaults. Malloc can be cured by the programmer touching the memory
> >when he gets it.
>
> Touching malloc()'ed pages doesn't solve anything -- this is no different

Toching malloc()ed pages does solve something. It forces the kernel
to try and find you a page to write to!

> from the case of not touching them immediately, and trying to use them

Yes it is. The touch will cause a segfault if there is no memory.
Since this happens in your malloc wrapper, you can return 0 and handle
that in the normal program. (ahem .. you better already had the stack
required for the segv handler in the wrapper).

> later. The malloc() still returns a valid pointer but no real memory. If
> you then try to touch the memory, what happens when the kernel can't get a
> free page?

You get a segfault at the time of the malloc call, instead of later.
The wrapper will handle it. Ummm .. you can guarantee stack space for
the handler by using longjmp just before you call malloc in the
wrapper I vaguely see.

> >Fork overhead is dealt with by having a reserve for the kernel.
>
> Seems like a kludge to me.

The latter is, but I believe that's the way things are now.

Requiring swap backing for a processes stack is not a kludge.

Peter


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

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.403 / U:0.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site