From patchwork Thu Aug 6 22:57:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 39700 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n76MxLod000974 for ; Thu, 6 Aug 2009 22:59:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752978AbZHFW7E (ORCPT ); Thu, 6 Aug 2009 18:59:04 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755690AbZHFW7E (ORCPT ); Thu, 6 Aug 2009 18:59:04 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:34590 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754990AbZHFW7C (ORCPT ); Thu, 6 Aug 2009 18:59:02 -0400 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id n76Mvu6x015725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 Aug 2009 15:57:57 -0700 Received: from localhost.localdomain (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id n76Mvt8r024262; Thu, 6 Aug 2009 15:57:55 -0700 Message-Id: <200908062257.n76Mvt8r024262@imap1.linux-foundation.org> Subject: [patch 8/9] cpuidle: menu governor: reduce latency on exit To: lenb@kernel.org Cc: linux-acpi@vger.kernel.org, akpm@linux-foundation.org, czoccolo@gmail.com, abelay@novell.com, len.brown@intel.com, venkatesh.pallipadi@intel.com From: akpm@linux-foundation.org Date: Thu, 06 Aug 2009 15:57:55 -0700 X-Spam-Status: No, hits=-3.511 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Corrado Zoccolo Move the state residency accounting and statistics computation off the hot exit path. On exit, the need to recompute statistics is recorded, and new statistics will be computed when menu_select is called again. Signed-off-by: Corrado Zoccolo Cc: Venkatesh Pallipadi Cc: Len Brown Cc: Adam Belay --- drivers/cpuidle/governors/menu.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff -puN drivers/cpuidle/governors/menu.c~cpuidle-menu-governor-reduce-latency-on-exit drivers/cpuidle/governors/menu.c --- a/drivers/cpuidle/governors/menu.c~cpuidle-menu-governor-reduce-latency-on-exit +++ a/drivers/cpuidle/governors/menu.c @@ -19,6 +19,7 @@ struct menu_device { int last_state_idx; + int needs_update; unsigned int expected_us; unsigned int predicted_us; @@ -29,6 +30,8 @@ struct menu_device { static DEFINE_PER_CPU(struct menu_device, menu_devices); +static void menu_update(struct cpuidle_device *dev); + /** * menu_select - selects the next idle state to enter * @dev: the CPU @@ -39,6 +42,11 @@ static int menu_select(struct cpuidle_de int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY); int i; + if (data->needs_update) { + menu_update(dev); + data->needs_update = 0; + } + /* Special case when user has set very strict latency requirement */ if (unlikely(latency_req == 0)) { data->last_state_idx = 0; @@ -72,7 +80,7 @@ static int menu_select(struct cpuidle_de } /** - * menu_reflect - attempts to guess what happened after entry + * menu_reflect - records that data structures need update * @dev: the CPU * * NOTE: it's important to be fast here because this operation will add to @@ -81,6 +89,16 @@ static int menu_select(struct cpuidle_de static void menu_reflect(struct cpuidle_device *dev) { struct menu_device *data = &__get_cpu_var(menu_devices); + data->needs_update = 1; +} + +/** + * menu_update - attempts to guess what happened after entry + * @dev: the CPU + */ +static void menu_update(struct cpuidle_device *dev) +{ + struct menu_device *data = &__get_cpu_var(menu_devices); int last_idx = data->last_state_idx; unsigned int last_idle_us = cpuidle_get_last_residency(dev); struct cpuidle_state *target = &dev->states[last_idx];