From patchwork Mon Sep 22 16:24:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 37695 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C84D7202A1 for ; Mon, 22 Sep 2014 16:25:41 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id b57sf2073556eek.6 for ; Mon, 22 Sep 2014 09:25:41 -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=1VyZbay0VOOKfet7KKrxCAoN4ba6ABCaTA3QVA40eA4=; b=UgTI6SCVwWD+4Y2fwDrKo/XEGshATHVZllNVtHgDmgI5twU+VTtmBWpHRC7s4EzuPb jUT5cz+PmQOA1iga8Rj4ni57tWWUa/1C+Hyjkd1Q//NIjjjgjCZI4cpHIGzYa2SmrfiQ wqhv+jFQyLxBD2KdcJJL4/9WKvLfAi4klLl8P4Pp5yk+59MrMY+p8WPJb9aHia+t6aiG +FhAC19HQtKCpxDDPxfNToG4QocnnCsaA26MfiOGLS1+S+q7xIQAhrCas/rmjujCW7q3 QW4bOutJLddkk/f5pFC/tNOCrpg5o0XgoMh0Unv1ai5coSNar7etfMYlf9bEFaLsEbPE Vkdg== X-Gm-Message-State: ALoCoQlQVtOIMKNmmCV5NV7enWnQDiZRGBwrsEauDIfdI9Obn4UzVzdzTR6SvsM/TbSoD+nKn2O3 X-Received: by 10.152.6.9 with SMTP id w9mr594651law.7.1411403140941; Mon, 22 Sep 2014 09:25:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.137 with SMTP id y9ls538158laj.93.gmail; Mon, 22 Sep 2014 09:25:40 -0700 (PDT) X-Received: by 10.112.200.134 with SMTP id js6mr25268641lbc.0.1411403140710; Mon, 22 Sep 2014 09:25:40 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) by mx.google.com with ESMTPS id tm3si9935214lbb.111.2014.09.22.09.25.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 09:25:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id ty20so7204423lab.9 for ; Mon, 22 Sep 2014 09:25:40 -0700 (PDT) X-Received: by 10.152.42.136 with SMTP id o8mr4337891lal.71.1411403140649; Mon, 22 Sep 2014 09:25:40 -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 of9csp269680lbb; Mon, 22 Sep 2014 09:25:39 -0700 (PDT) X-Received: by 10.68.136.2 with SMTP id pw2mr26392731pbb.39.1411403138758; Mon, 22 Sep 2014 09:25:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rb5si16356186pab.183.2014.09.22.09.25.38 for ; Mon, 22 Sep 2014 09:25:38 -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 S1754659AbaIVQZf (ORCPT + 27 others); Mon, 22 Sep 2014 12:25:35 -0400 Received: from service87.mimecast.com ([91.220.42.44]:60287 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754538AbaIVQYI (ORCPT ); Mon, 22 Sep 2014 12:24:08 -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:06 +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:05 +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 3/7] arm: Frequency invariant scheduler load-tracking support Date: Mon, 22 Sep 2014 17:24:03 +0100 Message-Id: <1411403047-32010-4-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:05.0924 (UTC) FILETIME=[A11DBE40:01CFD681] X-MC-Unique: 114092217240600201 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.50 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: , Implements arch-specific function to provide the scheduler with a frequency scaling correction factor for more accurate load-tracking. The factor is: current_freq(cpu) * SCHED_CAPACITY_SCALE / max_freq(cpu) This implementation only provides frequency invariance. No micro-architecture invariance yet. Signed-off-by: Morten Rasmussen --- arch/arm/kernel/topology.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 89cfdd6..3e9a979 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -169,6 +169,39 @@ static void update_cpu_capacity(unsigned int cpu) cpu, arch_scale_cpu_capacity(NULL, cpu)); } +/* + * Scheduler load-tracking scale-invariance + * + * Provides the scheduler with a scale-invariance correction factor that + * compensates for frequency scaling. + */ + +static DEFINE_PER_CPU(atomic_long_t, cpu_curr_freq); +static DEFINE_PER_CPU(atomic_long_t, cpu_max_freq); + +/* cpufreq callback function setting current cpu frequency */ +void arch_scale_set_curr_freq(int cpu, unsigned long freq) +{ + atomic_long_set(&per_cpu(cpu_curr_freq, cpu), freq); +} + +/* cpufreq callback function setting max cpu frequency */ +void arch_scale_set_max_freq(int cpu, unsigned long freq) +{ + atomic_long_set(&per_cpu(cpu_max_freq, cpu), freq); +} + +unsigned long arch_scale_load_capacity(int cpu) +{ + unsigned long curr = atomic_long_read(&per_cpu(cpu_curr_freq, cpu)); + unsigned long max = atomic_long_read(&per_cpu(cpu_max_freq, cpu)); + + if (!max) + return SCHED_CAPACITY_SCALE; + + return (curr * SCHED_CAPACITY_SCALE) / max; +} + #else static inline void parse_dt_topology(void) {} static inline void update_cpu_capacity(unsigned int cpuid) {}