From patchwork Thu Jan 15 10:09:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 43162 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1C26C240BA for ; Thu, 15 Jan 2015 10:16:57 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id a1sf7401194wgh.3 for ; Thu, 15 Jan 2015 02:16:56 -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=TD6zOcKtDfGdwhJZOHqT2kqso5vtTlBQ9yaJtoLyoufk647KVSh+KQuAODA5HZiqVK YsHQfKz5eM+xkseSx057zDTri2AGtDsjg9pBoNjFEIYmLo53+pgp+SgdsuTMbo2ZI4Et P1lUPgG9sLAYG9HnbNPnuSl9N+1WQs20djoPC58tPwFGS+pkrZmlIYXCdmqcFMqxW9By ZZj5D/jWwdwStyHAZLOWanxDCtJdyWivw0iPZ06QaS3q5+Qes4b1KhViTD0aY0C6aGEJ 3Pl4g/mjQNasjPUTmCqnPOdDwfc7UCWt6jIbRN86gr/QxG9lv5nL6kr7U3tw6e4dC7yw iqag== X-Gm-Message-State: ALoCoQmm2A6mPhez3j/UU7ZzRSwlKYhvL6WcPJN+Lp5n0+oFOJk352yV+0OS3k/RlpIEWwhzcpet X-Received: by 10.180.208.46 with SMTP id mb14mr1258837wic.4.1421317016219; Thu, 15 Jan 2015 02:16:56 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.202 with SMTP id u10ls164383lau.68.gmail; Thu, 15 Jan 2015 02:16:56 -0800 (PST) X-Received: by 10.152.207.37 with SMTP id lt5mr8819206lac.66.1421317016034; Thu, 15 Jan 2015 02:16:56 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id v3si956909lal.96.2015.01.15.02.16.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 02:16:55 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id hv19so12742088lab.0 for ; Thu, 15 Jan 2015 02:16:55 -0800 (PST) X-Received: by 10.152.23.38 with SMTP id j6mr8815242laf.81.1421317015907; Thu, 15 Jan 2015 02:16:55 -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.9.200 with SMTP id c8csp1982305lbb; Thu, 15 Jan 2015 02:16:55 -0800 (PST) X-Received: by 10.68.241.35 with SMTP id wf3mr13375941pbc.22.1421317014111; Thu, 15 Jan 2015 02:16:54 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ek16si1193816pac.200.2015.01.15.02.16.52; Thu, 15 Jan 2015 02:16:54 -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 S1752992AbbAOKMn (ORCPT + 28 others); Thu, 15 Jan 2015 05:12:43 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:64427 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752766AbbAOKMj (ORCPT ); Thu, 15 Jan 2015 05:12:39 -0500 Received: by mail-wi0-f169.google.com with SMTP id n3so2816650wiv.0 for ; Thu, 15 Jan 2015 02:12:38 -0800 (PST) X-Received: by 10.180.74.146 with SMTP id t18mr57880610wiv.62.1421316758781; Thu, 15 Jan 2015 02:12:38 -0800 (PST) Received: from lmenx30s.lme.st.com (LPuteaux-656-1-48-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPSA id fi10sm15113674wib.13.2015.01.15.02.12.35 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 02:12:37 -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 Cc: riel@redhat.com, efault@gmx.de, nicolas.pitre@linaro.org, dietmar.eggemann@arm.com, linaro-kernel@lists.linaro.org, Vincent Guittot Subject: [PATCH RESEND v9 05/10] sched: make scale_rt invariant with frequency Date: Thu, 15 Jan 2015 11:09:25 +0100 Message-Id: <1421316570-23097-6-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421316570-23097-1-git-send-email-vincent.guittot@linaro.org> References: <1421316570-23097-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.41 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