how to configure Linux to call oom_kill on its own

7

1

I do not want my computer to swap data to disk. I have no swap partition:

$ free
             total       used       free     shared    buffers     cached
Mem:       3841912    3670012     171900          0      74980     699652
-/+ buffers/cache:    2895380     946532
Swap:            0          0          0

Back in the day (maybe as recently as kernel 2.4?) this used to work. Memory-hungry processes would be killed by the oom killer and I would restart them. But now (Linux 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:24 UTC 2011 x86_64) google-chrome (13.0.782.24 beta) regularly sends my machine into a death-spiral of swapping. Or at least something that feels like swapping: X windows take forever to update, disk drive whirs, gnome panel memory chart hits the ceiling, and I see this message in the syslog:

rtkit-daemon[1771]: The canary thread is apparently starving. Taking action.
rtkit-daemon[1771]: Demoting known real-time threads.
...

But, according to syslog, the kernel does not run the oom killer. For good measure, I set swappiness to 0:

$ cat /proc/sys/vm/swappiness
0

My workaround is to use ctrl-alt-sysrq-f when this starts to happen. Anyone have a recipe for configuring Linux to run oom_kill on its own, in this situation?

Joe

Posted 2011-06-18T01:04:49.263

Reputation: 171

1

Are you sure that the OOM Killer is actually not running? It's certainly possible that Chrome dodges the OOM killer. Run the second program here to see if the OOM killer is working or not.

– new123456 – 2011-06-18T02:33:37.133

I am sure the OOM Killer is not running as soon as I would like it to. The only time I see "invoked oom-killer" in syslog is when I invoke it manually -- after more than a minute of swapping. – Joe – 2011-06-18T16:46:36.130

Update: I'm on kernel 3.0.0 (and new hardware) and the problem remains. I have to be proactive about killing google-chrome, because once it gets deep into the death-spiral, even the magic sysrq key fails to revive the system. – Joe – 2011-09-23T07:31:14.403

What I don't understand about this question is: If you had no swap space configured, how were you swapping? – Michael Hampton – 2012-07-28T20:32:05.027

Well, as mentioned in the question, it felt like swapping in that the machine would slow way down and it would be hard to get apps to respond but they would, eventually. It may have really been the kernel waiting for chrome to release memory or something. – Joe – 2012-07-29T23:16:05.097

Answers

0

I have come to the conclusion that modern linux doesn't like to run without virtual memory. Maybe getting rid of swap made sense in the days of slow hard drives / older VM algorithms / etc. Or maybe you could jump through some hoops to configure the oom killer...

But I've been running with a swap file for the past few months and I'm much happier with my machine's low-memory behavior. It slows down a bit at the limits, but it's easy to intervene and kill memory-hungry processes to get things back on track.

Joe

Posted 2011-06-18T01:04:49.263

Reputation: 171

But how does the system behave when it's low on memory? – Aaron Franke – 2019-06-05T10:04:13.510

5

OOM doesn't necessarily kill the process you think it will. Read about it here: http://lwn.net/Articles/317814/

I suspect what is happening is that because chrome uses a different process for each page, it's confusing the OOM-killer's heuristics and other processes are being killed rather than the parent chrome process.

According to this, the OOM-killer likes to kill niced processes. So try setting chrome to a niceness of greater than 0.. might make it more of a target :-)

sml

Posted 2011-06-18T01:04:49.263

Reputation: 1 582

I think your suspicion about chrome is on the right track. It seems to operate in a way that confuses the OOM-killer's heuristics. The first program on the page new123456 links to confuses my kernel in the same way: It allocates lots of memory and makes the system unresponsive, but the OOM killer doesn't kill it (at least not within a minute or so). – Joe – 2011-06-27T00:50:18.977