vdso: Remove struct getcpu_cache
PATCH v3 1/1 vdso: Remove struct getcpu_cache
The cache parameter of getcpu() is useless nowadays for various reasons.
* It is never passed by userspace for either the vDSO or syscalls.
* It is never used by the kernel.
* It could not be made to work on the current vDSO architecture.
* The structure definition is not part of the UAPI headers.
* vdso_getcpu() is superseded by restartable sequences in any case.
Remove the struct and its header.
As a side-effect we get rid of an unwanted inclusion of the linux/ header namespace from vDSO code.
---
Changes in v3:
- Rebase on v6.19-rc1
- Fix conflict with UML vdso_getcpu() removal
- Flesh out commit message
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Rebase on v6.18-rc1
- Link to v1: https://lore.kernel.org/r/[email protected]
---
We could also completely remove the parameter, but I am not sure if
that is a good idea for syscalls and vDSO entrypoints.
--- arch/loongarch/vdso/vgetcpu.c | 5 ++--- arch/s390/kernel/vdso/getcpu.c | 3 +-- arch/s390/kernel/vdso/vdso.h | 4 +--- arch/x86/entry/vdso/vgetcpu.c | 5 ++--- arch/x86/include/asm/vdso/processor.h | 4 +--- include/linux/getcpu.h | 19 ------------------- include/linux/syscalls.h | 3 +-- kernel/sys.c | 4 +--- tools/testing/selftests/vDSO/vdso_test_getcpu.c | 4 +--- 9 files changed, 10 insertions(+), 41 deletions(-)
arch/loongarch/vdso/vgetcpu.c +2 -3
@@ -4,7 +4,6 @@*/ #include <asm/vdso.h> -#include <linux/getcpu.h> static __always_inline int read_cpu_id(void) {
@@ -28,8 +27,8 @@ static __always_inline int read_cpu_id(void) }extern -int __vdso_getcpu (unsigned int *cpu,unsigned int *node,struct getcpu_cache *unused); -int __vdso_getcpu (unsigned int *cpu,unsigned int *node,struct getcpu_cache *unused) +int __vdso_getcpu (unsigned int *cpu,unsigned int *node,void *unused); +int __vdso_getcpu (unsigned int *cpu,unsigned int *node,void *unused) {int cpu_id;
arch/s390/kernel/vdso/getcpu.c +1 -2
@@ -2,11 +2,10 @@/* Copyright IBM Corp. 2020 */ #include <linux/compiler.h> -#include <linux/getcpu.h> #include <asm/timex.h> #include "vdso.h" -int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused) +int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,void *unused) {union tod_clock clk;
arch/s390/kernel/vdso/vdso.h +1 -3
@@ -4,9 +4,7 @@#include <vdso/datapage.h> -struct getcpu_cache ; - -int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused); +int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,void *unused);int __s390_vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz);int __s390_vdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts);int __s390_vdso_clock_getres (clockid_t clock,struct __kernel_timespec *ts);
arch/x86/entry/vdso/vgetcpu.c +2 -3
@@ -6,17 +6,16 @@*/ #include <linux/kernel.h> -#include <linux/getcpu.h> #include <asm/segment.h> #include <vdso/processor.h> notrace long -__vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused) +__vdso_getcpu (unsigned *cpu,unsigned *node,void *unused) {vdso_read_cpunode (cpu, node);return 0 ; } -long getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *tcache) +long getcpu (unsigned *cpu,unsigned *node,void *tcache) __attribute__((weak,alias ("__vdso_getcpu" )));
arch/x86/include/asm/vdso/processor.h +1 -3
@@ -18,9 +18,7 @@ static __always_inline void cpu_relax(void) native_pause(); } -struct getcpu_cache ; - -notrace long __vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused); +notrace long __vdso_getcpu (unsigned *cpu,unsigned *node,void *unused);#endif /* __ASSEMBLER__ */
include/linux/getcpu.h deleted +0 -19
@@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_GETCPU_H -#define _LINUX_GETCPU_H 1 - -/* Cache for getcpu() to speed it up. Results might be a short time -out of date, but will be faster. - -User programs should not refer to the contents of this structure. -I repeat they should not refer to it. If they do they will break -in future kernels. - -It is only a private cache for vgetcpu(). It will change in future kernels. -The user program must store this information per thread (__thread) -If you want 100% accurate information pass NULL instead. */ -struct getcpu_cache { -unsigned long blob[128 /sizeof (long )]; -}; - -#endif
include/linux/syscalls.h +1 -2
@@ -59,7 +59,6 @@ struct compat_stat;struct old_timeval32 ;struct robust_list_head ;struct futex_waitv ; -struct getcpu_cache ;struct old_linux_dirent ;struct perf_event_attr ;struct file_handle ;
@@ -718,7 +717,7 @@ asmlinkage long sys_getrusage(int who, struct rusage __user *ru);asmlinkage long sys_umask (int mask);asmlinkage long sys_prctl (int option,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5); -asmlinkage long sys_getcpu (unsigned __user *cpu,unsigned __user *node,struct getcpu_cache __user *cache); +asmlinkage long sys_getcpu (unsigned __user *cpu,unsigned __user *node,void __user *cache);asmlinkage long sys_gettimeofday (struct __kernel_old_timeval __user *tv,struct timezone __user *tz); asmlinkage long sys_settimeofday(struct __kernel_old_timeval __user *tv,
kernel/sys.c +1 -3
@@ -31,7 +31,6 @@#include <linux/tty.h> #include <linux/signal.h> #include <linux/cn_proc.h> -#include <linux/getcpu.h> #include <linux/task_io_accounting_ops.h> #include <linux/seccomp.h> #include <linux/cpu.h>
@@ -2876,8 +2875,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,return error; } -SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, - struct getcpu_cache __user *, unused) +SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, void __user *, unused) {int err =0 ;int cpu =raw_smp_processor_id ();
tools/testing/selftests/vDSO/vdso_test_getcpu.c +1 -3
@@ -16,9 +16,7 @@#include "vdso_config.h" #include "vdso_call.h" -struct getcpu_cache ; -typedef long (*getcpu_t )(unsigned int *,unsigned int *, -struct getcpu_cache *); +typedef long (*getcpu_t )(unsigned int *,unsigned int *,void *);int main (int argc,char **argv) {
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20250825-getcpu_cache-3abcd2e65437
Best regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
Quoted 7 lines · Thomas Weißschuh
The cache parameter of
getcpu()is useless nowadays for various reasons.
* It is never passed by userspace for either the vDSO or syscalls.
* It is never used by the kernel.
* It could not be made to work on the current vDSO architecture.
* The structure definition is not part of the UAPI headers.
*vdso_getcpu()is superseded by restartable sequences in any case.
Quoted 6 lines
Remove the struct and its header.
As a side-effect we get rid of an unwanted inclusion of the linux/ header namespace from vDSO code.
Signed-off-by Thomas Weißschuh <[email protected]>
Quoted 26 lines · Thomas Weißschuh
The cache parameter of
getcpu()is useless nowadays for various reasons.
* It is never passed by userspace for either the vDSO or syscalls.
* It is never used by the kernel.
* It could not be made to work on the current vDSO architecture.
* The structure definition is not part of the UAPI headers.
*vdso_getcpu()is superseded by restartable sequences in any case.Remove the struct and its header.
As a side-effect we get rid of an unwanted inclusion of the linux/ header namespace from vDSO code.
Signed-off-by Thomas Weißschuh <[email protected]>---
Changes in v3:
- Rebase on v6.19-rc1
- Fix conflict with UMLvdso_getcpu()removal
- Flesh out commit message
- Link to v2: https://lore.kernel.org/r/[email protected]Changes in v2:
- Rebase on v6.18-rc1
- Link to v1: https://lore.kernel.org/r/[email protected]
---
We could also completely remove the parameter, but I am not sure if
that is a good idea for syscalls and vDSO entrypoints.
Quoted 11 lines
--- arch/loongarch/vdso/vgetcpu.c | 5 ++--- arch/s390/kernel/vdso/getcpu.c | 3 +-- arch/s390/kernel/vdso/vdso.h | 4 +--- arch/x86/entry/vdso/vgetcpu.c | 5 ++--- arch/x86/include/asm/vdso/processor.h | 4 +--- include/linux/getcpu.h | 19 ------------------- include/linux/syscalls.h | 3 +-- kernel/sys.c | 4 +--- tools/testing/selftests/vDSO/vdso_test_getcpu.c | 4 +--- 9 files changed, 10 insertions(+), 41 deletions(-)
The following commit has been merged into the timers/vdso branch of tip:
The following commit has been merged into the timers/vdso branch of tip:
Commit-ID: 083103ebab933fd7752e21060a2974e2e9546b1a Gitweb: https://git.kernel.org/tip/083103ebab933fd7752e21060a2974e2e9546b1a Author: Thomas Weißschuh <[email protected]> AuthorDate: Tue, 30 Dec 2025 08:08:44 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Tue, 13 Jan 2026 14:42:24 +01:00
vdso: Remove struct getcpu_cache
The cache parameter of getcpu() is useless nowadays for various reasons.
* It is never passed by userspace for either the vDSO or syscalls.
* It is never used by the kernel.
* It could not be made to work on the current vDSO architecture.
* The structure definition is not part of the UAPI headers.
* vdso_getcpu() is superseded by restartable sequences in any case.
Remove the struct and its header.
As a side-effect this gets rid of an unwanted inclusion of the linux/ header namespace from vDSO code.
[ tglx: Adapt to s390 upstream changes */
--- arch/loongarch/vdso/vgetcpu.c | 5 +--- arch/s390/kernel/vdso/getcpu.c | 2 +- arch/s390/kernel/vdso/vdso.h | 4 +--- arch/x86/entry/vdso/vgetcpu.c | 5 +--- arch/x86/include/asm/vdso/processor.h | 4 +--- include/linux/getcpu.h | 19 +---------------- include/linux/syscalls.h | 3 +-- kernel/sys.c | 4 +--- tools/testing/selftests/vDSO/vdso_test_getcpu.c | 4 +--- 9 files changed, 10 insertions(+), 40 deletions(-) delete mode 100644 include/linux/getcpu.h
arch/loongarch/vdso/vgetcpu.c +2 -3
@@ -4,7 +4,6 @@*/ #include <asm/vdso.h> -#include <linux/getcpu.h> static __always_inline int read_cpu_id(void) {
@@ -28,8 +27,8 @@ static __always_inline int read_cpu_id(void) }extern -int __vdso_getcpu (unsigned int *cpu,unsigned int *node,struct getcpu_cache *unused); -int __vdso_getcpu (unsigned int *cpu,unsigned int *node,struct getcpu_cache *unused) +int __vdso_getcpu (unsigned int *cpu,unsigned int *node,void *unused); +int __vdso_getcpu (unsigned int *cpu,unsigned int *node,void *unused) {int cpu_id;
arch/s390/kernel/vdso/getcpu.c +1 -1
@@ -6,7 +6,7 @@#include <asm/timex.h> #include "vdso.h" -int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused) +int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,void *unused) {union tod_clock clk;
arch/s390/kernel/vdso/vdso.h +1 -3
@@ -4,9 +4,7 @@#include <vdso/datapage.h> -struct getcpu_cache ; - -int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused); +int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,void *unused);int __s390_vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz);int __s390_vdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts);int __s390_vdso_clock_getres (clockid_t clock,struct __kernel_timespec *ts);
arch/x86/entry/vdso/vgetcpu.c +2 -3
@@ -6,17 +6,16 @@*/ #include <linux/kernel.h> -#include <linux/getcpu.h> #include <asm/segment.h> #include <vdso/processor.h> notrace long -__vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused) +__vdso_getcpu (unsigned *cpu,unsigned *node,void *unused) {vdso_read_cpunode (cpu, node);return 0 ; } -long getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *tcache) +long getcpu (unsigned *cpu,unsigned *node,void *tcache) __attribute__((weak,alias ("__vdso_getcpu" )));
arch/x86/include/asm/vdso/processor.h +1 -3
@@ -18,9 +18,7 @@ static __always_inline void cpu_relax(void) native_pause(); } -struct getcpu_cache ; - -notrace long __vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused); +notrace long __vdso_getcpu (unsigned *cpu,unsigned *node,void *unused);#endif /* __ASSEMBLER__ */
include/linux/getcpu.h deleted +0 -19
@@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_GETCPU_H -#define _LINUX_GETCPU_H 1 - -/* Cache for getcpu() to speed it up. Results might be a short time -out of date, but will be faster. - -User programs should not refer to the contents of this structure. -I repeat they should not refer to it. If they do they will break -in future kernels. - -It is only a private cache for vgetcpu(). It will change in future kernels. -The user program must store this information per thread (__thread) -If you want 100% accurate information pass NULL instead. */ -struct getcpu_cache { -unsigned long blob[128 /sizeof (long )]; -}; - -#endif
include/linux/syscalls.h +1 -2
@@ -59,7 +59,6 @@ struct compat_stat;struct old_timeval32 ;struct robust_list_head ;struct futex_waitv ; -struct getcpu_cache ;struct old_linux_dirent ;struct perf_event_attr ;struct file_handle ;
@@ -718,7 +717,7 @@ asmlinkage long sys_getrusage(int who, struct rusage __user *ru);asmlinkage long sys_umask (int mask);asmlinkage long sys_prctl (int option,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5); -asmlinkage long sys_getcpu (unsigned __user *cpu,unsigned __user *node,struct getcpu_cache __user *cache); +asmlinkage long sys_getcpu (unsigned __user *cpu,unsigned __user *node,void __user *cache);asmlinkage long sys_gettimeofday (struct __kernel_old_timeval __user *tv,struct timezone __user *tz); asmlinkage long sys_settimeofday(struct __kernel_old_timeval __user *tv,
kernel/sys.c +1 -3
@@ -31,7 +31,6 @@#include <linux/tty.h> #include <linux/signal.h> #include <linux/cn_proc.h> -#include <linux/getcpu.h> #include <linux/task_io_accounting_ops.h> #include <linux/seccomp.h> #include <linux/cpu.h>
@@ -2876,8 +2875,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,return error; } -SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, - struct getcpu_cache __user *, unused) +SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, void __user *, unused) {int err =0 ;int cpu =raw_smp_processor_id ();
tools/testing/selftests/vDSO/vdso_test_getcpu.c +1 -3
@@ -16,9 +16,7 @@#include "vdso_config.h" #include "vdso_call.h" -struct getcpu_cache ; -typedef long (*getcpu_t )(unsigned int *,unsigned int *, -struct getcpu_cache *); +typedef long (*getcpu_t )(unsigned int *,unsigned int *,void *);int main (int argc,char **argv) {
The following commit has been merged into the timers/vdso branch of tip:
The following commit has been merged into the timers/vdso branch of tip:
Commit-ID: 7158fc54b2c6f124eec0d7cd13bff69da0172e59 Gitweb: https://git.kernel.org/tip/7158fc54b2c6f124eec0d7cd13bff69da0172e59 Author: Thomas Weißschuh <[email protected]> AuthorDate: Tue, 30 Dec 2025 08:08:44 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 14 Jan 2026 08:56:40 +01:00
vdso: Remove struct getcpu_cache
The cache parameter of getcpu() is useless nowadays for various reasons.
* It is never passed by userspace for either the vDSO or syscalls.
* It is never used by the kernel.
* It could not be made to work on the current vDSO architecture.
* The structure definition is not part of the UAPI headers.
* vdso_getcpu() is superseded by restartable sequences in any case.
Remove the struct and its header.
As a side-effect this gets rid of an unwanted inclusion of the linux/ header namespace from vDSO code.
[ tglx: Adapt to s390 upstream changes */
--- arch/loongarch/vdso/vgetcpu.c | 5 +--- arch/s390/kernel/vdso/getcpu.c | 3 +-- arch/s390/kernel/vdso/vdso.h | 4 +--- arch/x86/entry/vdso/vgetcpu.c | 5 +--- arch/x86/include/asm/vdso/processor.h | 4 +--- include/linux/getcpu.h | 19 +---------------- include/linux/syscalls.h | 3 +-- kernel/sys.c | 4 +--- tools/testing/selftests/vDSO/vdso_test_getcpu.c | 4 +--- 9 files changed, 10 insertions(+), 41 deletions(-) delete mode 100644 include/linux/getcpu.h
arch/loongarch/vdso/vgetcpu.c +2 -3
@@ -4,7 +4,6 @@*/ #include <asm/vdso.h> -#include <linux/getcpu.h> static __always_inline int read_cpu_id(void) {
@@ -28,8 +27,8 @@ static __always_inline int read_cpu_id(void) }extern -int __vdso_getcpu (unsigned int *cpu,unsigned int *node,struct getcpu_cache *unused); -int __vdso_getcpu (unsigned int *cpu,unsigned int *node,struct getcpu_cache *unused) +int __vdso_getcpu (unsigned int *cpu,unsigned int *node,void *unused); +int __vdso_getcpu (unsigned int *cpu,unsigned int *node,void *unused) {int cpu_id;
arch/s390/kernel/vdso/getcpu.c +1 -2
@@ -2,11 +2,10 @@/* Copyright IBM Corp. 2020 */ #include <linux/compiler.h> -#include <linux/getcpu.h> #include <asm/timex.h> #include "vdso.h" -int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused) +int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,void *unused) {union tod_clock clk;
arch/s390/kernel/vdso/vdso.h +1 -3
@@ -4,9 +4,7 @@#include <vdso/datapage.h> -struct getcpu_cache ; - -int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused); +int __s390_vdso_getcpu (unsigned *cpu,unsigned *node,void *unused);int __s390_vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz);int __s390_vdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts);int __s390_vdso_clock_getres (clockid_t clock,struct __kernel_timespec *ts);
arch/x86/entry/vdso/vgetcpu.c +2 -3
@@ -6,17 +6,16 @@*/ #include <linux/kernel.h> -#include <linux/getcpu.h> #include <asm/segment.h> #include <vdso/processor.h> notrace long -__vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused) +__vdso_getcpu (unsigned *cpu,unsigned *node,void *unused) {vdso_read_cpunode (cpu, node);return 0 ; } -long getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *tcache) +long getcpu (unsigned *cpu,unsigned *node,void *tcache) __attribute__((weak,alias ("__vdso_getcpu" )));
arch/x86/include/asm/vdso/processor.h +1 -3
@@ -18,9 +18,7 @@ static __always_inline void cpu_relax(void) native_pause(); } -struct getcpu_cache ; - -notrace long __vdso_getcpu (unsigned *cpu,unsigned *node,struct getcpu_cache *unused); +notrace long __vdso_getcpu (unsigned *cpu,unsigned *node,void *unused);#endif /* __ASSEMBLER__ */
include/linux/getcpu.h deleted +0 -19
@@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_GETCPU_H -#define _LINUX_GETCPU_H 1 - -/* Cache for getcpu() to speed it up. Results might be a short time -out of date, but will be faster. - -User programs should not refer to the contents of this structure. -I repeat they should not refer to it. If they do they will break -in future kernels. - -It is only a private cache for vgetcpu(). It will change in future kernels. -The user program must store this information per thread (__thread) -If you want 100% accurate information pass NULL instead. */ -struct getcpu_cache { -unsigned long blob[128 /sizeof (long )]; -}; - -#endif
include/linux/syscalls.h +1 -2
@@ -59,7 +59,6 @@ struct compat_stat;struct old_timeval32 ;struct robust_list_head ;struct futex_waitv ; -struct getcpu_cache ;struct old_linux_dirent ;struct perf_event_attr ;struct file_handle ;
@@ -718,7 +717,7 @@ asmlinkage long sys_getrusage(int who, struct rusage __user *ru);asmlinkage long sys_umask (int mask);asmlinkage long sys_prctl (int option,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5); -asmlinkage long sys_getcpu (unsigned __user *cpu,unsigned __user *node,struct getcpu_cache __user *cache); +asmlinkage long sys_getcpu (unsigned __user *cpu,unsigned __user *node,void __user *cache);asmlinkage long sys_gettimeofday (struct __kernel_old_timeval __user *tv,struct timezone __user *tz); asmlinkage long sys_settimeofday(struct __kernel_old_timeval __user *tv,
kernel/sys.c +1 -3
@@ -31,7 +31,6 @@#include <linux/tty.h> #include <linux/signal.h> #include <linux/cn_proc.h> -#include <linux/getcpu.h> #include <linux/task_io_accounting_ops.h> #include <linux/seccomp.h> #include <linux/cpu.h>
@@ -2876,8 +2875,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,return error; } -SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, - struct getcpu_cache __user *, unused) +SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, void __user *, unused) {int err =0 ;int cpu =raw_smp_processor_id ();
tools/testing/selftests/vDSO/vdso_test_getcpu.c +1 -3
@@ -16,9 +16,7 @@#include "vdso_config.h" #include "vdso_call.h" -struct getcpu_cache ; -typedef long (*getcpu_t )(unsigned int *,unsigned int *, -struct getcpu_cache *); +typedef long (*getcpu_t )(unsigned int *,unsigned int *,void *);int main (int argc,char **argv) {