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/linux (1 of 5 files). Show all

Unified · Split

include/linux/syscalls.h+2−0
@@ -53,6 +53,7 @@ struct mq_attr; · 52 unmodified lines
5353 struct compat_stat;
5454 struct compat_timeval;
5555 struct robust_list_head;
56+struct getcpu_cache;
5657
5758 #include <linux/types.h>
5859 #include <linux/aio_abi.h>
@@ -596,5 +597,6 @@ asmlinkage long sys_get_robust_list(int pid, · 537 unmodified lines
596597 size_t __user *len_ptr);
597598 asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
598599 size_t len);
600+asmlinkage long sys_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *cache);
599601
600602 #endif