diff options
author | Peter Zijlstra <peterz@infradead.org> | 2014-09-24 04:18:49 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-10-28 05:55:30 -0400 |
commit | 1029a2b52c09e479fd7b07275812ad97868c0fb0 (patch) | |
tree | 9fc5eacd5cc76fdcef6238eff08278cd79e253ed /kernel/exit.c | |
parent | e22b886a8a43b147e1994a9f970f678fc0df2033 (diff) |
sched, exit: Deal with nested sleeps
do_wait() is a big wait loop, but we set TASK_RUNNING too late; we end
up calling potential sleeps before we reset it.
Not strictly a bug since we're guaranteed to exit the loop and not
call schedule(); put in annotations to quiet might_sleep().
WARNING: CPU: 0 PID: 1 at ../kernel/sched/core.c:7123 __might_sleep+0x7e/0x90()
do not call blocking ops when !TASK_RUNNING; state=1 set at [<ffffffff8109a788>] do_wait+0x88/0x270
Call Trace:
[<ffffffff81694991>] dump_stack+0x4e/0x7a
[<ffffffff8109877c>] warn_slowpath_common+0x8c/0xc0
[<ffffffff8109886c>] warn_slowpath_fmt+0x4c/0x50
[<ffffffff810bca6e>] __might_sleep+0x7e/0x90
[<ffffffff811a1c15>] might_fault+0x55/0xb0
[<ffffffff8109a3fb>] wait_consider_task+0x90b/0xc10
[<ffffffff8109a804>] do_wait+0x104/0x270
[<ffffffff8109b837>] SyS_wait4+0x77/0x100
[<ffffffff8169d692>] system_call_fastpath+0x16/0x1b
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: tglx@linutronix.de
Cc: umgwanakikbuti@gmail.com
Cc: ilya.dryomov@inktank.com
Cc: Alex Elder <alex.elder@linaro.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Axel Lin <axel.lin@ingics.com>
Cc: Daniel Borkmann <dborkman@redhat.com>
Cc: Dave Jones <davej@redhat.com>
Cc: Guillaume Morin <guillaume@morinfr.org>
Cc: Ionut Alexa <ionut.m.alexa@gmail.com>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Michal Schmidt <mschmidt@redhat.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20140924082242.186408915@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/exit.c')
-rw-r--r-- | kernel/exit.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 5d30019ff953..232c4bc8bcc9 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -997,6 +997,8 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p) | |||
997 | 997 | ||
998 | get_task_struct(p); | 998 | get_task_struct(p); |
999 | read_unlock(&tasklist_lock); | 999 | read_unlock(&tasklist_lock); |
1000 | sched_annotate_sleep(); | ||
1001 | |||
1000 | if ((exit_code & 0x7f) == 0) { | 1002 | if ((exit_code & 0x7f) == 0) { |
1001 | why = CLD_EXITED; | 1003 | why = CLD_EXITED; |
1002 | status = exit_code >> 8; | 1004 | status = exit_code >> 8; |
@@ -1079,6 +1081,7 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p) | |||
1079 | * thread can reap it because we its state == DEAD/TRACE. | 1081 | * thread can reap it because we its state == DEAD/TRACE. |
1080 | */ | 1082 | */ |
1081 | read_unlock(&tasklist_lock); | 1083 | read_unlock(&tasklist_lock); |
1084 | sched_annotate_sleep(); | ||
1082 | 1085 | ||
1083 | retval = wo->wo_rusage | 1086 | retval = wo->wo_rusage |
1084 | ? getrusage(p, RUSAGE_BOTH, wo->wo_rusage) : 0; | 1087 | ? getrusage(p, RUSAGE_BOTH, wo->wo_rusage) : 0; |
@@ -1210,6 +1213,7 @@ unlock_sig: | |||
1210 | pid = task_pid_vnr(p); | 1213 | pid = task_pid_vnr(p); |
1211 | why = ptrace ? CLD_TRAPPED : CLD_STOPPED; | 1214 | why = ptrace ? CLD_TRAPPED : CLD_STOPPED; |
1212 | read_unlock(&tasklist_lock); | 1215 | read_unlock(&tasklist_lock); |
1216 | sched_annotate_sleep(); | ||
1213 | 1217 | ||
1214 | if (unlikely(wo->wo_flags & WNOWAIT)) | 1218 | if (unlikely(wo->wo_flags & WNOWAIT)) |
1215 | return wait_noreap_copyout(wo, p, pid, uid, why, exit_code); | 1219 | return wait_noreap_copyout(wo, p, pid, uid, why, exit_code); |
@@ -1272,6 +1276,7 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p) | |||
1272 | pid = task_pid_vnr(p); | 1276 | pid = task_pid_vnr(p); |
1273 | get_task_struct(p); | 1277 | get_task_struct(p); |
1274 | read_unlock(&tasklist_lock); | 1278 | read_unlock(&tasklist_lock); |
1279 | sched_annotate_sleep(); | ||
1275 | 1280 | ||
1276 | if (!wo->wo_info) { | 1281 | if (!wo->wo_info) { |
1277 | retval = wo->wo_rusage | 1282 | retval = wo->wo_rusage |