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: 5203351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3169CC11AC for ; Fri, 31 Oct 2014 08:53:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48981200FF for ; Fri, 31 Oct 2014 08:53:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E1E72015D for ; Fri, 31 Oct 2014 08:53:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xk7vl-0006eo-0J; Fri, 31 Oct 2014 08:51:37 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xk7t2-0003MN-7g for linux-arm-kernel@bombadil.infradead.org; Fri, 31 Oct 2014 08:48:48 +0000 Received: from mail-wi0-f171.google.com ([209.85.212.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xk7t0-0008V0-Dp for linux-arm-kernel@lists.infradead.org; Fri, 31 Oct 2014 08:48:47 +0000 Received: by mail-wi0-f171.google.com with SMTP id q5so654219wiv.16 for ; Fri, 31 Oct 2014 01:48:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ztVZQU+E0gnCdJRDI0l1ffwzXwAjemJXL+nDxYFWOP4=; b=ejOOnvYTBroBqM9qTzH2yyBxT1VgTmjVAMSod6jaBa9TFL37XL4yDyj9QKdLv5FB7v YSQb2V3VqPbyjYRjupVVBYAS2DVDH21gwKI7y7TXkRVanUih4WB+OTvD9zxkZk5M6Ilo Oxkg50d4JSxkwIMqLK0pQDlelwFYQkRSpBKmDZ2YfPOFA5k3kF8548fwtArO2f6WYiM4 Qxlshy+D0vzhJvryW/j6GG2jd6bK4XednnTOxPTFZmV5T/wezAEfNwJCs6fgAI8JKTyh /IdsWkgKULaHlwXDPy0FavsBMsQBd+TGwJ++7mI4quaa7CboqnX4qntZO4v6CRYIu7gy ha8g== X-Gm-Message-State: ALoCoQlE0ejlk92/1Lr/YC4aICXhRAJtAkSKk+ERGTABcVLMpY9Y8AgMSRzrpISszCKMHGm8kjCb 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141031_044846_568277_58B2EF7E X-CRM114-Status: GOOD ( 13.92 ) X-Spam-Score: -2.6 (--) Cc: nicolas.pitre@linaro.org, riel@redhat.com, efault@gmx.de, Vincent Guittot , linaro-kernel@lists.linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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