From patchwork Fri Aug 25 14:32:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 111027 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp1047241ybm; Fri, 25 Aug 2017 07:34:14 -0700 (PDT) X-Received: by 10.98.217.210 with SMTP id b79mr9651875pfl.110.1503671653905; Fri, 25 Aug 2017 07:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503671653; cv=none; d=google.com; s=arc-20160816; b=byOlhvQIfFaOinfN4RzSRBa48jNwd+GqNfyIc+SALY5OZizT8Epqu688LD05SwLmjk n9iKeWbaMdMyF6qeDypftsu1cQWq3YxSVIMLemNNUiCYPkc/yNTk3IY9u3gpQZ+m+rES +/+sn1trSlAREK6Z3bgrbvaUL0Atr6GyWTpmH9LrLakF3MpKw8wNetPb2ICaDsQ4cG5l ff177aueRuaqYHG2gxSLBrgyqGEpuLO7y0ljA7Q989cHErd//7oHVfCk58qxBi8TqUER kD+ySG9lWKnRpTjnzgpEIaV86FQvl0mAznJefcp0+i6ao0ZnsbNaXTC9bw/s+2A+yC7i VzmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=UQ3+aAZRm6PDo7U45jQBSwfDinVXgAhyc7tC3AXeMS0=; b=Sr+H4x36/EHty5j7QibJ0EXVEwnryGLHsgGxGqdKjKqjlpOsgqR0o3sbktvP42pKTH 6qVc9X9bf4ySaFqaFIIbIoFrXp5vU1HXq93blGVJAMSTsE57Mvp9POSxgyaCrYA/49pH LfHYH7VvhLkGHBZx0r6iUGrQO17UEA+V3me23oL1HuloxTF5iR6mcUGPIWOxIQDFDare N02w3sswWY8DV1p+f8KaprR4K7czMR4RbewSZOuKukM7t/jPvM9gYKkpHMHbJ6G4uB/q sYVmw40HnAJ40T2iKHsxmg5lZHQyE7U6Tsm/ECsBk2EwuXu3ESQmuo7Rl+pAzEe2ravi kEmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 123si4745946pgb.416.2017.08.25.07.34.11; Fri, 25 Aug 2017 07:34:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933365AbdHYOeJ (ORCPT + 26 others); Fri, 25 Aug 2017 10:34:09 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54086 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754632AbdHYOci (ORCPT ); Fri, 25 Aug 2017 10:32:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 536FE169E; Fri, 25 Aug 2017 07:32:38 -0700 (PDT) Received: from e107985-lin.cambridge.arm.com (e107985-lin.cambridge.arm.com [10.1.210.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 61ABD3F540; Fri, 25 Aug 2017 07:32:36 -0700 (PDT) From: Dietmar Eggemann To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux@arm.linux.org.uk, Greg Kroah-Hartman , Juri Lelli , Vincent Guittot , Peter Zijlstra , Morten Rasmussen , Viresh Kumar , "Rafael J . Wysocki" , Sudeep Holla Subject: [PATCH v4 05/10] drivers base/arch_topology: provide frequency-invariant accounting support Date: Fri, 25 Aug 2017 15:32:01 +0100 Message-Id: <20170825143206.30467-6-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170825143206.30467-1-dietmar.eggemann@arm.com> References: <20170825143206.30467-1-dietmar.eggemann@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implements the arch-specific (arm and arm64) frequency-invariance setter function arch_set_freq_scale() which provides the following frequency scaling factor: current_freq(cpu) << SCHED_CAPACITY_SHIFT / max_supported_freq(cpu) One possible consumer of the frequency-invariance getter function topology_get_freq_scale() is the Per-Entity Load Tracking (PELT) mechanism of the task scheduler. Allow inlining of topology_get_freq_scale() into the task scheduler fast path (e.g. __update_load_avg_se()) by coding it as a static inline function in the arch topology header file. Cc: Greg Kroah-Hartman Cc: Juri Lelli Signed-off-by: Dietmar Eggemann Acked-by: Viresh Kumar --- drivers/base/arch_topology.c | 14 ++++++++++++++ include/linux/arch_topology.h | 10 ++++++++++ 2 files changed, 24 insertions(+) -- 2.11.0 diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 562e0c93ae52..af9ab98a233e 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -22,6 +22,20 @@ #include #include +DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE; + +void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, + unsigned long max_freq) +{ + unsigned long scale; + int i; + + scale = (cur_freq << SCHED_CAPACITY_SHIFT) / max_freq; + + for_each_cpu(i, cpus) + per_cpu(freq_scale, i) = scale; +} + static DEFINE_MUTEX(cpu_scale_mutex); static DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE; diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h index 9af3c174c03a..3e3c2657c9a1 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -4,6 +4,8 @@ #ifndef _LINUX_ARCH_TOPOLOGY_H_ #define _LINUX_ARCH_TOPOLOGY_H_ +#include + void topology_normalize_cpu_scale(void); struct device_node; @@ -14,4 +16,12 @@ unsigned long topology_get_cpu_scale(struct sched_domain *sd, int cpu); void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity); +DECLARE_PER_CPU(unsigned long, freq_scale); + +static inline +unsigned long topology_get_freq_scale(struct sched_domain *sd, int cpu) +{ + return per_cpu(freq_scale, cpu); +} + #endif /* _LINUX_ARCH_TOPOLOGY_H_ */