aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle/driver.c
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2013-01-03 07:03:18 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-03 07:11:06 -0500
commitac34d7c8c87c247db0270285950753da045acaad (patch)
tree1ce0a154f71f4d812da17865454cf25e7bdedfa5 /drivers/cpuidle/driver.c
parent17915d582f9fe74efbd1c755f3ea5a5c2d9b3156 (diff)
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 <rja@sgi.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle/driver.c')
-rw-r--r--drivers/cpuidle/driver.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index 3af841fb397a..c2b281afe0ed 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -235,16 +235,10 @@ EXPORT_SYMBOL_GPL(cpuidle_get_driver);
235 */ 235 */
236struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev) 236struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev)
237{ 237{
238 struct cpuidle_driver *drv;
239
240 if (!dev) 238 if (!dev)
241 return NULL; 239 return NULL;
242 240
243 spin_lock(&cpuidle_driver_lock); 241 return __cpuidle_get_cpu_driver(dev->cpu);
244 drv = __cpuidle_get_cpu_driver(dev->cpu);
245 spin_unlock(&cpuidle_driver_lock);
246
247 return drv;
248} 242}
249EXPORT_SYMBOL_GPL(cpuidle_get_cpu_driver); 243EXPORT_SYMBOL_GPL(cpuidle_get_cpu_driver);
250 244