From patchwork Tue Sep 26 16:41:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 114276 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4043816qgf; Tue, 26 Sep 2017 09:43:52 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCkYmsQIDdtjTmIYZrV/2IwfGXCYRxPM1/htbKT0caVbprOFu9Gwpyk0HhDTVGx4+kvd3Pt X-Received: by 10.99.120.3 with SMTP id t3mr3276981pgc.388.1506444231903; Tue, 26 Sep 2017 09:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506444231; cv=none; d=google.com; s=arc-20160816; b=yVXeD6SYL1qSKOdGke8F3Ap0OLipEIBvBZC4SOTK9eaplMvNDW0YZosX8XztWn3/sw 9TKAjRMFXcVFiuh9/lBIy9/a/5txPUj1/+V3deTAN7a0DjpUKc1Uj02DcumeZT0ED8bg GkGpC10X4q2/QxLOaLT5u4xpktS3ObFFAynMKzed/KjwF+I8OCUjadKfPxBIBkQwdIkG 8bM3ppQk01UkfY7uj00AeZ+OcskODGBVYnQWFL0YOh1JlHhRbJioktgA7n7la7JAs21a NDSf08fX14VOdEMZYpuWNLK6gmPLK6qhwe+xFEKIoyv2Fh7z0cj5a7WHpIVVBzBMl7iE G1UQ== 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=e7a2aK43GRbcVZ838fOTcdl3DfSym0QuriHTtMrijVo=; b=TLiC7VsYU0UPG2fZAd+epJbbSQEwt37OvjmIwDrQ5g2FLWibHUwWyp4jMmvXzSm4a6 XZIRnF8N+IYNMKbdAnFX3mqzgWYzpaciJ2GHRJs6k4OwRe8kbx/Db9HyokESo/zfe5S2 ny2k6pDgWo98nGchwtqPJrF7SY21wjUHLjif9a9hoC+ojydH/0LnvaLqkGQXnUiQHy16 ju/BsbRIZ8D9OJ/FPA+jLPot3m0lZhBSTzlvz2KBF/Lyi5TZKvif4v3h70WerGmPHY82 og9Mh9FiqN25AIx7hV2MHv6NQipxIZ8oTNEFVA0IrQgPS1m1p/PiIFrzEcnM6yDOEYPC O++w== 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 z79si4148407pfi.486.2017.09.26.09.43.51; Tue, 26 Sep 2017 09:43:51 -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 S1030845AbdIZQnt (ORCPT + 26 others); Tue, 26 Sep 2017 12:43:49 -0400 Received: from foss.arm.com ([217.140.101.70]:36054 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030694AbdIZQme (ORCPT ); Tue, 26 Sep 2017 12:42:34 -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 0130E1684; Tue, 26 Sep 2017 09:42:34 -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 9C9193F483; Tue, 26 Sep 2017 09:42:31 -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 v5 05/10] drivers base/arch_topology: provide frequency-invariant accounting support Date: Tue, 26 Sep 2017 17:41:10 +0100 Message-Id: <20170926164115.32367-6-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170926164115.32367-1-dietmar.eggemann@arm.com> References: <20170926164115.32367-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 | 9 +++++++++ 2 files changed, 23 insertions(+) -- 2.11.0 diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index e9bb368f32b3..416ec2f5211d 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 716ce587247e..f6e490312e4d 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -5,6 +5,7 @@ #define _LINUX_ARCH_TOPOLOGY_H_ #include +#include void topology_normalize_cpu_scale(void); @@ -16,4 +17,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_ */