History

[PATCH] x86: Add portable getcpu call

For NUMA optimization and some other algorithms it is useful to have a fast to get the current CPU and node numbers in user space. x86-64 added a fast way to do this in a vsyscall. This adds a generic syscall for other architectures to make it a generic portable facility. I expect some of them will also implement it as a faster vsyscall. The cache is an optimization for the x86-64 vsyscall optimization. Since what the syscall returns is an approximation anyways and user space often wants very fast results it can be cached for some time. The norma methods to get this information in user space are relatively slow The vsyscall is in a better position to manage the cache because it has direct access to a fast time stamp (jiffies). For the generic syscall optimization it doesn't help much, but enforce a valid argument to keep programs portable I only added an i386 syscall entry for now. Other architectures can follow as needed. AK: Also added some cleanups from Andrew Morton

Andi Kleen committed 20 years ago

Commit 3cfc3481 parent c08c8205 files · +37 −1Browse files

Showing the changes to include/asm-i386 (1 of 5 files). Show all

Unified · Split

include/asm-i386/unistd.h+2−1
@@ -323,10 +323,11 @@ · 322 unmodified lines
323323 #define __NR_tee 315
324324 #define __NR_vmsplice 316
325325 #define __NR_move_pages 317
326+#define __NR_getcpu 318
326327
327328 #ifdef __KERNEL__
328329
329−#define NR_syscalls 318
330+#define NR_syscalls 319
330331
331332 /*
332333 * user-visible error numbers are in the range -1 - -128: see