mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
dc32cb4ba6
vdso/datapage.h provides symbols and functions to ease the access to shared vDSO data from both the kernel and the vDSO. Make use of it to simplify the current code and also prepare for further changes unifying the vDSO data storage between architectures. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20241010-vdso-generic-base-v1-8-b64f0842d512@linutronix.de
46 lines
788 B
C
46 lines
788 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Fast user context implementation of getcpu()
|
|
*/
|
|
|
|
#include <asm/vdso.h>
|
|
#include <linux/getcpu.h>
|
|
|
|
static __always_inline int read_cpu_id(void)
|
|
{
|
|
int cpu_id;
|
|
|
|
__asm__ __volatile__(
|
|
" rdtime.d $zero, %0\n"
|
|
: "=r" (cpu_id)
|
|
:
|
|
: "memory");
|
|
|
|
return cpu_id;
|
|
}
|
|
|
|
static __always_inline const struct vdso_pcpu_data *get_pcpu_data(void)
|
|
{
|
|
return _loongarch_data.pdata;
|
|
}
|
|
|
|
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 cpu_id;
|
|
const struct vdso_pcpu_data *data;
|
|
|
|
cpu_id = read_cpu_id();
|
|
|
|
if (cpu)
|
|
*cpu = cpu_id;
|
|
|
|
if (node) {
|
|
data = get_pcpu_data();
|
|
*node = data[cpu_id].node;
|
|
}
|
|
|
|
return 0;
|
|
}
|