Skip to contentSkip to conversation

cpuidle regression ?

PATCH New Daniel Lezcano 3 participants 10 messages Dec 8, 2019 – Dec 10, 2019 CPU idle time management framework

lore
Share & tools
lore
#0 lore raw

Hi Rafael,

the latest linux-next kernelci report indicates a kernel bug for the imx6 platform. I don't have this board so it is not possible to investigate it.

https://storage.kernelci.org/next/master/next-20191208/arm/multi_v7_defconfig/gcc-8/lab-collabora/boot-imx6q-sabrelite.html

[ ... ]

[    3.372501] Unable to handle kernel NULL pointer dereference at

virtual address 00000000

[ ... ]

[    3.408898] PC is at _find_first_bit_le+0xc/0x2c
[    3.413785] LR is at cpuidle_driver_state_disabled+0x40/0xa0

Not sure if it is related to the latest changes or not.

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
#1 lore raw
Quoted 15 lines · Daniel Lezcano

Hi Rafael,

the latest linux-next kernelci report indicates a kernel bug for the imx6 platform. I don't have this board so it is not possible to investigate it.

https://storage.kernelci.org/next/master/next-20191208/arm/multi_v7_defconfig/gcc-8/lab-collabora/boot-imx6q-sabrelite.html

[ ... ]

[    3.372501] Unable to handle kernel NULL pointer dereference at

virtual address 00000000

Quoted 7 lines

[ ... ]

[    3.408898] PC is at _find_first_bit_le+0xc/0x2c
[    3.413785] LR is at cpuidle_driver_state_disabled+0x40/0xa0

Not sure if it is related to the latest changes or not.

It does seem so, in which case the attached patch should address it.

Is there a way to test the patch alone or do I need to push it somewhere to be tested?

---
 drivers/cpuidle/driver.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/cpuidle/driver.c +10 -0
Index: linux-pm/drivers/cpuidle/driver.c
===================================================================
@@ -403,6 +403,13 @@ void cpuidle_driver_state_disabled(struc
 
 	mutex_lock(&cpuidle_lock);
 
+	spin_lock(&cpuidle_driver_lock);
+
+	if (!drv->cpumask) {
+		drv->states[idx].flags |= CPUIDLE_FLAG_UNUSABLE;
+		goto unlock;
+	}
+
 	for_each_cpu(cpu, drv->cpumask) {
 		struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
 
@@ -415,5 +422,8 @@ void cpuidle_driver_state_disabled(struc
 			dev->states_usage[idx].disable &= ~CPUIDLE_STATE_DISABLED_BY_DRIVER;
 	}
 
+unlock:
+	spin_unlock(&cpuidle_driver_lock);
+
 	mutex_unlock(&cpuidle_lock);
 }
#2 lore raw
Quoted 23 lines · Rafael J. Wysocki
Quoted 21 lines · Daniel Lezcano

Hi Rafael,

the latest linux-next kernelci report indicates a kernel bug for the imx6 platform. I don't have this board so it is not possible to investigate it.

https://storage.kernelci.org/next/master/next-20191208/arm/multi_v7_defconfig/gcc-8/lab-collabora/boot-imx6q-sabrelite.html

[ ... ]

[    3.372501] Unable to handle kernel NULL pointer dereference at

virtual address 00000000

[ ... ]

[    3.408898] PC is at _find_first_bit_le+0xc/0x2c
[    3.413785] LR is at cpuidle_driver_state_disabled+0x40/0xa0
Quoted 6 lines
Quoted 1 line

Not sure if it is related to the latest changes or not.

It does seem so, in which case the attached patch should address it.

Is there a way to test the patch alone or do I need to push it somewhere to be tested?

Is the bleeding-edge branch monitored by kernelci ?

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
#3 lore raw
Quoted 25 lines · Daniel Lezcano
Quoted 23 lines · Rafael J. Wysocki
Quoted 21 lines · Daniel Lezcano

Hi Rafael,

the latest linux-next kernelci report indicates a kernel bug for the imx6 platform. I don't have this board so it is not possible to investigate it.

https://storage.kernelci.org/next/master/next-20191208/arm/multi_v7_defconfig/gcc-8/lab-collabora/boot-imx6q-sabrelite.html

[ ... ]

[    3.372501] Unable to handle kernel NULL pointer dereference at

virtual address 00000000

[ ... ]

[    3.408898] PC is at _find_first_bit_le+0xc/0x2c
[    3.413785] LR is at cpuidle_driver_state_disabled+0x40/0xa0
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Not sure if it is related to the latest changes or not.

It does seem so, in which case the attached patch should address it.

Is there a way to test the patch alone or do I need to push it somewhere to be tested?

Is the bleeding-edge branch monitored by kernelci ?

No, it is not right now, AFAICS.

#4 lore raw
Quoted 29 lines · Rafael J. Wysocki
Quoted 27 lines · Daniel Lezcano
Quoted 25 lines · Rafael J. Wysocki
Quoted 22 lines · Daniel Lezcano

Hi Rafael,

the latest linux-next kernelci report indicates a kernel bug for the imx6 platform. I don't have this board so it is not possible to investigate it.

https://storage.kernelci.org/next/master/next-20191208/arm/multi_v7_defconfig/gcc-8/lab-collabora/boot-imx6q-sabrelite.html

[ ... ]

[    3.372501] Unable to handle kernel NULL pointer dereference at

virtual address 00000000

[ ... ]

[    3.408898] PC is at _find_first_bit_le+0xc/0x2c
[    3.413785] LR is at cpuidle_driver_state_disabled+0x40/0xa0

Not sure if it is related to the latest changes or not.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

It does seem so, in which case the attached patch should address it.

Is there a way to test the patch alone or do I need to push it somewhere to be tested?

Is the bleeding-edge branch monitored by kernelci ?

No, it is not right now, AFAICS.

I have a imx7, I will try to reproduce the issue on it. Otherwise, I can test on the 'testing' thermal branch temporarily.

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
#5 lore raw
Quoted 36 lines · Daniel Lezcano
Quoted 34 lines · Rafael J. Wysocki
Quoted 32 lines · Daniel Lezcano
Quoted 29 lines · Rafael J. Wysocki
Quoted 15 lines · Daniel Lezcano

Hi Rafael,

the latest linux-next kernelci report indicates a kernel bug for the imx6 platform. I don't have this board so it is not possible to investigate it.

https://storage.kernelci.org/next/master/next-20191208/arm/multi_v7_defconfig/gcc-8/lab-collabora/boot-imx6q-sabrelite.html

[ ... ]

[    3.372501] Unable to handle kernel NULL pointer dereference at

virtual address 00000000

Quoted 7 lines

[ ... ]

[    3.408898] PC is at _find_first_bit_le+0xc/0x2c
[    3.413785] LR is at cpuidle_driver_state_disabled+0x40/0xa0

Not sure if it is related to the latest changes or not.

It does seem so, in which case the attached patch should address it.

Is there a way to test the patch alone or do I need to push it somewhere to be tested?

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Is the bleeding-edge branch monitored by kernelci ?

No, it is not right now, AFAICS.

I have a imx7, I will try to reproduce the issue on it. Otherwise, I can test on the 'testing' thermal branch temporarily.

Thanks, that'll help!

#6 lore raw
Quoted 38 lines · Rafael J. Wysocki
Quoted 36 lines · Daniel Lezcano
Quoted 34 lines · Rafael J. Wysocki
Quoted 32 lines · Daniel Lezcano
Quoted 29 lines · Rafael J. Wysocki
Quoted 15 lines · Daniel Lezcano

Hi Rafael,

the latest linux-next kernelci report indicates a kernel bug for the imx6 platform. I don't have this board so it is not possible to investigate it.

https://storage.kernelci.org/next/master/next-20191208/arm/multi_v7_defconfig/gcc-8/lab-collabora/boot-imx6q-sabrelite.html

[ ... ]

[    3.372501] Unable to handle kernel NULL pointer dereference at

virtual address 00000000

Quoted 7 lines

[ ... ]

[    3.408898] PC is at _find_first_bit_le+0xc/0x2c
[    3.413785] LR is at cpuidle_driver_state_disabled+0x40/0xa0

Not sure if it is related to the latest changes or not.

It does seem so, in which case the attached patch should address it.

Is there a way to test the patch alone or do I need to push it somewhere to be tested?

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Is the bleeding-edge branch monitored by kernelci ?

No, it is not right now, AFAICS.

I have a imx7, I will try to reproduce the issue on it. Otherwise, I can test on the 'testing' thermal branch temporarily.

Thanks, that'll help!

The imx7 kernel has an issue with cpuidle but not related to your changes, so I was unable to double check with a local board.

However, kernelci does no longer report a regression on the baseline with your patch applied on my 'testing' branch.

I can not guarantee the bug is fixed because I can't reproduce it locally and check the patch is effectively solving the issue.

In order to increase the confidence on the fix, I updated the branch without your patch, so in a few hours, we should see the if the regression appears or not.

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
#7 lore raw

On 09/12/2019 18:22, Daniel Lezcano wrote:

[ ... ]

Quoted 9 lines

However, kernelci does no longer report a regression on the baseline with your patch applied on my 'testing' branch.

I can not guarantee the bug is fixed because I can't reproduce it locally and check the patch is effectively solving the issue.

In order to increase the confidence on the fix, I updated the branch without your patch, so in a few hours, we should see the if the regression appears or not.

The regression came back without the patch.

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
#8 lore raw
Quoted 8 lines · Daniel Lezcano

On 09/12/2019 18:22, Daniel Lezcano wrote:

[ ... ]

Quoted 3 lines

However, kernelci does no longer report a regression on the baseline with your patch applied on my 'testing' branch.

Quoted 8 lines
Quoted 6 lines

I can not guarantee the bug is fixed because I can't reproduce it locally and check the patch is effectively solving the issue.

In order to increase the confidence on the fix, I updated the branch without your patch, so in a few hours, we should see the if the regression appears or not.

The regression came back without the patch.

OK, thanks!

I'll post the patch properly then and queue it up as a regression fix.

#9 lore raw

PATCH 1/1 cpuidle: Fix cpuidle_driver_state_disabled()

In reply to Daniel Lezcano

From: Rafael J. Wysocki <[email protected]>

It turns out that cpuidle_driver_state_disabled() can be called before registering the cpufreq driver on some platforms, which was not expected when it was introduced and which leads to a NULL pointer dereference when trying to walk the CPUs associated with the given cpuidle driver.

Fix the problem by making cpuidle_driver_state_disabled() check if the driver's mask of CPUs associated with it is present and to set CPUIDLE_FLAG_UNUSABLE for the given idle state in the driver's states list if that is not the case to cause __cpuidle_register_device() to set CPUIDLE_STATE_DISABLED_BY_DRIVER for that state for all cpuidle devices registered by it later.

Fixes cbda56d5fefc ("cpuidle: Introduce cpuidle_driver_state_disabled() for driver quirks")
---
 drivers/cpuidle/driver.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/cpuidle/driver.c +10 -0
Index: linux-pm/drivers/cpuidle/driver.c
===================================================================
@@ -403,6 +403,13 @@ void cpuidle_driver_state_disabled(struc
 
 	mutex_lock(&cpuidle_lock);
 
+	spin_lock(&cpuidle_driver_lock);
+
+	if (!drv->cpumask) {
+		drv->states[idx].flags |= CPUIDLE_FLAG_UNUSABLE;
+		goto unlock;
+	}
+
 	for_each_cpu(cpu, drv->cpumask) {
 		struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
 
@@ -415,5 +422,8 @@ void cpuidle_driver_state_disabled(struc
 			dev->states_usage[idx].disable &= ~CPUIDLE_STATE_DISABLED_BY_DRIVER;
 	}
 
+unlock:
+	spin_unlock(&cpuidle_driver_lock);
+
 	mutex_unlock(&cpuidle_lock);
 }