Source: ocfs2-tools
Severity: normal
Tags: patch

Hi,
I am not sure where the upstream code sits for this package so I am
reporting it to distribution. Let me know if I should post the patch
somewhere else.
Anyway oom_adj is long deprecated and shouldn't be used. The attached
patch uses oom_score_adj in preference to oom_adj.

Thanks!

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.3.0-rc7 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

-- 
Michal Hocko
From: Michal Hocko <[email protected]>
Subject: use oom_score_adj instead of deprecated oom_adj

We are trying to get rid of oom_adj in the kernel. It has been
deprecated since 2.6.36. Let's use oom_score_adj preferably
and fallback to oom_adj when the former is not present (if
used on older systems).

While at it rename set_oom_adj to suppress_oom for an easier
transition because the file specific value can be handled
inside the function.

Signed-off-by: Michal Hocko <[email protected]>
Index: ocfs2-tools-1.6.4/ocfs2_controld/main.c
===================================================================
--- ocfs2-tools-1.6.4.orig/ocfs2_controld/main.c
+++ ocfs2-tools-1.6.4/ocfs2_controld/main.c
@@ -1150,11 +1150,16 @@ static void decode_arguments(int argc, c
 	}
 }
 
-static void set_oom_adj(int val)
+static void suppress_oom(int val)
 {
 	FILE *fp;
+	int val = -941; /* scaled out OOM_ADJUST_MIN */
 
-	fp = fopen("/proc/self/oom_adj", "w");
+	fp = fopen("/proc/self/oom_score_adj", "w");
+	if (!fp) {
+		fp = fopen("/proc/self/oom_adj", "w");
+		val = -16; /*OOM_ADJUST_MIN */
+	}
 	if (!fp)
 		return;
 
@@ -1212,7 +1217,7 @@ int main(int argc, char **argv)
 		daemonize();
 
 	set_scheduler();
-	set_oom_adj(-16);
+	suppress_oom();
 
 	return loop();
 }

Reply via email to