From patchwork Wed Mar 7 03:42:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob X-Patchwork-Id: 7128 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C4A9123E67 for ; Wed, 7 Mar 2012 03:42:31 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 7E8C6A182A0 for ; Wed, 7 Mar 2012 03:42:31 +0000 (UTC) Received: by iage36 with SMTP id e36so10767033iag.11 for ; Tue, 06 Mar 2012 19:42:30 -0800 (PST) Received: by 10.50.45.228 with SMTP id q4mr395696igm.58.1331091750939; Tue, 06 Mar 2012 19:42:30 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp1063ibg; Tue, 6 Mar 2012 19:42:30 -0800 (PST) Received: by 10.52.173.230 with SMTP id bn6mr818160vdc.19.1331091749573; Tue, 06 Mar 2012 19:42:29 -0800 (PST) Received: from mail-vw0-f50.google.com (mail-vw0-f50.google.com [209.85.212.50]) by mx.google.com with ESMTPS id dc7si18042618vdc.80.2012.03.06.19.42.29 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 06 Mar 2012 19:42:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of rob.lee@linaro.org) client-ip=209.85.212.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of rob.lee@linaro.org) smtp.mail=rob.lee@linaro.org Received: by mail-vw0-f50.google.com with SMTP id l22so7101837vbn.37 for ; Tue, 06 Mar 2012 19:42:29 -0800 (PST) Received: by 10.52.27.69 with SMTP id r5mr607283vdg.129.1331091746447; Tue, 06 Mar 2012 19:42:26 -0800 (PST) Received: from b18647-20 ([67.23.168.167]) by mx.google.com with ESMTPS id he3sm34341500vdb.2.2012.03.06.19.42.22 (version=SSLv3 cipher=OTHER); Tue, 06 Mar 2012 19:42:25 -0800 (PST) From: Robert Lee To: rjw@sisk.pl, len.brown@intel.com Cc: khilman@ti.com, robherring2@gmail.com, Baohua.Song@csr.com, amit.kucheria@linaro.org, nicolas.ferre@atmel.com, linux@maxim.org.za, kgene.kim@samsung.com, amit.kachhap@linaro.org, magnus.damm@gmail.com, nsekhar@ti.com, daniel.lezcano@linaro.org, mturquette@linaro.org, vincent.guittot@linaro.org, arnd.bergmann@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-dev@lists.linaro.org, patches@linaro.org, deepthi@linux.vnet.ibm.com, broonie@opensource.wolfsonmicro.com, nicolas.pitre@linaro.org, linux@arm.linux.org.uk, jean.pihet@newoldbits.com, venki@google.com, ccross@google.com, g.trinabh@gmail.com, kernel@wantstofly.org, lethal@linux-sh.org, jon-hunter@ti.com, tony@atomide.com, linux-omap@vger.kernel.org, linux-sh@vger.kernel.org, linux-pm@vger.kernel.org Subject: [RFC PATCH] cpuidle: avoid unnecessary expensive governor processing Date: Tue, 6 Mar 2012 21:42:18 -0600 Message-Id: <1331091738-26322-1-git-send-email-rob.lee@linaro.org> X-Mailer: git-send-email 1.7.1 X-Gm-Message-State: ALoCoQkYL5seKO+5TAt2jBgGcFZzUtmA5u0llBy2nqBzn8CfnV78M+QSiF1YWkwwHSkRn2qkfELg There a few cases when a platform's cpuidle_device will only have one cpuidle state. e.g., when a single idle state system uses cpuidle to provide sysfs staticstics for profiling (powertop, etc). This can also be the case for coupled smp system implementations that keep all but one cpuidle_device at a state_count of 1, but they still want to export idle statistics for these states using cpuidle. Signed-off-by: Robert Lee --- drivers/cpuidle/governors/ladder.c | 7 +++++-- drivers/cpuidle/governors/menu.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c index b6a09ea..13abdba 100644 --- a/drivers/cpuidle/governors/ladder.c +++ b/drivers/cpuidle/governors/ladder.c @@ -71,8 +71,11 @@ static int ladder_select_state(struct cpuidle_driver *drv, int last_residency, last_idx = ldev->last_state_idx; int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); - /* Special case when user has set very strict latency requirement */ - if (unlikely(latency_req == 0)) { + /* + * Special case when user has set very strict latency requirement or + * there is currently only one state for this device. + */ + if ((latency_req == 0) || (dev->state_count == 1)) { ladder_do_selection(ldev, last_idx, 0); return 0; } diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index ad09526..80eb606 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -249,8 +249,11 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) data->last_state_idx = 0; data->exit_us = 0; - /* Special case when user has set very strict latency requirement */ - if (unlikely(latency_req == 0)) + /* + * Special case when user has set very strict latency requirement or + * there is currently only one state for this device. + */ + if ((latency_req == 0) || (dev->state_count == 1)) return 0; /* determine the expected residency time, round up */