linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luca Tettamanti <kronos.it@gmail.com>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] Add support for oom_score_adj.
Date: Mon, 23 Aug 2010 12:35:37 +0000	[thread overview]
Message-ID: <1282566937-6604-1-git-send-email-kronos.it@gmail.com> (raw)

/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


             reply	other threads:[~2010-08-23 12:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-23 12:35 Luca Tettamanti [this message]
2010-08-25 14:51 ` [PATCH] Add support for oom_score_adj Martin Pitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1282566937-6604-1-git-send-email-kronos.it@gmail.com \
    --to=kronos.it@gmail.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).