Changes to Linux OOM killer in 2.6.36

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Changes to Linux OOM killer in 2.6.36
Date: 2010-11-19 02:43:03
Message-ID: 4CE5E437.7080902@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Last month's new Linux kernel 2.6.36 includes a rewrite of the out of
memory killer:

http://lwn.net/Articles/391222/
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=a63d83f427fbce97a6cea0db2e64b0eb8435cd10

The new "badness" method totals the task's RSS and swap as a percentage
of RAM, where the old one scored starting with the total memory used by
the process. I *think* that this is an improvement for PostgreSQL,
based on the sort of data I see with:

ps -o pid,rss,size,vsize,args -C postgres

But I haven't tested with one of the new kernels yet to be sure.
Something to look at next time I get in that bleeding edge kernel kind
of mood.

One thing that's definitely changed is the interface used to control
turning off the OOM killer. There's a backward compatibility
translation right now that maps the current "-17" bit mask value the
PostgreSQL code sends to /proc/<pid>/oom_adj into the new units scale.
However, oom_adj is deprecated, scheduled for removal in August 2010:
http://www.mjmwired.net/kernel/Documentation/feature-removal-schedule.txt

So eventually, if the OOM disabling code is still necessary in
PostgreSQL, it will need to do this sort of thing instead:

echo -1000 > /proc/<pid>/oom_score_adj

I've seen kernel stuff get deprecated before the timeline before for
code related reasons (when the compatibility bits were judged too
obtrusive to keep around anymore), but since this translation bit is
only a few lines of code I wouldn't expect that to happen here.

I don't think it's worth doing anything to the database code until tests
on the newer kernel confirm whether this whole thing is even necessary
anymore. Wanted to pass along the info while I was staring at it
though. Thanks to Daniel Farina for pointing this out.

--
Greg Smith 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services and Support www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2010-11-19 03:17:59 Re: duplicate connection failure messages
Previous Message Itagaki Takahiro 2010-11-19 02:40:05 Re: UNNEST ... WITH ORDINALITY (AND POSSIBLY OTHER STUFF)