From patchwork Thu Jul 3 16:26:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 33046 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DB523203AC for ; Thu, 3 Jul 2014 16:29:05 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wm4sf2138324obc.3 for ; Thu, 03 Jul 2014 09:29:05 -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=9cWmvRBjjEjhVfypYLgglRZEk9MAdggZtg2ymvu+UXI=; b=NzzhKgYyXN8jfrGgICX3snMiIscM3rxM2fPYC0htNfayGgVNFyGpOsHh6qaMaPVzAF sgAVKwsO6ryZDE4ZCrH9Ruzuy0pUr4tuIt6YAkRlz2WCHfmp8aye01MUpNbCfsYL9UIW qWctzzdUt+AX2V2d5OFDYn/9xWWjOpCAqvZ0sUvMdKzFt0WdpBkaL44LXepzKkypsaT5 tgPhvUU809AgIVvR4ce1g/KHbYd3RM6K5w56RVvH9NJlCYpxe/G8jGDAu0daJGxGMqS7 QYbCSllf9o8d0sXh8yX4MAkGq+d2PGcN75nSu658KYrxXo1dtjbtHVyblhWUPVB8SUk4 f6ng== X-Gm-Message-State: ALoCoQlhGkJqWq2l57HezYxq5R/B65fl76vll0JEM1c5p7z9Hl0HQebxDZgbJe6At0ti/aWs8dKn X-Received: by 10.42.109.148 with SMTP id l20mr5336612icp.0.1404404945514; Thu, 03 Jul 2014 09:29:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.109.182 with SMTP id l51ls263980qgf.95.gmail; Thu, 03 Jul 2014 09:29:05 -0700 (PDT) X-Received: by 10.58.116.4 with SMTP id js4mr1437182veb.38.1404404945381; Thu, 03 Jul 2014 09:29:05 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id fl10si1097504vec.42.2014.07.03.09.29.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Jul 2014 09:29:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.170 as permitted sender) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id i13so493195veh.29 for ; Thu, 03 Jul 2014 09:29:05 -0700 (PDT) X-Received: by 10.58.132.136 with SMTP id ou8mr2122450veb.0.1404404945285; Thu, 03 Jul 2014 09:29:05 -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.221.37.5 with SMTP id tc5csp390501vcb; Thu, 3 Jul 2014 09:29:04 -0700 (PDT) X-Received: by 10.68.226.197 with SMTP id ru5mr78861174pbc.77.1404404944491; Thu, 03 Jul 2014 09:29:04 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si963982pdl.449.2014.07.03.09.29.03; Thu, 03 Jul 2014 09:29:03 -0700 (PDT) Received-SPF: none (google.com: linux-pm-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 S1752890AbaGCQ27 (ORCPT + 13 others); Thu, 3 Jul 2014 12:28:59 -0400 Received: from service87.mimecast.com ([91.220.42.44]:45695 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759340AbaGCQ0U (ORCPT ); Thu, 3 Jul 2014 12:26:20 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 03 Jul 2014 17:26:18 +0100 Received: from e103034-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 3 Jul 2014 17:26:18 +0100 From: Morten Rasmussen To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, peterz@infradead.org, mingo@kernel.org Cc: rjw@rjwysocki.net, vincent.guittot@linaro.org, daniel.lezcano@linaro.org, preeti@linux.vnet.ibm.com, Dietmar.Eggemann@arm.com, pjt@google.com Subject: [RFCv2 PATCH 15/23] sched, cpufreq: Introduce current cpu compute capacity into scheduler Date: Thu, 3 Jul 2014 17:26:02 +0100 Message-Id: <1404404770-323-16-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404404770-323-1-git-send-email-morten.rasmussen@arm.com> References: <1404404770-323-1-git-send-email-morten.rasmussen@arm.com> X-OriginalArrivalTime: 03 Jul 2014 16:26:18.0506 (UTC) FILETIME=[84AE66A0:01CF96DB] X-MC-Unique: 114070317261810701 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@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.128.170 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: , The scheduler is currently unaware of frequency changes and the current compute capacity offered by the cpus. This patch is not the solution. It is a hack to give us something to experiment with for now. A proper solution could be based on the frequency invariant load tracking proposed in the past: https://lkml.org/lkml/2013/4/16/289 The best way to get current compute capacity is likely to be architecture specific. A potential solution is therefore to let the architecture implement get_curr_capacity() instead. This patch should _not_ be considered safe. Signed-off-by: Morten Rasmussen --- drivers/cpufreq/cpufreq.c | 2 ++ include/linux/sched.h | 2 ++ kernel/sched/fair.c | 11 +++++++++++ kernel/sched/sched.h | 2 ++ 4 files changed, 17 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index abda660..a2b788d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -28,6 +28,7 @@ #include #include #include +#include #include /** @@ -315,6 +316,7 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy, pr_debug("FREQ: %lu - CPU: %lu\n", (unsigned long)freqs->new, (unsigned long)freqs->cpu); trace_cpu_frequency(freqs->new, freqs->cpu); + set_curr_capacity(freqs->cpu, (freqs->new*1024)/policy->max); srcu_notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs); if (likely(policy) && likely(policy->cpu == freqs->cpu)) diff --git a/include/linux/sched.h b/include/linux/sched.h index e5d8d57..faebd87 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -3025,4 +3025,6 @@ static inline unsigned long rlimit_max(unsigned int limit) return task_rlimit_max(current, limit); } +void set_curr_capacity(int cpu, long capacity); + #endif diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 37e9ea1..9720f04 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7564,9 +7564,20 @@ void init_cfs_rq(struct cfs_rq *cfs_rq) atomic64_set(&cfs_rq->decay_counter, 1); atomic_long_set(&cfs_rq->removed_load, 0); atomic_long_set(&cfs_rq->uw_removed_load, 0); + atomic_long_set(&cfs_rq->curr_capacity, 1024); #endif } +void set_curr_capacity(int cpu, long capacity) +{ + atomic_long_set(&cpu_rq(cpu)->cfs.curr_capacity, capacity); +} + +static inline unsigned long get_curr_capacity(int cpu) +{ + return atomic_long_read(&cpu_rq(cpu)->cfs.curr_capacity); +} + #ifdef CONFIG_FAIR_GROUP_SCHED static void task_move_group_fair(struct task_struct *p, int on_rq) { diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 455d152..a6d5239 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -342,6 +342,8 @@ struct cfs_rq { u64 last_decay; atomic_long_t removed_load, uw_removed_load; + atomic_long_t curr_capacity; + #ifdef CONFIG_FAIR_GROUP_SCHED /* Required to track per-cpu representation of a task_group */ u32 tg_runnable_contrib;