Re: Small speedup for 'system_call'

Michael Elizabeth Chastain (mec@duracef.shout.net)
Tue, 5 Nov 1996 03:51:34 -0600


Hello hackers,

Ok, here is a small patch against Linux 2.1.7 to shrink system call
dispatch by four instructions.

I wrote a test program to make system calls with numbers 137
(afs_syscall), 200, 300, and -1, and all these cases work. Plus I'm
running this patch on my system so it's making thousands of system
calls.

Strace 3.1 works fine. When given funky system call numbers like 200,
it reports them as ipc subcalls and socket subcalls. But on the
previous kernel it wouldn't report them at all.

I'd appreciate it if one or two people would test this patch -- just
install it on your own system and drop me a line and tell me if it
works. And then I'll send it to Linus.

Michael Chastain
mec@shout.net

--- linux-2.1.7/arch/i386/kernel/entry.S Fri Oct 11 05:45:06 1996
+++ linux/arch/i386/kernel/entry.S Tue Nov 5 04:31:19 1996
@@ -271,15 +271,11 @@
#ifdef __SMP__
ENTER_KERNEL
#endif
- movl $-ENOSYS,EAX(%esp)
cmpl $(NR_syscalls),%eax
- jae ret_from_sys_call
- movl SYMBOL_NAME(sys_call_table)(,%eax,4),%eax
- testl %eax,%eax
- je ret_from_sys_call
+ jae badsys
testb $0x20,flags(%ebx) # PF_TRACESYS
jne tracesys
- call *%eax
+ call SYMBOL_NAME(sys_call_table)(,%eax,4)
movl %eax,EAX(%esp) # save the return value
ALIGN
.globl ret_from_sys_call
@@ -327,6 +323,9 @@
movl %eax,EAX(%esp) # save the return value
call SYMBOL_NAME(syscall_trace)
jmp ret_from_sys_call
+badsys:
+ movl $-ENOSYS,EAX(%esp)
+ jmp ret_from_sys_call


ENTRY(divide_error)
@@ -591,7 +590,7 @@
.long SYMBOL_NAME(sys_bdflush)
.long SYMBOL_NAME(sys_sysfs) /* 135 */
.long SYMBOL_NAME(sys_personality)
- .long 0 /* for afs_syscall */
+ .long SYMBOL_NAME(sys_ni_syscall) /* for afs_syscall */
.long SYMBOL_NAME(sys_setfsuid)
.long SYMBOL_NAME(sys_setfsgid)
.long SYMBOL_NAME(sys_llseek) /* 140 */
@@ -620,4 +619,6 @@
.long SYMBOL_NAME(sys_mremap)
.long SYMBOL_NAME(sys_setresuid)
.long SYMBOL_NAME(sys_getresuid)
- .space (NR_syscalls-165)*4
+ .rept NR_syscalls-165
+ .long SYMBOL_NAME(sys_ni_syscall)
+ .endr