ARM: Add BUG_ON when hlt counter is wrongly used
PATCH 1/1 ARM: Add BUG_ON when hlt counter is wrongly used
From: fwu <[email protected]>
1. On ARM platform, "nohlt" can be used to prevent core from idle process, returning immediately.
2. There are two interfaces, exported for other modules, named "disable_hlt" and "enable_hlt" are used to enable/disable the cpuidle mechanism by increasing/decreasing "hlt_counter". Disable_hlt and enable_hlt are paired operation,
when you first call disable_hlt and then enable_hlt, the semantics are right.
3. There is no obvious constraint to prevent user(driver/module) code to prevent the case that enable_hlt is ahead of disable_hlt, which is a fatal operation on kernel state change from user, and there is no any WARNING or notification if the case happens in current kernel code.
This patch aims to report BUG when the case happens, just like what the kernel do when enable_irq is ahead of disable_irq.
Change-Id: Iddacf45aec012bb663e130801727b4eb3d11436b
--- arch/arm/kernel/process.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/kernel/process.c +1 -0
@@ -70,6 +70,7 @@ EXPORT_SYMBOL(disable_hlt);void enable_hlt (void ) { hlt_counter--; + BUG_ON(hlt_counter < 0) }EXPORT_SYMBOL (enable_hlt);
Signature · 1 line
1.7.0.4
PATCH 1/1 ARM: Add BUG_ON when hlt counter is wrongly used
Quoted 18 lines · Fan Wu
From: fwu <[email protected]>
1. On ARM platform, "nohlt" can be used to prevent core from idle process, returning immediately.
2. There are two interfaces, exported for other modules, named "disable_hlt" and "enable_hlt" are used to enable/disable the cpuidle mechanism by increasing/decreasing "hlt_counter".Disable_hltandenable_hltare paired operation,
when you first calldisable_hltand thenenable_hlt, the semantics are right.
3. There is no obvious constraint to prevent user(driver/module) code to prevent the case thatenable_hltis ahead ofdisable_hlt, which is a fatal operation on kernel state change from user, and there is no any WARNING or notification if the case happens in current kernel code.
This patch aims to report BUG when the case happens, just like what the kernel do whenenable_irqis ahead ofdisable_irq.
Quoted 3 lines
Signed-off-by fwu <[email protected]>Signed-off-by YiLu Mao <[email protected]>Signed-off-by Ning Jiang <[email protected]>
This looks sensible to me.
Quoted 1 line
Change-Id: Iddacf45aec012bb663e130801727b4eb3d11436b
Please don't forget to strip that when submitting your patch to Russell's patch system.
Quoted 19 lines
--- arch/arm/kernel/process.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)arch/arm/kernel/process.c +1
-0@@ -70,6 +70,7 @@ EXPORT_SYMBOL(disable_hlt);void enable_hlt (void ) { hlt_counter--; + BUG_ON(hlt_counter < 0) }EXPORT_SYMBOL (enable_hlt);Signature · 1 line
1.7.0.4
PATCH 1/1 ARM: Add BUG_ON when hlt counter is wrongly used
Quoted 46 lines · Nicolas Pitre
Quoted 18 lines · Fan Wu
From: fwu <[email protected]>
1. On ARM platform, "nohlt" can be used to prevent core from idle process, returning immediately.
2. There are two interfaces, exported for other modules, named "disable_hlt" and "enable_hlt" are used to enable/disable the cpuidle mechanism by increasing/decreasing "hlt_counter".Disable_hltandenable_hltare paired operation,
when you first calldisable_hltand thenenable_hlt, the semantics are right.
3. There is no obvious constraint to prevent user(driver/module) code to prevent the case thatenable_hltis ahead ofdisable_hlt, which is a fatal operation on kernel state change from user, and there is no any WARNING or notification if the case happens in current kernel code.
This patch aims to report BUG when the case happens, just like what the kernel do whenenable_irqis ahead ofdisable_irq.Quoted 3 lines
Signed-off-by fwu <[email protected]>Signed-off-by YiLu Mao <[email protected]>Signed-off-by Ning Jiang <[email protected]>This looks sensible to me.
Acked-by Nicolas Pitre <[email protected]>Quoted 1 line
Change-Id: Iddacf45aec012bb663e130801727b4eb3d11436b
Please don't forget to strip that when submitting your patch to Russell's patch system.
Quoted 15 lines
--- arch/arm/kernel/process.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)arch/arm/kernel/process.c +1
-0@@ -70,6 +70,7 @@ EXPORT_SYMBOL(disable_hlt);void enable_hlt (void ) { hlt_counter--; + BUG_ON(hlt_counter < 0) }
Quoted 4 lines
Quoted 4 lines
arch/arm/kernel/process.c +0
-0EXPORT_SYMBOL (enable_hlt);Signature · 1 line
1.7.0.4
Thanks a lot for reviewing the patch.
I'll remove that in the new patch version.
Thanks again.