projects/linux·commit 933b787b

mm: copy over oom_adj value at fork time

933b787b · Rik van Riel <[email protected]> · 2009-07-29 15:02:07 -07:00

Fix a post-2.6.31 regression which was introduced by
2ff05b2b4eac2e63d345fc731ea151a060247f53 ("oom: move oom_adj value from
task_struct to mm_struct").

After moving the oom_adj value from the task struct to the mm_struct, the
oom_adj value was no longer properly inherited by child processes.

Copying over the oom_adj value at fork time fixes that bug.

[[email protected]: test for current->mm before dereferencing it]
Signed-off-by: Rik van Riel <[email protected]>
Reported-by: Paul Menage <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Acked-by: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
933b787b57ca8bdc0fc8fb2cbf67b5e6d21beb84
Parents
6583bb64

Changes

1 files changed · +1 −0

FileStatusAddDelContent
kernel/fork.cmodified+1−0View file

kernel/fork.c

View file
diff --git a/kernel/fork.c b/kernel/fork.c
index 9b42695..29b532e 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -426,6 +426,7 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p)
init_rwsem(&mm->mmap_sem);
INIT_LIST_HEAD(&mm->mmlist);
mm->flags = (current->mm) ? current->mm->flags : default_dump_filter;
+ mm->oom_adj = (current->mm) ? current->mm->oom_adj : 0;
mm->core_state = NULL;
mm->nr_ptes = 0;
set_mm_counter(mm, file_rss, 0);