1 // SPDX-License-Identifier: GPL-2.0-only
3 * Fast user context implementation of getcpu()
7 #include <linux/getcpu.h>
9 static __always_inline int read_cpu_id(void)
14 " rdtime.d $zero, %0\n"
22 static __always_inline const struct vdso_pcpu_data *get_pcpu_data(void)
24 return (struct vdso_pcpu_data *)(get_vdso_data() + VVAR_LOONGARCH_PAGES_START * PAGE_SIZE);
28 int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused);
29 int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused)
32 const struct vdso_pcpu_data *data;
34 cpu_id = read_cpu_id();
40 data = get_pcpu_data();
41 *node = data[cpu_id].node;