From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752575AbdB1QLh (ORCPT ); Tue, 28 Feb 2017 11:11:37 -0500 Received: from mail.kernel.org ([198.145.29.136]:35588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726AbdB1QLc (ORCPT ); Tue, 28 Feb 2017 11:11:32 -0500 Date: Tue, 28 Feb 2017 11:04:53 -0500 From: Steven Rostedt To: Daniel Bristot de Oliveira Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Tommaso Cucinotta , Luca Abeni , Mike Galbraith , Romulo Silva de Oliveira Subject: Re: [PATCH V3 2/3] sched/deadline: Throttle a constrained deadline task activated after the deadline Message-ID: <20170228110453.2694a2f6@gandalf.local.home> In-Reply-To: <5b6fa3cd9da84b8883afc169f44df247b551a4df.1488271007.git.bristot@redhat.com> References: <5b6fa3cd9da84b8883afc169f44df247b551a4df.1488271007.git.bristot@redhat.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Feb 2017 11:07:54 +0100 Daniel Bristot de Oliveira wrote: > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index 3c94d85..3a88def 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -694,6 +694,37 @@ void init_dl_task_timer(struct sched_dl_entity *dl_se) > timer->function = dl_task_timer; > } > > +/* > + * During the activation, CBS checks if it can reuse the current task's > + * runtime and period. If the deadline of the task is in the past, CBS > + * cannot use the runtime, and so it replenishes the task. This rule > + * works fine for implicit deadline tasks (deadline == period), and the > + * CBS was designed for implicit deadline tasks. However, a task with > + * constrained deadline (deadine < period) might be awakened after the > + * deadline, but before the next period. In this case, replenishing the > + * task would allow it to run for runtime / deadline. As in this case > + * deadline < period, CBS enables a task to run for more than the > + * runtime / period. In a very load system, this can cause the domino In a very loaded system, this can cause a domino > + * effect, making other tasks to miss their deadlines. effect, making other tasks miss their deadlines. > + * > + * To avoid this problem, in the activation of a constrained deadline > + * task after the deadline but before the next period, throttle the > + * task and set the replenishing timer to the begin of the next period, to the beginning of the next > + * unless it is boosted. > + */ > +static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se) > +{ > + struct task_struct *p = dl_task_of(dl_se); > + struct rq *rq = rq_of_dl_rq(dl_rq_of_se(dl_se)); > + > + if (dl_time_before(dl_se->deadline, rq_clock(rq)) && > + dl_time_before(rq_clock(rq), dl_next_period(dl_se))) { > + if (unlikely(dl_se->dl_boosted || !start_dl_timer(p))) > + return; > + dl_se->dl_throttled = 1; > + } > +} > + > static > int dl_runtime_exceeded(struct sched_dl_entity *dl_se) > { > @@ -927,6 +958,11 @@ static void dequeue_dl_entity(struct sched_dl_entity *dl_se) > __dequeue_dl_entity(dl_se); > } > > +static inline bool dl_is_constrained(struct sched_dl_entity *dl_se) > +{ > + return dl_se->dl_deadline < dl_se->dl_period; > +} > + > static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags) > { > struct task_struct *pi_task = rt_mutex_get_top_task(p); > @@ -953,6 +989,15 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags) > } > > /* > + * Check if a constrained deadline task was activated > + * after the deadline but before the next period. > + * If that is the case, the task will be throttled and > + * the replenishment timer will be set to the next period. > + */ > + if (!pi_se->dl_throttled && dl_is_constrained(pi_se)) > + dl_check_constrained_dl(pi_se); > + > + /* > * If p is throttled, we do nothing. In fact, if it exhausted > * its budget it needs a replenishment and, since it now is on > * its rq, the bandwidth timer callback (which clearly has not Except for the grammar mistakes... Reviewed-by: Steven Rostedt (VMware) -- Steve