From patchwork Wed Feb 4 18:30:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 44384 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 263EF21173 for ; Wed, 4 Feb 2015 18:44:59 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id u56sf2489642wes.2 for ; Wed, 04 Feb 2015 10:44:58 -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=4+Db/gx1VTAXAahXOH4P0NJ1aGbSbxq5Yf3FM9o+j3I=; b=VQnSAbdBdAoqD2Lop8jp7XH5nbyIePPtljY2SojWH/jMfdWRj7BdLv118YOlqyTdRA /cpogWEZItUMk7I1us0QeNkMZhxf+fp1igwhDCRnqQmCJrz7i2EMc/wkTfZOitzsVJ+M CgKV8kgWZF+Jy0BdQfLZbGgwV6C3+Uze/RSghT4LhPP1rUs5t0L3Lsi5v2x8FAbFmZ70 C473st2Nkcehn86bp+yFHKRIgVC6aqlGabB9jw3v+IqjGEpwUlumLBOoaKX+Np2Ckc1L iUzboWeEtZvwy+3m2hFkiwO7qtZ9WTCKDafC0nKLA8IZTJiEYEbnv7huRPg4gTuBfPz/ s6pQ== X-Gm-Message-State: ALoCoQk1Ebz5uRXQr0cQKU4FZ5G9YG9yPK25f++K1PuaoByxPNS3B2B5WYdyKTZFFjKVUvFlol9a X-Received: by 10.152.26.74 with SMTP id j10mr4083689lag.10.1423075498409; Wed, 04 Feb 2015 10:44:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.197 with SMTP id g5ls75307lam.99.gmail; Wed, 04 Feb 2015 10:44:58 -0800 (PST) X-Received: by 10.112.199.39 with SMTP id jh7mr32674259lbc.46.1423075498192; Wed, 04 Feb 2015 10:44:58 -0800 (PST) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id t1si2079353lag.91.2015.02.04.10.44.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Feb 2015 10:44:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id p9so3140808lbv.4 for ; Wed, 04 Feb 2015 10:44:58 -0800 (PST) X-Received: by 10.112.180.135 with SMTP id do7mr32001732lbc.23.1423075498045; Wed, 04 Feb 2015 10:44:58 -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.35.133 with SMTP id h5csp671452lbj; Wed, 4 Feb 2015 10:44:57 -0800 (PST) X-Received: by 10.70.37.4 with SMTP id u4mr48682617pdj.40.1423075492622; Wed, 04 Feb 2015 10:44:52 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ak2si3038446pad.207.2015.02.04.10.44.51; Wed, 04 Feb 2015 10:44:52 -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 S1161387AbbBDSot (ORCPT + 29 others); Wed, 4 Feb 2015 13:44:49 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:41486 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933897AbbBDSar (ORCPT ); Wed, 4 Feb 2015 13:30:47 -0500 Received: from foss-smtp-na-1.foss.arm.com (unknown [10.80.61.8]) by foss-mx-na.foss.arm.com (Postfix) with ESMTP id 918E1515; Wed, 4 Feb 2015 12:30:42 -0600 (CST) Received: from collaborate-mta1.arm.com (highbank-bc01-b06.austin.arm.com [10.112.81.134]) by foss-smtp-na-1.foss.arm.com (Postfix) with ESMTP id 7C4855FAC1; Wed, 4 Feb 2015 12:30:40 -0600 (CST) Received: from e105550-lin.cambridge.arm.com (e105550-lin.cambridge.arm.com [10.2.131.193]) by collaborate-mta1.arm.com (Postfix) with ESMTP id E254F13F6EE; Wed, 4 Feb 2015 12:30:38 -0600 (CST) From: Morten Rasmussen To: peterz@infradead.org, mingo@redhat.com Cc: vincent.guittot@linaro.org, dietmar.eggemann@arm.com, yuyang.du@intel.com, preeti@linux.vnet.ibm.com, mturquette@linaro.org, nico@linaro.org, rjw@rjwysocki.net, juri.lelli@arm.com, linux-kernel@vger.kernel.org Subject: [RFCv3 PATCH 05/48] sched: make scale_rt invariant with frequency Date: Wed, 4 Feb 2015 18:30:42 +0000 Message-Id: <1423074685-6336-6-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423074685-6336-1-git-send-email-morten.rasmussen@arm.com> References: <1423074685-6336-1-git-send-email-morten.rasmussen@arm.com> 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: morten.rasmussen@arm.com 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.173 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: , From: Vincent Guittot 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 Acked-by: Morten Rasmussen --- 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 b6fb7c4..cfe3aea 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5992,7 +5992,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; /* @@ -6008,19 +6008,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 17a3b6b..e61f00e 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1356,9 +1356,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