forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LoongArch: Add vDSO syscall __vdso_getcpu()
We test 20 million times of getcpu(), the real syscall version take 25 seconds, while the vsyscall version take only 2.4 seconds. Signed-off-by: Rui Wang <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
- Loading branch information
1 parent
57fc732
commit dce6098
Showing
6 changed files
with
75 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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 (struct vdso_pcpu_data *)(get_vdso_base() - VDSO_DATA_SIZE); | ||
} | ||
|
||
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; | ||
} |