From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751169AbdBWKMe (ORCPT ); Thu, 23 Feb 2017 05:12:34 -0500 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:60804 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952AbdBWKMd (ORCPT ); Thu, 23 Feb 2017 05:12:33 -0500 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 165.244.249.26 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Thu, 23 Feb 2017 19:11:23 +0900 From: Byungchul Park To: , CC: , , , Subject: Re: [PATCH v3] sched/deadline: Change the time to replenish runtime for sleep tasks Message-ID: <20170223101123.GE3817@X58A-UD3R> References: <1487830499-1691-1-git-send-email-byungchul.park@lge.com> MIME-Version: 1.0 In-Reply-To: <1487830499-1691-1-git-send-email-byungchul.park@lge.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB05/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/02/23 19:11:28, Serialize by Router on LGEKRMHUB05/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/02/23 19:11:28, Serialize complete at 2017/02/23 19:11:28 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 23, 2017 at 03:14:59PM +0900, Byungchul Park wrote: > Let's consider the following example. > > timeline : o...................o.........o.......o..o > ^ ^ ^ ^ ^ > | | | | | > start | | | | > original runtime | | | > sleep with (-)runtime | | > original deadline | > wake up > > When this task is woken up, a negative runtime should be considered, > which means that the task should get penalized when assigning runtime, > becasue it already spent more than expected. Current code handles this > by replenishing a runtime in hrtimer callback for deadline. But this > approach has room for improvement: > > It will be replenished twice unnecessarily if the task sleeps for > long time so that the deadline, assigned in the hrtimer callback, > also passed. In other words, one happens in the callback and the > other happens in update_dl_entiry() when waking it up. > > So force to replenish it for sleep tasks when waking it up. To be honest, I think this patch is more valuable when used with removing unnecessary hrtimer interrupt for deadline control, but not that much without it. I just wonder what you think. > > Signed-off-by: Byungchul Park > --- > kernel/sched/deadline.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index 27737f3..cb43ce9 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -498,8 +498,9 @@ static void update_dl_entity(struct sched_dl_entity *dl_se, > struct dl_rq *dl_rq = dl_rq_of_se(dl_se); > struct rq *rq = rq_of_dl_rq(dl_rq); > > - if (dl_time_before(dl_se->deadline, rq_clock(rq)) || > - dl_entity_overflow(dl_se, pi_se, rq_clock(rq))) { > + if (dl_time_before(dl_se->deadline, rq_clock(rq))) > + replenish_dl_entity(dl_se, pi_se); > + else if (dl_entity_overflow(dl_se, pi_se, rq_clock(rq))) { > dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline; > dl_se->runtime = pi_se->dl_runtime; > } > @@ -621,13 +622,11 @@ static enum hrtimer_restart dl_task_timer(struct hrtimer *timer) > * __dequeue_task_dl() > * prev->on_rq = 0; > * > - * We can be both throttled and !queued. Replenish the counter > - * but do not enqueue -- wait for our wakeup to do that. > + * We can be both throttled and !queued. Wait for our wakeup to > + * replenish runtime and enqueue p. > */ > - if (!task_on_rq_queued(p)) { > - replenish_dl_entity(dl_se, dl_se); > + if (!task_on_rq_queued(p)) > goto unlock; > - } > > #ifdef CONFIG_SMP > if (unlikely(!rq->online)) { > -- > 1.9.1