Skip site navigation (1)Skip section navigation (2)
Date:      09 Dec 1999 14:51:56 -0500
From:      Randell Jesup <rjesup@wgate.com>
To:        Julian Elischer <julian@whistle.com>
Cc:        arch@freebsd.org
Subject:   Re: kernel entry costs.
Message-ID:  <ybuwvqnj3j7.fsf@jesup.eng.tvol.net.jesup.eng.tvol.net>
In-Reply-To: Julian Elischer's message of "Sun, 28 Nov 1999 14:11:13 -0800 (PST)"
References:  <Pine.BSF.4.10.9911281352050.544-100000@current1.whistle.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Julian Elischer <julian@whistle.com> writes:
>> >   Julian, you shouldn't worry about userland<->kernel context switchso much.
>> >   The overhead for going into the kernel and coming out again, if all the
>> >   cruft is removed, is *very* tiny -- it's almost like a subroutine call.
>> 
>> I was rather suprised when I found out just how expensive kernel entry was
>> some time ago..  What I was doing was a reentrant syscall that aquired no
>> locks and ran about 5 instructions in kernel context..  Anyway, it took
>> something like 300 times longer to do that (called via int $0x81) than to
>> do a 'call' to equivalent code in userland.  Anyway, with overheads on that
>> scale, whether we push 5 or 8 or whatever registers in the handler is
>> almost lost in the noise.
>
>the IDT vercor is read
>leading to the  Interrupt gate that must be read,
[ lots of stuff snipped ]
>the new segment registers are then loaded. The generic syscall code is
>called, and the appropriate function is selected and called.
>
>on return, the return values are saved into the registers  in a 
>towers of hanoi simulation as the registers are reloaded and the
>segment registers are reloaded. Then the flags , SP and IP are reloaded.
>
>this is not an insignificant amount of work!

	Don't forget that even though it's 'invisible', there may be
extra overhead involved in the page table changes and TLB reloads occuring,
cache misses, etc.

-- 
Randell Jesup, Worldgate Communications, ex-Scala, ex-Amiga OS team ('88-94)
rjesup@wgate.com





To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ybuwvqnj3j7.fsf>