[PATCH] Add support for oom_score_adj.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



/proc/<pid>/oom_adj has been deprecated (kernel v2.6.36) due to the
rework of the badness heuristic; oom_score_adj is the replacement.
Keep a fallback to the old interface for compatibility with older
kernels.
---
 udev/udevd.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/udev/udevd.c b/udev/udevd.c
index ad2ca3b..ac2fae0 100644
--- a/udev/udevd.c
+++ b/udev/udevd.c
@@ -1302,12 +1302,19 @@ int main(int argc, char *argv[])
 		fclose(f);
 	}
 
-	/* OOM_DISABLE == -17 */
-	fd = open("/proc/self/oom_adj", O_RDWR);
+	fd = open("/proc/self/oom_score_adj", O_RDWR);
 	if (fd < 0) {
-		err(udev, "error disabling OOM: %m\n");
+		/* Fallback to old interface */
+		fd = open("/proc/self/oom_adj", O_RDWR);
+		if (fd < 0) {
+			err(udev, "error disabling OOM: %m\n");
+		} else {
+			/* OOM_DISABLE == -17 */
+			write(fd, "-17", 3);
+			close(fd);
+		}
 	} else {
-		write(fd, "-17", 3);
+		write(fd, "-1000", 5);
 		close(fd);
 	}
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux