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

Unified · Split

2 files
  1. include/asm-i386/unistd.h +2 −1
  2. include/linux/syscalls.h +2 −0
include/asm-i386/unistd.h+2−1
@@ -323,10 +323,11 @@ · 322 unmodified lines
323#define __NR_tee 315323#define __NR_tee 315
324#define __NR_vmsplice 316324#define __NR_vmsplice 316
325#define __NR_move_pages 317325#define __NR_move_pages 317
326#define __NR_getcpu 318
326 327
327#ifdef __KERNEL__328#ifdef __KERNEL__
328 329
329#define NR_syscalls 318330#define NR_syscalls 319
330 331
331/*332/*
332 * user-visible error numbers are in the range -1 - -128: see333 * user-visible error numbers are in the range -1 - -128: see
include/linux/syscalls.h+2−0
@@ -53,6 +53,7 @@ struct mq_attr; · 52 unmodified lines
53struct compat_stat;53struct compat_stat;
54struct compat_timeval;54struct compat_timeval;
55struct robust_list_head;55struct robust_list_head;
56struct getcpu_cache;
56 57
57#include <linux/types.h>58#include <linux/types.h>
58#include <linux/aio_abi.h>59#include <linux/aio_abi.h>
@@ -596,5 +597,6 @@ asmlinkage long sys_get_robust_list(int pid, · 537 unmodified lines
596 size_t __user *len_ptr);597 size_t __user *len_ptr);
597asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,598asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
598 size_t len);599 size_t len);
600asmlinkage long sys_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *cache);
599 601
600#endif602#endif