From patchwork Mon Sep 22 16:24:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 37690 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 BB7AF202A1 for ; Mon, 22 Sep 2014 16:24:33 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ho1sf1692524wib.0 for ; Mon, 22 Sep 2014 09:24:32 -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:content-type :content-transfer-encoding; bh=b0Ddr8CTGb2wVNXuLkMo9T2cLCA5bno5G94fhQ8xEg0=; b=aavNXyK5EoUiBfKtzLHqqsdimQZpw30q+zjXQLZQWosD77QZPMUnjoNHwlCV8J++WF SWR0Hyqe0hO62f/76ZlDZaElcet30rcdQS+DMDa93s4stO1V1vO2xJ8OEQ+ZdaFiHEUb H8JccLf59n3WrePI/U/M0YGFeSKdYBpU6px+Xy26KWHi5zO9jOw/MfuxBuitfFf/34zd 71PChlCv0DIBLzUIX0dtltyZ3e0oL8Hs84Sj5o09ui4Iy3Z1qsioaG3nwceR0pmWCC9B MMXlTuGIO0gi4+77pjjQxZxzRhA1NzdsVxqB3/1wZNOosUfNk8mYpYA7cm3IOlOjBwcc K6rg== X-Gm-Message-State: ALoCoQktAqYy938FI7BjV9UMDV+GQJ6vT6yyLsXrLkI1ufdGPT9OG89dHB/lLyKTovwv9WPO5zj5 X-Received: by 10.194.7.199 with SMTP id l7mr4295770wja.2.1411403072912; Mon, 22 Sep 2014 09:24:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.161.225 with SMTP id xv1ls543719lab.43.gmail; Mon, 22 Sep 2014 09:24:32 -0700 (PDT) X-Received: by 10.112.34.210 with SMTP id b18mr25661645lbj.62.1411403072602; Mon, 22 Sep 2014 09:24:32 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by mx.google.com with ESMTPS id x7si15046614lax.124.2014.09.22.09.24.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 09:24:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id gq15so7120262lab.11 for ; Mon, 22 Sep 2014 09:24:32 -0700 (PDT) X-Received: by 10.152.22.137 with SMTP id d9mr26873304laf.29.1411403072500; Mon, 22 Sep 2014 09:24:32 -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.130.169 with SMTP id of9csp269450lbb; Mon, 22 Sep 2014 09:24:31 -0700 (PDT) X-Received: by 10.70.130.195 with SMTP id og3mr31420831pdb.59.1411403070943; Mon, 22 Sep 2014 09:24:30 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nh4si5256648pdb.202.2014.09.22.09.24.30 for ; Mon, 22 Sep 2014 09:24:30 -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 S1754646AbaIVQYR (ORCPT + 27 others); Mon, 22 Sep 2014 12:24:17 -0400 Received: from service87.mimecast.com ([91.220.42.44]:60390 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754565AbaIVQYK (ORCPT ); Mon, 22 Sep 2014 12:24:10 -0400 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 22 Sep 2014 17:24:08 +0100 Received: from e103034-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 22 Sep 2014 17:24:07 +0100 From: Morten Rasmussen To: peterz@infradead.org, mingo@redhat.com Cc: dietmar.eggemann@arm.com, pjt@google.com, bsegall@google.com, vincent.guittot@linaro.org, nicolas.pitre@linaro.org, mturquette@linaro.org, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, Morten Rasmussen Subject: [PATCH 6/7] sched: Make sched entity usage tracking scale-invariant Date: Mon, 22 Sep 2014 17:24:06 +0100 Message-Id: <1411403047-32010-7-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1411403047-32010-1-git-send-email-morten.rasmussen@arm.com> References: <1411403047-32010-1-git-send-email-morten.rasmussen@arm.com> X-OriginalArrivalTime: 22 Sep 2014 16:24:07.0893 (UTC) FILETIME=[A24A3050:01CFD681] X-MC-Unique: 114092217240806701 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.215.52 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: , Apply scale-invariance correction factor to usage tracking as well. cc: Paul Turner cc: Ben Segall Signed-off-by: Morten Rasmussen --- kernel/sched/fair.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d8a8c83..c7aa8c1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2302,9 +2302,9 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu, int runnable, int running) { - u64 delta, periods; - u32 runnable_contrib; - int delta_w, decayed = 0; + u64 delta, scaled_delta, periods; + u32 runnable_contrib, scaled_runnable_contrib; + int delta_w, scaled_delta_w, decayed = 0; u32 scale_cap = arch_scale_load_capacity(cpu); delta = now - sa->last_runnable_update; @@ -2339,11 +2339,12 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu, */ delta_w = 1024 - delta_w; + scaled_delta_w = (delta_w * scale_cap) >> SCHED_CAPACITY_SHIFT; + if (runnable) - sa->runnable_avg_sum += (delta_w * scale_cap) - >> SCHED_CAPACITY_SHIFT; + sa->runnable_avg_sum += scaled_delta_w; if (running) - sa->usage_avg_sum += delta_w; + sa->usage_avg_sum += scaled_delta_w; sa->runnable_avg_period += delta_w; delta -= delta_w; @@ -2361,20 +2362,23 @@ static __always_inline int __update_entity_runnable_avg(u64 now, int cpu, /* Efficiently calculate \sum (1..n_period) 1024*y^i */ runnable_contrib = __compute_runnable_contrib(periods); - if (runnable) - sa->runnable_avg_sum += (runnable_contrib * scale_cap) + scaled_runnable_contrib = (runnable_contrib * scale_cap) >> SCHED_CAPACITY_SHIFT; + + if (runnable) + sa->runnable_avg_sum += scaled_runnable_contrib; if (running) - sa->usage_avg_sum += runnable_contrib; + sa->usage_avg_sum += scaled_runnable_contrib; sa->runnable_avg_period += runnable_contrib; } /* Remainder of delta accrued against u_0` */ + scaled_delta = (delta * scale_cap) >> SCHED_CAPACITY_SHIFT; + if (runnable) - sa->runnable_avg_sum += (delta * scale_cap) - >> SCHED_CAPACITY_SHIFT; + sa->runnable_avg_sum += scaled_delta; if (running) - sa->usage_avg_sum += delta; + sa->usage_avg_sum += scaled_delta; sa->runnable_avg_period += delta; return decayed;