diff options
author | David Rientjes <rientjes@google.com> | 2014-01-23 18:53:34 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-23 19:36:53 -0500 |
commit | d49ad9355420c743c736bfd1dee9eaa5b1a7722a (patch) | |
tree | edd5f00d2e7e6b2414f7063e3393934dc74e5c9b /mm/memcontrol.c | |
parent | c3ac14b2677e0bc130238c5d01856592ac7a584b (diff) |
mm, oom: prefer thread group leaders for display purposes
When two threads have the same badness score, it's preferable to kill
the thread group leader so that the actual process name is printed to
the kernel log rather than the thread group name which may be shared
amongst several processes.
This was the behavior when select_bad_process() used to do
for_each_process(), but it now iterates threads instead and leads to
ambiguity.
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Greg Thelen <gthelen@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9537e1389ee6..c8336e8f8df0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1841,13 +1841,18 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, | |||
1841 | break; | 1841 | break; |
1842 | }; | 1842 | }; |
1843 | points = oom_badness(task, memcg, NULL, totalpages); | 1843 | points = oom_badness(task, memcg, NULL, totalpages); |
1844 | if (points > chosen_points) { | 1844 | if (!points || points < chosen_points) |
1845 | if (chosen) | 1845 | continue; |
1846 | put_task_struct(chosen); | 1846 | /* Prefer thread group leaders for display purposes */ |
1847 | chosen = task; | 1847 | if (points == chosen_points && |
1848 | chosen_points = points; | 1848 | thread_group_leader(chosen)) |
1849 | get_task_struct(chosen); | 1849 | continue; |
1850 | } | 1850 | |
1851 | if (chosen) | ||
1852 | put_task_struct(chosen); | ||
1853 | chosen = task; | ||
1854 | chosen_points = points; | ||
1855 | get_task_struct(chosen); | ||
1851 | } | 1856 | } |
1852 | css_task_iter_end(&it); | 1857 | css_task_iter_end(&it); |
1853 | } | 1858 | } |