From patchwork Thu Jul 27 19:33:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 108854 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2484393qge; Thu, 27 Jul 2017 12:34:00 -0700 (PDT) X-Received: by 10.84.217.132 with SMTP id p4mr5393258pli.217.1501184040811; Thu, 27 Jul 2017 12:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501184040; cv=none; d=google.com; s=arc-20160816; b=Miaxex72Jp0xZgq0CyXKZsdxa/fMnC7/CkGpg5oprsKKTHgdogqDzEfdYmTroatgAn ihztrWoh0u4VXWBemHpU5qpBfNzDj1469yKmvZnORxlB7jo33Hl7gyTNm1pZy/o3+VNa JcGogp/XmiKV/ho513cedSwBZFcB+47WGJmfOwW7Bl1BRDCEhtVWMy4+8HEk5KMMjuP8 KGI+9ltEEGQ6MSl1uMf+uSVIDhwbtv3/1QhonPOCJMjst+376ldHqGN5v5bsPfrjcViP 6yVDxbB4mTnivEsrBJwNBWukNRImS6RzokN0bTvrw/K8GfB5lWmponBCSkWSzNpWcZ9J SrKw== 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=CY7gSVdYbJh9E9do4Fq4ZVy67fJv/dSDlHhvstk5gpc=; b=KQ4aBHYfKHde7RcovPNQZiMZvgSlztfN9i9dHtaGl/R+juhj0b95j9RjHkM+ha/aRy 54qJNVfypvarj532/DzugobHOpTiYttxhjF+fmb/mu86ArfFV2RwmrfECGG/MWvhgqzJ 3ttltsnrp7Hnc/pwjpfJbYcSpwxtgloVCrG3q5eGe/t02egBTYmOijSxOGjyZcmaYQXc k1/V8zGJC2+y8B956lynXpfalfRd6aqq9cdNADkSc7MtjyUDftXD1SBTwIEOCbSxSiq2 +3394tgs1RCknLstPPGoZwJ/KEyrpH2oLBcYRDfVmvOu1xFi7rqYbG5St9u8E+U+NgU/ 80Vw== 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 z63si3955997plh.986.2017.07.27.12.34.00; Thu, 27 Jul 2017 12:34:00 -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 S1751840AbdG0Td5 (ORCPT + 26 others); Thu, 27 Jul 2017 15:33:57 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51100 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751788AbdG0Tdu (ORCPT ); Thu, 27 Jul 2017 15:33:50 -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 B45F0164F; Thu, 27 Jul 2017 12:33:49 -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 7B27F3F540; Thu, 27 Jul 2017 12:33:47 -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 , Russell King , Catalin Marinas , Will Deacon , Juri Lelli , Vincent Guittot , Peter Zijlstra , Morten Rasmussen , Viresh Kumar , "Rafael J . Wysocki" , Sudeep Holla Subject: [PATCH v3 05/10] drivers base/arch_topology: provide frequency-invariant accounting support Date: Thu, 27 Jul 2017 20:33:07 +0100 Message-Id: <20170727193312.9849-6-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170727193312.9849-1-dietmar.eggemann@arm.com> References: <20170727193312.9849-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 --- 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_ */