From: Alexander Popov <alex.popov@linux.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
John Stultz <john.stultz@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Stephen Boyd <sboyd@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
linux-kernel@vger.kernel.org
Cc: notify@kernel.org
Subject: [PATCH 1/1] timer: Warn about schedule_timeout() called for tasks in TASK_RUNNING state
Date: Thu, 16 Jan 2020 17:02:18 +0300 [thread overview]
Message-ID: <20200116140218.1328022-1-alex.popov@linux.com> (raw)
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
next reply other threads:[~2020-01-16 14:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-16 14:02 Alexander Popov [this message]
2020-01-16 14:52 ` [PATCH 1/1] timer: Warn about schedule_timeout() called for tasks in TASK_RUNNING state Steven Rostedt
2020-01-16 14:55 ` Steven Rostedt
2020-01-17 15:33 ` Alexander Popov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200116140218.1328022-1-alex.popov@linux.com \
--to=alex.popov@linux.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=john.stultz@linaro.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=notify@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).