Skip to content

Commit 933c6c0

Browse files
committed
Loongarch: optimize syscall reg save
deepin inclusion category: performance It saves a st.d in the hot syscall path, and let the compiler know to optimize it in asm, and helps to improve the syscall performance little. Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent e83cbc9 commit 933c6c0

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

arch/loongarch/kernel/entry.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ SYM_CODE_START(handle_syscall)
3030
addi.d sp, sp, -PT_SIZE
3131
cfi_st t2, PT_R3
3232
cfi_rel_offset sp, PT_R3
33-
st.d zero, sp, PT_R0
33+
# Note it will be set in do_syscall regs->regs[0] = 0;
34+
# st.d zero, sp, PT_R0
3435
csrrd t2, LOONGARCH_CSR_PRMD
3536
st.d t2, sp, PT_PRMD
3637
csrrd t2, LOONGARCH_CSR_CRMD

arch/loongarch/kernel/syscall.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ void noinstr do_syscall(struct pt_regs *regs)
4444
sys_call_fn syscall_fn;
4545

4646
nr = regs->regs[11];
47+
// Move from handle_syscall macro to save a memio
48+
regs->regs[0] = 0;
4749
/* Set for syscall restarting */
4850
if (nr < NR_syscalls)
4951
regs->regs[0] = nr + 1;

0 commit comments

Comments
 (0)