From patchwork Mon Nov 3 16:54:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 40052 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C835C21894 for ; Mon, 3 Nov 2014 16:56:48 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id c41sf3095567eek.4 for ; Mon, 03 Nov 2014 08:56:48 -0800 (PST) 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=+S4/aIf+XPHdv1mRKQLX5woOykUL5QvDQtyrniUZPmc=; b=N1S5RYvPfJrHrSYO27LrTAJGNsQtd7ydC8643qxnGPuZsecH/sa/8W/btfv2vrxU5M Q3Qw6AbKLz6PYNhV2gyhmD9+0arcKc5qnu3HGKWDUkEO2Kuct9UnNhRhMTpag5cUevPI ZZchwNysZfr5quUvIQRUcrl2xwIf6LNSkE3dx/xAqrLfSYOtLclJHGUnS5EMCXTiZxv3 eZouw3zoJiSqN13BCe31+GOie0MusrPgdcNAdbogb1MnQ0/gqlOXz1YiJNZtDLI9Q6y9 8VRUD5o4fxKY5WMjTEL/SJjyRDb4Ga+3JvogYIiV3bkmXTqKeTYhASfxD2zjb5RrSXsH 0wlA== X-Gm-Message-State: ALoCoQk61DTFn53QtkiLmtmBEk4camtc+X3xgtjRo+knqDDU4iYON7yfF2Nfchvjjv7xMwcmEpTW X-Received: by 10.112.146.104 with SMTP id tb8mr28374lbb.22.1415033807992; Mon, 03 Nov 2014 08:56:47 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.103 with SMTP id l7ls495924laf.6.gmail; Mon, 03 Nov 2014 08:56:47 -0800 (PST) X-Received: by 10.113.5.7 with SMTP id ci7mr53274968lbd.9.1415033807420; Mon, 03 Nov 2014 08:56:47 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id wl2si21980084lbb.95.2014.11.03.08.56.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 08:56:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id b6so1659814lbj.30 for ; Mon, 03 Nov 2014 08:56:47 -0800 (PST) X-Received: by 10.152.5.38 with SMTP id p6mr51800697lap.44.1415033806984; Mon, 03 Nov 2014 08:56:46 -0800 (PST) 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.141.34 with SMTP id rl2csp20998lbb; Mon, 3 Nov 2014 08:56:45 -0800 (PST) X-Received: by 10.70.33.73 with SMTP id p9mr44207479pdi.103.1415033804524; Mon, 03 Nov 2014 08:56:44 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mr2si15757716pdb.73.2014.11.03.08.56.43 for ; Mon, 03 Nov 2014 08:56:44 -0800 (PST) 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 S1753441AbaKCQ42 (ORCPT + 25 others); Mon, 3 Nov 2014 11:56:28 -0500 Received: from mail-wi0-f175.google.com ([209.85.212.175]:47059 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753244AbaKCQ4I (ORCPT ); Mon, 3 Nov 2014 11:56:08 -0500 Received: by mail-wi0-f175.google.com with SMTP id ex7so7071386wid.8 for ; Mon, 03 Nov 2014 08:56:07 -0800 (PST) X-Received: by 10.180.9.169 with SMTP id a9mr17721364wib.7.1415033767308; Mon, 03 Nov 2014 08:56:07 -0800 (PST) Received: from lmenx30s.lme.st.com (LPuteaux-656-01-48-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPSA id s8sm22798078wjx.9.2014.11.03.08.56.05 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 08:56:06 -0800 (PST) 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-kernel@lists.infradead.org Cc: riel@redhat.com, efault@gmx.de, nicolas.pitre@linaro.org, linaro-kernel@lists.linaro.org, Vincent Guittot Subject: [PATCH v9 05/10] sched: make scale_rt invariant with frequency Date: Mon, 3 Nov 2014 17:54:42 +0100 Message-Id: <1415033687-23294-6-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415033687-23294-1-git-send-email-vincent.guittot@linaro.org> References: <1415033687-23294-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.217.171 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 a5039da..b37c27b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5785,7 +5785,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; /* @@ -5801,19 +5801,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 c34bd11..fc5b152 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1312,9 +1312,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