From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tony Jones Subject: Fwd: Patch for using /proc/oom_score_adj with newer kernels Date: Mon, 2 May 2011 16:08:31 -0700 Message-ID: <20110502230831.GA6875@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.17]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p42N8Y3b012142 for ; Mon, 2 May 2011 19:08:34 -0400 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p42N8UxD005452 for ; Mon, 2 May 2011 19:08:31 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 1348D8738D for ; Tue, 3 May 2011 01:08:29 +0200 (CEST) Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: linux-audit@redhat.com List-Id: linux-audit@redhat.com I'm not sure what the policy is on moderator approval for posts. AJ sent t= his = a while ago and resent again on 4/27 (he is not subscribed, so both times t= he post was waiting moderator approval). Anyways, we've had this patch in our OpenSuSE version for a while. Tony ----- Forwarded message from Andreas Jaeger ----- Date: Wed, 27 Apr 2011 08:43:00 +0200 From: Andreas Jaeger To: linux-audit@redhat.com Cc: Tony Jones Subject: Fwd: Patch for using /proc/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 archive= s = and it seems this patch is still needed, so let me resend it, Andreas ---------- Forwarded Message ---------- Subject: Patch for using /proc/oom_score_adj with newer kernels Date: Tuesday, September 28, 2010, 09:25:02 From: Andreas Jaeger 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 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D open("/proc/self/oom_score_adj", O_NOFOLLOW | O_WRONLY); + if (oomfd >=3D 0) { + (void)write(oomfd, "0", 1); + close(oomfd); + return; + } + /* Older kernel */ oomfd =3D open("/proc/self/oom_adj", O_NOFOLLOW | O_WRONLY); if (oomfd >=3D 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=FCrnberg) Maxfeldstr. 5, 90409 N=FCrnberg, Germany GPG fingerprint =3D 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126