public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Tony Jones <tonyj@suse.de>
To: linux-audit@redhat.com
Subject: Fwd: Patch for using /proc/<id>oom_score_adj with newer kernels
Date: Mon, 2 May 2011 16:08:31 -0700	[thread overview]
Message-ID: <20110502230831.GA6875@suse.de> (raw)

I'm not sure what the policy is on moderator approval for posts.  AJ sent this 
a while ago and resent again on 4/27 (he is not subscribed, so both times the
post was waiting moderator approval).  Anyways, we've had this patch in our
OpenSuSE version for a while.

Tony

----- Forwarded message from Andreas Jaeger <aj@novell.com> -----

Date: Wed, 27 Apr 2011 08:43:00 +0200
From: Andreas Jaeger <aj@novell.com>
To: linux-audit@redhat.com
Cc: Tony Jones <tonyj@suse.de>
Subject: Fwd: Patch for using /proc/<id>oom_score_adj with newer kernels
User-Agent: KMail/1.13.7 (Linux/2.6.37.6-0.0.30.67cfac5-desktop; KDE/4.6.2;
	x86_64; ; )

I send the following message some time ago but do not see it in the archives 
and it seems this patch is still needed, so let me resend it,

Andreas
----------  Forwarded Message  ----------

Subject: Patch for using /proc/<id>oom_score_adj with newer kernels
Date: Tuesday, September 28, 2010, 09:25:02
From: Andreas Jaeger <aj@novell.com>
To: linux-audit@redhat.com

Hi,

I see in dmesg on my 2.6.36 kernel:
[   19.424535] auditd (2576): /proc/2576/oom_adj is deprecated, please use 
/proc/2576/oom_score_adj instead.

Since oom_adj is deprecated, let's use oom_score_adj.

Patch appended,

Andreas

From: aj@suse.de
Subject: Use oom_score_adj on newer kernels
Date: 2010-09-27
Signed-Off-by: Andreas Jaeger <aj@suse.de>

I see in dmesg on my 2.6.36 kernel:
[   19.424535] auditd (2576): /proc/2576/oom_adj is deprecated, please use 
/proc/2576/oom_score_adj instead.

Since oom_adj is deprecated, let's use oom_score_adj.

Index: src/auditd.c
===================================================================
--- src/auditd.c.orig
+++ src/auditd.c
@@ -265,7 +265,15 @@ static int write_pid_file(void)
 static void avoid_oom_killer(void)
 {
 	int oomfd;
-	
+
+	/* Newer kernels (noticed in 2.6.36) */
+	oomfd =	open("/proc/self/oom_score_adj", O_NOFOLLOW | O_WRONLY);
+        if (oomfd >= 0) {
+                (void)write(oomfd, "0", 1);
+                close(oomfd);
+                return;
+        }
+	/* Older kernel */
 	oomfd = open("/proc/self/oom_adj", O_NOFOLLOW | O_WRONLY);
 	if (oomfd >= 0) {
 		(void)write(oomfd, "-17", 3);

-- 
 Andreas Jaeger, Program Manager openSUSE,  aj@{novell.com,opensuse.org}
  Twitter: jaegerandi | Identica: jaegerandi
   SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
    Maxfeldstr. 5, 90409 Nürnberg, Germany
     GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

             reply	other threads:[~2011-05-02 23:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02 23:08 Tony Jones [this message]
2011-05-09 15:18 ` Fwd: Patch for using /proc/<id>oom_score_adj with newer kernels Steve Grubb

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=20110502230831.GA6875@suse.de \
    --to=tonyj@suse.de \
    --cc=linux-audit@redhat.com \
    /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