--------------5B0E23B438DAB9F38305919
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
I've been playing with usermode page faults (using mprotect/catching
SIGSEGV), and I've found them a little slow. I've attached a very
simple patch with speeds it up significantly: rather than assuming all
bad page are from the kernel and scanning the exception tables, it
checks to see if it's a usermode pagefault and sends the signal before
doing exception processing. I get the following results:
Before:
real 86.52
user 9.52
sys 76.83
After:
real 67.40
user 9.64
sys 57.76
This is with 1000000 fault/signal/mprotect iterations. After applying
this patch, it looks like search_exception_table is hardly ever called
(as you'd expect).
Kernel profiling also shows its spending lots of time in
204 page_fault 12.7500
439 ret_with_reschedule 9.3404
These didn't look easy to tune though.
Thanks,
J
--------------5B0E23B438DAB9F38305919
Content-Type: text/plain; charset=us-ascii; name="kern.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="kern.patch"
--- linux/arch/i386/mm/fault.c~ Sun May 18 00:17:13 1997
+++ linux/arch/i386/mm/fault.c Fri Jun 6 11:07:15 1997
@@ -161,6 +161,14 @@
bad_area:
up(&mm->mmap_sem);
+ if (error_code & 4) {
+ tsk->tss.cr2 = address;
+ tsk->tss.error_code = error_code;
+ tsk->tss.trap_no = 14;
+ force_sig(SIGSEGV, tsk);
+ goto out;
+ }
+
/* Are we prepared to handle this fault? */
if ((fixup = search_exception_table(regs->eip)) != 0) {
printk(KERN_DEBUG "%s: Exception at [<%lx>] (%lx)\n",
@@ -168,14 +176,6 @@
regs->eip,
fixup);
regs->eip = fixup;
- goto out;
- }
-
- if (error_code & 4) {
- tsk->tss.cr2 = address;
- tsk->tss.error_code = error_code;
- tsk->tss.trap_no = 14;
- force_sig(SIGSEGV, tsk);
goto out;
}
/*
--------------5B0E23B438DAB9F38305919--