alistair23-linux/fs/proc
David Rientjes 2ff05b2b4e oom: move oom_adj value from task_struct to mm_struct
The per-task oom_adj value is a characteristic of its mm more than the
task itself since it's not possible to oom kill any thread that shares the
mm.  If a task were to be killed while attached to an mm that could not be
freed because another thread were set to OOM_DISABLE, it would have
needlessly been terminated since there is no potential for future memory
freeing.

This patch moves oomkilladj (now more appropriately named oom_adj) from
struct task_struct to struct mm_struct.  This requires task_lock() on a
task to check its oom_adj value to protect against exec, but it's already
necessary to take the lock when dereferencing the mm to find the total VM
size for the badness heuristic.

This fixes a livelock if the oom killer chooses a task and another thread
sharing the same memory has an oom_adj value of OOM_DISABLE.  This occurs
because oom_kill_task() repeatedly returns 1 and refuses to kill the
chosen task while select_bad_process() will repeatedly choose the same
task during the next retry.

Taking task_lock() in select_bad_process() to check for OOM_DISABLE and in
oom_kill_task() to check for threads sharing the same memory will be
removed in the next patch in this series where it will no longer be
necessary.

Writing to /proc/pid/oom_adj for a kthread will now return -EINVAL since
these threads are immune from oom killing already.  They simply report an
oom_adj value of OOM_DISABLE.

Cc: Nick Piggin <npiggin@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-16 19:47:43 -07:00
..
array.c proc: avoid information leaks to non-privileged processes 2009-05-04 15:14:23 -07:00
base.c oom: move oom_adj value from task_struct to mm_struct 2009-06-16 19:47:43 -07:00
cmdline.c
cpuinfo.c
devices.c
generic.c proc 1/2: do PDE usecounting even for ->read_proc, ->write_proc 2009-03-31 01:14:27 +04:00
inode.c proc 2/2: remove struct proc_dir_entry::owner 2009-03-31 01:14:44 +04:00
internal.h Move junk from proc_fs.h to fs/proc/internal.h 2009-06-11 21:36:01 -04:00
interrupts.c
Kconfig
kcore.c
kmsg.c
loadavg.c sched, timers: cleanup avenrun users 2009-05-15 15:32:45 +02:00
Makefile
meminfo.c mm: remove CONFIG_UNEVICTABLE_LRU config option 2009-06-16 19:47:42 -07:00
mmu.c
nommu.c trivial: fix typo "kernal" -> "kernel" 2009-03-30 15:21:57 +02:00
page.c mm: remove CONFIG_UNEVICTABLE_LRU config option 2009-06-16 19:47:42 -07:00
proc_devtree.c Move junk from proc_fs.h to fs/proc/internal.h 2009-06-11 21:36:01 -04:00
proc_net.c
proc_sysctl.c constify dentry_operations: procfs 2009-03-27 14:44:01 -04:00
proc_tty.c proc tty: remove struct tty_operations::read_proc 2009-04-01 08:59:10 -07:00
root.c Convert obvious places to deactivate_locked_super() 2009-05-09 10:49:40 -04:00
stat.c [S390] /proc/stat idle field for idle cpus 2009-04-23 13:58:17 +02:00
task_mmu.c pagemap: require aligned-length, non-null reads of /proc/pid/pagemap 2009-05-02 15:36:09 -07:00
task_nommu.c nommu: fix typo vma->pg_off to vma->vm_pgoff 2009-04-08 10:21:44 -07:00
uptime.c Revert "proc: revert /proc/uptime to ->read_proc hook" 2009-03-31 01:14:58 +04:00
version.c
vmcore.c