[PATCH] sched/deadline: Add update_rq_clock(later_rq) in push_dl_task()

From: Steven Rostedt
Date: Tue Jul 03 2018 - 12:03:38 EST


From: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>

Running tests on the deadline scheduler I triggered a WARN_ON() in
assert_clock_updated(). Unfortunately, this caused printk() to try
to wake up the klogd which caused a nasty deadlock. All I got out of
the output was:

"------------[ cut here ]------------"

But a bit of tweaking of where the 'cut here' prints were, I was able
to find the source. The warning is triggered by:

push_dl_task {
add_running_bw() {
__add_running_bw() {
cpufreq_update_util() {
data->func(data, rq_clock(rq), flags);
rq_clock() {
assert_clock_updated()

The rq_clock() is called on the rq of the CPU that is being pushed to.
There's no guarantee that it has been updated at this time. Since we
have the rq lock of that rq, the CPU doing the push can update the
clock to make sure that it is up-to-date before proceeding to do the
push.

Link: http://lkml.kernel.org/r/20180703105449.2a211fb2@xxxxxxxxxxxxxxxxxx
Suggested-by: Juri Lelli <juri.lelli@xxxxxxxxx>
Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index fbfc3f1d368a..90b6e9df79b2 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2085,6 +2085,8 @@ static int push_dl_task(struct rq *rq)
goto retry;
}

+ update_rq_clock(later_rq);
+
deactivate_task(rq, next_task, 0);
sub_running_bw(&next_task->dl, &rq->dl);
sub_rq_bw(&next_task->dl, &rq->dl);