Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932565AbdCWTyo (ORCPT ); Thu, 23 Mar 2017 15:54:44 -0400 Received: from mail.santannapisa.it ([193.205.80.99]:26882 "EHLO mail.santannapisa.it" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755686AbdCWTxK (ORCPT ); Thu, 23 Mar 2017 15:53:10 -0400 From: luca abeni To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Juri Lelli , Claudio Scordino , Steven Rostedt , Tommaso Cucinotta , Daniel Bristot de Oliveira , Joel Fernandes , Mathieu Poirier , Luca Abeni Subject: [RFC v5 8/9] sched/deadline: base GRUB reclaiming on the inactive utilization Date: Fri, 24 Mar 2017 04:53:01 +0100 Message-Id: <1490327582-4376-9-git-send-email-luca.abeni@santannapisa.it> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490327582-4376-1-git-send-email-luca.abeni@santannapisa.it> References: <1490327582-4376-1-git-send-email-luca.abeni@santannapisa.it> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2345 Lines: 62 From: Luca Abeni Instead of decreasing the runtime as "dq = -Uact dt" (eventually divided by the maximum utilization available for deadline tasks), decrease it as "dq = -(1 - Uinact) dt", where Uinact is the "inactive utilization". In this way, the maximum fraction of CPU time that can be reclaimed is given by the total utilization of deadline tasks. This approach solves some fairness issues that have been noticed with "traditional" global GRUB reclaiming. Signed-off-by: Luca Abeni Tested-by: Daniel Bristot de Oliveira --- kernel/sched/deadline.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index d70a7b9..c393c3d 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -900,14 +900,23 @@ extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq); /* * This function implements the GRUB accounting rule: * according to the GRUB reclaiming algorithm, the runtime is - * not decreased as "dq = -dt", but as "dq = -Uact dt", where - * Uact is the (per-runqueue) active utilization. - * Since rq->dl.running_bw contains Uact * 2^20, the result - * has to be shifted right by 20. + * not decreased as "dq = -dt", but as "dq = (1 - Uinact) dt", where + * Uinact is the (per-runqueue) inactive utilization, computed as the + * difference between the "total runqueue utilization" and the runqueue + * active utilization. + * Since rq->dl.running_bw and rq->dl.this_bw contain utilizations + * multiplied by 2^20, the result has to be shifted right by 20. */ -u64 grub_reclaim(u64 delta, struct rq *rq) +u64 grub_reclaim(u64 delta, struct rq *rq, u64 u) { - return (delta * rq->dl.running_bw * rq->dl.deadline_bw_inv) >> 20 >> 8; + u64 u_act; + + if (rq->dl.this_bw - rq->dl.running_bw > (1 << 20) - u) + u_act = u; + else + u_act = (1 << 20) - rq->dl.this_bw + rq->dl.running_bw; + + return (delta * u_act) >> 20; } /* @@ -953,7 +962,7 @@ static void update_curr_dl(struct rq *rq) sched_rt_avg_update(rq, delta_exec); if (unlikely(dl_se->flags & SCHED_FLAG_RECLAIM)) - delta_exec = grub_reclaim(delta_exec, rq); + delta_exec = grub_reclaim(delta_exec, rq, curr->dl.dl_bw); dl_se->runtime -= delta_exec; throttle: -- 2.7.4