2006-08-23 11:40:23

by Akinobu Mita

[permalink] [raw]
Subject: [RFC PATCH] prevent from killing OOM disabled task in do_page_fault()

The process protected from oom-killer may be killed when do_page_fault()
runs out of memory. This patch skips those processes as well as init task.

I couldn't touch several architectures (arm cris frv parisc sparc sparc64).
Because there is no survival path in that case for now.

Signed-off-by: Akinobu Mita <[email protected]>

arch/alpha/mm/fault.c | 2 +-
arch/arm26/mm/fault.c | 2 +-
arch/i386/mm/fault.c | 2 +-
arch/ia64/mm/fault.c | 2 +-
arch/m32r/mm/fault.c | 2 +-
arch/m68k/mm/fault.c | 2 +-
arch/mips/mm/fault.c | 2 +-
arch/powerpc/mm/fault.c | 2 +-
arch/ppc/mm/fault.c | 2 +-
arch/s390/mm/fault.c | 2 +-
arch/sh/mm/fault.c | 2 +-
arch/sh64/mm/fault.c | 2 +-
arch/x86_64/mm/fault.c | 2 +-
arch/xtensa/mm/fault.c | 2 +-
14 files changed, 14 insertions(+), 14 deletions(-)

Index: work-failmalloc/arch/alpha/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/alpha/mm/fault.c
+++ work-failmalloc/arch/alpha/mm/fault.c
@@ -193,7 +193,7 @@ do_page_fault(unsigned long address, uns
/* We ran out of memory, or some other thing happened to us that
made us unable to handle the page fault gracefully. */
out_of_memory:
- if (current->pid == 1) {
+ if (current->pid == 1 || current->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/arm26/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/arm26/mm/fault.c
+++ work-failmalloc/arch/arm26/mm/fault.c
@@ -185,7 +185,7 @@ survive:
}

fault = -3; /* out of memory */
- if (tsk->pid != 1)
+ if (tsk->pid != 1 && tsk->oomkilladj != OOM_DISABLE)
goto out;

/*
Index: work-failmalloc/arch/i386/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/i386/mm/fault.c
+++ work-failmalloc/arch/i386/mm/fault.c
@@ -598,7 +598,7 @@ no_context:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (tsk->pid == 1) {
+ if (tsk->pid == 1 || tsk->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/ia64/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/ia64/mm/fault.c
+++ work-failmalloc/arch/ia64/mm/fault.c
@@ -278,7 +278,7 @@ ia64_do_page_fault (unsigned long addres

out_of_memory:
up_read(&mm->mmap_sem);
- if (current->pid == 1) {
+ if (current->pid == 1 || current->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/m32r/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/m32r/mm/fault.c
+++ work-failmalloc/arch/m32r/mm/fault.c
@@ -299,7 +299,7 @@ no_context:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (tsk->pid == 1) {
+ if (tsk->pid == 1 || tsk->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/m68k/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/m68k/mm/fault.c
+++ work-failmalloc/arch/m68k/mm/fault.c
@@ -181,7 +181,7 @@ good_area:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (current->pid == 1) {
+ if (current->pid == 1 || current->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/mips/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/mips/mm/fault.c
+++ work-failmalloc/arch/mips/mm/fault.c
@@ -171,7 +171,7 @@ no_context:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (tsk->pid == 1) {
+ if (tsk->pid == 1 || tsk->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/powerpc/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/powerpc/mm/fault.c
+++ work-failmalloc/arch/powerpc/mm/fault.c
@@ -386,7 +386,7 @@ bad_area_nosemaphore:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (current->pid == 1) {
+ if (current->pid == 1 || current->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/ppc/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/ppc/mm/fault.c
+++ work-failmalloc/arch/ppc/mm/fault.c
@@ -291,7 +291,7 @@ bad_area:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (current->pid == 1) {
+ if (current->pid == 1 || current->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/s390/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/s390/mm/fault.c
+++ work-failmalloc/arch/s390/mm/fault.c
@@ -315,7 +315,7 @@ no_context:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (tsk->pid == 1) {
+ if (tsk->pid == 1 || tsk->oomkilladj == OOM_DISABLE) {
yield();
goto survive;
}
Index: work-failmalloc/arch/sh/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/sh/mm/fault.c
+++ work-failmalloc/arch/sh/mm/fault.c
@@ -160,7 +160,7 @@ no_context:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (current->pid == 1) {
+ if (current->pid == 1 || current->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/sh64/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/sh64/mm/fault.c
+++ work-failmalloc/arch/sh64/mm/fault.c
@@ -326,7 +326,7 @@ out_of_memory:
}
printk("fault:Out of memory\n");
up_read(&mm->mmap_sem);
- if (current->pid == 1) {
+ if (current->pid == 1 || current->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;
Index: work-failmalloc/arch/x86_64/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/x86_64/mm/fault.c
+++ work-failmalloc/arch/x86_64/mm/fault.c
@@ -586,7 +586,7 @@ no_context:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (current->pid == 1) {
+ if (current->pid == 1 || current->oomkilladj == OOM_DISABLE) {
yield();
goto again;
}
Index: work-failmalloc/arch/xtensa/mm/fault.c
===================================================================
--- work-failmalloc.orig/arch/xtensa/mm/fault.c
+++ work-failmalloc/arch/xtensa/mm/fault.c
@@ -144,7 +144,7 @@ bad_area:
*/
out_of_memory:
up_read(&mm->mmap_sem);
- if (current->pid == 1) {
+ if (current->pid == 1 || current->oomkilladj == OOM_DISABLE) {
yield();
down_read(&mm->mmap_sem);
goto survive;


2006-08-24 10:08:31

by Abu M. Muttalib

[permalink] [raw]
Subject: RE: [RFC PATCH] prevent from killing OOM disabled task in do_page_fault()

Hi,

> The process protected from oom-killer may be killed when do_page_fault()
> runs out of memory. This patch skips those processes as well as init task.

Do we have any patch set to disable OOM all together for linux kernel
2.6.13?

Regards and anticipation,
Abu.


2006-08-24 11:22:06

by Alan

[permalink] [raw]
Subject: RE: [RFC PATCH] prevent from killing OOM disabled task in do_page_fault()

Ar Iau, 2006-08-24 am 15:43 +0530, ysgrifennodd Abu M. Muttalib:
> Hi,
>
> > The process protected from oom-killer may be killed when do_page_fault()
> > runs out of memory. This patch skips those processes as well as init task.
>
> Do we have any patch set to disable OOM all together for linux kernel
> 2.6.13?

No, its run tme configurable as is selection priority of the processes
which you want killed, has been for some time.

Alan

2006-08-24 11:40:22

by Abu M. Muttalib

[permalink] [raw]
Subject: RE: [RFC PATCH] prevent from killing OOM disabled task indo_page_fault()

Hi,

> > > The process protected from oom-killer may be killed when
do_page_fault()
> > > runs out of memory. This patch skips those processes as well as init
task.
> >
> > Do we have any patch set to disable OOM all together for linux kernel
> > 2.6.13?
>
> No, its run tme configurable as is selection priority of the processes
> which you want killed, has been for some time.

Will you please elaborate upon your reply.

Thanks,
Abu.



2006-08-24 12:11:27

by Alan

[permalink] [raw]
Subject: RE: [RFC PATCH] prevent from killing OOM disabled task indo_page_fault()

Ar Iau, 2006-08-24 am 17:14 +0530, ysgrifennodd Abu M. Muttalib:
> > No, its run tme configurable as is selection priority of the processes
> > which you want killed, has been for some time.
>
> Will you please elaborate upon your reply.

See
Documentation/sysctl/vm.txt
Documenation/filesystems/proc.txt (look for oom_adj)

in 2.6.18-rc

Alan