> -----Original Message----- > From: linux-ia64-owner@xxxxxxxxxxxxxxx > [mailto:linux-ia64-owner@xxxxxxxxxxxxxxx] On Behalf Of Luck, Tony > Sent: 2007年2月8日 2:00 > To: Ken Chen; Yu, Fenghua > Cc: linux-ia64@xxxxxxxxxxxxxxx > Subject: RE: [PATCH] Hook up getcpu system call for IA64 > > > Andi Kleen used to lecture me every so often why it is important to > > have fast vgetcpu on x86-64 (I don't think ia64 is excluded from > > that). His lecture is also all over the lkml mailing list. > > I dug though that thread ... it isn't ever explicitly stated, but > it does appear that the intent is that a NUMA aware application > would use a malloc() library that called getcpu() on every memory > allocation. If that is the usage model, then I'll agree that > getcpu() does need to be fast. > > One possible way to achieve that on ia64 would be to make use of the > fact that the ar.k* registers are readable by applications, and > specifically ar.k3 contains a per-cpu value (physical address of the > kernel percpu area). *IF* (and that is a BIG IF) we were to guarantee > to maintain ar.k3 as a per-cpu unique value, then we could implement > a very fast (even faster than fsys.S) getcpu() as: > > #define __NR_getcpu 1304 > > int > getcpu(unsigned *cpup, unsigned *nodep, void *cachep) > { > static unsigned cpu = ~0, node = ~0; > static unsigned long save_ar_k3; > unsigned long ar_k3; > > asm volatile ("mov %0=ar.k3" : "=r" (ar_k3)); > if (cpu == ~0 || ar_k3 != save_ar_k3) { > if (syscall(__NR_getcpu, &cpu, &node, 0) == -1) > return -1; > save_ar_k3 = ar_k3; > } > *cpup = cpu; > *nodep = node; > > return 0; > } > > > Too ugly for words? Or worth serious consideration? > > -Tony I think it is possible to pin ar.k3 to processor id, then change the raw_smp_processor_id() implementation. This should be better than current raw_smp_processor_id() implementation. Then we could implement sys_getcpu in fsys.S That could not be very complex, only thing we need to care is exception handle in fsys code. Thanks Zou Nan hai > - > To unsubscribe from this list: send the line "unsubscribe linux-ia64" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html - To unsubscribe from this list: send the line "unsubscribe linux-ia64" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
![]() |