cpuidle - fix lock contention in the idle path
PATCH 1/1 cpuidle - fix lock contention in the idle path
The commit bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92 introduces a lock in the cpuidle_get_cpu_driver function. This function is used in the idle_call function.
The problem is the contention with a large number of cpus because they try to access the idle routine at the same time.
The lock could be safely removed because of how is used the cpuidle api. The cpuidle_register_driver is called first but until the cpuidle_register_device is not called we don't enter in the cpuidle idle call function because the device is not enabled.
The cpuidle_unregister_driver function, leading the a NULL driver, is not called before the cpuidle_unregister_device.
This is how is used the cpuidle api from the different drivers.
However, a cleanup around the lock and a proper refcounting mechanism should be used to ensure the consistency in the api, like cpuidle_unregister_driver should failed if its refcounting is not 0.
These modifications will need some code reorganization and rewrite which does not fit with a fix.
The following patch is a hot fix by returning to the initial behavior by removing the lock when getting the driver.
--- drivers/cpuidle/driver.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/cpuidle/driver.c +1 -7
@@ -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);
Signature · 1 line
1.7.9.5
Hi Russ,
Is it possible you try this patch on your 2048 cpus ?
Thanks
-- Daniel
Quoted 57 lines · Daniel Lezcano
The commit
bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92introduces a lock in thecpuidle_get_cpu_driverfunction. This function is used in theidle_callfunction.The problem is the contention with a large number of cpus because they try to access the idle routine at the same time.
The lock could be safely removed because of how is used the cpuidle api. The
cpuidle_register_driveris called first but until thecpuidle_register_deviceis not called we don't enter in the cpuidle idle call function because the device is not enabled.The
cpuidle_unregister_driverfunction, leading the a NULL driver, is not called before thecpuidle_unregister_device.This is how is used the cpuidle api from the different drivers.
However, a cleanup around the lock and a proper refcounting mechanism should be used to ensure the consistency in the api, like
cpuidle_unregister_drivershould failed if its refcounting is not 0.These modifications will need some code reorganization and rewrite which does not fit with a fix.
The following patch is a hot fix by returning to the initial behavior by removing the lock when getting the driver.
Signed-off-by Daniel Lezcano <[email protected]>--- drivers/cpuidle/driver.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/cpuidle/driver.c +1
-7@@ -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);
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 4 lines · Daniel Lezcano
Hi Russ,
Is it possible you try this patch on your 2048 cpus ?
Yes, I will try it later today.
Thanks
Quoted 70 lines
Thanks
-- Daniel
Quoted 57 lines · Daniel Lezcano
The commit
bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92introduces a lock in thecpuidle_get_cpu_driverfunction. This function is used in theidle_callfunction.The problem is the contention with a large number of cpus because they try to access the idle routine at the same time.
The lock could be safely removed because of how is used the cpuidle api. The
cpuidle_register_driveris called first but until thecpuidle_register_deviceis not called we don't enter in the cpuidle idle call function because the device is not enabled.The
cpuidle_unregister_driverfunction, leading the a NULL driver, is not called before thecpuidle_unregister_device.This is how is used the cpuidle api from the different drivers.
However, a cleanup around the lock and a proper refcounting mechanism should be used to ensure the consistency in the api, like
cpuidle_unregister_drivershould failed if its refcounting is not 0.These modifications will need some code reorganization and rewrite which does not fit with a fix.
The following patch is a hot fix by returning to the initial behavior by removing the lock when getting the driver.
Signed-off-by Daniel Lezcano <[email protected]>--- drivers/cpuidle/driver.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/cpuidle/driver.c +1
-7@@ -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);Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Signature · 2 lines
Russ Anderson, OS RAS/Partitioning Project Lead SGI - Silicon Graphics Inc [email protected]
Quoted 18 lines · Daniel Lezcano
The commit
bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92introduces a lock in thecpuidle_get_cpu_driverfunction. This function is used in theidle_callfunction.The problem is the contention with a large number of cpus because they try to access the idle routine at the same time.
The lock could be safely removed because of how is used the cpuidle api. The
cpuidle_register_driveris called first but until thecpuidle_register_deviceis not called we don't enter in the cpuidle idle call function because the device is not enabled.The
cpuidle_unregister_driverfunction, leading the a NULL driver, is not called before thecpuidle_unregister_device.This is how is used the cpuidle api from the different drivers.
Quoted 7 lines
However, a cleanup around the lock and a proper refcounting mechanism should be used to ensure the consistency in the api, like
cpuidle_unregister_drivershould failed if its refcounting is not 0.These modifications will need some code reorganization and rewrite which does not fit with a fix.
I agree.
Quoted 2 lines
The following patch is a hot fix by returning to the initial behavior by removing the lock when getting the driver.
The patch fixes the problem. Verified on a system with 1024 cpus. Thanks.
Quoted 1 line
Signed-off-by Daniel Lezcano <[email protected]>
Quoted 28 lines
--- drivers/cpuidle/driver.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/cpuidle/driver.c +1
-7@@ -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);Signature · 1 line
1.7.9.5
Signature · 2 lines
Russ Anderson, OS RAS/Partitioning Project Lead SGI - Silicon Graphics Inc [email protected]
Quoted 32 lines · Russ Anderson
Quoted 18 lines · Daniel Lezcano
The commit
bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92introduces a lock in thecpuidle_get_cpu_driverfunction. This function is used in theidle_callfunction.The problem is the contention with a large number of cpus because they try to access the idle routine at the same time.
The lock could be safely removed because of how is used the cpuidle api. The
cpuidle_register_driveris called first but until thecpuidle_register_deviceis not called we don't enter in the cpuidle idle call function because the device is not enabled.The
cpuidle_unregister_driverfunction, leading the a NULL driver, is not called before thecpuidle_unregister_device.This is how is used the cpuidle api from the different drivers.
Quoted 7 lines
However, a cleanup around the lock and a proper refcounting mechanism should be used to ensure the consistency in the api, like
cpuidle_unregister_drivershould failed if its refcounting is not 0.These modifications will need some code reorganization and rewrite which does not fit with a fix.
I agree.
Quoted 2 lines
The following patch is a hot fix by returning to the initial behavior by removing the lock when getting the driver.
Quoted 7 lines
The patch fixes the problem. Verified on a system with 1024 cpus. Thanks.
Quoted 1 line
Signed-off-by Daniel Lezcano <[email protected]>Reported-by Russ Anderson <[email protected]>Acked-by Russ Anderson <[email protected]>
Hi Rafael,
could you consider this patch for merging ?
Thanks
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 36 lines · Daniel Lezcano
Quoted 35 lines · Russ Anderson
Quoted 18 lines · Daniel Lezcano
The commit
bf4d1b5ddb78f86078ac6ae0415802d5f0c68f92introduces a lock in thecpuidle_get_cpu_driverfunction. This function is used in theidle_callfunction.The problem is the contention with a large number of cpus because they try to access the idle routine at the same time.
The lock could be safely removed because of how is used the cpuidle api. The
cpuidle_register_driveris called first but until thecpuidle_register_deviceis not called we don't enter in the cpuidle idle call function because the device is not enabled.The
cpuidle_unregister_driverfunction, leading the a NULL driver, is not called before thecpuidle_unregister_device.This is how is used the cpuidle api from the different drivers.
Quoted 7 lines
However, a cleanup around the lock and a proper refcounting mechanism should be used to ensure the consistency in the api, like
cpuidle_unregister_drivershould failed if its refcounting is not 0.These modifications will need some code reorganization and rewrite which does not fit with a fix.
I agree.
Quoted 2 lines
The following patch is a hot fix by returning to the initial behavior by removing the lock when getting the driver.
The patch fixes the problem. Verified on a system with 1024 cpus. Thanks.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Daniel Lezcano <[email protected]>Reported-by Russ Anderson <[email protected]>Acked-by Russ Anderson <[email protected]>Hi Rafael,
could you consider this patch for merging ?
Yes, I've taken it already.
I'll include it into the next pull request.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
[ ... ]
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines
The following patch is a hot fix by returning to the initial behavior by removing the lock when getting the driver.
The patch fixes the problem. Verified on a system with 1024 cpus. Thanks.
Quoted 1 line
Signed-off-by Daniel Lezcano <[email protected]>Reported-by Russ Anderson <[email protected]>Acked-by Russ Anderson <[email protected]>
Quoted 7 lines
Quoted 3 lines
Hi Rafael,
could you consider this patch for merging ?
Yes, I've taken it already.
I'll include it into the next pull request.
Ok, thanks.
I noticed you rephrased the changelog. Thanks for that also.
-- Daniel
Signature · 14 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog * English - detected * English * French * English * French <javascript:void(0);> <#>