Ying Han 3d5992d2ac oom: add per-mm oom disable count
It's pointless to kill a task if another thread sharing its mm cannot be
killed to allow future memory freeing.  A subsequent patch will prevent
kills in such cases, but first it's necessary to have a way to flag a task
that shares memory with an OOM_DISABLE task that doesn't incur an
additional tasklist scan, which would make select_bad_process() an O(n^2)
function.

This patch adds an atomic counter to struct mm_struct that follows how
many threads attached to it have an oom_score_adj of OOM_SCORE_ADJ_MIN.
They cannot be killed by the kernel, so their memory cannot be freed in
oom conditions.

This only requires task_lock() on the task that we're operating on, it
does not require mm->mmap_sem since task_lock() pins the mm and the
operation is atomic.

[rientjes@google.com: changelog and sys_unshare() code]
[rientjes@google.com: protect oom_disable_count with task_lock in fork]
[rientjes@google.com: use old_mm for oom_disable_count in exec]
Signed-off-by: Ying Han <yinghan@google.com>
Signed-off-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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-10-26 16:52:05 -07:00
..
2010-08-24 14:57:09 -07:00
2010-08-05 13:26:20 +01:00
2010-08-12 06:38:24 +10:00
2010-10-15 21:18:59 +02:00
2010-06-15 09:56:01 +10:00
2010-05-27 09:12:53 -07:00
2010-09-23 14:33:39 -07:00
2010-08-12 08:43:30 -07:00
2010-06-24 21:30:09 -07:00
2010-10-25 08:02:40 -07:00
2010-08-06 15:36:47 -05:00
2010-08-19 17:18:00 -07:00
2010-08-04 11:00:45 +02:00
2010-08-12 04:14:05 +01:00
2010-10-21 14:47:59 +02:00
2010-09-23 14:33:39 -07:00
2010-08-19 17:18:03 -07:00
2010-08-18 08:35:46 -04:00
2010-09-09 20:46:30 +02:00
2010-07-12 14:41:40 +02:00
2010-05-25 08:07:01 -07:00
2010-10-25 14:11:37 -07:00
2010-10-23 22:49:32 +02:00
2010-10-12 16:53:37 +02:00
2010-08-11 09:23:22 +02:00
2010-06-16 18:08:13 +02:00
2010-06-03 03:21:52 -07:00
2010-09-21 18:04:47 -07:00
2010-08-29 21:57:55 -07:00
2010-08-19 17:16:23 -07:00
2010-09-30 21:16:05 -07:00
2010-08-20 08:55:00 -07:00
2010-08-19 17:18:03 -07:00
2010-08-09 20:45:05 -07:00
2010-10-12 16:53:44 +02:00
2010-10-07 14:08:55 +01:00
2010-10-12 16:39:07 +02:00
2010-06-03 03:21:52 -07:00
2010-08-10 11:49:21 -07:00
2010-08-18 10:19:52 +02:00
2010-08-12 11:27:58 +02:00
2010-10-22 15:34:12 -05:00
2010-08-19 17:18:00 -07:00
2010-09-09 18:57:24 -07:00
2010-06-29 10:07:09 +02:00
2010-08-02 06:39:44 +03:00
2010-10-21 21:18:54 -04:00
2010-06-16 18:03:15 +02:00
2010-08-09 16:48:45 -04:00
2010-06-03 03:21:52 -07:00
2010-10-26 16:52:05 -07:00
2010-08-11 00:29:47 -04:00
2010-10-12 16:53:34 +02:00
2010-10-04 21:10:52 +02:00
2010-10-04 21:10:52 +02:00
2010-10-01 17:18:59 -04:00
2010-10-21 04:26:38 -07:00
2010-10-07 18:48:49 -04:00
2010-08-19 17:18:02 -07:00
2010-07-05 16:14:52 -06:00
2010-10-15 12:45:44 +02:00
2010-08-21 23:40:14 -07:00
2010-07-19 01:58:48 +02:00
2010-07-19 01:58:48 +02:00
2010-08-04 21:53:17 -07:00
2010-08-19 17:18:03 -07:00
2010-09-08 18:16:55 -07:00
2010-08-09 16:47:27 -04:00
2010-05-27 09:12:50 -07:00
2010-05-30 09:02:47 -07:00
2010-10-05 00:29:48 -07:00
2010-07-23 17:08:41 +04:00
2010-06-03 03:21:52 -07:00
2010-09-08 15:04:10 +02:00
2010-05-25 11:41:43 -04:00
2010-10-05 22:10:30 +09:00
2010-10-20 03:02:23 -07:00
2010-10-21 15:44:13 +02:00
2010-10-21 03:09:42 -07:00
2010-10-07 14:08:55 +01:00
2010-08-09 16:48:44 -04:00
2010-09-24 21:27:41 -07:00
2010-08-30 13:23:33 -07:00
2010-09-09 20:41:20 +02:00
2010-10-22 10:20:04 -07:00
2010-10-26 16:52:03 -07:00
2010-10-22 10:16:43 -07:00
2010-08-11 08:59:02 -07:00