summaryrefslogtreecommitdiff
path: root/sys/kern/kern_clock.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix an old bug related to BETTER_CLOCK. Call forward_*clock if SMPJohn Baldwin2001-04-171-3/+3
| | | | | | | | | | | | and __i386__ are defined rather than if SMP and BETTER_CLOCK are defined. The removal of BETTER_CLOCK would have broken this except that kern_clock.c doesn't include <machine/smptests.h>, so it doesn't see the definition of BETTER_CLOCK, and forward_*clock aren't called, even on 4.x. This seems to fix the problem where a n-way SMP system would see 100 * n clk interrupts and 128 * n rtc interrupts. Notes: svn path=/head/; revision=75616
* Catch up to header include changes:John Baldwin2001-03-281-1/+1
| | | | | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h> Notes: svn path=/head/; revision=74914
* Changed the aston() family to operate on a specified process instead ofBruce Evans2001-02-191-2/+2
| | | | | | | | | | | | | | | | | always on curproc. This is needed to implement signal delivery properly (see a future log message for kern_sig.c). Debogotified the definition of aston(). aston() was defined in terms of signotify() (perhaps because only the latter already operated on a specified process), but aston() is the primitive. Similar changes are needed in the ia64 versions of cpu.h and trap.c. I didn't make them because the ia64 is missing the prerequisite changes to make astpending and need_resched per-process and those changes are too large to make without testing. Notes: svn path=/head/; revision=72683
* - Catch up to the new swi API changes:John Baldwin2001-02-091-2/+2
| | | | | | | | | | - Use swi_* function names. - Use void * to hold cookies to handlers instead of struct intrhand *. - In sio.c, use 'driver_name' instead of "sio" as the name of the driver lock to minimize diffs with cy(4). Notes: svn path=/head/; revision=72238
* Change and clean the mutex lock interface.Bosko Milekic2001-02-091-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=72200
* - Proc locking.John Baldwin2001-01-241-7/+20
| | | | | | | - P_FOO -> PS_FOO. Notes: svn path=/head/; revision=71556
* Use PCPU_GET, PCPU_PTR and PCPU_SET to access all per-cpu variablesJake Burkholder2001-01-101-2/+2
| | | | | | | other then curproc. Notes: svn path=/head/; revision=70861
* o Export cp_time ("CPU time statistics") using SYSCTL_OPAQUE.Robert Watson2000-11-201-0/+3
| | | | | | | | This removes a reason that systat requires setgid kmem. More to come. Notes: svn path=/head/; revision=68923
* - Protect the callout wheel with a separate spin mutex, callout_lock.Jake Burkholder2000-11-191-2/+12
| | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=68889
* - Overhaul the software interrupt code to use interrupt threads for eachJohn Baldwin2000-10-251-1/+3
| | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=67551
* Catch up to moving headers:John Baldwin2000-10-201-2/+2
| | | | | | | | - machine/ipl.h -> sys/ipl.h - machine/mutex.h -> sys/mutex.h Notes: svn path=/head/; revision=67365
* - Change fast interrupts on x86 to push a full interrupt frame and toJohn Baldwin2000-10-061-18/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | return through doreti to handle ast's. This is necessary for the clock interrupts to work properly. - Change the clock interrupts on the x86 to be fast instead of threaded. This is needed because both hardclock() and statclock() need to run in the context of the current process, not in a separate thread context. - Kill the prevproc hack as it is no longer needed. - We really need Giant when we call psignal(), but we don't want to block during the clock interrupt. Instead, use two p_flag's in the proc struct to mark the current process as having a pending SIGVTALRM or a SIGPROF and let them be delivered during ast() when hardclock() has finished running. - Remove CLKF_BASEPRI, which was #ifdef'd out on the x86 anyways. It was broken on the x86 if it was turned on since cpl is gone. It's only use was to bogusly run softclock() directly during hardclock() rather than scheduling an SWI. - Remove the COM_LOCK simplelock and replace it with a clock_lock spin mutex. Since the spin mutex already handles disabling/restoring interrupts appropriately, this also lets us axe all the *_intr() fu. - Back out the hacks in the APIC_IO x86 cpu_initclocks() code to use temporary fast interrupts for the APIC trial. - Add two new process flags P_ALRMPEND and P_PROFPEND to mark the pending signals in hardclock() that are to be delivered in ast(). Submitted by: jakeb (making statclock safe in a fast interrupt) Submitted by: cp (concept of delaying signals until ast()) Notes: svn path=/head/; revision=66716
* Clean up process accounting some more. Unfortunately, it is still notJohn Baldwin2000-09-121-14/+12
| | | | | | | | quite right on i386 as the CPU who runs statclock() doesn't have a valid clockframe to calculate statistics with. Notes: svn path=/head/; revision=65782
* Major update to the way synchronization is done in the kernel. HighlightsJason Evans2000-09-071-16/+13
| | | | | | | | | | | | | | | | | | include: * Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The alpha port is still in transition and currently uses both.) * Per-CPU idle processes. * Interrupts are run in their own separate kernel threads and can be preempted (i386 only). Partially contributed by: BSDi (BSD/OS) Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh Notes: svn path=/head/; revision=65557
* Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.Poul-Henning Kamp2000-07-041-1/+1
| | | | | | | Pointed out by: bde Notes: svn path=/head/; revision=62573
* Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:Poul-Henning Kamp2000-07-031-1/+1
| | | | | | | | | | | Sanitize SYSCTL_HANDLER_ARGS so that simplistic tools can grog our sources: -sysctl_vm_zone SYSCTL_HANDLER_ARGS +sysctl_vm_zone (SYSCTL_HANDLER_ARGS) Notes: svn path=/head/; revision=62454
* Remove ~25 unneeded #include <sys/conf.h>Poul-Henning Kamp2000-04-191-1/+0
| | | | | | | Remove ~60 unneeded #include <sys/malloc.h> Notes: svn path=/head/; revision=59391
* The SMP cleanup commit broke UP compiles. Make UP compiles work again.Matthew Dillon2000-03-281-3/+1
| | | | Notes: svn path=/head/; revision=58755
* Isolate the Timecounter internals in their own two files.Poul-Henning Kamp2000-03-201-572/+2
| | | | | | | | | | | | | | | | | | Make the public interface more systematically named. Remove the alternate method, it doesn't do any good, only ruins performance. Add counters to profile the usage of the 8 access functions. Apply the beer-ware to my code. The weird +/- counts are caused by two repocopies behind the scenes: kern/kern_clock.c -> kern/kern_tc.c sys/time.h -> sys/timetc.h (thanks peter!) Notes: svn path=/head/; revision=58377
* Fix sign reversal in adjtime(2).Poul-Henning Kamp2000-02-131-1/+1
| | | | | | | Approved by: jkh Notes: svn path=/head/; revision=57182
* Make adjtime(2) adjust boottime so it doesn't cause non-monotonousPoul-Henning Kamp1999-12-081-2/+11
| | | | | | | uptime. Notes: svn path=/head/; revision=54299
* Fixed some comments in statclock(). The previous commit made it clearerBruce Evans1999-11-271-8/+8
| | | | | | | that one comment was attached to null code. Notes: svn path=/head/; revision=53751
* Moved scheduling-related code to kern_synch.c so that it is easier to fixBruce Evans1999-11-271-21/+1
| | | | | | | | | | | and extend. The new function containing the code is named schedclock() as in NetBSD, but it has slightly different semantics (it already handles incrementation of p->p_cpticks, and it should handle any calling frequency). Agreed with in principle by: dufault Notes: svn path=/head/; revision=53745
* #ifdef PPS_SYNC around "kapi" declaration to fix a -Wunused warning.Peter Wemm1999-10-101-0/+2
| | | | Notes: svn path=/head/; revision=52097
* Update the PPSAPI to draft-mogul-pps-api-05.txt which is the latest.John Hay1999-10-091-42/+54
| | | | | | | | | NOTE: This will break building ntpd until ntpd has been upgraded to also support draft 05. People that want to build ntpd in the meantime can get patches from me. Notes: svn path=/head/; revision=52061
* Moved the definition of `boottime' and its sysctl to the correct file.Bruce Evans1999-09-131-0/+4
| | | | Notes: svn path=/head/; revision=51229
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Oops, the previous commit only worked in the one case it was tested for.Bruce Evans1999-07-241-2/+3
| | | | Notes: svn path=/head/; revision=49065
* Added a sysctl "kern.timecounter.hardware" for selecting the hardwareBruce Evans1999-07-181-6/+41
| | | | | | | | | | | | used for timecounting. The possible values are the names of the physically present harware timecounters ("i8254" and "TSC" on i386's). Fixed some nearby bitrot in comments in <sys/time.h>. Reviewed by: phk Notes: svn path=/head/; revision=48887
* Remove four no-op casts.John Polstra1999-07-181-5/+5
| | | | Notes: svn path=/head/; revision=48872
* Make the machdep.i8254_freq and machdep.tsc_freq sysctls modify thePoul-Henning Kamp1999-04-251-3/+9
| | | | | | | | | timecounter as well Asked for by: bde, jhay Notes: svn path=/head/; revision=46054
* Don't open window for race condition.Poul-Henning Kamp1999-04-021-4/+1
| | | | | | | Detected by: Reg Clemens <reg@dwf.com> Notes: svn path=/head/; revision=45245
* Fix an old cut&paste bogon.Poul-Henning Kamp1999-03-121-2/+2
| | | | | | | Noticed by: bde Notes: svn path=/head/; revision=44695
* Remove duplicate include.Poul-Henning Kamp1999-03-121-4/+1
| | | | | | | Noticed by: bde Notes: svn path=/head/; revision=44685
* Make even more of the PPSAPI implementations generic.Poul-Henning Kamp1999-03-111-52/+147
| | | | | | | | | | | FLL support in hardpps() Various magic shuffles and improved comments Style fixes from Bruce. Notes: svn path=/head/; revision=44666
* Integrate the new "nanokernel" PLL from Dave Mills.Poul-Henning Kamp1999-03-081-5/+2
| | | | | | | | | | This code is backwards compatible with the older "microkernel" PLL, but allows ntpd v4 to use nanosecond resolution. Many other improvements. PPS_SYNC and hardpps() are NOT supported yet. Notes: svn path=/head/; revision=44574
* Introduce machine-dependent macro pgtok() to convert page count to numberLuoqi Chen1999-02-191-5/+5
| | | | | | | | of kilobytes. Its definition for each architecture could be optimized to avoid potential numerical overflows. Notes: svn path=/head/; revision=44157
* Hide access to vmspace:vm_pmap with inline function vmspace_pmap(). ThisLuoqi Chen1999-02-191-3/+2
| | | | | | | | | | is the preparation step for moving pmap storage out of vmspace proper. Reviewed by: Alan Cox <alc@cs.rice.edu> Matthew Dillion <dillon@apollo.backplane.com> Notes: svn path=/head/; revision=44146
* Make the previous behaviour the default, add a sysctl which youPoul-Henning Kamp1998-11-291-12/+42
| | | | | | | | | | | | | | | | | can set if your hw/sw produces the "calcru negative..." message. Setting the alternate method (sysctl -w kern.timecounter.method=1) makes the the get{nano|micro}*() functions call the real thing at resulting in a measurable but minor overhead. I decided to NOT have the "calcru" change the method automatically because you should be aware of this problem if you have it. The problems currently seen, related to usleep and a few other corners are fixed for both methods. Notes: svn path=/head/; revision=41415
* Make timecounters more resistant to badly behaved SW/HW which locksPoul-Henning Kamp1998-11-231-10/+18
| | | | | | | | | | | | | | out interrupts for too long. If you still see the "calcru: negative time..." message you can increase NTIMECOUNTER (see LINT). Sideeffect is that a timecounter is required to not wrap around in less than (1 + delta) seconds instead of the (1/hz + delta) required until now. Many thanks to: msmith, wpaul, wosch & bde Notes: svn path=/head/; revision=41306
* Add a kludge to prevent panicing when using VM86 and hitting hereSøren Schmidt1998-11-231-2/+2
| | | | | | | | | with a NULL curproc. Originally by: Tor Egge (IIRC) Notes: svn path=/head/; revision=41305
* Fixed breakage of the GPROF case of statclock() in the previous commit.Bruce Evans1998-10-261-1/+2
| | | | Notes: svn path=/head/; revision=40657
* Nitpicking and dusting performed on a train. Removes trivial warningsPoul-Henning Kamp1998-10-251-3/+2
| | | | | | | about unused variables, labels and other lint. Notes: svn path=/head/; revision=40648
* Change the way we simulate stable storage for timecounters.Poul-Henning Kamp1998-10-231-57/+52
| | | | | | | | | If you have problems with the "calcru" messages and processes being killed for excessive cpu time, try to increase the NTIMECOUNTER #define and report your findings. Notes: svn path=/head/; revision=40609
* Cast the return value of tvtohz() from a long to an int to satisfy theAlexander Langer1998-10-061-2/+2
| | | | | | | | | | compiler that we know what we're doing (the value returned has already been restricted to int ranges). Reviewed by: bde Notes: svn path=/head/; revision=40012
* kern_clock.c:Justin T. Gibbs1998-09-151-18/+2
| | | | | | | | | | Remove old disk statistics variables. vfs_bio.c: Enable bowrite now that B_ORDERED works for all buffer devices. Notes: svn path=/head/; revision=39245
* Removed unused function hzto().Bruce Evans1998-08-051-18/+1
| | | | Notes: svn path=/head/; revision=38129
* Fixed printf format errors.Bruce Evans1998-07-111-2/+2
| | | | Notes: svn path=/head/; revision=37555
* Hmm, braino in last commit.Poul-Henning Kamp1998-07-041-4/+5
| | | | Notes: svn path=/head/; revision=37383
* Change the sign on a race-condition, so that instead of ending up severalPoul-Henning Kamp1998-07-041-8/+18
| | | | | | | | tens of milliseconds out in the future we end up the right place with a subweeniesecond error. Notes: svn path=/head/; revision=37382