From patchwork Fri May 23 18:16:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Morten Rasmussen X-Patchwork-Id: 30850 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CAED420369 for ; Fri, 23 May 2014 18:19:29 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rq2sf19738531pbb.5 for ; Fri, 23 May 2014 11:19:29 -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=7t3+cShwCslnz4OfGMHP6HzjhXI0VvtIzQCoeMLH3v4=; b=JzwiapSuKwPvX2KtyWBsjYSg8CSXLDvKk5qbj+UTuiEdaPND7AkIbCHOBrwL7EfPi7 lHDeJxqTHcsXCcIYIHkn1v2nRB8Jbjp2/0YfjKudMPMzwdwclzYvONcSo1hjWM3XviVZ sG/a6tohEVJuOtibJf1H7BOh0cRCRM1dg7OIzXND+cPG5ze3konZncIBexPmqzZW5MYH f4+xzyU+tbxM8FZlQ0Ah/SaaiReQs1BCBa/azf8mmQz1ayVEQzYai/TGdSQr0efB4s/v pVsWFMQ7YM6lp5IPTtqXPIbzH/upapRtrlLBFU9nC0CJFbtalcqa54vVbEtOIsEd4y07 0NaQ== X-Gm-Message-State: ALoCoQnzuW4zzM2PDCShz+HS5OVOCA9CfDWssSyMf5I5b3A1u/avc5I0/abPd19oygrSboosF2fG X-Received: by 10.66.158.6 with SMTP id wq6mr2802315pab.39.1400869169131; Fri, 23 May 2014 11:19:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.195 with SMTP id f61ls1828681qgf.59.gmail; Fri, 23 May 2014 11:19:29 -0700 (PDT) X-Received: by 10.221.30.14 with SMTP id sa14mr1924170vcb.44.1400869168978; Fri, 23 May 2014 11:19:28 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id fv10si2117236vdc.39.2014.05.23.11.19.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 11:19:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hq11so900052vcb.36 for ; Fri, 23 May 2014 11:19:28 -0700 (PDT) X-Received: by 10.58.216.163 with SMTP id or3mr51465vec.80.1400869168900; Fri, 23 May 2014 11:19:28 -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.220.221.72 with SMTP id ib8csp52413vcb; Fri, 23 May 2014 11:19:28 -0700 (PDT) X-Received: by 10.66.246.229 with SMTP id xz5mr8079367pac.119.1400869167878; Fri, 23 May 2014 11:19:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gc6si5008153pac.152.2014.05.23.11.19.27 for ; Fri, 23 May 2014 11:19:27 -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 S1752145AbaEWSTQ (ORCPT + 27 others); Fri, 23 May 2014 14:19:16 -0400 Received: from service87.mimecast.com ([91.220.42.44]:36200 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751498AbaEWSQy (ORCPT ); Fri, 23 May 2014 14:16:54 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 23 May 2014 19:16:52 +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); Fri, 23 May 2014 19:16:52 +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 Subject: [RFC PATCH 09/16] sched, cpufreq: Introduce current cpu compute capacity into scheduler Date: Fri, 23 May 2014 19:16:36 +0100 Message-Id: <1400869003-27769-10-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1400869003-27769-1-git-send-email-morten.rasmussen@arm.com> References: <1400869003-27769-1-git-send-email-morten.rasmussen@arm.com> X-OriginalArrivalTime: 23 May 2014 18:16:52.0291 (UTC) FILETIME=[2BC9E930:01CF76B3] X-MC-Unique: 114052319165215601 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.220.177 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 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 | 6 ++++++ kernel/sched/sched.h | 2 ++ 4 files changed, 12 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 62d61b5..727b936 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -3068,4 +3068,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 7570dd9..3a2aeee 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7410,9 +7410,15 @@ void init_cfs_rq(struct cfs_rq *cfs_rq) #ifdef CONFIG_SMP atomic64_set(&cfs_rq->decay_counter, 1); atomic_long_set(&cfs_rq->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); +} + #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 9ff67a7..5a117b8 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -341,6 +341,8 @@ struct cfs_rq { u64 last_decay; atomic_long_t 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;