linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] timer: Warn about schedule_timeout() called for tasks in TASK_RUNNING state
@ 2020-01-16 14:02 Alexander Popov
  2020-01-16 14:52 ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Popov @ 2020-01-16 14:02 UTC (permalink / raw)
  To: Linus Torvalds, John Stultz, Thomas Gleixner, Stephen Boyd,
	Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	linux-kernel
  Cc: notify

When we were preparing the patch 6dcd5d7a7a29c1e, we made a mistake noticed
by Linus: schedule_timeout() was called without setting the task state to
anything particular. It calls the scheduler, but doesn't delay anything,
because the task stays runnable. That happens because sched_submit_work()
does nothing for tasks in TASK_RUNNING state.

Let's add a WARN_ONCE() under CONFIG_SCHED_DEBUG to detect such kernel
API misuse.

Signed-off-by: Alexander Popov <alex.popov@linux.com>
---
 kernel/time/timer.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 4820823515e9..52ad2d6ce352 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1887,6 +1887,11 @@ signed long __sched schedule_timeout(signed long timeout)
 		}
 	}
 
+#ifdef CONFIG_SCHED_DEBUG
+	WARN_ONCE(current->state == TASK_RUNNING,
+			"schedule_timeout for TASK_RUNNING\n");
+#endif
+
 	expire = timeout + jiffies;
 
 	timer.task = current;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-17 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 14:02 [PATCH 1/1] timer: Warn about schedule_timeout() called for tasks in TASK_RUNNING state Alexander Popov
2020-01-16 14:52 ` Steven Rostedt
2020-01-16 14:55   ` Steven Rostedt
2020-01-17 15:33   ` Alexander Popov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).