Skip to contentSkip to conversation

powerpc/pseries: fix idle sleep early exit state

PATCH In review Sebastien Dugue 2 participants 3 messages Nov 27, 2008 – Dec 3, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/pseries: fix idle sleep early exit state

In pseries_dedicated_idle_sleep(), if we need to exit idle during the
snooze period (i.e. need_resched or cpu has been offlined), then we should re-disable the interrupts and clear TIF_POLLING_NRFLAG before leaving.

---
 arch/powerpc/platforms/pseries/setup.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/setup.c +8 -2
index ec34170..8270f04 100644
@@ -504,8 +504,13 @@ static void pseries_dedicated_idle_sleep(void)
 		set_thread_flag(TIF_POLLING_NRFLAG);
 
 		while (get_tb() < start_snooze) {
-			if (need_resched() || cpu_is_offline(cpu))
-				goto out;
+			if (need_resched() || cpu_is_offline(cpu)) {
+				HMT_medium();
+				clear_thread_flag(TIF_POLLING_NRFLAG);
+				smp_mb();
+				local_irq_disable();
+				goto out2;
+			}
 			ppc64_runlatch_off();
 			HMT_low();
 			HMT_very_low();
@@ -523,6 +528,7 @@ static void pseries_dedicated_idle_sleep(void)
 
 out:
 	HMT_medium();
+out2:
 	out_purr = mfspr(SPRN_PURR);
 	get_lppaca()->wait_state_cycles += out_purr - in_purr;
 	get_lppaca()->donate_dedicated_cpu = 0;
Signature · 1 line
1.6.0.1.308.gede4c
#1 lore raw
Quoted 3 lines · Sebastien Dugue

In pseries_dedicated_idle_sleep(), if we need to exit idle during the
snooze period (i.e. need_resched or cpu has been offlined), then we should re-disable the interrupts and clear TIF_POLLING_NRFLAG before leaving.

Are you doing this because of a bug you actually observed, or did you just find this by inspection? I don't believe it's necessary to do these things (disabling interrupts, clearing TIF_POLLING_NRFLAG) because the code that calls it immediately reenables interrupts and sets TIF_POLLING_NRFLAG again. From arch/powerpc/kernel/idle.c (line 73):

				if (!need_resched() && !cpu_should_die())
					ppc_md.power_save();

				local_irq_enable();
				set_thread_flag(TIF_POLLING_NRFLAG);

Paul.

#2 lore raw
Quoted 8 lines · On Wed, 3 Dec 2008 20:38:54 +1100 Paul Mackerras <[email protected]> wrote:
Quoted 3 lines · Sebastien Dugue

In pseries_dedicated_idle_sleep(), if we need to exit idle during the
snooze period (i.e. need_resched or cpu has been offlined), then we should re-disable the interrupts and clear TIF_POLLING_NRFLAG before leaving.

Are you doing this because of a bug you actually observed, or did you just find this by inspection?

By inspection, and just to be consistent with the other way out. But
you're right, it's not really necessary here.

Quoted 6 lines

I don't believe it's necessary to do
these things (disabling interrupts, clearing TIF_POLLING_NRFLAG) because the code that calls it immediately reenables interrupts and sets TIF_POLLING_NRFLAG again. From arch/powerpc/kernel/idle.c (line 73):

Quoted 8 lines
				if (!need_resched() && !cpu_should_die())
					ppc_md.power_save();

				local_irq_enable();
				set_thread_flag(TIF_POLLING_NRFLAG);

Paul.

Thanks,

Sebastien.