From patchwork Wed Jul 5 08:59:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 107051 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp567065obb; Wed, 5 Jul 2017 02:01:35 -0700 (PDT) X-Received: by 10.99.2.213 with SMTP id 204mr19735793pgc.180.1499245295884; Wed, 05 Jul 2017 02:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499245295; cv=none; d=google.com; s=arc-20160816; b=xHn94EemD2nywapSAqaTrPptifmKwZIH0PXIQyH6azZLQpB6IVzVvMsr/IEWjJ0b8V 3ZtKfMDDZ8NwfeSInLBcr0DtX3N3avnzic+1Csv/IAChNOqCPvFLl84tdnDiIKlMThRZ 4f3MBApocD0B7XWAaJZPhkB4Kg2/kAcs8wYDqjNi6h8kkx4aZDDNNrte3zxKMT0HhuL6 MMc+K+6KmzDi234g+C0Gcl4qW3gF77WJYkk3AuDahiZqsEDs+boYUtx9akitHFFW1SUa qRw+b2vHYXpKjUx5yWMTl5fBqFg6TbCveQ5rBHqtwY7wogEYvC6CJ9401p4cD8EhnMyq At4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=kCVlSW2rPJVCDpWM07iF1x3RUtTK7P46m+/AJ8O95BI=; b=lr9iw1nOW+ZhIleXmfqo0CUq3PDPlWFdmtR88TqlNEUbhOBI+3UROQfooJnEpOz2qc Aynr3FosEroNG6jed6NiXlbwMgYYclJpKnM+ihOD5RRprPY56PLXV2dA2d+iv2vThaFE 0nyvqxeizpsQTMx76Hn780uAissVjZYi3Ec0edfF3ut+lTksxUmgWhh+hQC1mbEA9sy6 FViphkqG30Wbja2N3vyGVOzmpMtahUBC0aIq8Nzvj6ZyBB7URzv6lmnXXYTjEp7V5bjm C2dJ8Jj6XZcWZ2SkEaGaNJbyvh9eCqqvoFGEiYUb8YpXTt7YDMg5rN7f9eQW2tMGmbQj yIog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q20si16413839pgn.21.2017.07.05.02.01.35; Wed, 05 Jul 2017 02:01:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752702AbdGEJBD (ORCPT + 25 others); Wed, 5 Jul 2017 05:01:03 -0400 Received: from foss.arm.com ([217.140.101.70]:53678 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752431AbdGEJBB (ORCPT ); Wed, 5 Jul 2017 05:01:01 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D06C15AD; Wed, 5 Jul 2017 02:00:42 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (e106622-lin.cambridge.arm.com [10.1.211.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C43CE3F581; Wed, 5 Jul 2017 02:00:38 -0700 (PDT) From: Juri Lelli To: peterz@infradead.org, mingo@redhat.com, rjw@rjwysocki.net, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, tglx@linutronix.de, vincent.guittot@linaro.org, rostedt@goodmis.org, luca.abeni@santannapisa.it, claudio@evidence.eu.com, tommaso.cucinotta@santannapisa.it, bristot@redhat.com, mathieu.poirier@linaro.org, tkjos@android.com, joelaf@google.com, andresoportus@google.com, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, patrick.bellasi@arm.com, juri.lelli@arm.com, Ingo Molnar , "Rafael J . Wysocki" Subject: [RFC PATCH v1 8/8] sched/deadline: make bandwidth enforcement scale-invariant Date: Wed, 5 Jul 2017 09:59:05 +0100 Message-Id: <20170705085905.6558-9-juri.lelli@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170705085905.6558-1-juri.lelli@arm.com> References: <20170705085905.6558-1-juri.lelli@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Apply frequency and cpu scale-invariance correction factor to bandwidth enforcement (similar to what we already do to fair utilization tracking). Each delta_exec gets scaled considering current frequency and maximum cpu capacity; which means that the reservation runtime parameter (that need to be specified profiling the task execution at max frequency on biggest capacity core) gets thus scaled accordingly. Signed-off-by: Juri Lelli Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Rafael J. Wysocki Cc: Viresh Kumar Cc: Luca Abeni Cc: Claudio Scordino --- kernel/sched/deadline.c | 26 ++++++++++++++++++++++---- kernel/sched/fair.c | 2 -- kernel/sched/sched.h | 2 ++ 3 files changed, 24 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 4ec82fa56b04..5bed1a2fae06 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1122,7 +1122,8 @@ static void update_curr_dl(struct rq *rq) { struct task_struct *curr = rq->curr; struct sched_dl_entity *dl_se = &curr->dl; - u64 delta_exec; + u64 delta_exec, scaled_delta_exec; + int cpu = cpu_of(rq); if (!dl_task(curr) || !on_dl_rq(dl_se)) return; @@ -1156,9 +1157,26 @@ static void update_curr_dl(struct rq *rq) if (unlikely(dl_entity_is_special(dl_se))) return; - if (unlikely(dl_se->flags & SCHED_FLAG_RECLAIM)) - delta_exec = grub_reclaim(delta_exec, rq, &curr->dl); - dl_se->runtime -= delta_exec; + /* + * For tasks that participate in GRUB, we implement GRUB-PA: the + * spare reclaimed bandwidth is used to clock down frequency. + * + * For the others, we still need to scale reservation parameters + * according to current frequency and CPU maximum capacity. + */ + if (unlikely(dl_se->flags & SCHED_FLAG_RECLAIM)) { + scaled_delta_exec = grub_reclaim(delta_exec, + rq, + &curr->dl); + } else { + unsigned long scale_freq = arch_scale_freq_capacity(cpu); + unsigned long scale_cpu = arch_scale_cpu_capacity(NULL, cpu); + + scaled_delta_exec = cap_scale(delta_exec, scale_freq); + scaled_delta_exec = cap_scale(scaled_delta_exec, scale_cpu); + } + + dl_se->runtime -= scaled_delta_exec; throttle: if (dl_runtime_exceeded(dl_se) || dl_se->dl_yielded) { diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 97bd5aae285d..a6e8a4f5786f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2844,8 +2844,6 @@ static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3) return c1 + c2 + c3; } -#define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) - /* * Accumulate the three separate parts of the sum; d1 the remainder * of the last (incomplete) period, d2 the span of full periods and d3 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 178f4a5df2fa..688185761eaf 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -155,6 +155,8 @@ static inline int task_has_dl_policy(struct task_struct *p) return dl_policy(p->policy); } +#define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) + /* * !! For sched_setattr_nocheck() (kernel) only !! *