From patchwork Fri Mar 28 12:29:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 27277 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7ED6A20062 for ; Fri, 28 Mar 2014 12:30:19 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id lg15sf10903965vcb.11 for ; Fri, 28 Mar 2014 05:30:19 -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; bh=CO/oRH/AHszWgy3kS/FQ/XN507B2h1nY+3x3eT+vcm0=; b=SaPcYegXxI/5AJe9NOJ0e+b/ONKuKOKnH+0aQZCgOIKBkaDgi0g2yk7MOFADd/aqWH hlKJx+EGDER4OXlJPdRtg8d7T//gMMZZiWE/Eghz7eSeV5e2cPxEWr//ynZ0FKMKHHyE xHcJGyjpjhviJYORGdHNESxdKu2I9l+SCCAGcfCfaRNN+eVkoLB6jX4pwWDXmNeq8+2S 8eMs/ahhiBON3oChdswr1BS/N4NIq2niIb7IrvakRjzye5HGSnftdBfPULmj9HLWoQng hVj89daUbXi0vG0Sw427UjAxreoQ5VaFjlOxaiRlniVZIxf5j2AiRn3cgUn5+tGo2527 po8g== X-Gm-Message-State: ALoCoQkKJA24DwbwtGBQdyLYQnum4qIJdVvkBkvOUiWUF9Jexop5D0nqYmpp/p0H8lJk8gku7V/z X-Received: by 10.236.117.79 with SMTP id i55mr2451193yhh.16.1396009819276; Fri, 28 Mar 2014 05:30:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.131 with SMTP id z3ls1499349qgd.59.gmail; Fri, 28 Mar 2014 05:30:19 -0700 (PDT) X-Received: by 10.220.147.16 with SMTP id j16mr7014651vcv.14.1396009819193; Fri, 28 Mar 2014 05:30:19 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id k20si1104340vcm.205.2014.03.28.05.30.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 05:30:19 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id ld13so5768213vcb.33 for ; Fri, 28 Mar 2014 05:30:19 -0700 (PDT) X-Received: by 10.58.91.101 with SMTP id cd5mr6810488veb.5.1396009819116; Fri, 28 Mar 2014 05:30:19 -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.12.8 with SMTP id v8csp4563vcv; Fri, 28 Mar 2014 05:30:18 -0700 (PDT) X-Received: by 10.68.28.69 with SMTP id z5mr8217423pbg.121.1396009818672; Fri, 28 Mar 2014 05:30:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ys6si3582994pab.377.2014.03.28.05.30.18; Fri, 28 Mar 2014 05:30:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751427AbaC1M36 (ORCPT + 12 others); Fri, 28 Mar 2014 08:29:58 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:35266 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095AbaC1M34 (ORCPT ); Fri, 28 Mar 2014 08:29:56 -0400 Received: by mail-wi0-f178.google.com with SMTP id bs8so694693wib.5 for ; Fri, 28 Mar 2014 05:29:55 -0700 (PDT) X-Received: by 10.180.97.72 with SMTP id dy8mr12102419wib.5.1396009787616; Fri, 28 Mar 2014 05:29:47 -0700 (PDT) Received: from localhost.localdomain (AToulouse-654-1-301-183.w86-199.abo.wanadoo.fr. [86.199.84.183]) by mx.google.com with ESMTPSA id u6sm6805514wif.6.2014.03.28.05.29.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 05:29:47 -0700 (PDT) From: Daniel Lezcano To: linux-kernel@vger.kernel.org, mingo@elte.hu, peterz@infradead.org Cc: rjw@rjwysocki.net, nicolas.pitre@linaro.org, linux-pm@vger.kernel.org, alex.shi@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com Subject: [RFC PATCHC 2/3] idle: store the idle state the cpu is Date: Fri, 28 Mar 2014 13:29:55 +0100 Message-Id: <1396009796-31598-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1396009796-31598-1-git-send-email-daniel.lezcano@linaro.org> References: <1396009796-31598-1-git-send-email-daniel.lezcano@linaro.org> 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: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , When the cpu enters idle it stores the cpuidle power info in the struct rq which in turn could be used to take a right decision when balancing a task. As soon as the cpu exits the idle state, the structure is filled with the NULL pointer. Signed-off-by: Daniel Lezcano --- kernel/sched/idle.c | 17 +++++++++++++++-- kernel/sched/sched.h | 5 +++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 8f4390a..5c32c11 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -12,6 +12,8 @@ #include +#include "sched.h" + static int __read_mostly cpu_idle_force_poll; void cpu_idle_poll_ctrl(bool enable) @@ -69,7 +71,7 @@ void __weak arch_cpu_idle(void) * NOTE: no locks or semaphores should be used here * return non-zero on failure */ -static int cpuidle_idle_call(void) +static int cpuidle_idle_call(struct cpuidle_power **power) { struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); @@ -143,6 +145,10 @@ static int cpuidle_idle_call(void) if (!ret) { trace_cpu_idle_rcuidle(next_state, dev->cpu); + *power = &drv->states[next_state].power; + + wmb(); + /* * Enter the idle state previously * returned by the governor @@ -154,6 +160,10 @@ static int cpuidle_idle_call(void) entered_state = cpuidle_enter(drv, dev, next_state); + *power = NULL; + + wmb(); + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); @@ -198,6 +208,9 @@ static int cpuidle_idle_call(void) */ static void cpu_idle_loop(void) { + struct rq *rq = this_rq(); + struct cpuidle_power **power = &rq->power; + while (1) { tick_nohz_idle_enter(); @@ -223,7 +236,7 @@ static void cpu_idle_loop(void) if (cpu_idle_force_poll || tick_check_broadcast_expired()) cpu_idle_poll(); else - cpuidle_idle_call(); + cpuidle_idle_call(power); arch_cpu_idle_exit(); } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 1929deb..1bcac35 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -14,6 +14,7 @@ #include "cpuacct.h" struct rq; +struct cpuidle_power; extern __read_mostly int scheduler_running; @@ -632,6 +633,10 @@ struct rq { #ifdef CONFIG_SMP struct llist_head wake_list; #endif + +#ifdef CONFIG_CPU_IDLE + struct cpuidle_power *power; +#endif }; static inline int cpu_of(struct rq *rq)