Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1378771

[PATCH] sched/deadline: Fix a bug in dl_overflow()

From Xunlei Pang <xlpang@redhat.com>
Newsgroups linux.kernel
Subject [PATCH] sched/deadline: Fix a bug in dl_overflow()
Date 2016-04-14 14:20 +0200
Message-ID <rnOpC-1sB-57@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


I got a minus(very big) dl_b->total_bw during my deadline tests.

    # grep dl /proc/sched_debug
    dl_rq[0]:
    .dl_nr_running                 : 0
    .dl_bw->bw                     : 996147
    .dl_bw->total_bw               : -222297900

Something unusual must have happened.

After some digging, I finally noticed that when changing a deadline
task to normal(cfs), and changing it back to deadline immediately,
after it died, we will got the wrong dl_bw->total_bw.

The root cause is in dl_overflow(), it has:
    if (new_bw == p->dl.dl_bw)
    	return 0;

1) When a deadline task is changed to !deadline task, it will start
   dl timer in switched_from_dl(), and retain previous deadline parameter
   till the timer expires.
2) If we change it back to deadline with the same bandwidth parameter
   before the timer expires, as it keeps the old bandwidth although it
   is not a deadline task. dl_overflow() simply returns success without
   updating the right data, and got the wrong dl_bw->total_bw.

The solution is simple, if @p is not deadline, don't return.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
---
 kernel/sched/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4a2c79d..5988fee 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2378,7 +2378,8 @@ static int dl_overflow(struct task_struct *p, int policy,
 	u64 new_bw = dl_policy(policy) ? to_ratio(period, runtime) : 0;
 	int cpus, err = -1;
 
-	if (new_bw == p->dl.dl_bw)
+	/* !deadline task may carry old deadline bandwidth */
+	if (new_bw == p->dl.dl_bw && task_has_dl_policy(p))
 		return 0;
 
 	/*
-- 
1.8.3.1

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] sched/deadline: Fix a bug in dl_overflow() Xunlei Pang <xlpang@redhat.com> - 2016-04-14 14:20 +0200
  Re: [PATCH] sched/deadline: Fix a bug in dl_overflow() Juri Lelli <juri.lelli@arm.com> - 2016-04-15 09:10 +0200
    Re: [PATCH] sched/deadline: Fix a bug in dl_overflow() Xunlei Pang <xpang@redhat.com> - 2016-04-15 10:20 +0200

csiph-web