aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index c445f8cc408d..e87aaaaf5131 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -65,6 +65,7 @@
65#include <linux/perf_event.h> 65#include <linux/perf_event.h>
66#include <linux/posix-timers.h> 66#include <linux/posix-timers.h>
67#include <linux/user-return-notifier.h> 67#include <linux/user-return-notifier.h>
68#include <linux/oom.h>
68 69
69#include <asm/pgtable.h> 70#include <asm/pgtable.h>
70#include <asm/pgalloc.h> 71#include <asm/pgalloc.h>
@@ -488,6 +489,7 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p)
488 mm->cached_hole_size = ~0UL; 489 mm->cached_hole_size = ~0UL;
489 mm_init_aio(mm); 490 mm_init_aio(mm);
490 mm_init_owner(mm, p); 491 mm_init_owner(mm, p);
492 atomic_set(&mm->oom_disable_count, 0);
491 493
492 if (likely(!mm_alloc_pgd(mm))) { 494 if (likely(!mm_alloc_pgd(mm))) {
493 mm->def_flags = 0; 495 mm->def_flags = 0;
@@ -741,6 +743,8 @@ good_mm:
741 /* Initializing for Swap token stuff */ 743 /* Initializing for Swap token stuff */
742 mm->token_priority = 0; 744 mm->token_priority = 0;
743 mm->last_interval = 0; 745 mm->last_interval = 0;
746 if (tsk->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
747 atomic_inc(&mm->oom_disable_count);
744 748
745 tsk->mm = mm; 749 tsk->mm = mm;
746 tsk->active_mm = mm; 750 tsk->active_mm = mm;
@@ -1299,8 +1303,13 @@ bad_fork_cleanup_io:
1299bad_fork_cleanup_namespaces: 1303bad_fork_cleanup_namespaces:
1300 exit_task_namespaces(p); 1304 exit_task_namespaces(p);
1301bad_fork_cleanup_mm: 1305bad_fork_cleanup_mm:
1302 if (p->mm) 1306 if (p->mm) {
1307 task_lock(p);
1308 if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
1309 atomic_dec(&p->mm->oom_disable_count);
1310 task_unlock(p);
1303 mmput(p->mm); 1311 mmput(p->mm);
1312 }
1304bad_fork_cleanup_signal: 1313bad_fork_cleanup_signal:
1305 if (!(clone_flags & CLONE_THREAD)) 1314 if (!(clone_flags & CLONE_THREAD))
1306 free_signal_struct(p->signal); 1315 free_signal_struct(p->signal);
@@ -1693,6 +1702,10 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
1693 active_mm = current->active_mm; 1702 active_mm = current->active_mm;
1694 current->mm = new_mm; 1703 current->mm = new_mm;
1695 current->active_mm = new_mm; 1704 current->active_mm = new_mm;
1705 if (current->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) {
1706 atomic_dec(&mm->oom_disable_count);
1707 atomic_inc(&new_mm->oom_disable_count);
1708 }
1696 activate_mm(active_mm, new_mm); 1709 activate_mm(active_mm, new_mm);
1697 new_mm = mm; 1710 new_mm = mm;
1698 } 1711 }