.\"
.\" 2008, mtk, various edits
.\"
-.TH GETCPU 2 2012-07-13 "Linux" "Linux Programmer's Manual"
+.TH GETCPU 2 2019-03-06 "Linux" "Linux Programmer's Manual"
.SH NAME
getcpu \- determine CPU and NUMA node on which the calling thread is running
.SH SYNOPSIS
.nf
.B #include <linux/getcpu.h>
-.sp
+.PP
.BI "int getcpu(unsigned *" cpu ", unsigned *" node \
", struct getcpu_cache *" tcache );
.fi
-
-.IR Note :
-There is no glibc wrapper for this system call; see NOTES.
.SH DESCRIPTION
The
.BR getcpu ()
or
.I node
is NULL nothing is written to the respective pointer.
-
-The third argument to this system call is nowadays unused (see NOTES).
-
+.PP
+The third argument to this system call is nowadays unused,
+and should be specified as NULL
+unless portability to Linux 2.6.23 or earlier is required (see NOTES).
+.PP
The information placed in
.I cpu
is guaranteed to be current only at the time of the call:
Arguments point outside the calling process's address space.
.SH VERSIONS
.BR getcpu ()
-was added in kernel 2.6.19 for x86_64 and i386.
+was added in kernel 2.6.19 for x86-64 and i386.
+Library support was added in glibc 2.29
+(Earlier glibc versions did not provide a wrapper for this system call,
+necessitating the use of
+.BR syscall (2).)
.SH CONFORMING TO
.BR getcpu ()
-is Linux specific.
+is Linux-specific.
.SH NOTES
-Linux makes a best effort to make this call as fast possible.
+Linux makes a best effort to make this call as fast as possible.
+(On some architectures, this is done via an implementation in the
+.BR vdso (7).)
The intention of
.BR getcpu ()
is to allow programs to make optimizations with per-CPU data
or for NUMA optimization.
-
-Glibc does not provide a wrapper for this system call; call it using
-.BR syscall (2);
-or use
-.BR sched_getcpu (3)
-instead.
-
+.PP
The
.I tcache
argument is unused since Linux 2.6.24.
.BR sched_setaffinity (2),
.BR set_mempolicy (2),
.BR sched_getcpu (3),
-.BR cpuset (7)
+.BR cpuset (7),
+.BR vdso (7)