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(a)novell.com> -----
Date: Wed, 27 Apr 2011 08:43:00 +0200
From: Andreas Jaeger <aj(a)novell.com>
To: linux-audit(a)redhat.com
Cc: Tony Jones <tonyj(a)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(a)novell.com>
To: linux-audit(a)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(a)suse.de
Subject: Use oom_score_adj on newer kernels
Date: 2010-09-27
Signed-Off-by: Andreas Jaeger <aj(a)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(a){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