[LWN Logo]
Date:	Wed, 4 Apr 2001 13:41:54 -0700 (PDT)
From:	Jonathan Morton <chromi@cyberspace.org>
To:	linux-kernel@vger.kernel.org
Subject: [PATCH] Revised memory-management stuff (was: OOM killer)

The attached patch applies to 2.4.3 and should address the most serious
concerns surrounding OOM and low-memory situations for most people.  A
summary of the patch contents follows:

MAJOR: OOM killer now only activates when truly out of memory, ie. when
buffer and cache memory has already been eaten down to the bone.

MEDIUM: The allocation mechanism will now only allow processes to reserve
memory if there is sufficient memory remaining *and* the process is not
already hogging RAM.  IOW, if the allocating process is already 4x the
size of the remaining free memory, reservation of more memory (by fork(),
malloc() or related calls) will fail.

MEDIUM: The OOM killer algorithm has been reworked to be a little more
intelligent by default, and also now allows the sysadmin to specify PIDs
and/or process names which should be left untouched.  Simply echo a
space-delimited list of PIDs and/or process names into
/proc/sys/vm/oom-no-kill, and the OOM killer will ignore all processes
matching any entry in the list until only they and init remain.  Init (as
PID 1 or as a root process named "init") is now always
ignored.  TODO: make certain parameters of the OOM killer configurable.

W-I-P: The memory-accounting code from an old 2.3.99 patch has been
re-introduced, but is in sore need of debugging.  It can be activated by
echoing a negative number into /proc/sys/vm/overcommit_memory - but do
this at your own risk.  Interested kernel hackers should alter the
"#define VM_DEBUG 0" to 1 in include/linux/mm.h to view lots of debugging
and warning messages.  I have seen the memory-accounting code attempt to
"free" blocks of memory exceeding 2GB which had never been allocated,
while running gcc.  The sanity-check code detects these anomalies and
attempts to correct for them, but this isn't good...

SIDE EFFECT: All parts of the kernel which can change the total amount of
VM (eg. by adding/removing swap) should now call
vm_invalidate_totalmem() to notify the VM about this.  A new function
vm_total() now reports the total amount of VM available.  The total VM and
the amount of reserved memory are now available from /proc/meminfo.

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/