summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/base.c2
-rw-r--r--include/linux/mm.h3
-rw-r--r--mm/oom_kill.c2
3 files changed, 5 insertions, 2 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index dad8ea4..39fd336 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -751,7 +751,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
if (copy_from_user(buffer, buf, count))
return -EFAULT;
oom_adjust = simple_strtol(buffer, &end, 0);
- if (oom_adjust < -16 || oom_adjust > 15)
+ if ((oom_adjust < -16 || oom_adjust > 15) && oom_adjust != OOM_DISABLE)
return -EINVAL;
if (*end == '\n')
end++;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6a93137..85f7d1b 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -857,5 +857,8 @@ int in_gate_area_no_task(unsigned long addr);
#define in_gate_area(task, addr) ({(void)task; in_gate_area_no_task(addr);})
#endif /* __HAVE_ARCH_GATE_AREA */
+/* /proc/<pid>/oom_adj set to -17 protects from the oom-killer */
+#define OOM_DISABLE -17
+
#endif /* __KERNEL__ */
#endif /* _LINUX_MM_H */
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 9595a0f..4bbb1cb 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -145,7 +145,7 @@ static struct task_struct * select_bad_process(void)
do_posix_clock_monotonic_gettime(&uptime);
do_each_thread(g, p)
/* skip the init task with pid == 1 */
- if (p->pid > 1) {
+ if (p->pid > 1 && p->oomkilladj != OOM_DISABLE) {
unsigned long points;
/*
OpenPOWER on IntegriCloud