[PATCH] use _smp_processor_id() in idle loops

Nathan Lynch nathanl at austin.ibm.com
Fri Jan 28 09:23:45 EST 2005


With 2.6.11-rc2-mm1 and 2.6-bk kernels with CONFIG_DEBUG_PREEMPT I'm
seeing lots of smp_processor_id warnings from the idle loops:

BUG: using smp_processor_id() in preemptible [00000001] code:
swapper/0
caller is .dedicated_idle+0x64/0x228
Call Trace:
[c0000000004a3c50] [ffffffffffffffff] 0xffffffffffffffff (unreliable)
[c0000000004a3cd0] [c0000000001d179c] .smp_processor_id+0x154/0x168
[c0000000004a3d90] [c00000000000f990] .dedicated_idle+0x64/0x228
[c0000000004a3e80] [c00000000000fce0] .cpu_idle+0x34/0x4c
[c0000000004a3f00] [c00000000003a908] .start_secondary+0x10c/0x150
[c0000000004a3f90] [c00000000000bd28] .enable_64b_mode+0x0/0x28

This patch replaces smp_processor_id() with _smp_processor_id() in the
idle loop code, since we know the idle thread can't jump to a
different cpu.

Signed-off-by: Nathan Lynch <nathanl at austin.ibm.com>


---


diff -puN arch/ppc64/kernel/idle.c~kill-idle-loop-smp_processor_id-warnings arch/ppc64/kernel/idle.c
--- linux-2.6.11-rc2-mm1/arch/ppc64/kernel/idle.c~kill-idle-loop-smp_processor_id-warnings	2005-01-27 16:14:31.000000000 -0600
+++ linux-2.6.11-rc2-mm1-nathanl/arch/ppc64/kernel/idle.c	2005-01-27 16:14:31.000000000 -0600
@@ -122,7 +122,7 @@ static int iSeries_idle(void)
 static int default_idle(void)
 {
 	long oldval;
-	unsigned int cpu = smp_processor_id();
+	unsigned int cpu = _smp_processor_id();
 
 	while (1) {
 		oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
@@ -164,7 +164,7 @@ int dedicated_idle(void)
 	struct paca_struct *lpaca = get_paca(), *ppaca;
 	unsigned long start_snooze;
 	unsigned long *smt_snooze_delay = &__get_cpu_var(smt_snooze_delay);
-	unsigned int cpu = smp_processor_id();
+	unsigned int cpu = _smp_processor_id();
 
 	ppaca = &paca[cpu ^ 1];
 
@@ -244,7 +244,7 @@ int dedicated_idle(void)
 static int shared_idle(void)
 {
 	struct paca_struct *lpaca = get_paca();
-	unsigned int cpu = smp_processor_id();
+	unsigned int cpu = _smp_processor_id();
 
 	while (1) {
 		/*
@@ -275,8 +275,7 @@ static int shared_idle(void)
 		HMT_medium();
 		lpaca->lppaca.idle = 0;
 		schedule();
-		if (cpu_is_offline(smp_processor_id()) &&
-		    system_state == SYSTEM_RUNNING)
+		if (cpu_is_offline(cpu) && system_state == SYSTEM_RUNNING)
 			cpu_die();
 	}
 

_





More information about the Linuxppc64-dev mailing list