summaryrefslogtreecommitdiff
path: root/sys/kern/kern_synch.c
Commit message (Collapse)AuthorAgeFilesLines
...
* The SMP cleanup commit broke UP compiles. Make UP compiles work again.Matthew Dillon2000-03-281-2/+0
| | | | Notes: svn path=/head/; revision=58755
* Commit major SMP cleanups and move the BGL (big giant lock) in theMatthew Dillon2000-03-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | syscall path inward. A system call may select whether it needs the MP lock or not (the default being that it does need it). A great deal of conditional SMP code for various deadended experiments has been removed. 'cil' and 'cml' have been removed entirely, and the locking around the cpl has been removed. The conditional separately-locked fast-interrupt code has been removed, meaning that interrupts must hold the CPL now (but they pretty much had to anyway). Another reason for doing this is that the original separate-lock for interrupts just doesn't apply to the interrupt thread mechanism being contemplated. Modifications to the cpl may now ONLY occur while holding the MP lock. For example, if an otherwise MP safe syscall needs to mess with the cpl, it must hold the MP lock for the duration and must (as usual) save/restore the cpl in a nested fashion. This is precursor work for the real meat coming later: avoiding having to hold the MP lock for common syscalls and I/O's and interrupt threads. It is expected that the spl mechanisms and new interrupt threading mechanisms will be able to run in tandem, allowing a slow piecemeal transition to occur. This patch should result in a moderate performance improvement due to the considerable amount of code that has been removed from the critical path, especially the simplification of the spl*() calls. The real performance gains will come later. Approved by: jkh Reviewed by: current, bde (exception.s) Some work taken from: luoqi's patch Notes: svn path=/head/; revision=58717
* I applied the wrong patch set. Back out anything associatedPeter Dufault2000-03-021-6/+1
| | | | | | | | | | | | with the known bogus currtpriority. This undoes the previous changes to sys/i386/i386/trap.c, sys/alpha/alpha/trap.c, sys/sys/systm.h Now we have the patch set approved by bde. Approved by: bde Notes: svn path=/head/; revision=57704
* Patches that eliminate extra context switches in FIFO case.Peter Dufault2000-03-021-11/+47
| | | | | | | | | | Fixes p1003_1b regression test in the simple case of no RR and FIFO processes competing. Reviewed by: jkh, bde Notes: svn path=/head/; revision=57701
* Don't make the ktrace hook in tsleep() deref a null curproc after a panic.Peter Wemm1999-11-301-1/+1
| | | | | | | | PR: 15169 Submitted by: David Gilbert <dgilbert@velocet.ca> Notes: svn path=/head/; revision=53944
* Add a bit of sanity checking and problem avoidance in case thePoul-Henning Kamp1999-11-291-2/+9
| | | | | | | | | | timecounter hardware is bogus. This will produce a new warning "microuptime() went backwards" and try to not screw up the process resource accounting. Notes: svn path=/head/; revision=53880
* Scheduler fixes equivalent to the ones logged in the following NetBSDBruce Evans1999-11-281-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit to kern_synch.c: ---------------------------- revision 1.55 date: 1999/02/23 02:56:03; author: ross; state: Exp; lines: +39 -10 Scheduler bug fixes and reorganization * fix the ancient nice(1) bug, where nice +20 processes incorrectly steal 10 - 20% of the CPU, (or even more depending on load average) * provide a new schedclk() mechanism at a new clock at schedhz, so high platform hz values don't cause nice +0 processes to look like they are niced * change the algorithm slightly, and reorganize the code a lot * fix percent-CPU calculation bugs, and eliminate some no-op code === nice bug === Correctly divide the scheduler queues between niced and compute-bound processes. The current nice weight of two (sort of, see `algorithm change' below) neatly divides the USRPRI queues in half; this should have been used to clip p_estcpu, instead of UCHAR_MAX. Besides being the wrong amount, clipping an unsigned char to UCHAR_MAX is a no-op, and it was done after decay_cpu() which can only _reduce_ the value. It has to be kept <= NICE_WEIGHT * PRIO_MAX - PPQ or processes can scheduler-penalize themselves onto the same queue as nice +20 processes. (Or even a higher one.) === New schedclk() mechansism === Some platforms should be cutting down stathz before hitting the scheduler, since the scheduler algorithm only works right in the vicinity of 64 Hz. Rather than prescale hz, then scale back and forth by 4 every time p_estcpu is touched (each occurance an abstraction violation), use p_estcpu without scaling and require schedhz to be generated directly at the right frequency. Use a default stathz (well, actually, profhz) / 4, so nothing changes unless a platform defines schedhz and a new clock. Define these for alpha, where hz==1024, and nice was totally broke. === Algorithm change === The nice value used to be added to the exponentially-decayed scheduler history value p_estcpu, in _addition_ to be incorporated directly (with greater wieght) into the priority calculation. At first glance, it appears to be a pointless increase of 1/8 the nice effect (pri = p_estcpu/4 + nice*2), but it's actually at least 3x that because it will ramp up linearly but be decayed only exponentially, thus converging to an additional .75 nice for a loadaverage of one. I killed this, it makes the behavior hard to control, almost impossible to analyze, and the effect (~~nothing at for the first second, then somewhat increased niceness after three seconds or more, depending on load average) pointless. === Other bugs === hz -> profhz in the p_pctcpu = f(p_cpticks) calcuation. Collect scheduler functionality. Try to put each abstraction in just one place. ---------------------------- The details are a little different in FreeBSD: === nice bug === Fixing this is the main point of this commit. We use essentially the same clipping rule as NetBSD (our limit on p_estcpu differs by a scale factor). However, clipping at all is fundamentally bad. It gives free CPU the hoggiest hogs once they reach the limit, and reaching the limit is normal for long-running hogs. This will be fixed later. === New schedclk() mechanism === We don't use the NetBSD schedclk() (now schedclock()) mechanism. We require (real)stathz to be about 128 and scale by an extra factor of 2 compared with NetBSD's statclock(). We scale p_estcpu instead of scaling the clock. This is more accurate and flexible. === Algorithm change === Same change. === Other bugs === The p_pctcpu bug was fixed long ago. We don't try as hard to abstract functionality yet. Related changes: the new limit on p_estcpu must be exported to kern_exit.c for clipping in wait1(). Agreed with by: dufault Notes: svn path=/head/; revision=53822
* Updated comments for the move in the previous commit.Bruce Evans1999-11-271-5/+5
| | | | Notes: svn path=/head/; revision=53752
* Moved scheduling-related code to kern_synch.c so that it is easier to fixBruce Evans1999-11-271-0/+26
| | | | | | | | | | | 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
* This is a partial commit of the patch from PR 14914:Poul-Henning Kamp1999-11-161-3/+3
| | | | | | | | | | | | | | | | Alot of the code in sys/kern directly accesses the *Q_HEAD and *Q_ENTRY structures for list operations. This patch makes all list operations in sys/kern use the queue(3) macros, rather than directly accessing the *Q_{HEAD,ENTRY} structures. This batch of changes compile to the same object files. Reviewed by: phk Submitted by: Jake Burkholder <jake@checker.org> PR: 14914 Notes: svn path=/head/; revision=53212
* sigset_t change (part 2 of 5)Marcel Moolenaar1999-09-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ----------------------------- The core of the signalling code has been rewritten to operate on the new sigset_t. No methodological changes have been made. Most references to a sigset_t object are through macros (see signalvar.h) to create a level of abstraction and to provide a basis for further improvements. The NSIG constant has not been changed to reflect the maximum number of signals possible. The reason is that it breaks programs (especially shells) which assume that all signals have a non-null name in sys_signame. See src/bin/sh/trap.c for an example. Instead _SIG_MAXSIG has been introduced to hold the maximum signal possible with the new sigset_t. struct sigprop has been moved from signalvar.h to kern_sig.c because a) it is only used there, and b) access must be done though function sigprop(). The latter because the table doesn't holds properties for all signals, but only for the first NSIG signals. signal.h has been reorganized to make reading easier and to add the new and/or modified structures. The "old" structures are moved to signalvar.h to prevent namespace polution. Especially the coda filesystem suffers from the change, because it contained lines like (p->p_sigmask == SIGIO), which is easy to do for integral types, but not for compound types. NOTE: kdump (and port linux_kdump) must be recompiled. Thanks to Garrett Wollman and Daniel Eischen for pressing the importance of changing sigreturn as well. Notes: svn path=/head/; revision=51791
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Don't initialize run queues here, do it all in one place.Peter Wemm1999-08-191-22/+2
| | | | Notes: svn path=/head/; revision=50033
* The magic "no-cpu" cpu number is 0xff. Don't misrepresent cpuBruce Evans1999-03-051-2/+2
| | | | | | | | | numbers as chars or use bogus casts in an attempt to unmisrepresnt them. In top, don't assume that 0xff is the only negative cpu number when cpu numbers are (mis)represented. Notes: svn path=/head/; revision=44487
* The tunable parameter for the scheduler quantum was inverted.Julian Elischer1999-03-031-30/+23
| | | | | | | | | | | | | | Higher numbers led to smaller quanta. In discussion with BDE, change this parameter to be in uSecs to make it machine independent, and limit it to non zero multiples of 'tick' (rounding down). Also make the variabel globally available so that the present function that returns its value (used for posix scheduling I believe) can go away. Submitted by: Bruce Evans <bde@freebsd.org> Notes: svn path=/head/; revision=44452
* Removed all traces of `p_switchtime'. The relevant timestamp is per-cpu,Bruce Evans1999-02-281-8/+8
| | | | | | | | | | | | | | | | not per-process. Keep it in `switchtime' consistently. It is now clear that the timestamp is always valid in fork_trampoline() except when the child is running on a previously idle cpu, which can only happen if there are multiple cpus, so don't check or set the timestamp in fork_trampoline except in the (i386) SMP case. Just remove the alpha code for setting it unconditionally, since there is no SMP case for alpha and the code had rotted. Parts reviewed by: dfr, phk Notes: svn path=/head/; revision=44327
* Improved scheduling in uiomove(), etc. resched_wanted() is true tooBruce Evans1999-02-221-1/+6
| | | | | | | | | often for it to be a good criterion for switching kernel cpu hogs -- it is true after most wakeups. Use the criterion "has been running for >= 2 quanta" instead. Notes: svn path=/head/; revision=44218
* KNFize, by bde.Eivind Eklund1999-01-101-5/+2
| | | | Notes: svn path=/head/; revision=42453
* Split DIAGNOSTIC -> DIAGNOSTIC, INVARIANTS, and INVARIANT_SUPPORT asEivind Eklund1999-01-081-35/+6
| | | | | | | | | | | | discussed on -hackers. Introduce 'KASSERT(assertion, ("panic message", args))' for simple check + panic. Reviewed by: msmith Notes: svn path=/head/; revision=42408
* Add asleep() and await() support. Currently highly experimental. AMatthew Dillon1998-12-211-2/+189
| | | | | | | | small support structure had to be added to the proc structure, and a few minor conditional panics no longer apply. Notes: svn path=/head/; revision=41971
* Compare p_cpulimit with RLIM_INFINITY before comparing it with the processDavid Greenman1998-11-271-2/+3
| | | | | | | | | runtime. p_runtime is unsigned while p_cpulimit is not, so this avoids the nasty side effect of the process getting killed when the runtime comes up "negative" due to other bugs. Notes: svn path=/head/; revision=41373
* Fixed the previous fix - stathz doesn't give the statclock frequencyBruce Evans1998-11-261-5/+6
| | | | | | | | | when it is 0. Submitted by: mostly by Hidetoshi Shimokawa <simokawa@sat.t.u-tokyo.ac.jp> Notes: svn path=/head/; revision=41361
* Oops, yet again back out some local changes that shouldn't have beenBruce Evans1998-11-261-5/+5
| | | | | | | in the previous commit. Notes: svn path=/head/; revision=41360
* Fixed scaling of p_pctcpu. It was wrong by a factor of stathz/hz.Bruce Evans1998-11-261-8/+8
| | | | | | | | Until recently, this was half compensated for in at least ps and top by multiplying by 100/stathz to get a better wrong factor of 100/hz. Notes: svn path=/head/; revision=41359
* Oops, back out some local changes that shouldn't have been in theBruce Evans1998-10-251-5/+5
| | | | | | | previous commit. Notes: svn path=/head/; revision=40653
* Fixed breakage of the !SMP case of roundrobin() in the previous commit.Bruce Evans1998-10-251-5/+8
| | | | Notes: svn path=/head/; revision=40652
* Nitpicking and dusting performed on a train. Removes trivial warningsPoul-Henning Kamp1998-10-251-4/+3
| | | | | | | about unused variables, labels and other lint. Notes: svn path=/head/; revision=40648
* priority comparison in maybe_resched() didn't work properly if currentMatthew Dillon1998-08-261-6/+13
| | | | | | | and chk process were on different scheduler queues. Fixed. Notes: svn path=/head/; revision=38551
* Cast pointers to uintptr_t/intptr_t instead of to u_long/long,Bruce Evans1998-07-151-2/+2
| | | | | | | | | | respectively. Most of the longs should probably have been u_longs, but this changes is just to prevent warnings about casts between pointers and integers of different sizes, not to fix poorly chosen types. Notes: svn path=/head/; revision=37649
* Moved definition of fscale from param.c to kern_synch.c where itBruce Evans1998-07-111-1/+5
| | | | | | | | should always have been (it has no user-servicable parts even at compile time) and staticized it. Notes: svn path=/head/; revision=37565
* Add 3 sysctl variables for future use by ps)1_Poul-Henning Kamp1998-06-301-1/+2
| | | | Notes: svn path=/head/; revision=37315
* Removed unused includes.Bruce Evans1998-06-211-2/+1
| | | | Notes: svn path=/head/; revision=37101
* Some cleanups related to timecounters and weird ifdefs in <sys/time.h>.Poul-Henning Kamp1998-05-281-28/+16
| | | | | | | | | | | | | | | | | | | | | | | Clean up (or if antipodic: down) some of the msgbuf stuff. Use an inline function rather than a macro for timecounter delta. Maintain process "on-cpu" time as 64 bits of microseconds to avoid needless second rollover overhead. Avoid calling microuptime the second time in mi_switch() if we do not pass through _idle in cpu_switch() This should reduce our context-switch overhead a bit, in particular on pre-P5 and SMP systems. WARNING: Programs which muck about with struct proc in userland will have to be fixed. Reviewed, but found imperfect by: bde Notes: svn path=/head/; revision=36441
* Add forwarding of roundrobin to other cpus. This gives a more regularTor Egge1998-05-171-1/+10
| | | | | | | | | | | | | | update of cpu usage as shown by top when one process is cpu bound (no system calls) while the system is otherwise idle (except for top). Don't attempt to switch to the BSP in boot(). If the system was idle when an interrupt caused a panic, this won't work. Instead, switch to the BSP in cpu_reset. Remove some spurious forward_statclock/forward_hardclock warnings. Notes: svn path=/head/; revision=36135
* s/nanoruntime/nanouptime/gPoul-Henning Kamp1998-05-171-3/+3
| | | | | | | | | s/microruntime/microuptime/g Reviewed by: bde Notes: svn path=/head/; revision=36119
* Time changes mark 2:Poul-Henning Kamp1998-04-041-5/+5
| | | | | | | | | | | | | | | | | | | | * Figure out UTC relative to boottime. Four new functions provide time relative to boottime. * move "runtime" into struct proc. This helps fix the calcru() problem in SMP. * kill mono_time. * add timespec{add|sub|cmp} macros to time.h. (XXX: These may change!) * nanosleep, select & poll takes long sleeps one day at a time Reviewed by: bde Tested by: ache and others Notes: svn path=/head/; revision=35029
* Remove duplicate commentPeter Dufault1998-03-281-4/+1
| | | | Notes: svn path=/head/; revision=34931
* Finish _POSIX_PRIORITY_SCHEDULING. Needs P1003_1B andPeter Dufault1998-03-281-1/+4
| | | | | | | | | | | | | | | | | | | _KPOSIX_PRIORITY_SCHEDULING options to work. Changes: Change all "posix4" to "p1003_1b". Misnamed files are left as "posix4" until I'm told if I can simply delete them and add new ones; Add _POSIX_PRIORITY_SCHEDULING system calls for FreeBSD and Linux; Add man pages for _POSIX_PRIORITY_SCHEDULING system calls; Add options to LINT; Minor fixes to P1003_1B code during testing. Notes: svn path=/head/; revision=34925
* Moved some #includes from <sys/param.h> nearer to where they are actuallyBruce Evans1998-03-281-1/+2
| | | | | | | used. Notes: svn path=/head/; revision=34924
* idprio processes must be preempted as soon as anything is runnable.Peter Dufault1998-03-111-4/+7
| | | | Notes: svn path=/head/; revision=34489
* Reviewed by: dyson@freebsd.org (john Dyson), dg@root.com (david greenman)Julian Elischer1998-03-081-2/+2
| | | | | | | | Submitted by: Kirk McKusick (mcKusick@mckusick.com) Obtained from: WHistle development tree Notes: svn path=/head/; revision=34266
* Reviewed by: msmith, bde long agoPeter Dufault1998-03-041-11/+31
| | | | | | | | | | Fix for RTPRIO scheduler to eliminate invalid context switches. POSIX.4 headers and sysctl variables. Nothing should change unless POSIX4 is defined or _POSIX_VERSION is set to 199309. Notes: svn path=/head/; revision=34029
* Fixed a missing newline in a debugging printf.Bruce Evans1998-02-251-4/+4
| | | | | | | Fixed punctuation in some comments. Notes: svn path=/head/; revision=33823
* Back out DIAGNOSTIC changes.Eivind Eklund1998-02-061-2/+1
| | | | Notes: svn path=/head/; revision=33134
* Turn DIAGNOSTIC into a new-style option.Eivind Eklund1998-02-041-1/+2
| | | | Notes: svn path=/head/; revision=33108
* Fixed style bugs in previous commit.Bruce Evans1997-12-291-3/+3
| | | | Notes: svn path=/head/; revision=32081
* Lots of improvements, including restructring the caching and managementJohn Dyson1997-12-291-1/+3
| | | | | | | | | | | | | | | | | of vnodes and objects. There are some metadata performance improvements that come along with this. There are also a few prototypes added when the need is noticed. Changes include: 1) Cleaning up vref, vget. 2) Removal of the object cache. 3) Nuke vnode_pager_uncache and friends, because they aren't needed anymore. 4) Correct some missing LK_RETRY's in vn_lock. 5) Correct the page range in the code for msync. Be gentle, and please give me feedback asap. Notes: svn path=/head/; revision=32071
* Shift a few SYSINT() calls around.Julian Elischer1997-11-251-3/+16
| | | | | | | | | | | | | this results in a few functions becoming static, and the SYSINITs being close to the code they are related to. setting up the dump device is with dumpsys() and kicking off the scheduler is with the scheduler. Mounting root is with the code that does it. Reviewed by: phk Notes: svn path=/head/; revision=31403
* Staticized.Bruce Evans1997-11-221-7/+7
| | | | Notes: svn path=/head/; revision=31352
* Const poisoning from ks_shortdesc.Bruce Evans1997-11-211-2/+2
| | | | Notes: svn path=/head/; revision=31333