From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751934AbdFHJbF (ORCPT ); Thu, 8 Jun 2017 05:31:05 -0400 Received: from terminus.zytor.com ([65.50.211.136]:50661 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751619AbdFHJbC (ORCPT ); Thu, 8 Jun 2017 05:31:02 -0400 Date: Thu, 8 Jun 2017 02:25:13 -0700 From: tip-bot for Luca Abeni Message-ID: Cc: rostedt@goodmis.org, linux-kernel@vger.kernel.org, claudio@evidence.eu.com, tglx@linutronix.de, bristot@redhat.com, juri.lelli@arm.com, mathieu.poirier@linaro.org, luca.abeni@santannapisa.it, efault@gmx.de, tommaso.cucinotta@sssup.it, mingo@kernel.org, peterz@infradead.org, joelaf@google.com, torvalds@linux-foundation.org, hpa@zytor.com Reply-To: rostedt@goodmis.org, claudio@evidence.eu.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, bristot@redhat.com, peterz@infradead.org, joelaf@google.com, mingo@kernel.org, tommaso.cucinotta@sssup.it, efault@gmx.de, luca.abeni@santannapisa.it, juri.lelli@arm.com, mathieu.poirier@linaro.org, torvalds@linux-foundation.org, hpa@zytor.com In-Reply-To: <1495138417-6203-5-git-send-email-luca.abeni@santannapisa.it> References: <1495138417-6203-5-git-send-email-luca.abeni@santannapisa.it> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/deadline: Implement GRUB accounting Git-Commit-ID: c52f14d384628db0217a7a9080ab800d5ffb2d72 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c52f14d384628db0217a7a9080ab800d5ffb2d72 Gitweb: http://git.kernel.org/tip/c52f14d384628db0217a7a9080ab800d5ffb2d72 Author: Luca Abeni AuthorDate: Thu, 18 May 2017 22:13:31 +0200 Committer: Ingo Molnar CommitDate: Thu, 8 Jun 2017 10:31:51 +0200 sched/deadline: Implement GRUB accounting According to the GRUB (Greedy Reclaimation of Unused Bandwidth) reclaiming algorithm, the runtime is not decreased as "dq = -dt", but as "dq = -Uact dt" (where Uact is the per-runqueue active utilization). Hence, this commit modifies the runtime accounting rule in update_curr_dl() to implement the GRUB rule. Tested-by: Daniel Bristot de Oliveira Signed-off-by: Luca Abeni Signed-off-by: Peter Zijlstra (Intel) Cc: Claudio Scordino Cc: Joel Fernandes Cc: Juri Lelli Cc: Linus Torvalds Cc: Mathieu Poirier Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Cc: Tommaso Cucinotta Link: http://lkml.kernel.org/r/1495138417-6203-5-git-send-email-luca.abeni@santannapisa.it Signed-off-by: Ingo Molnar --- kernel/sched/core.c | 4 ++-- kernel/sched/deadline.c | 17 +++++++++++++++++ kernel/sched/sched.h | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 126339d..b68a1fa 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2423,7 +2423,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) unsigned long to_ratio(u64 period, u64 runtime) { if (runtime == RUNTIME_INF) - return 1ULL << 20; + return BW_UNIT; /* * Doing this here saves a lot of checks in all @@ -2433,7 +2433,7 @@ unsigned long to_ratio(u64 period, u64 runtime) if (period == 0) return 0; - return div64_u64(runtime << 20, period); + return div64_u64(runtime << BW_SHIFT, period); } #ifdef CONFIG_SMP diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index add9cba..0bee537 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -918,6 +918,22 @@ int dl_runtime_exceeded(struct sched_dl_entity *dl_se) 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^BW_SHIFT, the result + * has to be shifted right by BW_SHIFT. + */ +u64 grub_reclaim(u64 delta, struct rq *rq) +{ + delta *= rq->dl.running_bw; + delta >>= BW_SHIFT; + + return delta; +} + +/* * Update the current task's runtime statistics (provided it is still * a -deadline task and has not been removed from the dl_rq). */ @@ -959,6 +975,7 @@ static void update_curr_dl(struct rq *rq) sched_rt_avg_update(rq, delta_exec); + delta_exec = grub_reclaim(delta_exec, rq); dl_se->runtime -= delta_exec; throttle: diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index c58f389..bb409ef 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1496,6 +1496,8 @@ extern void init_dl_bandwidth(struct dl_bandwidth *dl_b, u64 period, u64 runtime extern void init_dl_task_timer(struct sched_dl_entity *dl_se); extern void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se); +#define BW_SHIFT 20 +#define BW_UNIT (1 << BW_SHIFT) unsigned long to_ratio(u64 period, u64 runtime); extern void init_entity_runnable_average(struct sched_entity *se);