diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-10-21 15:16:08 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-10-21 15:16:08 +0300 |
| commit | 00d3ae26dfd7c91c0817e71d71636982680d0b28 (patch) | |
| tree | 866908a7f5b4fbbfd4ee32f752a4b96f2c867c63 /arch/riscv64 | |
| parent | 08619630e9c7b638354323b443937701811b11d4 (diff) | |
| download | kmi-00d3ae26dfd7c91c0817e71d71636982680d0b28.tar.gz kmi-00d3ae26dfd7c91c0817e71d71636982680d0b28.zip | |
slight optimisation to cur_tcb on riscv
Diffstat (limited to 'arch/riscv64')
| -rw-r--r-- | arch/riscv64/kernel/cpu.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/arch/riscv64/kernel/cpu.c b/arch/riscv64/kernel/cpu.c index 38cf262..4273d02 100644 --- a/arch/riscv64/kernel/cpu.c +++ b/arch/riscv64/kernel/cpu.c @@ -16,12 +16,15 @@ void cpu_assign(struct tcb *t) id_t cpu_id() { - /* yes, slightly weird situation where cur_tcb() call cpu_id() which - * gets the current tcb and returns the cpu id in the tcb, so that that - * id can be used to get the tcb we want. I might try to work out - * something slightly smarter, although this is likely not going to have - * basically any kind of importance for perfomance. */ - struct tcb *t; - __asm__ volatile ("mv %0, tp\n" : "=r" (t) ::); + struct tcb *t = cur_tcb(); return t->cpu_id; } + +/* override cur_tcb() in common/tcb.c since on risc-v this is apparently the + * optimal strategy. */ +/* @todo should this be the default for all arches? */ +struct tcb *cur_tcb() +{ + register struct tcb *t __asm__ ("tp"); + return t; +} |
