Skip to contentSkip to conversation

oom-killer disable for iscsi/lvm2/multipath userland critical sections

PATCH In review [email protected] 1 participant 1 message Apr 12, 2005

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 16/198 oom-killer disable for iscsi/lvm2/multipath userland critical sections

From: Andrea Arcangeli <[email protected]>

iscsi/lvm2/multipath needs guaranteed protection from the oom-killer, so make the magical value of -17 in /proc/<pid>/oom_adj defeat the oom-killer altogether.

(akpm: we still need to document oom_adj and friends in Documentation/filesystems/proc.txt!)

---

 25-akpm/fs/proc/base.c     |    2 +-
 25-akpm/include/linux/mm.h |    3 +++
 25-akpm/mm/oom_kill.c      |    2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)
fs/proc/base.c renamed from fs/proc/base.c~oom-killer-disable-for-iscsi-lvm2-multipath-userland-critical-sections +1 -1
diff -puN fs/proc/base.c~oom-killer-disable-for-iscsi-lvm2-multipath-userland-critical-sections fs/proc/base.c
@@ -751,7 +751,7 @@ static ssize_t oom_adjust_write(struct f
 	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++;
include/linux/mm.h renamed from include/linux/mm.h~oom-killer-disable-for-iscsi-lvm2-multipath-userland-critical-sections +3 -0
diff -puN include/linux/mm.h~oom-killer-disable-for-iscsi-lvm2-multipath-userland-critical-sections include/linux/mm.h
@@ -857,5 +857,8 @@ int in_gate_area_no_task(unsigned long a
 #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 */
mm/oom_kill.c renamed from mm/oom_kill.c~oom-killer-disable-for-iscsi-lvm2-multipath-userland-critical-sections +1 -1
diff -puN mm/oom_kill.c~oom-killer-disable-for-iscsi-lvm2-multipath-userland-critical-sections mm/oom_kill.c
@@ -145,7 +145,7 @@ static struct task_struct * select_bad_p
 	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;
 
 			/*

_