* [PATCH] Trivial -critical : BUG()gy behaviour on OOM
@ 2004-02-15 15:47 BlaisorBlade
2004-02-16 0:01 ` William Lee Irwin III
0 siblings, 1 reply; 2+ messages in thread
From: BlaisorBlade @ 2004-02-15 15:47 UTC (permalink / raw)
To: Andrew Morton, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]
In short: in vanilla 2.6.3-rc2 (and also 2.6.2-mm1) do_swap_page() can return
-ENOMEM while value return values are VM_FAULT_*; invalid return values can
result in BUG() being called, so this patch (or a better fix) should go in
soon. This patch corrects this by returning VM_FAULT_OOM in that case.
CC me on replies, please, as I'm not subscribed. Thanks.
In detail: do_swap_page returns -ENOMEM when memory allocation fails; the
return value will in turn be returned by handle_pte_fault and handle_mm_fault
to this code in do_page_fault:
switch (handle_mm_fault(mm, vma, address, write)) {
case VM_FAULT_MINOR:
tsk->min_flt++;
break;
case VM_FAULT_MAJOR:
tsk->maj_flt++;
break;
case VM_FAULT_SIGBUS:
goto do_sigbus;
case VM_FAULT_OOM:
goto out_of_memory;
default:
BUG();
}
So on OOM we can get a BUG. Since do_file_page does this:
if (err == -ENOMEM)
return VM_FAULT_OOM;
and other code shows similar behaviour, I think that the attached fix is the
correct one.
--
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
[-- Attachment #2: Fix-mm-return.patch --]
[-- Type: text/x-diff, Size: 302 bytes --]
--- ./mm/memory.c.fix 2004-02-04 20:48:15.000000000 +0100
+++ ./mm/memory.c 2004-02-14 17:59:42.000000000 +0100
@@ -1250,7 +1250,7 @@
mark_page_accessed(page);
pte_chain = pte_chain_alloc(GFP_KERNEL);
if (!pte_chain) {
- ret = -ENOMEM;
+ ret = VM_FAULT_OOM;
goto out;
}
lock_page(page);
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Trivial -critical : BUG()gy behaviour on OOM
2004-02-15 15:47 [PATCH] Trivial -critical : BUG()gy behaviour on OOM BlaisorBlade
@ 2004-02-16 0:01 ` William Lee Irwin III
0 siblings, 0 replies; 2+ messages in thread
From: William Lee Irwin III @ 2004-02-16 0:01 UTC (permalink / raw)
To: BlaisorBlade; +Cc: Andrew Morton, linux-kernel
On Sun, Feb 15, 2004 at 04:47:39PM +0100, BlaisorBlade wrote:
> In short: in vanilla 2.6.3-rc2 (and also 2.6.2-mm1) do_swap_page() can return
> -ENOMEM while value return values are VM_FAULT_*; invalid return values can
> result in BUG() being called, so this patch (or a better fix) should go in
> soon. This patch corrects this by returning VM_FAULT_OOM in that case.
> CC me on replies, please, as I'm not subscribed. Thanks.
> In detail: do_swap_page returns -ENOMEM when memory allocation fails; the
> return value will in turn be returned by handle_pte_fault and handle_mm_fault
> to this code in do_page_fault:
Yep. This is bust.
akpm please apply.
-- wli
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-02-16 0:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-15 15:47 [PATCH] Trivial -critical : BUG()gy behaviour on OOM BlaisorBlade
2004-02-16 0:01 ` William Lee Irwin III
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox