From patchwork Fri Oct 31 08:47:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 39869 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77685202FE for ; Fri, 31 Oct 2014 08:49:37 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ex7sf321378wid.4 for ; Fri, 31 Oct 2014 01:49:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=gXosCQVZ/T3BaTFu4KtgorML1h3No3PRgB3gjjs42Io=; b=KJXJHnfj3O1V2BpIJBvYHKF4RRaK80s+ngDToKzb90Sjr2n4597kXFlcMLUKljJPHT FrCMgnIqg90DgfW5rGediPmnyXajGKWZCAnkoTrovoeXUsChQ8sCL/71Hbc5nPpi98wr 2dsSWGY2us/lpDjlya1XIj659ocJoqGCqof33XCtANYFV8bnr9ExpRT32n7GxNL8Cpzi Xaw5GCq9gJ1XQ4/+rkQc1FojkjebdoMG05Ji4v8LGRi+hXIsRWajBliBWfcRsfWsRQfy OFDzB1HjSMjlD96kdhPr1nFHaakLjJRh+cpD/R8rrb9HYkY0PP4oKpEB2IS2OW/u4q8V CPDQ== X-Gm-Message-State: ALoCoQn8sKjIhRkBe5CthCxMaGE43TVOaMkGXXTSj9eFF6oYR8S+M5z3F2uT+S7dLbKgcKoBTD8R X-Received: by 10.112.166.2 with SMTP id zc2mr14419lbb.24.1414745376651; Fri, 31 Oct 2014 01:49:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.200 with SMTP id y8ls444917lal.93.gmail; Fri, 31 Oct 2014 01:49:36 -0700 (PDT) X-Received: by 10.152.20.72 with SMTP id l8mr24808505lae.43.1414745376484; Fri, 31 Oct 2014 01:49:36 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id js17si15658576lab.24.2014.10.31.01.49.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 01:49:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id mc6so5888861lab.12 for ; Fri, 31 Oct 2014 01:49:36 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr24350972lbc.23.1414745376406; Fri, 31 Oct 2014 01:49:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp168173lbz; Fri, 31 Oct 2014 01:49:35 -0700 (PDT) X-Received: by 10.70.131.66 with SMTP id ok2mr23331823pdb.33.1414745374770; Fri, 31 Oct 2014 01:49:34 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ui1si8812754pbc.4.2014.10.31.01.49.34 for ; Fri, 31 Oct 2014 01:49:34 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757417AbaJaItF (ORCPT + 26 others); Fri, 31 Oct 2014 04:49:05 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:43322 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757262AbaJaIsV (ORCPT ); Fri, 31 Oct 2014 04:48:21 -0400 Received: by mail-wi0-f178.google.com with SMTP id q5so662651wiv.11 for ; Fri, 31 Oct 2014 01:48:20 -0700 (PDT) X-Received: by 10.194.23.104 with SMTP id l8mr25417911wjf.26.1414745300257; Fri, 31 Oct 2014 01:48:20 -0700 (PDT) Received: from lmenx30s.st.com. (pas72-3-88-189-71-117.fbx.proxad.net. [88.189.71.117]) by mx.google.com with ESMTPSA id u5sm11636547wiz.9.2014.10.31.01.48.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 01:48:19 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, preeti@linux.vnet.ibm.com, Morten.Rasmussen@arm.com, kamalesh@linux.vnet.ibm.com, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org Cc: riel@redhat.com, efault@gmx.de, nicolas.pitre@linaro.org, linaro-kernel@lists.linaro.org, Vincent Guittot Subject: [PATCH v8 10/10] sched: make scale_rt invariant with frequency Date: Fri, 31 Oct 2014 09:47:32 +0100 Message-Id: <1414745252-4895-11-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414745252-4895-1-git-send-email-vincent.guittot@linaro.org> References: <1414745252-4895-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vincent.guittot@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The average running time of RT tasks is used to estimate the remaining compute capacity for CFS tasks. This remaining capacity is the original capacity scaled down by a factor (aka scale_rt_capacity). This estimation of available capacity must also be invariant with frequency scaling. A frequency scaling factor is applied on the running time of the RT tasks for computing scale_rt_capacity. In sched_rt_avg_update, we scale the RT execution time like below: rq->rt_avg += rt_delta * arch_scale_freq_capacity() >> SCHED_CAPACITY_SHIFT Then, scale_rt_capacity can be summarized by: scale_rt_capacity = SCHED_CAPACITY_SCALE - ((rq->rt_avg << SCHED_CAPACITY_SHIFT) / period) We can optimize by removing right and left shift in the computation of rq->rt_avg and scale_rt_capacity The call to arch_scale_frequency_capacity in the rt scheduling path might be a concern for RT folks because I'm not sure whether we can rely on arch_scale_freq_capacity to be short and efficient ? Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 17 +++++------------ kernel/sched/sched.h | 4 +++- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 31c3ec2..02e8f7f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5817,7 +5817,7 @@ unsigned long __weak arch_scale_cpu_capacity(struct sched_domain *sd, int cpu) static unsigned long scale_rt_capacity(int cpu) { struct rq *rq = cpu_rq(cpu); - u64 total, available, age_stamp, avg; + u64 total, used, age_stamp, avg; s64 delta; /* @@ -5833,19 +5833,12 @@ static unsigned long scale_rt_capacity(int cpu) total = sched_avg_period() + delta; - if (unlikely(total < avg)) { - /* Ensures that capacity won't end up being negative */ - available = 0; - } else { - available = total - avg; - } + used = div_u64(avg, total); - if (unlikely((s64)total < SCHED_CAPACITY_SCALE)) - total = SCHED_CAPACITY_SCALE; + if (likely(used < SCHED_CAPACITY_SCALE)) + return SCHED_CAPACITY_SCALE - used; - total >>= SCHED_CAPACITY_SHIFT; - - return div_u64(available, total); + return 1; } static void update_cpu_capacity(struct sched_domain *sd, int cpu) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 7963981..8fd30c1 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1313,9 +1313,11 @@ static inline int hrtick_enabled(struct rq *rq) #ifdef CONFIG_SMP extern void sched_avg_update(struct rq *rq); +extern unsigned long arch_scale_freq_capacity(struct sched_domain *sd, int cpu); + static inline void sched_rt_avg_update(struct rq *rq, u64 rt_delta) { - rq->rt_avg += rt_delta; + rq->rt_avg += rt_delta * arch_scale_freq_capacity(NULL, cpu_of(rq)); sched_avg_update(rq); } #else