Seems to me a guard page would do the trick. Make the last page of the
stack
non-overcommitable and marked not present. Maybe non-swappable too in
case
nothing else can be swapped out for some reason.
(Yes, that wastes a page per process)
Whenever we hit the guard page, try expanding the stack.
If it works - fine. If not - make the guard page present _and_ deliver
the SIGSEGV using this last page of stack. No complicated alternate
stack construct, just report OOM one page in advance.
OOM is still possible if the program don't handle SIGSEGV well.
But a smart program now have the option of doing emergency deallocations
and/or dump its precious intermediate results to file.
Helge Hafting
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/