Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Mar 2008 21:04:17 -1000 (HST)
From:      Jeff Roberson <jroberson@chesapeake.net>
To:        arch@freebsd.org
Subject:   timeout/callout small step forward
Message-ID:  <20080328202602.N72156@desktop>
In-Reply-To: <20080312152744.I29518@fledge.watson.org>
References:  <10004.1205307334@critter.freebsd.dk> <200803120908.10403.jhb@freebsd.org> <20080312140422.B29518@fledge.watson.org> <200803121059.45614.jhb@freebsd.org> <20080312152744.I29518@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~jeff/callout.diff

This patch takes the current callout implementation and makes it per-cpu. 
It also hides callout details from the rest of the kernel by making the 
callwheel structure private to kern_timeout.c among other things.

All callouts default to the first softclock thread to maintain ordering 
and concurrency guarantees of the older code.  The only new interface 
that is implemented is 'callout_reset_on' which can specify a cpu to run 
the callout on.  This can force a callout which is not presently being 
dispatched to migrate to a new cpu.

The threads are not hard bound to each cpu so that they can't be starved 
into not processing their queues.  They are 'medium' bound by ULE and 
probably tend to run where they are scheduled on 4BSD but there is no 
guarantee.  The ULE rules will run them on their native CPU if it's 
running something of lesser priority or idle.  If it's running something 
of greater priority it will look for a more idle cpu.  This prevents the 
softclock thread from being starved by other interrupt thread activity.

I believe this helps phk's effort rather than hindering it because:

1)  It collects up more implementation details and pushes them into 
kern_timeout.c

2)  It sounds like we're keeping the same current/waiting/cancel algorithm 
so this packages it up into a per-instances structure as would need to 
happen in phk's proposal as well.

3)  The only new interface, a varient of callout_reset() should be trivial 
to implement whatever the new scheme is.

Also included is changes to kern_event.c and subr_sleepq.c so sleepq() 
timeouts happen on the cpu that generated them and so do kqueue() poll 
timeouts.  You can see that the additional interface is quite simple.

This has been tested and debugged by nokia.

Thanks,
Jeff



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