From 0e5537b30d3029d784226ab51c2b923d1155b553 Mon Sep 17 00:00:00 2001 From: Sivaram Nair Date: Tue, 18 Dec 2012 13:52:50 +0100 Subject: cpuidle: Fix finding state with min power_usage Since cpuidle_state.power_usage is a signed value, use INT_MAX (instead of -1) to init the local copies so that functions that tries to find cpuidle states with minimum power usage works correctly even if they use non-negative values. Signed-off-by: Sivaram Nair Reviewed-by: Rik van Riel Signed-off-by: Rafael J. Wysocki --- drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/governors/menu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 8df53dd8dbe..fb4a7dd57f9 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -70,7 +70,7 @@ int cpuidle_play_dead(void) struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); int i, dead_state = -1; - int power_usage = -1; + int power_usage = INT_MAX; if (!drv) return -ENODEV; diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index bd40b943b6d..20ea33afdda 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -312,7 +312,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) { struct menu_device *data = &__get_cpu_var(menu_devices); int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); - int power_usage = -1; + int power_usage = INT_MAX; int i; int multiplier; struct timespec t; -- cgit v1.2.3-70-g09d2 From 92638e2facc5330475c7d558acec77721c3214e4 Mon Sep 17 00:00:00 2001 From: Sivaram Nair Date: Tue, 18 Dec 2012 13:52:54 +0100 Subject: cpuidle / coupled: fix ready counter decrement The ready_waiting_counts atomic variable is compared against the wrong online cpu count. The latter is computed incorrectly using logical-OR instead of bit-OR. This patch fixes that. Signed-off-by: Sivaram Nair Acked-by: Santosh Shilimkar Acked-by: Colin Cross Cc: Signed-off-by: Rafael J. Wysocki --- drivers/cpuidle/coupled.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/cpuidle/coupled.c b/drivers/cpuidle/coupled.c index 3265844839b..2a297f86dba 100644 --- a/drivers/cpuidle/coupled.c +++ b/drivers/cpuidle/coupled.c @@ -209,7 +209,7 @@ inline int cpuidle_coupled_set_not_ready(struct cpuidle_coupled *coupled) int all; int ret; - all = coupled->online_count || (coupled->online_count << WAITING_BITS); + all = coupled->online_count | (coupled->online_count << WAITING_BITS); ret = atomic_add_unless(&coupled->ready_waiting_counts, -MAX_WAITING_CPUS, all); -- cgit v1.2.3-70-g09d2 From 17915d582f9fe74efbd1c755f3ea5a5c2d9b3156 Mon Sep 17 00:00:00 2001 From: Youquan Song Date: Tue, 18 Dec 2012 13:54:22 +0100 Subject: intel_idle: pr_debug information need separated When debug kernel, the the below information is found: intel_idle: unaware of model 0x1a MWAIT 4 please contact lenb@kernel.orgACPI: Device input0 -> No ACPI support so this patch separates it. Signed-off-by: Youquan Song Signed-off-by: Rafael J. Wysocki --- drivers/idle/intel_idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index c49c04d9c2b..4ba384f1ab5 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -506,7 +506,7 @@ static int intel_idle_cpuidle_driver_init(void) if (*cpuidle_state_table[cstate].name == '\0') pr_debug(PREFIX "unaware of model 0x%x" " MWAIT %d please" - " contact lenb@kernel.org", + " contact lenb@kernel.org\n", boot_cpu_data.x86_model, cstate); continue; } -- cgit v1.2.3-70-g09d2 From ac34d7c8c87c247db0270285950753da045acaad Mon Sep 17 00:00:00 2001 From: Daniel Lezcano Date: Thu, 3 Jan 2013 13:03:18 +0100 Subject: cpuidle: fix lock contention in the idle path Commit bf4d1b5 (cpuidle: support multiple drivers) introduced locking in cpuidle_get_cpu_driver(), which is used in the idle_call() function. This leads to a contention problem with a large number of CPUs, because they all try to run the idle routine at the same time. The lock can be safely removed because of how is used the cpuidle API. Namely, cpuidle_register_driver() is called first, but the cpuidle idle function is not entered before cpuidle_register_device() is called, because the cpuidle device is not enabled then. Moreover, cpuidle_unregister_driver(), which would reset the driver value to NULL, is not called before cpuidle_unregister_device(). All of the cpuidle drivers use the API in the same way. In general, a cleanup around the lock is necessary and a proper refcounting mechanism should be used to ensure the consistency in the API (for example, cpuidle_unregister_driver() should fail if the driver's refcount is not 0). However, these modifications will require some code reorganization and rewrite which will be too intrusive for a fix. For this reason, fix the contention problem introduced by commit bf4d1b5 by simply removing the locking from cpuidle_get_cpu_driver(), which restores the original behavior of that routine. [rjw: Changelog.] Reported-and-tested-by: Russ Anderson Signed-off-by: Daniel Lezcano Signed-off-by: Rafael J. Wysocki --- drivers/cpuidle/driver.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 3af841fb397..c2b281afe0e 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -235,16 +235,10 @@ EXPORT_SYMBOL_GPL(cpuidle_get_driver); */ struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev) { - struct cpuidle_driver *drv; - if (!dev) return NULL; - spin_lock(&cpuidle_driver_lock); - drv = __cpuidle_get_cpu_driver(dev->cpu); - spin_unlock(&cpuidle_driver_lock); - - return drv; + return __cpuidle_get_cpu_driver(dev->cpu); } EXPORT_SYMBOL_GPL(cpuidle_get_cpu_driver); -- cgit v1.2.3-70-g09d2