From patchwork Tue May 23 08:53:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 100360 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp217526qge; Tue, 23 May 2017 01:55:28 -0700 (PDT) X-Received: by 10.99.160.68 with SMTP id u4mr30816732pgn.39.1495529728724; Tue, 23 May 2017 01:55:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495529728; cv=none; d=google.com; s=arc-20160816; b=GZoRzNMkROF9Bp+2Vu8Bn22VaVOI6vQILgIz5npBx1Hfw+idoGDJWAl4mF8sg14BgW bBGcRN/MDFwwh+QJfsXGBj/nTu/KylMPRY6OFjekYoUwX2j30U8ltzBCgoPPOlPk8hsJ XT6Qxo2DLb/5ZKHPLEECGt8Q1sTR0+7zNva4MSF7XSfck4FImxMNR544FwvOyhe8DvJs qBwjV/GTikQv/YRwOeNXNS6owN5yktbTqkcA9jUb/Ixehd2pwv9i6MgZJrOv5/Ij3Sd0 Ai2XmyG192JAvQOOXNYBK+Ywb5zq67Ghlu4tD4KIgYEHQDqx90Z7/7IyNyvJEMjIo1yk QofA== 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=IwWvXwAz4GeY8KHi5XwyilF1+2dVeZIhy4wJjnt1IkE=; b=mjoVZuDb68L2yi+NQC8AlygnEur6SiQgNVpTIvWzNfNmBW79RMCxfLNVWVrO+dD1Br VgJX9APsSranoG2BoEUMsnonn89WO9fqb/eNLJCZXkeOFZJwoIGOuS1oewEltxIylhbf H25e3UOkUL1pk9h43NxuiLsu9D+P+lFPwfjQo+C9SC/4k4QyTTZgPLor7uzGT8ZNNGbm fRkrCLXwDylH4xPf5YlbuPlo/QqPUJjCvOHJawITL9H/eajnHQPTgZN6pxacihbF7XyM g5tKUOxoymtaBJwQVm2X+2Y381ooJfQFNErrYaO/Q1VOpw8TzPCqsi8Z6gbF/unqt7q+ vffw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 h83si20224967pfk.207.2017.05.23.01.55.28; Tue, 23 May 2017 01:55:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936761AbdEWIzK (ORCPT + 14 others); Tue, 23 May 2017 04:55:10 -0400 Received: from foss.arm.com ([217.140.101.70]:48262 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936737AbdEWIzD (ORCPT ); Tue, 23 May 2017 04:55:03 -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 DAEBF15A1; Tue, 23 May 2017 01:54:57 -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 430853F53D; Tue, 23 May 2017 01:54:54 -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: [PATCH RFC 8/8] sched/deadline: make bandwidth enforcement scale-invariant Date: Tue, 23 May 2017 09:53:51 +0100 Message-Id: <20170523085351.18586-9-juri.lelli@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170523085351.18586-1-juri.lelli@arm.com> References: <20170523085351.18586-1-juri.lelli@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 --- Changes from RFD - either apply grub_reclaim or perform freq/cpu scaling; what's the correct thing to do it's actually very much up for discussion --- 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 5ee4fd9b1c7f..b6c3886478c3 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1008,7 +1008,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; @@ -1042,9 +1043,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 b0f31064bbbd..39224813e038 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2781,8 +2781,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 cc474c62cd18..019c46768ecb 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) + static inline int dl_entity_is_special(struct sched_dl_entity *dl_se) { return dl_se->flags & SCHED_FLAG_SPECIAL;