Source: android-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.

-- 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 b31a0fbaa22f8cbba2c2c6fb0d6867adc9de592a Mon Sep 17 00:00:00 2001
From: Michal Hocko <[email protected]>
Date: Fri, 30 Oct 2015 15:09:39 +0100
Subject: [PATCH] use oom_score_adj rather than 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).

Signed-off-by: Michal Hocko <[email protected]>
---
 core/adb/services.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/core/adb/services.c b/core/adb/services.c
index 54d21a8b74d9..1d1abf79928d 100644
--- a/core/adb/services.c
+++ b/core/adb/services.c
@@ -308,8 +308,13 @@ static int create_subprocess(const char *cmd, const char *arg0, const char *arg1
 
         // set OOM adjustment to zero
         char text[64];
-        snprintf(text, sizeof text, "/proc/%d/oom_adj", getpid());
+        snprintf(text, sizeof text, "/proc/%d/oom_score_adj", getpid());
         int fd = adb_open(text, O_WRONLY);
+        if (fd < 0) {
+           // fallback to oom_adj if oom_score_adj doesn't exist
+           snprintf(text, sizeof text, "/proc/%d/oom_adj", getpid());
+           fd = adb_open(text, O_WRONLY);
+        }
         if (fd >= 0) {
             adb_write(fd, "0", 1);
             adb_close(fd);
-- 
2.6.1

Reply via email to