MIPS: convert to generic entry
Subsystems (3)
v2 cover MIPS: convert to generic entry
Convert MIPS to use the generic entry infrastructure from kernel/entry/*.
v2: Use regs->regs[27] to mark whether to restore all registers in handle_sys and enable IRQ stack.
Feiyang Chen (2):
MIPS: convert syscall to generic entry
MIPS: convert irq to generic entry
arch/mips/Kconfig | 1 + arch/mips/include/asm/entry-common.h | 13 ++ arch/mips/include/asm/irqflags.h | 42 ---- arch/mips/include/asm/ptrace.h | 8 +- arch/mips/include/asm/sim.h | 70 ------- arch/mips/include/asm/stackframe.h | 8 + arch/mips/include/asm/syscall.h | 5 + arch/mips/include/asm/thread_info.h | 17 +- arch/mips/include/uapi/asm/ptrace.h | 7 +- arch/mips/kernel/Makefile | 14 +- arch/mips/kernel/entry.S | 143 +------------- arch/mips/kernel/genex.S | 150 +++------------ arch/mips/kernel/head.S | 1 - arch/mips/kernel/linux32.c | 1 - arch/mips/kernel/ptrace.c | 78 -------- arch/mips/kernel/r4k-bugs64.c | 14 +- arch/mips/kernel/scall.S | 136 +++++++++++++ arch/mips/kernel/scall32-o32.S | 223 --------------------- arch/mips/kernel/scall64-n32.S | 107 ---------- arch/mips/kernel/scall64-n64.S | 116 ----------- arch/mips/kernel/scall64-o32.S | 221 --------------------- arch/mips/kernel/signal.c | 59 +----- arch/mips/kernel/signal_n32.c | 15 +- arch/mips/kernel/signal_o32.c | 29 +-- arch/mips/kernel/syscall.c | 148 +++++++++++--- arch/mips/kernel/syscalls/syscall_n32.tbl | 8 +- arch/mips/kernel/syscalls/syscall_n64.tbl | 8 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 8 +- arch/mips/kernel/traps.c | 225 ++++++++++++++++------ arch/mips/kernel/unaligned.c | 19 +- arch/mips/mm/c-octeon.c | 15 ++ arch/mips/mm/cex-oct.S | 8 +- arch/mips/mm/fault.c | 12 +- arch/mips/mm/tlbex-fault.S | 7 +- 34 files changed, 594 insertions(+), 1342 deletions(-) create mode 100644 arch/mips/include/asm/entry-common.h delete mode 100644 arch/mips/include/asm/sim.h create mode 100644 arch/mips/kernel/scall.S delete mode 100644 arch/mips/kernel/scall32-o32.S delete mode 100644 arch/mips/kernel/scall64-n32.S delete mode 100644 arch/mips/kernel/scall64-n64.S delete mode 100644 arch/mips/kernel/scall64-o32.S
Signature · 1 line
2.27.0
PATCH v2 1/2 MIPS: convert syscall to generic entry
Convert MIPS syscall to use the generic entry infrastructure from kernel/entry/*.
There are a few special things on MIPS:
- There is one type of syscall on MIPS32 (scall32-o32) and three types of syscalls on MIPS64 (scall64-o32, scall64-n32 and scall64-n64). Now convert to C code to handle different types of syscalls.
- For some special syscalls (e.g. fork, clone, clone3 and sysmips), save_static_function() wrapper is used to save static registers. Now SAVE_STATIC is used in handle_sys before calling do_syscall(), so the save_static_function() wrapper can be removed.
- For sigreturn/rt_sigreturn and sysmips, inline assembly is used to jump to syscall_exit directly for skipping setting the error flag and restoring all registers. Now use regs->regs[27] to mark whether to handle the error flag and restore all registers in handle_sys, so these functions can return normally as other architecture.
--- arch/mips/Kconfig | 1 + arch/mips/include/asm/entry-common.h | 13 ++ arch/mips/include/asm/ptrace.h | 8 +- arch/mips/include/asm/sim.h | 70 ------- arch/mips/include/asm/syscall.h | 5 + arch/mips/include/asm/thread_info.h | 17 +- arch/mips/include/uapi/asm/ptrace.h | 7 +- arch/mips/kernel/Makefile | 14 +- arch/mips/kernel/entry.S | 75 ++------ arch/mips/kernel/linux32.c | 1 - arch/mips/kernel/ptrace.c | 78 -------- arch/mips/kernel/scall.S | 137 +++++++++++++ arch/mips/kernel/scall32-o32.S | 223 ---------------------- arch/mips/kernel/scall64-n32.S | 107 ----------- arch/mips/kernel/scall64-n64.S | 116 ----------- arch/mips/kernel/scall64-o32.S | 221 --------------------- arch/mips/kernel/signal.c | 35 ++-- arch/mips/kernel/signal_n32.c | 15 +- arch/mips/kernel/signal_o32.c | 29 +-- arch/mips/kernel/syscall.c | 148 +++++++++++--- arch/mips/kernel/syscalls/syscall_n32.tbl | 8 +- arch/mips/kernel/syscalls/syscall_n64.tbl | 8 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 8 +- 23 files changed, 349 insertions(+), 995 deletions(-) create mode 100644 arch/mips/include/asm/entry-common.h delete mode 100644 arch/mips/include/asm/sim.h create mode 100644 arch/mips/kernel/scall.S delete mode 100644 arch/mips/kernel/scall32-o32.S delete mode 100644 arch/mips/kernel/scall64-n32.S delete mode 100644 arch/mips/kernel/scall64-n64.S delete mode 100644 arch/mips/kernel/scall64-o32.S
arch/mips/Kconfig +1 -0
@@ -32,6 +32,7 @@ config MIPS select GENERIC_ATOMIC64 if !64BIT select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE + select GENERIC_ENTRY select GENERIC_GETTIMEOFDAY select GENERIC_IOMAP select GENERIC_IRQ_PROBE
arch/mips/include/asm/entry-common.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef ARCH_LOONGARCH_ENTRY_COMMON_H +#define ARCH_LOONGARCH_ENTRY_COMMON_H + +#include <linux/sched.h> +#include <linux/processor.h> + +static inline bool on_thread_stack (void ) +{ +return !(((unsigned long )(current->stack) ^ current_stack_pointer) & ~(THREAD_SIZE -1 )); +} + +#endif
arch/mips/include/asm/ptrace.h +5 -3
@@ -51,6 +51,11 @@ struct pt_regs {unsigned long __last[0 ]; }__aligned(8) ; +static inline int regs_irqs_disabled (struct pt_regs *regs) +{ +return arch_irqs_disabled_flags (regs->cp0_status); +} +static inline unsigned long kernel_stack_pointer (struct pt_regs *regs) {return regs->regs[29 ];
@@ -156,9 +161,6 @@ static inline long regs_return_value(struct pt_regs *regs)#define instruction_pointer (regs) ((regs)->cp0_epc)#define profile_pc (regs) instruction_pointer(regs) -extern asmlinkage long syscall_trace_enter (struct pt_regs *regs,long syscall); -extern asmlinkage void syscall_trace_leave(struct pt_regs *regs); -extern void die (const char *,struct pt_regs *)__noreturn ;static inline void die_if_kernel (const char *str,struct pt_regs *regs)
arch/mips/include/asm/sim.h deleted +0 -70
70 lines not on this page · raw message
arch/mips/include/asm/syscall.h +5 -0
@@ -157,4 +157,9 @@ static inline int syscall_get_arch(struct task_struct *task) return arch; } +static inline bool arch_syscall_is_vdso_sigreturn (struct pt_regs *regs) +{ +return false; +} +#endif /* __ASM_MIPS_SYSCALL_H */
arch/mips/include/asm/thread_info.h +4 -13
@@ -29,7 +29,8 @@ struct thread_info {__u32 cpu;/* current CPU */ int preempt_count;/* 0 => preemptable, <0 => BUG */ struct pt_regs *regs; -long syscall;/* syscall number */ +unsigned long syscall;/* syscall number */ +unsigned long syscall_work;/* SYSCALL_WORK_ flags */ };/*
@@ -69,6 +70,8 @@ static inline struct thread_info *current_thread_info(void) return __current_thread_info; } +registerunsigned long current_stack_pointer __asm__("$29" ); +#endif /* !__ASSEMBLY__ */ /* thread information allocation */
@@ -149,22 +152,10 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_MSA_CTX_LIVE (1<<TIF_MSA_CTX_LIVE)#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT) -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \ - _TIF_SYSCALL_AUDIT | \ - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP) - -/* work to do in syscall_trace_leave() */ -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \ - _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT) -/* work to do on interrupt/exception return */ #define _TIF_WORK_MASK \ (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME | \ _TIF_UPROBE | _TIF_NOTIFY_SIGNAL) -/* work to do on any return to u-space */ -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \ - _TIF_WORK_SYSCALL_EXIT | \ - _TIF_SYSCALL_TRACEPOINT)/* * We stash processor id into a COP0 register to retrieve it fast
arch/mips/include/uapi/asm/ptrace.h +4 -3
@@ -102,8 +102,9 @@ struct pt_watch_regs { }; }; -#define PTRACE_GET_WATCH_REGS 0xd0 -#define PTRACE_SET_WATCH_REGS 0xd1 - +#define PTRACE_SYSEMU 0x1f +#define PTRACE_SYSEMU_SINGLESTEP 0x20 +#define PTRACE_GET_WATCH_REGS 0xd0 +#define PTRACE_SET_WATCH_REGS 0xd1#endif /* _UAPI_ASM_PTRACE_H */
arch/mips/kernel/Makefile +6 -8
@@ -5,10 +5,10 @@ extra-y := head.o vmlinux.lds -obj-y += branch.o cmpxchg.o elf.o entry.o genex.o idle.o irq.o \ - process.o prom.o ptrace.o reset.o setup.o signal.o \ - syscall.o time.o topology.o traps.o unaligned.o watch.o \ - vdso.o cacheinfo.o +obj-y += branch.o cacheinfo.o cmpxchg.o elf.o entry.o genex.o \ + idle.o irq.o process.o prom.o ptrace.o reset.o scall.o \ + setup.o signal.o syscall.o time.o topology.o traps.o \ + unaligned.o watch.o vdso.o ifdef CONFIG_CPU_R3K_TLB obj-y += cpu-r3k-probe.o
@@ -76,11 +76,9 @@ obj-$(CONFIG_IRQ_TXX9) += irq_txx9.o obj-$(CONFIG_IRQ_GT641XX) += irq-gt641xx.o obj-$(CONFIG_KPROBES) += kprobes.o -obj-$(CONFIG_32BIT) += scall32-o32.o -obj-$(CONFIG_64BIT) += scall64-n64.o obj-$(CONFIG_MIPS32_COMPAT) += linux32.o ptrace32.o signal32.o -obj-$(CONFIG_MIPS32_N32) += scall64-n32.o signal_n32.o -obj-$(CONFIG_MIPS32_O32) += scall64-o32.o signal_o32.o +obj-$(CONFIG_MIPS32_N32) += signal_n32.o +obj-$(CONFIG_MIPS32_O32) += signal_o32.o obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_PROC_FS) += proc.o
arch/mips/kernel/entry.S +16 -59
97 lines not on this page · raw message
arch/mips/kernel/linux32.c +0 -1
@@ -38,7 +38,6 @@#include <net/scm.h> #include <asm/compat-signal.h> -#include <asm/sim.h> #include <linux/uaccess.h> #include <asm/mmu_context.h> #include <asm/mman.h>
arch/mips/kernel/ptrace.c +0 -78
87 lines not on this page · raw message
arch/mips/kernel/scall.S new file +137 -0
137 lines not on this page · raw message
arch/mips/kernel/scall32-o32.S deleted +0 -223
223 lines not on this page · raw message
arch/mips/kernel/scall64-n32.S deleted +0 -107
107 lines not on this page · raw message
arch/mips/kernel/scall64-n64.S deleted +0 -116
116 lines not on this page · raw message
arch/mips/kernel/scall64-o32.S deleted +0 -221
221 lines not on this page · raw message
arch/mips/kernel/signal.c +11 -24
@@ -32,7 +32,6 @@#include <linux/bitops.h> #include <asm/cacheflush.h> #include <asm/fpu.h> -#include <asm/sim.h> #include <asm/ucontext.h> #include <asm/cpu-features.h> #include <asm/war.h>
@@ -627,7 +626,7 @@ SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,#endif #ifdef CONFIG_TRAD_SIGNALS -asmlinkage void sys_sigreturn(void) +asmlinkage long sys_sigreturn (void ) {struct sigframe __user *frame;struct pt_regs *regs;
@@ -649,22 +648,16 @@ asmlinkage void sys_sigreturn(void) else if (sig)force_sig (sig); -/* -* Don't let your children do this ... -*/ -__asm__ __volatile__ ( - "move\t$29, %0\n\t" - "j\tsyscall_exit" - : /* no outputs */ - : "r" (regs)); -/* Unreached */ + regs->regs[27] = 1; /* return directly */ + return regs->regs[2]; badframe:force_sig (SIGSEGV ); + return 0; } #endif /* CONFIG_TRAD_SIGNALS */ -asmlinkage void sys_rt_sigreturn(void) +asmlinkage long sys_rt_sigreturn(void) {struct rt_sigframe __user *frame;struct pt_regs *regs;
@@ -689,18 +682,12 @@ asmlinkage void sys_rt_sigreturn(void)if (restore_altstack (&frame->rs_uc.uc_stack)) goto badframe; -/* -* Don't let your children do this ... -*/ - __asm__ __volatile__( -"move\t$29, %0\n\t" -"j\tsyscall_exit" - :/* no outputs */ - :"r" (regs)); -/* Unreached */ + regs->regs[27 ] =1 ;/* return directly */ +return regs->regs[2 ]; badframe:force_sig (SIGSEGV ); +return 0 ; }#ifdef CONFIG_TRAD_SIGNALS
@@ -852,11 +839,11 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)signal_setup_done (ret, ksig,0 ); } -static void do_signal (struct pt_regs *regs) +void arch_do_signal_or_restart (struct pt_regs *regs,bool has_signal) {struct ksignal ksig; -if (get_signal (&ksig)) { +if (has_signal &&get_signal (&ksig)) {/* Whee! Actually deliver the signal. */ handle_signal (&ksig, regs);return ;
@@ -904,7 +891,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,/* deal with pending signal delivery */ if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) -do_signal (regs); +arch_do_signal_or_restart (regs, thread_info_flags & _TIF_SIGPENDING);if (thread_info_flags & _TIF_NOTIFY_RESUME) {tracehook_notify_resume (regs);
arch/mips/kernel/signal_n32.c +4 -11
@@ -19,7 +19,6 @@#include <asm/asm.h> #include <asm/cacheflush.h> #include <asm/compat-signal.h> -#include <asm/sim.h> #include <linux/uaccess.h> #include <asm/ucontext.h> #include <asm/fpu.h>
@@ -51,7 +50,7 @@ struct rt_sigframe_n32 {struct ucontextn32 rs_uc; }; -asmlinkage void sysn32_rt_sigreturn(void) +asmlinkage long sysn32_rt_sigreturn (void ) {struct rt_sigframe_n32 __user *frame;struct pt_regs *regs;
@@ -76,18 +75,12 @@ asmlinkage void sysn32_rt_sigreturn(void)if (compat_restore_altstack (&frame->rs_uc.uc_stack)) goto badframe; -/* -* Don't let your children do this ... -*/ - __asm__ __volatile__( -"move\t$29, %0\n\t" -"j\tsyscall_exit" - :/* no outputs */ - :"r" (regs)); -/* Unreached */ + regs->regs[27 ] =1 ;/* return directly */ +return regs->regs[2 ]; badframe:force_sig (SIGSEGV ); +return 0 ; } static int setup_rt_frame_n32(void *sig_return, struct ksignal *ksig,
arch/mips/kernel/signal_o32.c +8 -21
@@ -17,7 +17,6 @@#include <asm/abi.h> #include <asm/compat-signal.h> #include <asm/dsp.h> -#include <asm/sim.h> #include <asm/unistd.h> #include "signal-common.h"
@@ -151,7 +150,7 @@ static int setup_frame_32(void *sig_return, struct ksignal *ksig,return 0 ; } -asmlinkage void sys32_rt_sigreturn(void) +asmlinkage long sys32_rt_sigreturn (void ) {struct rt_sigframe32 __user *frame;struct pt_regs *regs;
@@ -176,18 +175,12 @@ asmlinkage void sys32_rt_sigreturn(void)if (compat_restore_altstack (&frame->rs_uc.uc_stack)) goto badframe; -/* -* Don't let your children do this ... -*/ - __asm__ __volatile__( -"move\t$29, %0\n\t" -"j\tsyscall_exit" - :/* no outputs */ - :"r" (regs)); -/* Unreached */ + regs->regs[27 ] =1 ;/* return directly */ +return regs->regs[2 ]; badframe:force_sig (SIGSEGV ); +return 0 ; } static int setup_rt_frame_32(void *sig_return, struct ksignal *ksig,
@@ -253,7 +246,7 @@ struct mips_abi mips_abi_32 = { }; -asmlinkage void sys32_sigreturn(void) +asmlinkage long sys32_sigreturn (void ) {struct sigframe32 __user *frame;struct pt_regs *regs;
@@ -275,16 +268,10 @@ asmlinkage void sys32_sigreturn(void)else if (sig)force_sig (sig); -/* -* Don't let your children do this ... -*/ - __asm__ __volatile__( -"move\t$29, %0\n\t" -"j\tsyscall_exit" - :/* no outputs */ - :"r" (regs)); -/* Unreached */ + regs->regs[27 ] =1 ;/* return directly */ +return regs->regs[2 ]; badframe:force_sig (SIGSEGV ); +return 0 ; }
arch/mips/kernel/syscall.c +123 -25
179 lines not on this page · raw message
arch/mips/kernel/syscalls/syscall_n32.tbl +4 -4
@@ -62,8 +62,8 @@ 52 n32 socketpair sys_socketpair 53 n32 setsockopt sys_setsockopt 54 n32 getsockopt sys_getsockopt -55 n32 clone __sys_clone -56 n32 fork __sys_fork +55 n32 clone sys_clone +56 n32 fork sys_fork 57 n32 execve compat_sys_execve 58 n32 exit sys_exit 59 n32 wait4 compat_sys_wait4
@@ -207,7 +207,7 @@ 196 n32 sched_getaffinity compat_sys_sched_getaffinity 197 n32 cacheflush sys_cacheflush 198 n32 cachectl sys_cachectl -199 n32 sysmips __sys_sysmips +199 n32 sysmips sys_sysmips 200 n32 io_setup compat_sys_io_setup 201 n32 io_destroy sys_io_destroy 202 n32 io_getevents sys_io_getevents_time32
@@ -373,7 +373,7 @@ 432 n32 fsmount sys_fsmount 433 n32 fspick sys_fspick 434 n32 pidfd_open sys_pidfd_open -435 n32 clone3 __sys_clone3 +435 n32 clone3 sys_clone3 436 n32 close_range sys_close_range 437 n32 openat2 sys_openat2 438 n32 pidfd_getfd sys_pidfd_getfd
arch/mips/kernel/syscalls/syscall_n64.tbl +4 -4
@@ -62,8 +62,8 @@ 52 n64 socketpair sys_socketpair 53 n64 setsockopt sys_setsockopt 54 n64 getsockopt sys_getsockopt -55 n64 clone __sys_clone -56 n64 fork __sys_fork +55 n64 clone sys_clone +56 n64 fork sys_fork 57 n64 execve sys_execve 58 n64 exit sys_exit 59 n64 wait4 sys_wait4
@@ -207,7 +207,7 @@ 196 n64 sched_getaffinity sys_sched_getaffinity 197 n64 cacheflush sys_cacheflush 198 n64 cachectl sys_cachectl -199 n64 sysmips __sys_sysmips +199 n64 sysmips sys_sysmips 200 n64 io_setup sys_io_setup 201 n64 io_destroy sys_io_destroy 202 n64 io_getevents sys_io_getevents
@@ -349,7 +349,7 @@ 432 n64 fsmount sys_fsmount 433 n64 fspick sys_fspick 434 n64 pidfd_open sys_pidfd_open -435 n64 clone3 __sys_clone3 +435 n64 clone3 sys_clone3 436 n64 close_range sys_close_range 437 n64 openat2 sys_openat2 438 n64 pidfd_getfd sys_pidfd_getfd
arch/mips/kernel/syscalls/syscall_o32.tbl +4 -4
@@ -9,7 +9,7 @@ # 0 o32 syscall sys_syscall sys32_syscall 1 o32 exit sys_exit -2 o32 fork __sys_fork +2 o32 fork sys_fork 3 o32 read sys_read 4 o32 write sys_write 5 o32 open sys_open compat_sys_open
@@ -131,7 +131,7 @@ 117 o32 ipc sys_ipc compat_sys_ipc 118 o32 fsync sys_fsync 119 o32 sigreturn sys_sigreturn sys32_sigreturn -120 o32 clone __sys_clone +120 o32 clone sys_clone 121 o32 setdomainname sys_setdomainname 122 o32 uname sys_newuname 123 o32 modify_ldt sys_ni_syscall
@@ -160,7 +160,7 @@ 146 o32 writev sys_writev 147 o32 cacheflush sys_cacheflush 148 o32 cachectl sys_cachectl -149 o32 sysmips __sys_sysmips +149 o32 sysmips sys_sysmips 150 o32 unused150 sys_ni_syscall 151 o32 getsid sys_getsid 152 o32 fdatasync sys_fdatasync
@@ -422,7 +422,7 @@ 432 o32 fsmount sys_fsmount 433 o32 fspick sys_fspick 434 o32 pidfd_open sys_pidfd_open -435 o32 clone3 __sys_clone3 +435 o32 clone3 sys_clone3 436 o32 close_range sys_close_range 437 o32 openat2 sys_openat2 438 o32 pidfd_getfd sys_pidfd_getfd
Signature · 1 line
2.27.0
PATCH v2 2/2 MIPS: convert irq to generic entry
In reply to Feiyang ChenConvert MIPS irq to use the generic entry infrastructure from kernel/entry/*.
When entering the handler functions written in C, there are three
status: STI, CLI and KMODE. Now use CLI for all handler functions, since interrupts must be disabled before calling irqentry_enter().
- For handler functions who originally used STI, enable interrupts after calling irqentry_enter().
- For handler functions who originally used KMODE, enable interrupts after calling irqentry_enter() only if they are enabled in the parent context.
- If CONFIG_HARDWARE_WATCHPOINTS is defined, interrupts will be enabled after the watch registers are read. Only enable interrupts manually in do_watch() if it is not defined.
Use call_on_irq_stack() to help invoking a function on IRQ stack.
--- arch/mips/include/asm/irqflags.h | 42 ------ arch/mips/include/asm/stackframe.h | 8 + arch/mips/kernel/entry.S | 82 ----------- arch/mips/kernel/genex.S | 150 ++++--------------- arch/mips/kernel/head.S | 1 - arch/mips/kernel/r4k-bugs64.c | 14 +- arch/mips/kernel/scall.S | 1 - arch/mips/kernel/signal.c | 26 ---- arch/mips/kernel/traps.c | 225 +++++++++++++++++++++-------- arch/mips/kernel/unaligned.c | 19 ++- arch/mips/mm/c-octeon.c | 15 ++ arch/mips/mm/cex-oct.S | 8 +- arch/mips/mm/fault.c | 12 +- arch/mips/mm/tlbex-fault.S | 7 +- 14 files changed, 254 insertions(+), 356 deletions(-)
arch/mips/include/asm/irqflags.h +0 -42
@@ -11,8 +11,6 @@#ifndef _ASM_IRQFLAGS_H#define _ASM_IRQFLAGS_H -#ifndef __ASSEMBLY__ -#include <linux/compiler.h> #include <linux/stringify.h> #include <asm/compiler.h>
@@ -142,44 +140,4 @@ static inline int arch_irqs_disabled(void) return arch_irqs_disabled_flags(arch_local_save_flags()); } -#endif /* #ifndef __ASSEMBLY__ */ - -/* -* Do the CPU's IRQ-state tracing from assembly code. -*/ -#ifdef CONFIG_TRACE_IRQFLAGS -/* Reload some registers clobbered by trace_hardirqs_on */ -#ifdef CONFIG_64BIT -# define TRACE_IRQS_RELOAD_REGS \ - LONG_L $11, PT_R11(sp); \ - LONG_L $10, PT_R10(sp); \ - LONG_L $9, PT_R9(sp); \ - LONG_L $8, PT_R8(sp); \ - LONG_L $7, PT_R7(sp); \ - LONG_L $6, PT_R6(sp); \ - LONG_L $5, PT_R5(sp); \ - LONG_L $4, PT_R4(sp); \ - LONG_L $2, PT_R2(sp) -#else -# define TRACE_IRQS_RELOAD_REGS \ - LONG_L $7, PT_R7(sp); \ - LONG_L $6, PT_R6(sp); \ - LONG_L $5, PT_R5(sp); \ - LONG_L $4, PT_R4(sp); \ - LONG_L $2, PT_R2(sp) -#endif -# define TRACE_IRQS_ON \ - CLI; /* make sure trace_hardirqs_on() is called in kernel level */ \ - jal trace_hardirqs_on -# define TRACE_IRQS_ON_RELOAD \ - TRACE_IRQS_ON; \ - TRACE_IRQS_RELOAD_REGS -# define TRACE_IRQS_OFF \ - jal trace_hardirqs_off -#else -# define TRACE_IRQS_ON -# define TRACE_IRQS_ON_RELOAD -# define TRACE_IRQS_OFF -#endif -#endif /* _ASM_IRQFLAGS_H */
arch/mips/include/asm/stackframe.h +8 -0
@@ -444,6 +444,14 @@ RESTORE_SP \docfi .endm + .macro RESTORE_ALL_AND_RET docfi=0 + RESTORE_TEMP \docfi + RESTORE_STATIC \docfi + RESTORE_AT \docfi + RESTORE_SOME \docfi + RESTORE_SP_AND_RET \docfi + .endm +/* * Move to kernel mode and disable interrupts. * Set cp0 enable bit as sign that we're running on the kernel stack
arch/mips/kernel/entry.S +0 -82
102 lines not on this page · raw message
arch/mips/kernel/genex.S +28 -122
230 lines not on this page · raw message
arch/mips/kernel/head.S +0 -1
@@ -19,7 +19,6 @@ #include <asm/addrspace.h> #include <asm/asm.h> #include <asm/asmmacro.h> -#include <asm/irqflags.h> #include <asm/regdef.h> #include <asm/mipsregs.h> #include <asm/stackframe.h>
arch/mips/kernel/r4k-bugs64.c +10 -4
@@ -3,6 +3,7 @@* Copyright (C) 2003, 2004, 2007 Maciej W. Rozycki */ #include <linux/context_tracking.h> +#include <linux/entry-common.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/ptrace.h>
@@ -168,14 +169,19 @@ static __always_inline __init void check_mult_sh(void)static volatile int daddi_ov; -asmlinkage void __init do_daddi_ov(struct pt_regs *regs) +asmlinkage void noinstr __init do_daddi_ov(struct pt_regs *regs) { -enum ctx_state prev_state; +irqentry_state_t state =irqentry_enter (regs); + +/* Enable interrupt if enabled in parent context */ +if (likely (!regs_irqs_disabled (regs))) +local_irq_enable (); - prev_state =exception_enter (); daddi_ov =1 ; regs->cp0_epc +=4 ; -exception_exit (prev_state); + +local_irq_disable (); +irqentry_exit (regs, state); }static __init void check_daddi (void )
arch/mips/kernel/scall.S +0 -1
@@ -9,7 +9,6 @@ #include <linux/errno.h> #include <asm/asm.h> #include <asm/asmmacro.h> -#include <asm/irqflags.h> #include <asm/mipsregs.h> #include <asm/regdef.h> #include <asm/stackframe.h>
arch/mips/kernel/signal.c +0 -26
@@ -875,32 +875,6 @@ void arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal)restore_saved_sigmask (); } -/* -* notification of userspace execution resumption -* - triggered by the TIF_WORK_MASK flags -*/ -asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused, -__u32 thread_info_flags) -{ -local_irq_enable (); - -user_exit (); - -if (thread_info_flags & _TIF_UPROBE) -uprobe_notify_resume (regs); - -/* deal with pending signal delivery */ -if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) -arch_do_signal_or_restart (regs, thread_info_flags & _TIF_SIGPENDING); - -if (thread_info_flags & _TIF_NOTIFY_RESUME) { -tracehook_notify_resume (regs); -rseq_handle_notify_resume (NULL , regs); - } - -user_enter (); -} -#if defined(CONFIG_SMP ) && defined(CONFIG_MIPS_FP_SUPPORT )static int smp_save_fp_context (void __user *sc) {
arch/mips/kernel/traps.c +164 -61
464 lines not on this page · raw message
arch/mips/kernel/unaligned.c +11 -8
@@ -74,6 +74,7 @@* Undo the partial store in this case. */ #include <linux/context_tracking.h> +#include <linux/entry-common.h> #include <linux/mm.h> #include <linux/signal.h> #include <linux/smp.h>
@@ -1472,12 +1473,15 @@ static void emulate_load_store_MIPS16e(struct pt_regs *regs, void __user * addr)force_sig (SIGILL ); } -asmlinkage void do_ade(struct pt_regs *regs) +asmlinkage void noinstr do_ade(struct pt_regs *regs) { -enum ctx_state prev_state; +irqentry_state_t state =irqentry_enter (regs);unsigned int *pc; - prev_state =exception_enter (); +/* Enable interrupt if enabled in parent context */ +if (likely (!regs_irqs_disabled (regs))) +local_irq_enable (); +perf_sw_event (PERF_COUNT_SW_ALIGNMENT_FAULTS ,1 , regs, regs->cp0_badvaddr);/*
@@ -1530,16 +1534,15 @@ asmlinkage void do_ade(struct pt_regs *regs)emulate_load_store_insn (regs, (void __user *)regs->cp0_badvaddr, pc); -return ; + goto out; sigbus:die_if_kernel ("Kernel unaligned instruction access" , regs);force_sig (SIGBUS ); -/* -* XXX On return from the signal handler we should advance the epc -*/ -exception_exit (prev_state); +out: +local_irq_disable (); +irqentry_exit (regs, state); }#ifdef CONFIG_DEBUG_FS
arch/mips/mm/c-octeon.c +15 -0
@@ -5,6 +5,7 @@* * Copyright (C) 2005-2007 Cavium Networks */ +#include <linux/entry-common.h> #include <linux/export.h> #include <linux/kernel.h> #include <linux/sched.h>
@@ -349,3 +350,17 @@ asmlinkage void cache_parity_error_octeon_non_recoverable(void)co_cache_error_call_notifiers (1 );panic ("Can't handle cache error: nested exception" ); } + +asmlinkage void noinstr do_cache_err(struct pt_regs *regs) +{ +irqentry_state_t state =irqentry_enter (regs); + +/* Enable interrupt if enabled in parent context */ +if (likely (!regs_irqs_disabled (regs))) +local_irq_enable (); + +cache_parity_error_octeon_recoverable (); + +local_irq_disable (); +irqentry_exit (regs, state); +}
arch/mips/mm/cex-oct.S +4 -4
@@ -60,11 +60,11 @@ .set noat SAVE_ALL - KMODE - jal cache_parity_error_octeon_recoverable - nop - j ret_from_exception + CLI + move a0, sp + jal do_cache_err nop + RESTORE_ALL_AND_RET .set pop END(handle_cache_err)
arch/mips/mm/fault.c +9 -3
@@ -8,6 +8,7 @@#include <linux/context_tracking.h> #include <linux/signal.h> #include <linux/sched.h> +#include <linux/entry-common.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/errno.h>
@@ -327,9 +328,14 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,unsigned long write,unsigned long address) { -enum ctx_state prev_state; +irqentry_state_t state =irqentry_enter (regs); + +/* Enable interrupt if enabled in parent context */ +if (likely (!regs_irqs_disabled (regs))) +local_irq_enable (); - prev_state =exception_enter ();__do_page_fault (regs, write, address); -exception_exit (prev_state); + +local_irq_disable (); +irqentry_exit (regs, state); }
arch/mips/mm/tlbex-fault.S +5 -2
@@ -15,12 +15,15 @@ .cfi_signal_frame SAVE_ALL docfi=1 MFC0 a2, CP0_BADVADDR - KMODE + CLI move a0, sp REG_S a2, PT_BVADDR(sp) li a1, \write jal do_page_fault - j ret_from_exception + + .set noat + RESTORE_ALL_AND_RET + .set at END(tlb_do_page_fault_\write) .endm
Signature · 1 line
2.27.0
Quoted 5 lines · Feiyang Chen
Convert MIPS to use the generic entry infrastructure from
kernel/entry/*.v2: Use regs->regs[27] to mark whether to restore all registers in
handle_sysand enable IRQ stack.
Hi Feiyang,
Thanks for your patch, could you please expand how could this improve the performance?
Thanks.
- Jiaxun
Quoted 48 lines
Feiyang Chen (2):
MIPS: convert syscall to generic entry
MIPS: convert irq to generic entryarch/mips/Kconfig | 1 + arch/mips/include/asm/entry-common.h | 13 ++ arch/mips/include/asm/irqflags.h | 42 ---- arch/mips/include/asm/ptrace.h | 8 +- arch/mips/include/asm/sim.h | 70 ------- arch/mips/include/asm/stackframe.h | 8 + arch/mips/include/asm/syscall.h | 5 + arch/mips/include/asm/thread_info.h | 17 +- arch/mips/include/uapi/asm/ptrace.h | 7 +- arch/mips/kernel/Makefile | 14 +- arch/mips/kernel/entry.S | 143 +------------- arch/mips/kernel/genex.S | 150 +++------------ arch/mips/kernel/head.S | 1 - arch/mips/kernel/linux32.c | 1 - arch/mips/kernel/ptrace.c | 78 -------- arch/mips/kernel/r4k-bugs64.c | 14 +- arch/mips/kernel/scall.S | 136 +++++++++++++ arch/mips/kernel/scall32-o32.S | 223 --------------------- arch/mips/kernel/scall64-n32.S | 107 ---------- arch/mips/kernel/scall64-n64.S | 116 ----------- arch/mips/kernel/scall64-o32.S | 221 --------------------- arch/mips/kernel/signal.c | 59 +----- arch/mips/kernel/signal_n32.c | 15 +- arch/mips/kernel/signal_o32.c | 29 +-- arch/mips/kernel/syscall.c | 148 +++++++++++--- arch/mips/kernel/syscalls/syscall_n32.tbl | 8 +- arch/mips/kernel/syscalls/syscall_n64.tbl | 8 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 8 +- arch/mips/kernel/traps.c | 225 ++++++++++++++++------ arch/mips/kernel/unaligned.c | 19 +- arch/mips/mm/c-octeon.c | 15 ++ arch/mips/mm/cex-oct.S | 8 +- arch/mips/mm/fault.c | 12 +- arch/mips/mm/tlbex-fault.S | 7 +- 34 files changed, 594 insertions(+), 1342 deletions(-)create mode 100644
arch/mips/include/asm/entry-common.hdelete mode 100644arch/mips/include/asm/sim.hcreate mode 100644arch/mips/kernel/scall.Sdelete mode 100644arch/mips/kernel/scall32-o32.Sdelete mode 100644arch/mips/kernel/scall64-n32.Sdelete mode 100644arch/mips/kernel/scall64-n64.Sdelete mode 100644arch/mips/kernel/scall64-o32.S
Quoted 7 lines · Jiaxun Yang
Quoted 3 lines · Feiyang Chen
Convert MIPS to use the generic entry infrastructure from
kernel/entry/*.
Quoted 7 lines
Quoted 2 lines
v2: Use regs->regs[27] to mark whether to restore all registers in
handle_sysand enable IRQ stack.Hi Feiyang,
Thanks for your patch, could you please expand how could this improve the performance?
Hi, Jiaxun,
We always restore all registers in handle_sys in the v1 of the patchset. Since regs->regs[27] is marked where we need to restore all registers, now we simply use it as the return value of do_syscall to determine whether we can only restore partial registers in handle_sys.
+ move a0, sp + jal do_syscall + beqz v0, 1f # restore all registers? + nop + + .set noat + RESTORE_TEMP + RESTORE_STATIC + RESTORE_AT +1: RESTORE_SOME + RESTORE_SP_AND_RET + .set at
Thanks,
Feiyang
Quoted 51 lines
Thanks.
- JiaxunQuoted 48 lines
Feiyang Chen (2):
MIPS: convert syscall to generic entry
MIPS: convert irq to generic entryarch/mips/Kconfig | 1 + arch/mips/include/asm/entry-common.h | 13 ++ arch/mips/include/asm/irqflags.h | 42 ---- arch/mips/include/asm/ptrace.h | 8 +- arch/mips/include/asm/sim.h | 70 ------- arch/mips/include/asm/stackframe.h | 8 + arch/mips/include/asm/syscall.h | 5 + arch/mips/include/asm/thread_info.h | 17 +- arch/mips/include/uapi/asm/ptrace.h | 7 +- arch/mips/kernel/Makefile | 14 +- arch/mips/kernel/entry.S | 143 +------------- arch/mips/kernel/genex.S | 150 +++------------ arch/mips/kernel/head.S | 1 - arch/mips/kernel/linux32.c | 1 - arch/mips/kernel/ptrace.c | 78 -------- arch/mips/kernel/r4k-bugs64.c | 14 +- arch/mips/kernel/scall.S | 136 +++++++++++++ arch/mips/kernel/scall32-o32.S | 223 --------------------- arch/mips/kernel/scall64-n32.S | 107 ---------- arch/mips/kernel/scall64-n64.S | 116 ----------- arch/mips/kernel/scall64-o32.S | 221 --------------------- arch/mips/kernel/signal.c | 59 +----- arch/mips/kernel/signal_n32.c | 15 +- arch/mips/kernel/signal_o32.c | 29 +-- arch/mips/kernel/syscall.c | 148 +++++++++++--- arch/mips/kernel/syscalls/syscall_n32.tbl | 8 +- arch/mips/kernel/syscalls/syscall_n64.tbl | 8 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 8 +- arch/mips/kernel/traps.c | 225 ++++++++++++++++------ arch/mips/kernel/unaligned.c | 19 +- arch/mips/mm/c-octeon.c | 15 ++ arch/mips/mm/cex-oct.S | 8 +- arch/mips/mm/fault.c | 12 +- arch/mips/mm/tlbex-fault.S | 7 +- 34 files changed, 594 insertions(+), 1342 deletions(-)create mode 100644
arch/mips/include/asm/entry-common.hdelete mode 100644arch/mips/include/asm/sim.hcreate mode 100644arch/mips/kernel/scall.Sdelete mode 100644arch/mips/kernel/scall32-o32.Sdelete mode 100644arch/mips/kernel/scall64-n32.Sdelete mode 100644arch/mips/kernel/scall64-n64.Sdelete mode 100644arch/mips/kernel/scall64-o32.S
Thomas Bogendoerfer
maintainerQuoted 16 lines · Feiyang Chen
Quoted 7 lines · Jiaxun Yang
Quoted 3 lines · Feiyang Chen
Convert MIPS to use the generic entry infrastructure from
kernel/entry/*.Quoted 7 lines
Quoted 2 lines
v2: Use regs->regs[27] to mark whether to restore all registers in
handle_sysand enable IRQ stack.Hi Feiyang,
Thanks for your patch, could you please expand how could this improve the performance?
Quoted 6 lines
Hi, Jiaxun,
We always restore all registers in
handle_sysin the v1 of the patchset. Since regs->regs[27] is marked where we need to restore all registers, now we simply use it as the return value ofdo_syscallto determine whether we can only restore partial registers inhandle_sys.
can people, who provided performance numbers for v1 do the same for v2 ?
Thomas,
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Hi Thomas,
Quoted 15 lines · Thomas Bogendoerfer
Quoted 14 lines · Feiyang Chen
Quoted 13 lines · Jiaxun Yang
Quoted 5 lines · Feiyang Chen
Convert MIPS to use the generic entry infrastructure from
kernel/entry/*.v2: Use regs->regs[27] to mark whether to restore all registers in
handle_sysand enable IRQ stack.Hi Feiyang,
Thanks for your patch, could you please expand how could this improve the performance?
Quoted 7 lines
Quoted 6 lines
Hi, Jiaxun,
We always restore all registers in
handle_sysin the v1 of the patchset. Since regs->regs[27] is marked where we need to restore all registers, now we simply use it as the return value ofdo_syscallto determine whether we can only restore partial registers inhandle_sys.can people, who provided performance numbers for v1 do the same for v2 ?
Sure, I will test the v2 in the next few days.
Thanks and best regards!
Quoted 3 lines
Thomas,
Hi Thomas,
Quoted 20 lines · Zhou Yanjie
Hi Thomas,
Quoted 17 lines · Thomas Bogendoerfer
Quoted 16 lines · Feiyang Chen
Quoted 6 lines · Jiaxun Yang
Quoted 3 lines · Feiyang Chen
Convert MIPS to use the generic entry infrastructure from
kernel/entry/*.Quoted 7 lines
Quoted 2 lines
v2: Use regs->regs[27] to mark whether to restore all registers in
handle_sysand enable IRQ stack.Hi Feiyang,
Thanks for your patch, could you please expand how could this improve the performance?
Hi, Jiaxun,
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
We always restore all registers in
handle_sysin the v1 of the patchset. Since regs->regs[27] is marked where we need to restore all registers, now we simply use it as the return value ofdo_syscallto determine whether we can only restore partial registers inhandle_sys.can people, who provided performance numbers for v1 do the same for v2 ?
Sure, I will test the v2 in the next few days.
Sorry for the delay, It took a lot of time to migrate the environment to my new computer, here is the results:
Score Without Patches Score With Patches Performance Change SoC Model 105.9 102.1 -3.6% JZ4775 132.4 124.1 -6.3% JZ4780(SMP off) 170.2 155.7 -8.5% JZ4780(SMP on) 101.3 91.5 -9.7% X1000E 187.1 179.4 -4.1% X1830 324.9 314.3 -3.3% X2000(SMT off) 394.6 373.9 -5.2% X2000(SMT off)
Compared with the V1 version, there are some improvements, but the performance loss is still a bit obvious
Thanks and best regards!
Quoted 8 lines
Thanks and best regards!
Quoted 3 lines
Thomas,
Quoted 20 lines · Zhou Yanjie
Quoted 4 lines
Quoted 1 line
can people, who provided performance numbers for v1 do the same for v2 ?
Sure, I will test the v2 in the next few days.
Sorry for the delay, It took a lot of time to migrate the environment to my new computer, here is the results:
Score Without Patches Score With Patches Performance Change SoC Model 105.9 102.1 -3.6% JZ4775 132.4 124.1 -6.3% JZ4780(SMP off) 170.2 155.7 -8.5% JZ4780(SMP on) 101.3 91.5 -9.7% X1000E 187.1 179.4 -4.1% X1830 324.9 314.3 -3.3% X2000(SMT off) 394.6 373.9 -5.2% X2000(SMT off)
Quoted 2 lines
Compared with the V1 version, there are some improvements, but the performance loss is still a bit obvious
The MIPS port of Linux has always had the pride of having a particularly
low syscall overhead and I'd rather we didn't lose this quality.
FWIW,
Maciej
Quoted 23 lines · Maciej W. Rozycki
Quoted 20 lines · Zhou Yanjie
Quoted 4 lines
Quoted 1 line
can people, who provided performance numbers for v1 do the same for v2 ?
Sure, I will test the v2 in the next few days.
Sorry for the delay, It took a lot of time to migrate the environment to my new computer, here is the results:
Score Without Patches Score With Patches Performance Change SoC Model
105.9 102.1 -3.6% JZ4775 132.4 124.1 -6.3% JZ4780(SMP off) 170.2 155.7 -8.5% JZ4780(SMP on) 101.3 91.5 -9.7% X1000E 187.1 179.4 -4.1% X1830 324.9 314.3 -3.3% X2000(SMT off) 394.6 373.9 -5.2% X2000(SMT off)
Quoted 5 lines
Quoted 2 lines
Compared with the V1 version, there are some improvements, but the performance loss is still a bit obvious
The MIPS port of Linux has always had the pride of having a particularly
low syscall overhead and I'd rather we didn't lose this quality.
Hi, Maciej,
1. The current trend is to use generic code, so I think this work is worth it, even if there is some performance loss.
2. We tested the performance on 5.15-rc1~rc5 and the performance loss on JZ4780 (SMP off) is not so obvious (about -3%).
3. Yanjie, is there any problem with the code base you tested? Could you help to test patch v3 on the latest mainline kernel?
Thanks,
Feiyang
Quoted 4 lines
FWIW,
Maciej
Quoted 13 lines · Feiyang Chen
Quoted 13 lines
Quoted 12 lines
Score Without Patches Score With Patches Performance Change SoC Model
105.9 102.1 -3.6% JZ4775 132.4 124.1 -6.3% JZ4780(SMP off) 170.2 155.7 -8.5% JZ4780(SMP on) 101.3 91.5 -9.7% X1000E 187.1 179.4 -4.1% X1830 324.9 314.3 -3.3% X2000(SMT off) 394.6 373.9 -5.2% X2000(SMT off)Compared with the V1 version, there are some improvements, but the performance loss is still a bit obvious
Quoted 7 lines
Quoted 2 lines
The MIPS port of Linux has always had the pride of having a particularly
low syscall overhead and I'd rather we didn't lose this quality.Hi, Maciej,
1. The current trend is to use generic code, so I think this work is worth it, even if there is some performance loss.
Well, a trend is not a proper justification on its own for existing code,
and mature one for that matter, that works. Surely it might be for an entirely new port, but the MIPS port is not exactly one.
Quoted 2 lines
2. We tested the performance on 5.15-rc1~rc5 and the performance loss on JZ4780 (SMP off) is not so obvious (about -3%).
I've seen teams work hard to improve performance by less than 3%, so
depending on how you look at it the loss is not necessarily small, even if not abysmal. And I find the figure of almost 10% cited for another system even more worrisome. Also you've written the figures are from UnixBench, which I suppose measures some kind of an average across various workloads. Can you elaborate on the methodology used by that benchmark?
Can you tell me what the performance loss is for a cheap syscall such as
`getuid'? That would indicate how much is actually lost in the invocation overhead.
With that amount known, would you be able to indicate where exactly the
performance is getting lost in generic code? Can it be improved?
Maciej
Quoted 31 lines · Maciej W. Rozycki
Quoted 13 lines · Feiyang Chen
Quoted 13 lines
Quoted 12 lines
Score Without Patches Score With Patches Performance Change SoC Model
105.9 102.1 -3.6% JZ4775 132.4 124.1 -6.3% JZ4780(SMP off) 170.2 155.7 -8.5% JZ4780(SMP on) 101.3 91.5 -9.7% X1000E 187.1 179.4 -4.1% X1830 324.9 314.3 -3.3% X2000(SMT off) 394.6 373.9 -5.2% X2000(SMT off)Compared with the V1 version, there are some improvements, but the performance loss is still a bit obvious
Quoted 7 lines
Quoted 2 lines
The MIPS port of Linux has always had the pride of having a particularly
low syscall overhead and I'd rather we didn't lose this quality.Hi, Maciej,
1. The current trend is to use generic code, so I think this work is worth it, even if there is some performance loss.
Well, a trend is not a proper justification on its own for existing code,
and mature one for that matter, that works. Surely it might be for an entirely new port, but the MIPS port is not exactly one.Quoted 2 lines
2. We tested the performance on 5.15-rc1~rc5 and the performance loss on JZ4780 (SMP off) is not so obvious (about -3%).
Quoted 6 lines
I've seen teams work hard to improve performance by less than 3%, so
depending on how you look at it the loss is not necessarily small, even if not abysmal. And I find the figure of almost 10% cited for another system even more worrisome. Also you've written the figures are from UnixBench, which I suppose measures some kind of an average across various workloads. Can you elaborate on the methodology used by that benchmark?
Hi, Maciej,
UnixBench uses multiple tests to test various aspects of the system's performance:
- Dhrystone test measures the speed and efficiency of non-floating-point operations.
- Whetstone test measures the speed and efficiency of floating-point operations.
- execl Throughput test measures the number of execl() calls that can be performed per second.
- File Copy test measures the rate at which data can be transferred from one file to another, using various buffer sizes.
- Pipe Throughput test measures the number of times (per second) a process can write 512 bytes to a pipe and read them back.
- Pipe-based Context Switching test measures the number of times two processes can exchange an increasing integer through a pipe.
- Process Creation test measures the number of times a process can fork and reap a child that immediately exits.
- Shell Scripts test measures the number of times per minute a process can start and reap a set of one, two, four and eight concurrent copies of a shell script where the shell script applies a series of transformations to a data file.
- System Call Overhead test measures the cost of entering and leaving the operating system kernel.
In these tests above, the most affected is the System Call Overhead test, and I'll go into more detail about how it's measured.
The System Call Overhead test counts the sets of system calls that are completed within the specified time (usually 10 seconds). By default, a set of system calls contain close(), getpid(), getuid(), and umask(). We call the test score "index". Specifically, the score for this test is calculated as follows:
product = log(count) - log(time / timebase)
result = exp(product / iterations)
index = result / baseline * 10
"timebase" and "baseline" are fixed values that are different for each test. Scores for other tests are calculated in a similar way. The final total score is calculated as follows (The total number of tests is "N"):
index = exp((log(result1) + log(result2) + ... + log(resultN)) / N) * 10
Quoted 4 lines
Can you tell me what the performance loss is for a cheap syscall such as
`getuid'? That would indicate how much is actually lost in the invocation overhead.
We use perf to measure the sys time of the the following program on Loongson 3A4000:
int main(void)
{
for (int i = 0; i < 10000000; i++)
getuid();
return 0;
}The program will take about 1.2 seconds of sys time before the kernel is patched, and about 1.3 seconds after the kernel is patched.
Quoted 3 lines
With that amount known, would you be able to indicate where exactly the
performance is getting lost in generic code? Can it be improved?
Sorry, we tried to use perf to analyze the extra time, but have no idea at the moment, since most of the code is located in __noinstr_text_start.
Thanks,
Feiyang
Quoted 2 lines
Maciej
Quoted 2 lines · 在2021年9月21日九月 下午4:57,Thomas Bogendoerfer写道:
can people, who provided performance numbers for v1 do the same for v2 ?
Sorry I just move abroad (to UK) to seek higher education. Currently I don't have any MIPS device available so I won't be able to provide test results as v1.
I'll try to get some MIPS devices soonish.
Thanks.
Quoted 6 lines
Thomas,
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Signature · 1 line
- Jiaxun