diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9bc081962934440a928afa65a7f2d6e401b0a6f7..606a481afe2e2e587115f7228b949cf2cf008c7f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1322,6 +1322,7 @@ void mem_cgroup_scan_tasks(struct mem_cgroup *memcg, { struct mem_cgroup *iter; int ret = 0; + int i = 0; BUG_ON(mem_cgroup_is_root(memcg)); @@ -1330,8 +1331,12 @@ void mem_cgroup_scan_tasks(struct mem_cgroup *memcg, struct task_struct *task; css_task_iter_start(&iter->css, CSS_TASK_ITER_PROCS, &it); - while (!ret && (task = css_task_iter_next(&it))) + while (!ret && (task = css_task_iter_next(&it))) { + /* Avoid potential softlockup warning */ + if ((++i & 1023) == 0) + cond_resched(); ret = fn(task, arg); + } css_task_iter_end(&it); if (ret) { mem_cgroup_iter_break(memcg, iter); diff --git a/mm/oom_kill.c b/mm/oom_kill.c index dc932c5837479a147eb1cf9604ea75ac30bb52d4..f8a45a224ca2a220b50302ef10dc21e049a62e1b 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "internal.h" @@ -482,10 +483,15 @@ static void dump_tasks(struct oom_control *oc) memcg_print_bad_task(oc); } else { struct task_struct *p; + int i = 0; rcu_read_lock(); - for_each_process(p) + for_each_process(p) { + /* Avoid potential softlockup warning */ + if ((++i & 1023) == 0) + touch_softlockup_watchdog(); dump_task(p, oc); + } rcu_read_unlock(); } }