Skip to contentSkip to conversation

old oom-vm for 2.4.32 (was oom killer in 2.4.23)

DISCUSSION Peter Bergmann 3 participants 7 messages Dec 5, 2003 – Dec 16, 2003

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

If anyone is interested:
Norbert Federa sent me this link for a "quick&dirty" patch he made for 2.4.23-vanilla which rolls back the complete 2.4.22 vm including the old oom-killer - without guarantee but it does work very well for me ...

http://www.esesix.at/kernel/vm-2.4.22.diff
http://www.esesix.at/kernel/vm-2.4.22.diff.gz

Signature · 2 lines
+++ GMX - die erste Adresse für Mail, Message, More +++
Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net
#1 lore raw
Quoted 4 lines · Peter Bergmann

If anyone is interested:
Norbert Federa sent me this link for a "quick&dirty" patch he made for 2.4.23-vanilla which rolls back the complete 2.4.22 vm including the old oom-killer - without guarantee but it does work very well for me ...

I suppose the oom killer is the only reason for you using .22 VM correct?

Or do you have any other reason for this?

#2 lore raw
Quoted 9 lines
Quoted 4 lines

If anyone is interested:
Norbert Federa sent me this link for a "quick&dirty" patch he made for 2.4.23-vanilla which rolls back the complete 2.4.22 vm including the old oom-killer - without guarantee but it does work very well for me

...

I suppose the oom killer is the only reason for you using .22 VM correct?

Or do you have any other reason for this?

No, you're right. The oom killer is the _only_reason.
I did not succeed in integrating the disabled oom_kill.c in 2.4.23. The only solution for me is applying Norbert's .22vm patch.

Signature · 2 lines
+++ GMX - die erste Adresse für Mail, Message, More +++
Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net
#3 lore raw

Configurable OOM killer Re: old oom-vm for 2.4.32 (was oom killer in 2.4.23)

Quoted 6 lines · Peter Bergmann
Quoted 6 lines
Quoted 4 lines

If anyone is interested:
Norbert Federa sent me this link for a "quick&dirty" patch he made for 2.4.23-vanilla which rolls back the complete 2.4.22 vm including the old oom-killer - without guarantee but it does work very well for me

...

Quoted 7 lines
Quoted 3 lines

I suppose the oom killer is the only reason for you using .22 VM correct?

Or do you have any other reason for this?

No, you're right. The oom killer is the _only_reason.
I did not succeed in integrating the disabled oom_kill.c in 2.4.23. The only solution for me is applying Norbert's .22vm patch.

Hi,

The following patch makes OOM killer configurable (its the same as the other patches posted except its around CONFIG_OOM_KILLER).

I hope the Configure.help entry is clear enough.

Peter, can you please try this.

Comments are appreciated.

Documentation/Configure.help +14 -0
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.24.orig/Documentation/Configure.help linux-2.4.24/Documentation/Configure.help
@@ -412,6 +412,20 @@
   Otherwise low memory pages are used as bounce buffers causing a
   degrade in performance.
 
+OOM killer support
+CONFIG_OOM_KILLER
+   This option selects the kernel behaviour during total out of memory
+   condition. 
+
+   The default behaviour is to, as soon as no freeable memory and no swap
+   space are available, kill the task which tries to allocate memory. 
+   The default behaviour is very reliable.
+
+   If you select this option, as soon as no freeable memory is available, 
+   the kernel will try to select the "best" task to be killed.
+
+   If unsure, say N.
+
 Normal floppy disk support
 CONFIG_BLK_DEV_FD
   If you want to use the floppy disk drive(s) of your PC under Linux,
arch/i386/config.in +1 -0
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.24.orig/arch/i386/config.in linux-2.4.24/arch/i386/config.in
@@ -328,6 +328,7 @@
 tristate 'Kernel support for a.out binaries' CONFIG_BINFMT_AOUT
 tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF
 tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC
+bool 'Select task to kill on out of memory condition' CONFIG_OOM_KILLER
 
 bool 'Power Management support' CONFIG_PM
 
include/linux/sched.h +1 -0
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.24.orig/include/linux/sched.h linux-2.4.24/include/linux/sched.h
@@ -429,6 +429,7 @@
 #define PF_DUMPCORE	0x00000200	/* dumped core */
 #define PF_SIGNALED	0x00000400	/* killed by a signal */
 #define PF_MEMALLOC	0x00000800	/* Allocating memory */
+#define PF_MEMDIE      0x00001000       /* Killed for out-of-memory */
 #define PF_FREE_PAGES	0x00002000	/* per process page freeing */
 #define PF_NOIO		0x00004000	/* avoid generating further I/O */
 #define PF_FSTRANS	0x00008000	/* inside a filesystem transaction */
mm/oom_kill.c +1 -4
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.24.orig/mm/oom_kill.c linux-2.4.24/mm/oom_kill.c
@@ -21,8 +21,6 @@
 #include <linux/swapctl.h>
 #include <linux/timex.h>
 
-#if 0		/* Nothing in this file is used */
-
 /* #define DEBUG */
 
 /**
@@ -153,6 +151,7 @@
 	 * exit() and clear out its resources quickly...
 	 */
 	p->counter = 5 * HZ;
+	p->flags |= PF_MEMALLOC | PF_MEMDIE;
 
 	/* This process has hardware access, be more careful. */
 	if (cap_t(p->cap_effective) & CAP_TO_MASK(CAP_SYS_RAWIO)) {
@@ -271,5 +270,3 @@
 out_unlock:
 	spin_unlock(&oom_lock);
 }
-
-#endif	/* Unused file */
mm/page_alloc.c +2 -1
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.24.orig/mm/page_alloc.c linux-2.4.24/mm/page_alloc.c
@@ -378,7 +378,8 @@
 
 	/* here we're in the low on memory slow path */
 
-	if (current->flags & PF_MEMALLOC && !in_interrupt()) {
+	if (((current->flags & PF_MEMALLOC) && !in_interrupt()) || 
+			(current->flags & (PF_MEMALLOC | PF_MEMDIE))) {
 		zone = zonelist->zones;
 		for (;;) {
 			zone_t *z = *(zone++);
mm/vmscan.c +4 -0
diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.24.orig/mm/vmscan.c linux-2.4.24/mm/vmscan.c
@@ -649,6 +649,9 @@
 				failed_swapout = !swap_out(classzone);
 		} while (--tries);
 
+#ifdef	CONFIG_OOM_KILLER
+	out_of_memory();
+#else
 	if (likely(current->pid != 1))
 		break;
 	if (!check_classzone_need_balance(classzone))
@@ -656,6 +659,7 @@
 
 	__set_current_state(TASK_RUNNING);
 	yield();
+#endif
 	}
 
 	return 0;
#4 lore raw

Re: Configurable OOM killer Re: old oom-vm for 2.4.32 (was oom killer in 2.4.23)

Quoted 22 lines · Peter Bergmann
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

If anyone is interested:
Norbert Federa sent me this link for a "quick&dirty" patch he made for 2.4.23-vanilla which rolls back the complete 2.4.22 vm including

the

Quoted 1 line
Quoted 1 line
Quoted 1 line

old oom-killer - without guarantee but it does work very well for

me

Quoted 3 lines
Quoted 3 lines

...

I suppose the oom killer is the only reason for you using .22 VM

correct?

Quoted 6 lines
Quoted 2 lines

Or do you have any other reason for this?

No, you're right. The oom killer is the _only_reason.
I did not succeed in integrating the disabled oom_kill.c in 2.4.23. The only solution for me is applying Norbert's .22vm patch.

Hi,

Quoted 8 lines

The following patch makes OOM killer configurable (its the same as the other patches posted except its around CONFIG_OOM_KILLER).

I hope the Configure.help entry is clear enough.

Peter, can you please try this.

Comments are appreciated.

Great. seems to work very well. Thx.
Ran some very hungry testprogs (memeat.c), filled a tmpfs with crap, ... I was satisfied with oom's kill decisions.
And it is/was very easy to modify/extend oom_kill.c for special needs.

Maybe the Configure.help text should be somewhat more frightening. I think aa had good reasons for disabling oom (possibility of lock up) but among others
I'd prefer to see your patch - a config option (default disabled + experimental) - in 2.4.24.

Cheers,
Pet

Signature · 2 lines
+++ GMX - die erste Adresse für Mail, Message, More +++
Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net
#5 lore raw

Re: Configurable OOM killer Re: old oom-vm for 2.4.32 (was oom killer in 2.4.23)

In reply to Marcelo Tosatti
Quoted 8 lines · Marcelo Tosatti

The following patch makes OOM killer configurable (its the same as the other patches posted except its around CONFIG_OOM_KILLER).

I hope the Configure.help entry is clear enough.

Peter, can you please try this.

Comments are appreciated.

[...]

mm/page_alloc.c line 385

Quoted 12 lines
mm/page_alloc.c +2 -1
@@ -378,7 +378,8 @@
 
 	/* here we're in the low on memory slow path */
 
-	if (current->flags & PF_MEMALLOC && !in_interrupt()) {
+	if (((current->flags & PF_MEMALLOC) && !in_interrupt()) || 
+			(current->flags & (PF_MEMALLOC | PF_MEMDIE))) {
 		zone = zonelist->zones;
 		for (;;) {
 			zone_t *z = *(zone++);

[...]

Hi, Marcelo. I haven't studied this patch, but the change above looks suspicious. The part added after the || makes the original condition irrelevant (because the 2nd part is true if either the PF_MEMALLOC or PF_MEMDIE flags are set).

Were you perhaps thinking of something like this?

	if ((current->flags & PF_MEMALLOC) &&
	    ((current->flags & PF_MEMDIE) || !in_interrupt())) {

Cheers. -ernie

#6 lore raw

Re: Configurable OOM killer Re: old oom-vm for 2.4.32 (was oom killer in 2.4.23)

Quoted 32 lines · Ernie Petrides
Quoted 8 lines · Marcelo Tosatti

The following patch makes OOM killer configurable (its the same as the other patches posted except its around CONFIG_OOM_KILLER).

I hope the Configure.help entry is clear enough.

Peter, can you please try this.

Comments are appreciated.

[...]

mm/page_alloc.c line 385

Quoted 12 lines
mm/page_alloc.c +2 -1
@@ -378,7 +378,8 @@
 
 	/* here we're in the low on memory slow path */
 
-	if (current->flags & PF_MEMALLOC && !in_interrupt()) {
+	if (((current->flags & PF_MEMALLOC) && !in_interrupt()) || 
+			(current->flags & (PF_MEMALLOC | PF_MEMDIE))) {
 		zone = zonelist->zones;
 		for (;;) {
 			zone_t *z = *(zone++);

[...]

Hi, Marcelo. I haven't studied this patch, but the change above looks suspicious. The part added after the || makes the original condition irrelevant (because the 2nd part is true if either the PF_MEMALLOC or PF_MEMDIE flags are set).

Quoted 6 lines

Were you perhaps thinking of something like this?

	if ((current->flags & PF_MEMALLOC) &&
	    ((current->flags & PF_MEMDIE) || !in_interrupt())) {

Cheers. -ernie

Correct.

I'll change it. Thanks