Skip to contentSkip to conversation

powerpc: check_and_cede_processor never cedes

PATCH In review Anton Blanchard 2 participants 4 messages Jun 27, 2012 – Jun 28, 2012 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: check_and_cede_processor never cedes

Commit f948501b36c6 ("Make hard_irq_disable() actually hard-disable interrupts") caused check_and_cede_processor to stop working. ->irq_happened will never be zero right after a hard_irq_disable so the compiler removes the call to cede_processor completely.

The bug was introduced back in the lazy interrupt handling rework of 3.4 but was hidden until recently because hard_irq_disable did nothing.

This issue will eventually appear in 3.4 stable since the hard_irq_disable fix is marked stable, so mark this one for stable too.

---

arch/powerpc/platforms/pseries/processor_idle.c +1 -1
Index: linux-build/arch/powerpc/platforms/pseries/processor_idle.c
===================================================================
@@ -106,7 +106,7 @@ static void check_and_cede_processor(voi
 	 * we first hard disable then check.
 	 */
 	hard_irq_disable();
-	if (get_paca()->irq_happened == 0)
+	if (get_paca()->irq_happened == PACA_IRQ_HARD_DIS)
 		cede_processor();
 }
 
#1 lore raw

arch/powerpc/platforms/pseries/processor_idle.c static void check_and_cede_processor(voi · line 110

Quoted 4 lines · Anton Blanchard
arch/powerpc/platforms/pseries/processor_idle.c +1 -1
 	hard_irq_disable();
-	if (get_paca()->irq_happened == 0)
+	if (get_paca()->irq_happened == PACA_IRQ_HARD_DIS)
 		cede_processor();

I'd rather add a helper, something like lazy_irq_pending() and hide the actual check for the bits in irq_happened, in case we change the scheme again.

Something like:

static inline bool lazy_irq_pending(void)

{
	return !!(get_paca()->irq_happened & ~PACA_IRQ_HARD_DIS);
}

Cheers,
Ben.

#2 lore raw

PATCH 1/1 powerpc: check_and_cede_processor never cedes

Hi,

Quoted 3 lines

I'd rather add a helper, something like lazy_irq_pending() and hide the actual check for the bits in irq_happened, in case we change the scheme again.

Good idea. Look ok?

--

Commit f948501b36c6 ("Make hard_irq_disable() actually hard-disable interrupts") caused check_and_cede_processor to stop working. ->irq_happened will never be zero right after a hard_irq_disable so the compiler removes the call to cede_processor completely.

The bug was introduced back in the lazy interrupt handling rework of 3.4 but was hidden until recently because hard_irq_disable did nothing.

This issue will eventually appear in 3.4 stable since the hard_irq_disable fix is marked stable, so mark this one for stable too.

---

v2: create a helper, suggested by Ben.

arch/powerpc/platforms/pseries/processor_idle.c +1 -1
Index: linux-build/arch/powerpc/platforms/pseries/processor_idle.c
===================================================================
@@ -106,7 +106,7 @@ static void check_and_cede_processor(voi
 	 * we first hard disable then check.
 	 */
 	hard_irq_disable();
-	if (get_paca()->irq_happened == 0)
+	if (!lazy_irq_pending())
 		cede_processor();
 }
 
arch/powerpc/include/asm/hw_irq.h +5 -0
Index: linux-build/arch/powerpc/include/asm/hw_irq.h
===================================================================
@@ -103,6 +103,11 @@ static inline void hard_irq_disable(void
 /* include/linux/interrupt.h needs hard_irq_disable to be a macro */
 #define hard_irq_disable	hard_irq_disable
 
+static inline bool lazy_irq_pending(void)
+{
+	return !!(get_paca()->irq_happened & ~PACA_IRQ_HARD_DIS);
+}
+
 /*
  * This is called by asynchronous interrupts to conditionally
  * re-enable hard interrupts when soft-disabled after having
#3 lore raw
Quoted 15 lines · Anton Blanchard

Hi,

Quoted 3 lines

I'd rather add a helper, something like lazy_irq_pending() and hide the actual check for the bits in irq_happened, in case we change the scheme again.

Good idea. Look ok?

--

Commit f948501b36c6 ("Make hard_irq_disable() actually hard-disable interrupts") caused check_and_cede_processor to stop working. ->irq_happened will never be zero right after a hard_irq_disable so the compiler removes the call to cede_processor completely.

Quoted 7 lines

The bug was introduced back in the lazy interrupt handling rework of 3.4 but was hidden until recently because hard_irq_disable did nothing.

This issue will eventually appear in 3.4 stable since the hard_irq_disable fix is marked stable, so mark this one for stable too.

Yup, looks good, I'll send to Linus tomorrow.

Cheers,
Ben.

Quoted 35 lines

---

v2: create a helper, suggested by Ben.

Index: linux-build/arch/powerpc/platforms/pseries/processor_idle.c
===================================================================

arch/powerpc/platforms/pseries/processor_idle.c +1 -1
@@ -106,7 +106,7 @@ static void check_and_cede_processor(voi
 	 * we first hard disable then check.
 	 */
 	hard_irq_disable();
-	if (get_paca()->irq_happened == 0)
+	if (!lazy_irq_pending())
 		cede_processor();
 }
 

Index: linux-build/arch/powerpc/include/asm/hw_irq.h
===================================================================

arch/powerpc/include/asm/hw_irq.h +5 -0
@@ -103,6 +103,11 @@ static inline void hard_irq_disable(void
 /* include/linux/interrupt.h needs hard_irq_disable to be a macro */
 #define hard_irq_disable	hard_irq_disable
 
+static inline bool lazy_irq_pending(void)
+{
+	return !!(get_paca()->irq_happened & ~PACA_IRQ_HARD_DIS);
+}
+
 /*
  * This is called by asynchronous interrupts to conditionally
  * re-enable hard interrupts when soft-disabled after having