From patchwork Wed Apr 20 17:27:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 722521 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3KHSua9023753 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Apr 2011 17:29:19 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p3KHRPFf016214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 20 Apr 2011 12:27:25 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id p3KHROMG005939; Wed, 20 Apr 2011 12:27:24 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id C84DF80627; Wed, 20 Apr 2011 12:27:23 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 0BFF480626 for ; Wed, 20 Apr 2011 12:27:22 -0500 (CDT) Received: from white.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id p3KHRLj5013735 for ; Wed, 20 Apr 2011 12:27:21 -0500 (CDT) Received: from psmtp.com (na3sys009amx239.postini.com [74.125.149.123]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id p3KHRJPP026603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 20 Apr 2011 12:27:19 -0500 Received: from na3sys009aog113.obsmtp.com ([74.125.83.175]) (using TLSv1) by na3sys009amx239.postini.com ([74.125.148.10]) with SMTP; Wed, 20 Apr 2011 13:27:21 EDT Received: from mail-pv0-f175.google.com ([74.125.83.175]) (using TLSv1) by na3sys009aob113.postini.com ([74.125.148.12]) with SMTP ID DSNKTa8XdhXcoQT60/c3ajmOHwPh4huf5TDJ@postini.com; Wed, 20 Apr 2011 10:27:19 PDT Received: by mail-pv0-f175.google.com with SMTP id 30so552529pvc.20 for ; Wed, 20 Apr 2011 10:27:18 -0700 (PDT) Received: by 10.143.20.3 with SMTP id x3mr4209316wfi.159.1303320438174; Wed, 20 Apr 2011 10:27:18 -0700 (PDT) Received: from localhost (c-24-18-179-55.hsd1.wa.comcast.net [24.18.179.55]) by mx.google.com with ESMTPS id m10sm1447113wfl.23.2011.04.20.10.27.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Apr 2011 10:27:17 -0700 (PDT) From: Kevin Hilman To: Trinabh Gupta Subject: Re: [linux-pm] [RFC PATCH V3 1/4] cpuidle: Move dev->last_residency update to driver enter routine; remove dev->last_state Organization: Texas Instruments, Inc. References: <20110420065445.332.13688.stgit@tringupt.in.ibm.com> <20110420065523.332.58678.stgit@tringupt.in.ibm.com> Date: Wed, 20 Apr 2011 10:27:15 -0700 In-Reply-To: <20110420065523.332.58678.stgit@tringupt.in.ibm.com> (Trinabh Gupta's message of "Wed, 20 Apr 2011 12:25:34 +0530") Message-ID: <87pqog6dfw.fsf@ti.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: venki@google.com, davinci-linux-open-source@linux.davincidsp.com, ak@linux.intel.com, len.brown@intel.com, peterz@infradead.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@lists.linux-foundation.org, linux-omap@vger.kernel.org, arjan@linux.intel.com, linux-arm-kernel@lists.infradead.org, lenb@kernel.org X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 20 Apr 2011 17:29:19 +0000 (UTC) Trinabh Gupta writes: > Cpuidle subsystem only suggests the state to enter and does not > guarantee if the suggested state is entered. The actual entered state > may be different because of software or hardware demotion. Software > demotion is done by the back-end cpuidle driver and can be accounted > correctly. Current cpuidle code uses last_state field to capture the > actual state entered and based on that updates the statistics for the > state entered. > > Ideally the driver enter routine should update the counters, > and it should return the state actually entered rather than the time > spent there. OK, the return type was changed to return the state index instead of the time, but since the governors are still relying on dev->last_residency, drivers are required to update it. Because of that, why not keep the update of the time/usage counters in common code rather than duplicating it (9 times in this patch) into all the drivers? Something like the patch below should suffice. Kevin diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 845d3ef..875d241 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -91,6 +91,11 @@ static void cpuidle_idle_call(void) entered_state = target_state->enter(dev, drv, next_state); + /* Update cpuidle counters */ + dev->states_usage[entered_state].time += + (unsigned long long)dev->last_residency; + dev->states_usage[entered_state].usage++; + trace_power_end(dev->cpu); trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu);