Subject: Re: halving context switch time
To: David Laight <david@l8s.co.uk>
From: Chuck Silvers <chuq@chuq.com>
List: tech-perform
Date: 09/01/2002 22:24:14
hi,

this seems like a fine idea, however I agree with others
that putting a counter in cpu_switch() wouldn't be the best way
to go about it.  personally I think using the return value from
cpu_switch() would be the best, but the per-cpu flag to indicate
that we didn't sleep would also work.

to allow giving cpu_switch() a return value without needing to
change all the instances at once, we could just conditionalize
that part of mi_switch() on __HAVE_CPU_SWITCH_RETVAL or something
like that, so we can convert each instance of cpu_switch()
independently.  as for the SA code also adding a return value
to cpu_switch(), we could just have it return two bits, one bit
for if the current process is the same as the last process,
and a different bit for whether or not cpu_switch() slept.

-Chuck


On Thu, Aug 15, 2002 at 12:22:47PM +0100, David Laight wrote:
> By far the largest contribution to the context switch time
> for netbsd i386 comes from the calls to microtime().
> 
> Now if the kernel doesn't actually enter the idle loop, there
> is no reason not to use the same time for the end of one
> process and the start of another.  This cuts the context
> switch time by about 5us (6us with my faster microtime).
> 
> Ideally the return value of cpu_switch() [1] would need to be
> changed to indicate whether it went into the idle loop or not.
...