The attached patch adds the can_wait_task() and can_wait_task_ptrace() functions by splitting out the checks from wait_consider_task(). int ret = wait_consider_task(wo, 0, p); gets then replaced by ret = can_wait_task(wo, p); if (!ret) continue; ret = wait_consider_task(wo, 0, p);