List Info

Thread: Use ar.kr2 for smp_processor_id




Use ar.kr2 for smp_processor_id
user name
2007-02-07 21:28:44
Pin ar.kr2 of each CPU, so that smp_processor_id can use
it.
This will save some memory foot-print when
smp_procerror_id() 
is called.

This is also useful for implement sys_getcpu in fast path.

I have simply tested the patch by boot on a 16p system then
try 
offline and online some CPUs through /sys/.
 

Signed-off-by: Zou Nan hai <nanhai.zouintel.com>


diff -Nraup linux-2.6.20/arch/ia64/kernel/setup.c
b/arch/ia64/kernel/setup.c
--- linux-2.6.20/arch/ia64/kernel/setup.c	2007-02-04
13:44:54.000000000 -0500
+++ b/arch/ia64/kernel/setup.c	2007-02-07 23:30:03.000000000
-0500
 -458,6
+458,9  early_param("elfcorehdr", parse_elfcoreh
 void __init
 setup_arch (char **cmdline_p)
 {
+	/* setup SMP processor id */
+	ia64_set_kr(IA64_KR_CPU_ID,
(current_thread_info()->cpu));
+
 	unw_init();
 
 	ia64_patch_vtop((u64) __start___vtop_patchlist, (u64)
__end___vtop_patchlist);
diff -Nraup linux-2.6.20/arch/ia64/kernel/smpboot.c
b/arch/ia64/kernel/smpboot.c
--- linux-2.6.20/arch/ia64/kernel/smpboot.c	2007-02-04
13:44:54.000000000 -0500
+++ b/arch/ia64/kernel/smpboot.c	2007-02-07
23:29:44.000000000 -0500
 -445,8
+445,12  smp_callin (void)
 int __devinit
 start_secondary (void *unused)
 {
+	/* setup SMP processor id */
+	ia64_set_kr(IA64_KR_CPU_ID,
(current_thread_info()->cpu));
+	
 	/* Early console may use I/O ports */
 	ia64_set_kr(IA64_KR_IO_BASE, __pa(ia64_iobase));
+
 	Dprintk("start_secondary: starting CPU 0x%xn",
hard_smp_processor_id());
 	efi_map_pal_code();
 	cpu_init();
diff -Nraup linux-2.6.20/include/asm-ia64/kregs.h
b/include/asm-ia64/kregs.h
--- linux-2.6.20/include/asm-ia64/kregs.h	2007-02-04
13:44:54.000000000 -0500
+++ b/include/asm-ia64/kregs.h	2007-02-07 23:28:21.000000000
-0500
 -14,6
+14,7 
  */
 #define IA64_KR_IO_BASE		0	/* ar.k0: legacy I/O base
address */
 #define IA64_KR_TSSD		1	/* ar.k1: IVE uses this as the TSSD
*/
+#define IA64_KR_CPU_ID		2	/* ar.k2: Processor ID */
 #define IA64_KR_PER_CPU_DATA	3	/* ar.k3: physical per-CPU
base */
 #define IA64_KR_CURRENT_STACK	4	/* ar.k4: what's mapped in
IA64_TR_CURRENT_STACK */
 #define IA64_KR_FPU_OWNER	5	/* ar.k5: fpu-owner (UP only,
at the moment) */
diff -Nraup linux-2.6.20/include/asm-ia64/smp.h
b/include/asm-ia64/smp.h
--- linux-2.6.20/include/asm-ia64/smp.h	2007-02-04
13:44:54.000000000 -0500
+++ b/include/asm-ia64/smp.h	2007-02-08 00:53:58.000000000
-0500
 -45,7
+45,7  ia64_get_lid (void)
 #define SMP_IRQ_REDIRECTION	(1 << 0)
 #define SMP_IPI_REDIRECTION	(1 << 1)
 
-#define raw_smp_processor_id()
(current_thread_info()->cpu)
+#define raw_smp_processor_id()
(ia64_get_kr(IA64_KR_CPU_ID))
 
 extern struct smp_boot_data {
 	int cpu_count;




  
-
To unsubscribe from this list: send the line
"unsubscribe linux-ia64" in
the body of a message to majordomovger.kernel.org
More majordomo info at  http://vge
r.kernel.org/majordomo-info.html

Re: Use ar.kr2 for smp_processor_id
country flaguser name
United States
2007-02-08 00:04:30
Zou Nan hai (on 08 Feb 2007 11:28:44 +0800) wrote:
>Pin ar.kr2 of each CPU, so that smp_processor_id can use
it.

Historically ar.k2 has been reserved for debugging purposes,
for
example in ivt.S.  Debuggers often need a location that can
be used to
track progress, it has to be somewhere that does not rely on
TLB
entries and is guaranteed to appear in MCA/INIT records -
ar.k2 is
perfect for this.

Use Tony's suggestion of testing for a change in ar.k3
(guaranteed to
be unique on every cpu) and caching the corresponding cpu
number when
it changes.

-
To unsubscribe from this list: send the line
"unsubscribe linux-ia64" in
the body of a message to majordomovger.kernel.org
More majordomo info at  http://vge
r.kernel.org/majordomo-info.html

Re: Use ar.kr2 for smp_processor_id
user name
2007-02-08 02:28:55
>>>>> "Zou" == Zou Nan hai
<nanhai.zouintel.com> writes:

Zou> Pin ar.kr2 of each CPU, so that smp_processor_id can
use it.
Zou> This will save some memory foot-print when
smp_procerror_id() is
Zou> called.

Accessing ar.k? takes 12 cycles... it's faster in the kernel
to
use current_thread_info()->cpu which if cache hot can be
done in two
cycles.

--
Dr Peter Chubb  http://www.gelato.unsw.
edu.au  peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.
com.au           ERTOS within National ICT Australia
-
To unsubscribe from this list: send the line
"unsubscribe linux-ia64" in
the body of a message to majordomovger.kernel.org
More majordomo info at  http://vge
r.kernel.org/majordomo-info.html

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )