summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_timeout.c
Commit message (Collapse)AuthorAgeFilesLines
* When processing a timeout() callout and returning it to the freeiedowse2005-02-111-1/+2
| | | | | | | | | list, set `curr_callout' to NULL. This ensures that we won't attempt to cancel the current callout if the original callout structure gets recycled while we wait to acquire Giant. This is reported to fix an intermittent syscons problem that was introduced by revision 1.96.
* Add a mechanism for associating a mutex with a callout when theiedowse2005-02-071-15/+106
| | | | | | | | | | | | | | | | | | | | | | callout is first initialised, using a new function callout_init_mtx(). The callout system will acquire this mutex before calling the callout function and release it on return. In addition, the callout system uses the mutex to avoid most of the complications and race conditions inherent in asynchronous timer facilities, so mutex-protected callouts have much simpler semantics. As long as the mutex is held when invoking callout_stop() or callout_reset(), then these functions will guarantee that the callout will be stopped, even if softclock() had already begun to process the callout. Existing Giant-locked callouts will automatically pick up the new race-free semantics. This should close a number of race conditions in the USB code and probably other areas of the kernel too. There should be no change in behaviour for "MP-safe" callouts; these still need to use the techniques mentioned in timeout(9) to avoid race conditions.
* Make "c->c_func = NULL" conditional on CALLOUT_LOCAL_ALLOC in bothcperciva2005-01-191-1/+1
| | | | | | | places where it occurs, not just one. :-) Pointed out by: glebius Pointy had to: cperciva
* Make "c->c_func = NULL" conditional on the CALLOUT_LOCAL_ALLOC flag,cperciva2005-01-191-1/+1
| | | | | | | i.e., only clear c->c_func if the callout c is being used via the old timeout(9) interface. Requested by: glebius
* Clarify the description of the callout_active() macro: It is cleared bycperciva2005-01-191-1/+3
| | | | | callout_stop, callout_drain, and callout_deactivate, but is not automatically cleared when a callout returns.
* Adjust two of my comments to the new world order: Indent protection incperciva2005-01-071-2/+2
| | | | the first column is performed using /**, not /*-.
* Cut a KTR record whenever a callout is invoked. Mark whether it runsrwatson2004-08-061-0/+4
| | | | | with Giant or not, and include the function point so it can be looked up against the kernel symbol table during trace analysis.
* When reseting a pending callout, perform the deregistration incperciva2004-08-061-2/+16
| | | | | | | | callout_reset rather than calling callout_stop. This results in a few lines of code duplication, but it provides a significant performance improvement because it avoids recursing on callout_lock. Requested by: rwatson
* The paper "Hashed Timers and Hierarchical Wheels: Data Structures for thehmp2004-04-251-1/+1
| | | | | | | Efficient Implementation of a Timer Facility" was co-author'ed by T. Lauk, not A. Lauk. Adjust nearby whitespace.
* 1. Remove callout_stop binary compatibility.cperciva2004-04-201-10/+0
| | | | | | | 2. Document that this means that kernel modules must be rebuilt. 3. While I'm here, fix my sorting error in callout.h Requested by: many [1], scottl [2], bde [3]
* Add whitespace before comment blocks. (reported by njl)cperciva2004-04-081-16/+13
| | | | | | | | | Remove spurious whitespace, add indent protection, fix punctuation, remove initialization of static variables to zero, put wakeup_ctr and wakeup_needed in the correct order. (reported by bde) This doesn't fix all the style bugs I introduced, but the remaining style bugs make it easier for me to understand what I did here.
* Introduce a callout_drain() function. This acts in the same manner ascperciva2004-04-061-1/+90
| | | | | | | | | | | callout_stop(), except that if the callout being stopped is currently in progress, it blocks attempts to reset the callout and waits until the callout is completed before it returns. This makes it possible to clean up callout-using code safely, e.g., without potentially freeing memory which is still being used by a callout. Reviewed by: mux, gallatin, rwatson, jhb
* Remove advertising clause from University of California Regent's license,imp2004-04-051-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core
* Make the DIAGNOSTIC code which complains about long {call|time}out(9)phk2003-12-071-5/+11
| | | | | | functions less noisy: We printf if a new function took longer than the previous record holder, or of the previous record holder took more than twice as long as the current record.
* Rename the debugging mutex "callout_no_sleep" to "dont_sleep_in_callout".phk2003-11-151-4/+4
|
* At the request of several developers, restore the DIAGNOSIC codemckusick2003-11-121-0/+28
| | | | | | | | | | deleted in 1.81. Increase the initial timeout limit to 2ms to eliminate spurious messages of excessive timeouts in the NFS client code. Requested by: Poul-Henning Kamp <phk@phk.freebsd.dk> Requested by: Mike Silbersack <silby@silby.com> Requested by: Sam Leffler <sam@errno.com>
* Get rid of DIAGNOSTIC that gives false positives on slow CPUs.mckusick2003-11-041-28/+0
|
* On ia64 time_t is 64 bit. Explicitly cast tv_sec to long and changemarcel2003-08-231-2/+2
| | | | | | | the corresponding format specifier to %ld in a call to printf() in function softclock(). The printf() is conditional upon DIAGNOSTIC. Found by: LINT
* Don't put callout_lock under #ifdef DIAGNOSTIC despite the fact that itphk2003-06-201-1/+2
| | | | works anyway.
* Crude but efficient:phk2003-06-201-1/+8
| | | | | #ifdef DIAGNOSTIC hold a mutex while calling callout's so that we hear about it if they sleep.
* Use __FBSDID().obrien2003-06-111-1/+3
|
* Add instrumentation which tells us how much work softclock() doesphk2003-06-041-2/+26
| | | | per invocation.
* Under DIAGNOSTIC, only report expensive timeouts if they are more expensivephk2003-02-011-1/+2
| | | | than the last on we reported.
* Fix a format buglet.phk2002-09-051-1/+1
| | | | Spotted by: iedowse
* Under DIAGNOSTIC, complain if a timeout(9) routine took more than 1msec.phk2002-09-041-4/+23
|
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-1/+1
| | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64
* Remove __P.alfred2002-03-191-1/+1
|
* Move most of the kernel submap initialization code, including thedillon2001-08-221-0/+49
| | | | | | | | timeout callwheel and buffer cache, out of the platform specific areas and into the machine independant area. i386 and alpha adjusted here. Other cpus can be fixed piecemeal. Reviewed by: freebsd-smp, jake
* Change callout_stop() to return an integer. If callout_stop() succeeds injhb2001-08-101-2/+3
| | | | | | | | | | removing the callout entry, return 1. If callout_stop() fails to remove the callout entry because it is currently executing or has already been executed, then the function returns 0. The idea was obtained from BSD/OS, however, BSD/OS changed untimeout(), and I've just changed callout_stop() to be more conservative. Obtained from: BSD/OS
* Axe spl's obsoleted by the callout mutex.jhb2001-08-101-26/+4
|
* Catch up to header include changes:jhb2001-03-281-0/+1
| | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
* Change and clean the mutex lock interface.bmilekic2001-02-091-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
* Revert the last commit to the callout interface, and add a flag tojlemon2000-11-251-6/+7
| | | | | | | callout_init() indicating whether the callout is safe or not. Update the callers of callout_init() to reflect the new interface. Okayed by: Jake
* - Rename callout_reset to _callout_reset and add a flags argument.jake2000-11-251-2/+4
| | | | | - Add macros callout_reset, which does the obvious, and mp_callout_reset, which passes the CALLOUT_MPSAFE flag.
* - Protect the callout wheel with a separate spin mutex, callout_lock.jake2000-11-191-17/+24
| | | | | | | | | | | - Use the mutex in hardclock to ensure no races between it and softclock. - Make softclock be INTR_MPSAFE and provide a flag, CALLOUT_MPSAFE, which specifies that a callout handler does not need giant. There is still no way to set this flag when regstering a callout. Reviewed by: -smp@, jlemon
* Release sched_lock very briefly to give interrupts a chance to fire if wejhb2000-11-181-0/+2
| | | | | | are in softclock() for a long time. The old code already did an splx()/slphigh() pair here, I just missed adding in the equivalent mutex operations on sched_lock earlier.
* The recent changes to msleep() and mawait() resulted in timeout() andjhb2000-11-161-1/+16
| | | | | | | | untimeout() not being called with Giant in those functions. For now, use the sched_lock to protect the callout wheel in softclock() and in the various timeout and callout functions. Noticed by: tegge
* - Overhaul the software interrupt code to use interrupt threads for eachjhb2000-10-251-1/+1
| | | | | | | | | | | | | | | | | | | type of software interrupt. Roughly, what used to be a bit in spending now maps to a swi thread. Each thread can have multiple handlers, just like a hardware interrupt thread. - Instead of using a bitmask of pending interrupts, we schedule the specific software interrupt thread to run, so spending, NSWI, and the shandlers array are no longer needed. We can now have an arbitrary number of software interrupt threads. When you register a software interrupt thread via sinthand_add(), you get back a struct intrhand that you pass to sched_swi() when you wish to schedule your swi thread to run. - Convert the name of 'struct intrec' to 'struct intrhand' as it is a bit more intuitive. Also, prefix all the members of struct intrhand with 'ih_'. - Make swi_net() a MI function since there is now no point in it being MD. Submitted by: cp
* Restructure TCP timeout handling:jlemon1999-08-301-9/+9
| | | | | | | | | | - eliminate the fast/slow timeout lists for TCP and instead use a callout entry for each timer. - increase the TCP timer granularity to HZ - implement "bad retransmit" recovery, as presented in "On Estimating End-to-End Network Path Properties", by Allman and Paxson. Submitted by: jlemon, wollmann
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Fix callout_init(). This didn't have any practical effect since itwollman1999-03-061-2/+2
| | | | | was only used to initialize the static timeouts, which unconditionally clears the only bits which could have caused problems.
* Expose a slightly-lower-level interface to timeouts which allows callerswollman1999-03-061-24/+96
| | | | | | | | to manage their own memory. Tested on my machine (make buildworld). I've made analogous changes on the alpha, but don't have a machine to test. Not-objected-to by: dg, gibbs
* Fixed stale references to hzto() in comments.bde1998-05-171-2/+2
|
* Declare function pointer args as pointers, not as functions.bde1998-02-251-3/+3
|
* A bunch of nits from bde.phk1998-02-151-15/+13
|
* Make softticks static.phk1998-01-141-35/+2
| | | | Remove unneeded stuff.
* Fix softclock calling so we don't loose timeouts (I broke this ~10h ago)phk1998-01-111-6/+2
|
* Whoops. softclock is called from doreti_swi as well. Abandon call fromphk1998-01-101-8/+2
| | | | | | | | hardclock(). Forgot this: Pointed hat sent by: bd
* Effect the divorce of kern_clock.c and kern_timeout.c (which wasphk1998-01-101-1111/+20
| | | | repository copied from kern_clock.c)
* Improve hardpps readability a bit:phk1998-01-071-50/+45
| | | | | * Rename usec to p_usec so you can search for it. * Macroize the huge median_of_3_samples if statement.
OpenPOWER on IntegriCloud