From mboxrd@z Thu Jan 1 00:00:00 1970 From: Luca Tettamanti Date: Mon, 23 Aug 2010 12:35:37 +0000 Subject: [PATCH] Add support for oom_score_adj. Message-Id: <1282566937-6604-1-git-send-email-kronos.it@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org /proc//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