Mandeep Singh Baines dabb16f639 oom: allow a non-CAP_SYS_RESOURCE proces to oom_score_adj down
We'd like to be able to oom_score_adj a process up/down as it
enters/leaves the foreground.  Currently, it is not possible to oom_adj
down without CAP_SYS_RESOURCE.  This patch allows a task to decrease its
oom_score_adj back to the value that a CAP_SYS_RESOURCE thread set it to
or its inherited value at fork.  Assuming the thread that has forked it
has oom_score_adj of 0, each process could decrease it back from 0 upon
activation unless a CAP_SYS_RESOURCE thread elevated it to something
higher.

Alternative considered:

* a setuid binary
* a daemon with CAP_SYS_RESOURCE

Since you don't wan't all processes to be able to reduce their oom_adj, a
setuid or daemon implementation would be complex.  The alternatives also
have much higher overhead.

This patch updated from original patch based on feedback from David
Rientjes.

Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Acked-by: David Rientjes <rientjes@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Ying Han <yinghan@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-01-13 17:32:35 -08:00
..
2011-01-12 20:03:43 -05:00
2011-01-12 20:02:45 -05:00
2011-01-12 20:03:42 -05:00
2011-01-12 20:04:20 -05:00
2011-01-07 17:50:26 +11:00
2011-01-12 20:02:46 -05:00
2011-01-12 20:03:12 -05:00
2010-10-29 04:16:28 -04:00
2010-10-29 04:16:28 -04:00
2011-01-13 17:19:38 -08:00
2011-01-07 17:50:26 +11:00
2011-01-07 17:50:26 +11:00
2011-01-07 17:50:26 +11:00
2011-01-12 20:02:44 -05:00
2011-01-12 20:02:45 -05:00
2011-01-12 20:02:45 -05:00
2011-01-12 20:03:42 -05:00
2011-01-12 20:02:47 -05:00
2011-01-07 17:50:26 +11:00
2011-01-07 17:50:26 +11:00
2011-01-12 20:02:43 -05:00
2011-01-12 20:02:44 -05:00
2010-10-29 04:16:13 -04:00
2011-01-07 17:50:26 +11:00
2011-01-07 17:50:26 +11:00
2010-10-29 04:16:31 -04:00
2011-01-07 17:50:26 +11:00
2011-01-07 17:50:26 +11:00
2011-01-12 20:02:44 -05:00
2011-01-07 17:50:26 +11:00
2011-01-07 17:50:26 +11:00
2011-01-13 08:03:22 -08:00
2011-01-13 08:03:12 -08:00
2010-10-29 04:16:28 -04:00
2010-10-15 15:53:27 +02:00
2011-01-07 17:50:27 +11:00
2011-01-07 17:50:33 +11:00
2011-01-07 17:50:33 +11:00
2010-10-28 09:44:56 -07:00
2011-01-07 17:50:21 +11:00
2010-10-28 09:44:56 -07:00
2011-01-13 17:32:32 -08:00
2011-01-07 17:50:33 +11:00
2011-01-12 20:16:43 -05:00
2011-01-07 17:50:33 +11:00
2010-08-09 16:48:44 -04:00
2010-08-09 16:47:43 -04:00