Files
linux/arch/loongarch/vdso/vgetcpu.c
Thomas Weißschuh 7158fc54b2 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 */

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Heiko Carstens <hca@linux.ibm.com> # s390
Link: https://patch.msgid.link/20251230-getcpu_cache-v3-1-fb9c5f880ebe@linutronix.de
2026-01-14 08:56:40 +01:00

45 lines
691 B
C

// SPDX-License-Identifier: GPL-2.0-only
/*
* Fast user context implementation of getcpu()
*/
#include <asm/vdso.h>
static __always_inline int read_cpu_id(void)
{
int cpu_id;
#ifdef CONFIG_64BIT
__asm__ __volatile__(
" rdtime.d $zero, %0\n"
: "=r" (cpu_id)
:
: "memory");
#else
__asm__ __volatile__(
" rdtimel.w $zero, %0\n"
: "=r" (cpu_id)
:
: "memory");
#endif
return cpu_id;
}
extern
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;
cpu_id = read_cpu_id();
if (cpu)
*cpu = cpu_id;
if (node)
*node = vdso_u_arch_data.pdata[cpu_id].node;
return 0;
}