Subject: [PATCH 0813/2944] mm: memcontrol: use CSS_TASK_ITER_PROCS at mem_cgroup_scan_tasks()

From: Tetsuo Handa <[email-masked]>
Date: Thu, 11 Jul 2019 21:00:20 -0700

commit f168a9a54ec39b3f832c353733898b713b6b5c1f upstream.

Since commit c03cd7738a83 ("cgroup: Include dying leaders with live
threads in PROCS iterations") corrected how CSS_TASK_ITER_PROCS works,
mem_cgroup_scan_tasks() can use CSS_TASK_ITER_PROCS in order to check
only one thread from each thread group.

[[email-masked]: remove thread group leader check in oom_evaluate_task()]
  Link: http://lkml.kernel.org/r/[email-masked]
Link: http://lkml.kernel.org/r/[email-masked]
Signed-off-by: Tetsuo Handa <[email-masked]>
Acked-by: Michal Hocko <[email-masked]>
Reviewed-by: Shakeel Butt <[email-masked]>
Cc: Johannes Weiner <[email-masked]>
Cc: Tejun Heo <[email-masked]>
Signed-off-by: Andrew Morton <[email-masked]>
Signed-off-by: Linus Torvalds <[email-masked]>
Signed-off-by: Xu Yu <[email-masked]>
Reviewed-by: Yang Shi <[email-masked]>
Reviewed-by: Xunlei Pang <[email-masked]>
---
 mm/memcontrol.c | 2 +-
 mm/oom_kill.c   | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2d556fd..4d8748d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1229,7 +1229,7 @@ int mem_cgroup_scan_tasks(struct mem_cgroup *memcg,
 		struct css_task_iter it;
 		struct task_struct *task;
 
-		css_task_iter_start(&iter->css, 0, &it);
+		css_task_iter_start(&iter->css, CSS_TASK_ITER_PROCS, &it);
 		while (!ret && (task = css_task_iter_next(&it)))
 			ret = fn(task, arg);
 		css_task_iter_end(&it);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index f1d323e1..bcbac9d 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -354,9 +354,6 @@ int oom_evaluate_task(struct task_struct *task, void *arg)
 	if (points < oc->chosen_points)
 		goto next;
 
-	/* Prefer thread group leaders for display purposes */
-	if (points == oc->chosen_points && thread_group_leader(oc->chosen))
-		goto next;
 select:
 	if (oc->chosen)
 		put_task_struct(oc->chosen);
-- 
1.8.3.1