Bug 1838 - /proc/self/oom_adj needs to use /proc/self/oom_score_adj
Summary: /proc/self/oom_adj needs to use /proc/self/oom_score_adj
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 5.6p1
Hardware: All Linux
: P2 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_5_7
  Show dependency treegraph
 
Reported: 2010-11-16 11:31 AEDT by David Rientjes
Modified: 2011-01-24 12:33 AEDT (History)
6 users (show)

See Also:


Attachments
openssh-linux-new-oomkill.patch (2.90 KB, patch)
2010-11-16 16:24 AEDT, Darren Tucker
djm: ok+
Details | Diff
Switched to end-of-array sentinel. (2.90 KB, patch)
2011-01-17 11:04 AEDT, Darren Tucker
djm: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Rientjes 2010-11-16 11:31:09 AEDT
/proc/self/oom_adj is deprecated in Linux 2.6.36 and later kernels; it is scheduled for removal in August 2012.

sshd uses this interface to disable oom killing.

The new interface to use is /proc/self/oom_score_adj.  Instead of writing -17 to /proc/self/oom_adj, sshd should now write -1000 to /proc/self/oom_score_adj for the same behavior.

The filename and OOM_ADJ_NOKILL needs to be changed in openbsd-compat/port-linux.c for 2.6.36 and later kernels.
Comment 1 Darren Tucker 2010-11-16 16:24:22 AEDT
Created attachment 1957 [details]
openssh-linux-new-oomkill.patch

Try new OOM interface first then fall back if necessary.  Tested only on 2.6.32.
Comment 2 Darren Tucker 2010-11-24 10:22:56 AEDT
Comment on attachment 1957 [details]
openssh-linux-new-oomkill.patch

Works for me (2.6.32) but it would be nice if someone with a 2.6.36+ kernel could confirm it behaves as expected on that too.
Comment 3 Damien Miller 2010-12-18 09:31:12 AEDT
ping: Darren's patch can't go in until someone with a 2.6.36 system tests his patch.
Comment 4 Don Gray 2011-01-05 12:13:31 AEDT
(In reply to comment #3)
> ping: Darren's patch can't go in until someone with a 2.6.36 system
> tests his patch.

Tested on 2.6.36-ck5-r5 x86_64 openssh-5.6_p1

Error is gone from dmesg when restarting sshd.

value of /proc/$PID/oom_score_adj is -1000
value of /proc/$PID/oom_adj is -17
Comment 5 Mike Frysinger 2011-01-09 09:08:10 AEDT
your oom_adjust should be static and constant, and you should be using
ARRAY_SIZE() instead of "2"
Comment 6 Damien Miller 2011-01-10 06:41:32 AEDT
The idiom we use is to have a sentinel array entry with an obvious NULL or -1 somewhere we can test for:

for (i = 0; whatever[i].fnord != NULL; i++) ...
Comment 7 Darren Tucker 2011-01-17 11:04:18 AEDT
Created attachment 1980 [details]
Switched to end-of-array sentinel.

fair comments, I've changed it to use the sentinel since that's consistent with what we do elsewhere.
Comment 8 Darren Tucker 2011-01-17 11:56:21 AEDT
Thanks, this has been committed and will be in 5.7p1.
Comment 9 Damien Miller 2011-01-24 12:33:46 AEDT
Move resolved bugs to CLOSED after 5.7 release