public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH UPDATED 04/16] x86: Use local variable to cache smp_processor_id() in setup_local_APIC()
  2010-11-27 15:21 ` [PATCH 04/16] x86: Use local variable to cache smp_processor_id() in setup_local_APIC() Tejun Heo
@ 2010-11-30 16:17   ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2010-11-30 16:17 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: linux-kernel, mingo, tglx, hpa, x86, eric.dumazet, yinghai,
	brgerst, gorcunov, penberg

Subject: x86: Use local variable to cache smp_processor_id() in setup_local_APIC()

This is a trivial clean up.

* Move initialization of @cpu inside preemption disabled region as
  suggested by Cyrill Gorcunov.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
---
Updated as suggested.  Git tree updated too.

Thanks.

 arch/x86/kernel/apic/apic.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Index: work/arch/x86/kernel/apic/apic.c
===================================================================
--- work.orig/arch/x86/kernel/apic/apic.c
+++ work/arch/x86/kernel/apic/apic.c
@@ -1202,7 +1202,7 @@ static void __cpuinit lapic_setup_esr(vo
 void __cpuinit setup_local_APIC(void)
 {
 	unsigned int value, queued;
-	int i, j, acked = 0;
+	int cpu, i, j, acked = 0;
 	unsigned long long tsc = 0, ntsc;
 	long long max_loops = cpu_khz;

@@ -1226,6 +1226,7 @@ void __cpuinit setup_local_APIC(void)
 	perf_events_lapic_init();

 	preempt_disable();
+	cpu = smp_processor_id();

 	/*
 	 * Double-check whether this APIC is really registered.
@@ -1342,21 +1343,19 @@ void __cpuinit setup_local_APIC(void)
 	 * TODO: set up through-local-APIC from through-I/O-APIC? --macro
 	 */
 	value = apic_read(APIC_LVT0) & APIC_LVT_MASKED;
-	if (!smp_processor_id() && (pic_mode || !value)) {
+	if (!cpu && (pic_mode || !value)) {
 		value = APIC_DM_EXTINT;
-		apic_printk(APIC_VERBOSE, "enabled ExtINT on CPU#%d\n",
-				smp_processor_id());
+		apic_printk(APIC_VERBOSE, "enabled ExtINT on CPU#%d\n", cpu);
 	} else {
 		value = APIC_DM_EXTINT | APIC_LVT_MASKED;
-		apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n",
-				smp_processor_id());
+		apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n", cpu);
 	}
 	apic_write(APIC_LVT0, value);

 	/*
 	 * only the BP should see the LINT1 NMI signal, obviously.
 	 */
-	if (!smp_processor_id())
+	if (!cpu)
 		value = APIC_DM_NMI;
 	else
 		value = APIC_DM_NMI | APIC_LVT_MASKED;
@@ -1368,7 +1367,7 @@ void __cpuinit setup_local_APIC(void)

 #ifdef CONFIG_X86_MCE_INTEL
 	/* Recheck CMCI information after local APIC is up on CPU #0 */
-	if (smp_processor_id() == 0)
+	if (cpu == 0)
 		cmci_recheck();
 #endif
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH UPDATED 04/16] x86: Use local variable to cache smp_processor_id() in setup_local_APIC()
@ 2010-11-30 17:32 Cyrill Gorcunov
  0 siblings, 0 replies; 2+ messages in thread
From: Cyrill Gorcunov @ 2010-11-30 17:32 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-kernel, mingo, tglx, hpa, x86, eric.dumazet, yinghai,
	brgerst, penberg

On Tue, Nov 30, 2010 at 05:17:19PM +0100, Tejun Heo wrote:
> Subject: x86: Use local variable to cache smp_processor_id() in setup_local_APIC()
> 
> This is a trivial clean up.
> 
> * Move initialization of @cpu inside preemption disabled region as
>   suggested by Cyrill Gorcunov.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Yinghai Lu <yinghai@kernel.org>
> Cc: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
> Updated as suggested.  Git tree updated too.
> 
> Thanks.
> 

Thanks Tejun, but please don't modify the snippet below
(ie leave it with smp_processor_id). It happens when preempt
gets enabled again but cpu cached with preempt disabled.
So we should not mess this I believe. ok?

Other than that
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>

Thanks!

> @@ -1368,7 +1367,7 @@ void __cpuinit setup_local_APIC(void)
> 
>  #ifdef CONFIG_X86_MCE_INTEL
>  	/* Recheck CMCI information after local APIC is up on CPU #0 */
> -	if (smp_processor_id() == 0)
> +	if (cpu == 0)
>  		cmci_recheck();
>  #endif
>  }
> 
  Cyrill

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-30 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-30 17:32 [PATCH UPDATED 04/16] x86: Use local variable to cache smp_processor_id() in setup_local_APIC() Cyrill Gorcunov
  -- strict thread matches above, loose matches on Subject: below --
2010-11-27 15:21 [PATCHSET] x86: unify x86_32 and 64 NUMA init paths, take#2 Tejun Heo
2010-11-27 15:21 ` [PATCH 04/16] x86: Use local variable to cache smp_processor_id() in setup_local_APIC() Tejun Heo
2010-11-30 16:17   ` [PATCH UPDATED " Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox