From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Juri Lelli <juri.lelli@redhat.com>
Cc: Luca Abeni <luca.abeni@santannapisa.it>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Valentin Schneider <Valentin.Schneider@arm.com>,
Qais Yousef <Qais.Yousef@arm.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] sched/deadline: Fix double accounting of rq/running bw in push_dl_task()
Date: Fri, 26 Jul 2019 09:27:52 +0100 [thread overview]
Message-ID: <20190726082756.5525-2-dietmar.eggemann@arm.com> (raw)
In-Reply-To: <20190726082756.5525-1-dietmar.eggemann@arm.com>
push_dl_task() always calls deactivate_task() with flags=0 which sets
p->on_rq=TASK_ON_RQ_MIGRATING.
push_dl_task()->deactivate_task()->dequeue_task()->dequeue_task_dl()
calls sub_[running/rq]_bw() since p->on_rq=TASK_ON_RQ_MIGRATING.
So sub_[running/rq]_bw() in push_dl_task() is double-accounting for
that task.
The same is true for add_[rq/running]_bw() and activate_task() on the
destination (later) CPU.
push_dl_task()->activate_task()->enqueue_task()->enqueue_task_dl()
calls add_[rq/running]_bw() again since p->on_rq is still set to
TASK_ON_RQ_MIGRATING.
So the add_[rq/running]_bw() in enqueue_task_dl() is double-accounting
for that task.
Fix this by removing the rq/running bw accounting in push_dl_task().
Trace (CONFIG_SCHED_DEBUG=y) before the fix on a 6 CPUs system with 6
DL (12000, 100000, 100000) tasks showing the issue:
[ 48.147868] dl_rq->running_bw > old
[ 48.147886] WARNING: CPU: 1 PID: 0 at kernel/sched/deadline.c:98
...
[ 48.274832] inactive_task_timer+0x468/0x4e8
[ 48.279057] __hrtimer_run_queues+0x10c/0x3b8
[ 48.283364] hrtimer_interrupt+0xd4/0x250
[ 48.287330] tick_handle_oneshot_broadcast+0x198/0x1d0
...
[ 48.360057] dl_rq->running_bw > dl_rq->this_bw
[ 48.360065] WARNING: CPU: 1 PID: 0 at kernel/sched/deadline.c:86
...
[ 48.488294] task_contending+0x1a0/0x208
[ 48.492172] enqueue_task_dl+0x3b8/0x970
[ 48.496050] activate_task+0x70/0xd0
[ 48.499584] ttwu_do_activate+0x50/0x78
[ 48.503375] try_to_wake_up+0x270/0x7a0
[ 48.507167] wake_up_process+0x14/0x20
[ 48.510873] hrtimer_wakeup+0x1c/0x30
...
[ 50.062867] dl_rq->this_bw > old
[ 50.062885] WARNING: CPU: 1 PID: 2048 at kernel/sched/deadline.c:122
...
[ 50.190520] dequeue_task_dl+0x1e4/0x1f8
[ 50.194400] __sched_setscheduler+0x1d0/0x860
[ 50.198707] _sched_setscheduler+0x74/0x98
[ 50.202757] do_sched_setscheduler+0xa8/0x110
[ 50.207065] __arm64_sys_sched_setscheduler+0x1c/0x30
Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
---
kernel/sched/deadline.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index de2bd006fe93..d1aeada374e1 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2121,17 +2121,13 @@ static int push_dl_task(struct rq *rq)
}
deactivate_task(rq, next_task, 0);
- sub_running_bw(&next_task->dl, &rq->dl);
- sub_rq_bw(&next_task->dl, &rq->dl);
set_task_cpu(next_task, later_rq->cpu);
- add_rq_bw(&next_task->dl, &later_rq->dl);
/*
* Update the later_rq clock here, because the clock is used
* by the cpufreq_update_util() inside __add_running_bw().
*/
update_rq_clock(later_rq);
- add_running_bw(&next_task->dl, &later_rq->dl);
activate_task(later_rq, next_task, ENQUEUE_NOCLOCK);
ret = 1;
--
2.17.1
next prev parent reply other threads:[~2019-07-26 8:29 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-26 8:27 [PATCH 0/5] sched/deadline: Fix double accounting in push_dl_task() & some cleanups Dietmar Eggemann
2019-07-26 8:27 ` Dietmar Eggemann [this message]
2019-07-26 10:11 ` [PATCH 1/5] sched/deadline: Fix double accounting of rq/running bw in push_dl_task() luca abeni
2019-07-29 8:59 ` Dietmar Eggemann
2019-07-29 16:10 ` Peter Zijlstra
2019-07-26 13:30 ` luca abeni
2019-07-29 9:00 ` Dietmar Eggemann
2019-07-31 10:32 ` Dietmar Eggemann
2019-07-26 8:27 ` [PATCH 2/5] sched/deadline: Remove unused int flags from __dequeue_task_dl() Dietmar Eggemann
2019-07-29 16:35 ` Peter Zijlstra
2019-07-29 17:12 ` Dietmar Eggemann
2019-07-26 8:27 ` [PATCH 3/5] sched/deadline: Use __sub_running_bw() throughout dl_change_utilization() Dietmar Eggemann
2019-07-29 16:47 ` Peter Zijlstra
2019-07-29 17:21 ` Dietmar Eggemann
2019-07-26 8:27 ` [PATCH 4/5] sched/deadline: Cleanup on_dl_rq() handling Dietmar Eggemann
2019-07-26 8:37 ` Valentin Schneider
2019-07-26 8:58 ` Qais Yousef
2019-07-26 9:20 ` Juri Lelli
2019-07-26 9:32 ` Valentin Schneider
2019-07-29 16:49 ` Peter Zijlstra
2019-07-30 6:41 ` Juri Lelli
2019-07-30 8:21 ` Peter Zijlstra
2019-07-31 17:32 ` Dietmar Eggemann
2019-07-31 20:20 ` luca abeni
2019-08-01 16:01 ` Dietmar Eggemann
2019-07-26 8:27 ` [PATCH 5/5] sched/deadline: Use return value of SCHED_WARN_ON() in bw accounting Dietmar Eggemann
2019-07-26 10:18 ` luca abeni
2019-07-29 16:54 ` Peter Zijlstra
2019-07-29 16:59 ` Dietmar Eggemann
2019-07-30 8:23 ` Peter Zijlstra
2019-07-30 16:08 ` Dietmar Eggemann
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=20190726082756.5525-2-dietmar.eggemann@arm.com \
--to=dietmar.eggemann@arm.com \
--cc=Qais.Yousef@arm.com \
--cc=Valentin.Schneider@arm.com \
--cc=bristot@redhat.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.abeni@santannapisa.it \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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).